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
# This code is via http://www.turnkeylinux.org/blog/python-symmetric-encryption | |
# Author: Alon Swartz | |
import zlib | |
import struct | |
from Crypto.Cipher import AES | |
class CheckSumError(Exception): | |
pass |
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
import csv | |
import codecs | |
fin = 'quick-statistics.csv' | |
threshold = 40 | |
lines_to_keep = [] | |
with open(fin, 'r') as f: | |
keep_line = 0 | |
reader = csv.reader(f) |
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
import sys | |
num = 0 | |
def printNum(func): | |
def pprint(*args, **kwargs): | |
global num | |
num += 1 | |
sys.stdout.write(u'%s: ' % num) | |
sys.stdout.write(func(*args, **kwargs)) | |
sys.stdout.write(u'\n') | |
return pprint |
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
// ---- | |
// Sass (v3.3.14) | |
// Compass (v1.0.0) | |
// ---- | |
@mixin animation($animate...) { | |
$max: length($animate); | |
$animations: ''; | |
@for $i from 1 through $max { |
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
def is_equal(val1, val2): | |
""" | |
This is a really nice way to comparing two hash values using the set operation XOR | |
This snippet is from the plone project https://github.com/plone/plone.session/blob/master/plone/session/tktauth.py | |
""" | |
# constant time comparison | |
if not isinstance(val1, basestring) or not isinstance(val2, basestring): | |
return False |
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
$.fn.scrollFoo = function() { | |
'use strict' | |
var that = this, | |
didscroll = false; | |
$(window).scroll(function() { | |
didscroll = true; | |
}); |
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
# Last, Middle, First | |
(\w+)(,\ )(\w+.),\ (\w+) | |
# First Middle. Last, Title | |
(\w+)\ (\w+).\ (\w+),\ (\w+) | |
# First Last (via Twitter) | |
(\w+)\ (\w+)\ (\([\w\ ]+\)) |
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
// ---- | |
// Sass (v3.4.9) | |
// Compass (v1.0.1) | |
// ---- | |
//Use placeholders for repeating visual styles | |
%dotted-border { border: 1px dotted #eee; } | |
.box1 { | |
@extend %dotted-border; |
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
// ---- | |
// Sass (v3.4.9) | |
// Compass (v1.0.1) | |
// ---- | |
//Write mixins where the pattern takes variables | |
@mixin transparent-backgroung($color, $alpha) { | |
$rgba: rgba($color, $alpha); | |
$ie-hex-str: ie-hex-str($rgba); | |
background-color: transparent; |
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
// ---- | |
// Sass (v3.4.9) | |
// Compass (v1.0.1) | |
// ---- | |
//Use placeholders for repeating visual styles: | |
%dotted-border { border: 1px dotted #eee; } | |
.box { | |
@extend %dotted-border; |
OlderNewer