This file contains hidden or 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
/* crc64.c -- compute CRC-64 | |
* Copyright (C) 2013 Mark Adler | |
* Version 1.4 16 Dec 2013 Mark Adler | |
*/ | |
/* | |
This software is provided 'as-is', without any express or implied | |
warranty. In no event will the author be held liable for any damages | |
arising from the use of this software. |
This file contains hidden or 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 argparse | |
import csv | |
import gzip | |
import sys | |
import re | |
from contextlib import closing | |
# This prevents prematurely closed pipes from raising | |
# an exception in Python | |
from signal import signal, SIGPIPE, SIG_DFL |
This file contains hidden or 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 | |
""" | |
Fixes a MySQL dump made with the right format so it can be | |
imported to a Redshift database. | |
Dump using: | |
mysqldump --compatible=postgresql --default-character-set=utf8 -r databasename.mysql -u root databasename tablename | |
""" |
This file contains hidden or 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 re | |
USER_AGENT_REGEX = re.compile( | |
r"android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|" | |
r"ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|" | |
r"phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|" | |
r"vodafone|wap|indows (ce|phone)|xda|xiino", re.M) | |
def is_mobile(request): | |
ua = request.META.get('HTTP_USER_AGENT', '').lower() |
This file contains hidden or 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
### Latency numbers every programmer should know | |
L1 cache reference ......................... 0.5 ns | |
Branch mispredict ............................ 5 ns | |
L2 cache reference ........................... 7 ns | |
Mutex lock/unlock ........................... 25 ns | |
Main memory reference ...................... 100 ns | |
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs | |
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs | |
SSD random read ........................ 150,000 ns = 150 µs | |
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs |
NewerOlder