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
DROP TRIGGER Dive_Insert; | |
/* | |
if no dives predate this then | |
if lowest number is > 1: | |
lowest number - 1 | |
else | |
1 | |
else | |
pick most recent +1 |
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
"CREATE TRIGGER Dive_Update AFTER " | |
"UPDATE OF dive_datetime ON Dive BEGIN " | |
"UPDATE Dive " | |
"SET dive_number= " | |
" (SELECT CASE " | |
" WHEN dive_id = NEW.dive_id THEN " | |
" /* The updated dive, set the number to the number of older dives */ " | |
" 1 + (SELECT COUNT(*) FROM Dive WHERE dive_datetime < NEW.dive_datetime) " | |
" WHEN NEW.dive_datetime > OLD.dive_datetime " | |
" /* All other dive, move by +/- 1 depending on whether we've moved the datetime " |
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
# Example code doing SSL using pycurl and CurlMulti | |
import pycurl | |
import cStringIO | |
response_buffer = cStringIO.StringIO() | |
multi = pycurl.CurlMulti() | |
curl = pycurl.Curl() | |
curl.setopt(pycurl.URL, 'https://www.yammer.com') | |
curl.setopt(pycurl.SSL_VERIFYPEER, 1) |
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
""" | |
Tools for creating a CA cert and signed server certs. | |
Divined from http://svn.osafoundation.org/m2crypto/trunk/tests/test_x509.py | |
The mk_temporary_xxx calls return a NamedTemporaryFile with certs. | |
Usage ; | |
# Create a temporary CA cert and it's private key | |
cacert, cakey = mk_temporary_cacert() |
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
(defun my-yelp-python-mode-hook () | |
(setq tab-width 4) | |
(setq py-indent-offset 4) | |
(setq indent-tabs-mode (or (string-match "/pg/yelp-main/" (buffer-file-name)) | |
(string-match "/pg/yelp_conn/" (buffer-file-name)) | |
(string-match "/pg/yelp_lib/" (buffer-file-name)) | |
(and (string-match "/pg/services/" (buffer-file-name)) | |
(not (or (string-match "/zygote/" (buffer-file-name)) | |
(string-match "/google/" (buffer-file-name)) | |
) |
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
template<bool> struct _compile_time_assert; | |
template<> struct _compile_time_assert<true> {}; | |
#define ctassert(expr) if (0) { int flaming_goat_sausage = sizeof(_compile_time_assert<(bool)(expr)>); flaming_goat_sausage++; } | |
int main (int argc, char *argv[]) { | |
ctassert (sizeof (int) == 4); | |
ctassert ((sizeof (int) == 5) == false); | |
//BLAM | |
ctassert (sizeof (int) == 5); |
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
/* | |
C++11 version of chunkserv.util.TimeWindowedStats | |
A dumb test that feeds a ton of entries into both the python and C++ version shows that; | |
Python | |
- insert_events time 0.237569570541 | |
- compute_stats time 19.1441180706 | |
C++ | |
- insert_events time 0.234213590622 |
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
/* | |
Test that implements some template meta programming. | |
- two_to_the_power_of<Power> calculates 2^Power into it's ::value. | |
- rightshits<V> calculates how many times V can be rightshifted | |
until it's 1 or 0, result is in ::value. | |
- if_t<bool,A,B> places A or B in ::value, depending on the bool | |
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
To run flask_security unit-tests: | |
virtualenv --no-site-packages env/ | |
. env/bin/activate | |
pip install nose simplejson Flask-SQLAlchemy Flask-MongoEngine Flask-Mail py-bcrypt Flask Flask-Login Flask-Principal itsdangerous passlib | |
Apply this diff to disable mongo tests and use sqlite instead of postgres: | |
diff --git a/tests/functional_tests.py b/tests/functional_tests.py |
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
#!/bin/bash | |
# Put in ~/bin/fixbaseedit.sh | |
# alias fixbase="EDITOR=~/bin/fixbaseedit.sh git rebase -i origin/master" | |
# You can also just make a script that does "git commit -a -m fix" and | |
# the rebase for you. | |
sed -i.old \ | |
-e '2,$s/pick \(.*\) fixup/f \1 .../g' \ |
OlderNewer