Mostrando entradas con la etiqueta python. Mostrar todas las entradas
Mostrando entradas con la etiqueta python. Mostrar todas las entradas

jueves, 20 de diciembre de 2018

PyTweet2Img: a tweet to image conversion tool

PyTweet2Img

Sometimes we need to quote to tweet but we do not want to retweet it. A easy way is to make a screenshot but it's necessary to crop it to a proper size.

This online tool can generate an image (a .PNG) from the tweet's URL.

https://dev.minoriadeunosolo.com/convert_tweet

A title can be added as a header ("Tweet Captured")
Emojis are supported. Mentions and hashtags are properply coloured.
Example of a generated Image



Technical Details 

-Python 3.x
-Requests to retrieve the tweet content, the author image and the emojis
-It isn't a "screenshot", the image is rendered from the tweet information.


TODO

-Threads
-Images

lunes, 27 de agosto de 2018

Graphical Shutdown/Reboot in OpenBox: pyshutdown

Pyshutdown 

A graphical interface to Shutdown/reboot. Useful if your favourite WM hasn't that functionality. (i.e. OpenBox). A very good guide to install/configure OpenBox: https://www.emezeta.com/articulos/openbox-personalizar-escritorio-linux


PyShutdown Git Repository

This project starts like a personal needed due I use OpenBox everyday. I had a little bash script to automatize shutdown/reboot but it was ugly and It can't be cancelled.

It uses Tk-inter to the graphical interface. The language is autodetected (only english (default), spanish and german) and it's easy add new translations due to the .po/.mo translations files.

English:

 German:

 Spanish:


Due to debugging needs there is a command line parameter (-l) to write a log in /var/tmp

Dependencies:

tk-inter
#apt-get install python-tk

User grants


User need to be enough privilegies to shutdown/reboot the machine:
Create a new group:
sudo groupadd power
Adding your user to the group power:
sudo usermod -a -G power yourusername
Allow members of group power to shutdown without a password:
sudo visudo

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
# Allow members of group power to shutdown (or reboot) system
%power  ALL = NOPASSWD: /sbin/shutdown
It is necessary re-login to the changes take effect.


lunes, 7 de noviembre de 2016

My contribution to 99-bottles-of-beer


99-bottles-of-beer.net is site that collects pieces of code in different languages that print the well-known song "99 bottles of beer"


This is my version in Python, using list Comprenhensions





#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
"""
99 Bottles of Beer (by Miguel A. Rico)
List Comprehensions
"""
tn = '%i bottles of beers on the wall, %i bottles of beer\r\nTake one down, pass it around, %i bottle%s of beer on the wall.' + '\r\n--\r\n'
t0 = '1 bottle of beers on the wall, 1 bottle of beer\r\nTake one down, pass it around, no more beer on the wall!' + '\r\n--\r\n'
print reduce((lambda x,y: x + y ), map((lambda x: tn % (x,x,x-1,'s') if x>2 else tn % (x,x,x-1,'') if x>1 else t0),range(99,0,-1)))