A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
/* | |
Use like this (or with <dl>, <ol>, <table>)... | |
<ul> | |
<li> | |
<input type="checkbox" class="check-all" /> | |
</li> | |
<li> | |
<input type="checkbox" /> | |
</li> |
#!/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 |
# -*- 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 |
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) |
#!/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 |
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({ |
import time | |
class Timing(object): | |
def __init__(self): | |
self.timings = {} | |
self.col = self.__collector() | |
self.col.next() #coroutine syntax | |
def __collector(self): | |
while True: |
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') |