This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT "businesses_business"."id", "businesses_business"."user_id", "businesses_business"."slug", "businesses_business"."name", "businesses_business"."business_type_id", "businesses_business"."street", "businesses_business"."additional", "businesses_business"."town", "businesses_business"."county", "businesses_business"."postcode_id", "businesses_business"."phone_number", "businesses_business"."fax_number", "businesses_business"."email", "businesses_business"."website", "businesses_business"."strapline", "businesses_business"."description", "businesses_business"."active", "businesses_business"."deleted", "businesses_business"."activation_code", "businesses_business"."created_on", "businesses_business"."account_confirmed", "businesses_business"."preview", "businesses_business"."paid", "businesses_business"."last_updated", "businesses_business"."copy_id", "businesses_business"."logo", "businesses_business"."security_reference", "businesses_business"."video", "businesses_business"."embed_url", "businesses_busine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# abort if already under tmux | |
[[ -n $TMUX_PANE ]] && return | |
# zsh-specific includes | |
zmodload -i zsh/datetime | |
zmodload -i zsh/stat | |
# place to store the chart | |
RAINBARF_OUT=~/.rainbarf.out | |
# update period, in seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.filter('bytes', function() { | |
return function(bytes, precision) { | |
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-'; | |
if (typeof precision === 'undefined') precision = 1; | |
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'], | |
number = Math.floor(Math.log(bytes) / Math.log(1024)); | |
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number]; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Two things are wrong with Django's default `SECRET_KEY` system: | |
1. It is not random but pseudo-random | |
2. It saves and displays the SECRET_KEY in `settings.py` | |
This snippet | |
1. uses `SystemRandom()` instead to generate a random key | |
2. saves a local `secret.txt` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import random | |
import time | |
import platform | |
snowflakes = {} | |
try: | |
# Windows Support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# coding=utf-8 | |
# Python version of Zach Holman's "spark" | |
# https://github.com/holman/spark | |
# by Stefan van der Walt <[email protected]> | |
""" | |
USAGE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import http | |
try: | |
from django.conf import settings | |
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS | |
XS_SHARING_ALLOWED_METHODS = settings.XS_SHARING_ALLOWED_METHODS | |
XS_SHARING_ALLOWED_HEADERS = settings.XS_SHARING_ALLOWED_HEADERS | |
XS_SHARING_ALLOWED_CREDENTIALS = settings.XS_SHARING_ALLOWED_CREDENTIALS | |
except AttributeError: | |
XS_SHARING_ALLOWED_ORIGINS = '*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn partition-between | |
"Splits coll into a lazy sequence of lists, with partition | |
boundaries between items where (f item1 item2) is true. | |
(partition-between = '(1 2 2 3 4 4 4 5)) => | |
((1 2) (2 3 4) (4) (4 5))" | |
[f coll] | |
(lazy-seq | |
(when-let [s (seq coll)] | |
(let [fst (first s)] | |
(if-let [rest-seq (next s)] |
NewerOlder