Skip to content

Instantly share code, notes, and snippets.

Avatar

Hans Roman snahor

  • Wakanda
View GitHub Profile
@snahor
snahor / gist:1249404
Created Sep 28, 2011
fabfile example
View gist:1249404
import os
from fabric.api import *
env.user = ''
env.hosts = ['']
env.password = ''
LOCAL_PATH = os.path.abspath('.')
SERVER_PATH = ''
View strip_html.py
try:
from lxml.html import fromstring
strip_html = lambda html: fromstring(html).text_content()
except ImportError:
try:
from bs4 import BeautifulSoup
strip_html = lambda html: ''.join(
BeautifulSoup(html).findAll(text=True))
except ImportError:
from HTMLParser import HTMLParser
View gist:1400815
[core]
excludesfile = /path/to/gitignore_global
[alias]
serve = daemon \
--reuseaddr --verbose --export-all \
--base-path=/path/to/projects/ \
--interpolated-path=/path/to/projects%D
View gist:1535448
import json
import hmac
import base64
import hashlib
def parse_signed_request(signed_request, secret):
encoded_sig, payload = signed_request.split('.')
sig = base64.b64decode(encoded_sig + '==')
data = json.loads(base64.b64decode(payload + '=='))
@snahor
snahor / admin.py
Created Jan 4, 2012
Django admin export all the records of the current queryset to XLS
View admin.py
import xlwt
from django.http import HttpResponse
def export_xls(modeladmin, request, queryset):
meta = modeladmin.model._meta
filename = '%s.xls' % meta.verbose_name_plural.lower()
def get_verbose_name(fieldname):
name = filter(lambda x: x.name == fieldname, meta.fields)
View sender.py
import urllib
URL = 'http://api.tropo.com/1.0/sessions'
TOKEN = ''
def send_sms(to, shout):
params = urllib.urlencode({
'action': 'create',
'token': TOKEN,
'shout': shout,
View foo.php
<?php
class Persona
{
public $nombres = '';
public $ape_paterno = '';
public $ape_materno = '';
public $edad = null;
public function ponerNombresApellidos($nombres, $ape_pat, $ape_mat)
{
View disqus_requirements.txt
# dev
django-debug-toolbar==0.9.4
django-data-tools==0.1
django-devserver==0.3
nashvegas==0.8-disqus-5
Sphinx>=1.0.7
piplint==0.1.1
# global
amqplib==1.0.0
View wawared.md

“Conectándose para una mejor salud materno-infantil en el Perú”

View die.sh
#!/bin/bash
if [ -n "$1" ]
then
ps xu | grep $1 | awk '{print $2}' | xargs kill -9
else
echo "Usage: die <process-name>"
fi