Skip to content

Instantly share code, notes, and snippets.

View GuilhermeBarile's full-sized avatar

Guilherme Barile GuilhermeBarile

  • Toptal
  • São Paulo
View GitHub Profile
@GuilhermeBarile
GuilhermeBarile / Facebook like button
Last active December 5, 2017 08:01
Wordpress code snippets
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink()) ?>&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light&amp;height=21" width="90" height="21" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
# this program uploads to google storage using boto and eventlet all the jpg files of a selected folder
import eventlet
bcon = eventlet.import_patched("boto.gs.connection")
import glob
FOLDER = "/Users/myself/Documents/" # replace this with your chosen folder
BUCKET_NAME = "whateveryourbucketname" # replace this with your bucket name
def upload(myfile):
c = bcon.GSConnection()
@GuilhermeBarile
GuilhermeBarile / gist:1149808
Created August 16, 2011 18:38
limit textarea length
onkeydown="return jQuery(this).val().length < 144"
@GuilhermeBarile
GuilhermeBarile / gist:1174437
Created August 26, 2011 21:02
mass delete for postfix mail queue
# delete mail from some@email.com
mailq | grep some@email.com | cut -d" " -f1 |tr -d '*' | xargs -L1 postsuper -d
@GuilhermeBarile
GuilhermeBarile / gencss.sh
Created August 29, 2011 18:43
Generate formatted CSS from image files with width/height info
#!/bin/bash
# ~/bin/gencss.sh
# specify a prefix or suffix using
# PREFIX="#" SUFFIX=" .image" ~/bin/gencss.sh *.png
FORMAT="$PREFIX%t$SUFFIX { background: url('%i') no-repeat center center; width: %wpx; height: %hpx; }"
until [ -z "$1" ] # Until all parameters used up . . .
do
@GuilhermeBarile
GuilhermeBarile / gist:1195418
Created September 5, 2011 16:39
javascript split() behaviour
> var t = "inventory/coisa"
> t.split("/")
[ 'inventory', 'coisa' ]
> var t1 = "inventory"
> t1.split("/")
[ 'inventory' ]
@GuilhermeBarile
GuilhermeBarile / showmail
Created October 16, 2011 14:58
postfix - view body of messages in queue
postcat -q 3AED88366B | head --lines 100
@GuilhermeBarile
GuilhermeBarile / gist:1325043
Created October 29, 2011 20:25
CPAN force install
perl -MCPAN -e "CPAN::Shell->force(qw(install IO::Socket::SSL));"
@GuilhermeBarile
GuilhermeBarile / gist:1337426
Created November 3, 2011 18:53
Play Youtube video on XBMC
curl -i -X POST -d '{"jsonrpc": "2.0", "method": "XBMC.Play", "params":{ "file" : "plugin://plugin.video.youtube/?action=play_video&videoid=VIDEOIDFROMYOUTUBEURL" }, "id": 1}' http://xbmc:8080/jsonrpc
@GuilhermeBarile
GuilhermeBarile / fcl.py
Created November 21, 2011 12:53
Extract torrent/subtitles from rar
#!/usr/local/bin/python
#coding: utf-8
TRANSMISSION_HOST='xbmc'
DOWNLOAD_DIR='/Users/guigouz/tmp/Downloads'
#
# Processa um arquivo rar, inicia o download do filme e copia a legenda junto com o avi
#
import os, sys, rarfile, transmissionrpc, base64, os.path