Skip to content

Instantly share code, notes, and snippets.

View cstrap's full-sized avatar
🐍

Christian Strappazzon cstrap

🐍
View GitHub Profile
@sloria
sloria / bobp-python.md
Last active April 27, 2025 07:06
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@nathansmith
nathansmith / check_all.js
Last active December 11, 2015 12:38
For when you need a master checkbox, that will cause others to be checked.
/*
Use like this (or with <dl>, <ol>, <table>)...
<ul>
<li>
<input type="checkbox" class="check-all" />
</li>
<li>
<input type="checkbox" />
</li>
@ljos
ljos / cocoa_keypress_monitor.py
Last active August 12, 2024 17:34
Showing how to listen to all keypresses in OS X through the Cocoa API using Python and PyObjC
#!/usr/bin/env python
#
# cocoa_keypress_monitor.py
# Copyright © 2016 Bjarte Johansen <[email protected]>
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# “Software”), to deal in the Software without restriction, including
@kennethreitz
kennethreitz / flaskapp.py
Created June 9, 2012 15:38
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
web: gunicorn -w4 -b0.0.0.0:$PORT app:app
@vrde
vrde / pymodoro.py
Created May 9, 2012 14:40
simple pomodoro implementation with pynotify
import pynotify
from time import sleep
def mins_to_secs(ms):
return map(lambda x: x * 60, ms)
class Pymodoro(object):
POMODORO_TIME = 25 * 60
POMODORO_CHECKPOINTS = mins_to_secs([25, 15, 10, 5, 3, 1]) + range(10)
@gasman
gasman / pnginator.rb
Created April 30, 2012 18:08
pnginator: pack Javascript into a self-extracting PNG
#!/usr/bin/env ruby -w
# pnginator.rb: pack a .js file into a PNG image with an HTML payload;
# when saved with an .html extension and opened in a browser, the HTML extracts and executes
# the javascript.
# Usage: ruby pnginator.rb input.js output.png.html
# By Gasman <http://matt.west.co.tt/>
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos
@fael
fael / gist:1212446
Created September 12, 2011 21:10
Javascript Easter Egg - Konami Code
var kkeys = [],
konami = "38,38,40,40,37,39,37,39,66,65";
easterEgg = function (e) {
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(konami) == 0) {
var ee = $('<div id="ee">TROLOLOL</div>');
ee.css({
@enjalot
enjalot / timing.py
Created March 7, 2011 11:31
A timing decorator class using a coroutine for the fun of it
import time
class Timing(object):
def __init__(self):
self.timings = {}
self.col = self.__collector()
self.col.next() #coroutine syntax
def __collector(self):
while True:
@cstrap
cstrap / json_field.py
Created November 8, 2010 16:51 — forked from paltman/json_field.py
Serialize JSON object into a model object and retrieve a python dictionary on load
from django.db import models
from django.utils import simplejson as json
from django.conf import settings
from datetime import datetime
import time
class JSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, datetime):
return obj.strftime('%Y-%m-%d %H:%M:%S')