Skip to content

Instantly share code, notes, and snippets.

View rchrd2's full-sized avatar

Richard Caceres rchrd2

View GitHub Profile
@rcrowley
rcrowley / deps.pp
Created November 16, 2010 00:14
Deploying Django with Puppet
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => "latest";
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
@amundo
amundo / html2text.py
Created May 14, 2011 05:36
unescape hex entities in html
#!/usr/bin/env python
"""html2text: Turn HTML into equivalent Markdown-structured text."""
__version__ = "2.35"
__author__ = "Aaron Swartz (me@aaronsw.com)"
__copyright__ = "(C) 2004-2008 Aaron Swartz. GNU GPL 3."
__contributors__ = ["Martin 'Joey' Schulze", "Ricardo Reyes"]
# TODO:
# Support decoded entities with unifiable.
# Relative URL resolution
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@davidmarble
davidmarble / patch_model.py
Created November 28, 2011 21:02
Monkey patch django built-in models so that any fields can be overwritten or added
from django.db.models.fields import Field
import types
def patch_model(model_to_patch, class_to_patch_with):
"""
Adapted from http://www.ravelsoft.com/blog/2010/patchmodel-hacky-solution-extending-authuser-class
Monkey patch a django model with additional or replacement fields and methods.
All fields and methods that didn't exist previously are added.
@schocco
schocco / gist:1762611
Created February 7, 2012 22:36
encode any string to html
# can be used to hide email addresses in the html source of Web sites from spiders
def html_encode(email):
'''
Takes a unicode string as only parameter and returns
a sequence of html encoded chars.
>>> html_encode(u"test@website.org")
'&#116;&#101;&#115;&#116;&#64;&#119;&#101;&#98;&#115;&#105;&#116;&#101;&#46;&#111;&#114;&#103'
'''
@ymotongpoo
ymotongpoo / requests-oauth2.py
Created February 25, 2012 07:53
Google API OAuth 2.0 Authorization Sample in Python
# -*- coding: utf-8 -*-
"""
This scripts reqire a third party module 'requests'.
You can get it from PyPI, i.e. you can install it using
easy_install or pip.
http://docs.python-requests.org/en/v0.10.4/
Original source code is written by shin1ogawa, which is in Java.
@hrldcpr
hrldcpr / tree.md
Last active April 26, 2024 08:53
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@lukaslundgren
lukaslundgren / python27_on_debian.sh
Created May 11, 2012 12:58
How to install python 2.7 on debian
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xzf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/usr --enable-shared
make
sudo make install
cd ..
@bennylope
bennylope / LICENSE
Last active August 17, 2023 10:44
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
Copyright the authors of Honcho and/or Ben Lopatin
Licensed for reuse, modification, and distribution under the terms of the MIT license