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
(define-minor-mode code-wrap-mode | |
"Visually wrap the buffer text to the previous lines indent, plus a tab." | |
:lighter "" | |
(if code-wrap-mode | |
(progn | |
(visual-line-mode 1) | |
(jit-lock-register #'indent-prefix-wrap-function)) | |
(visual-line-mode 0) | |
(jit-lock-unregister #'indent-prefix-wrap-function) | |
(with-silent-modifications |
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
class simple; | |
typedef statemachines::traits<my_state_type, threads::single_threaded> my_traits; | |
class simple : public statemachines::statemachine<simple, my_traits> { | |
public: | |
class generic_event : public event_t {}; | |
class one_event : public event_t { | |
public: | |
one_event (std::string msg) : m_message (msg) {} |
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
.----.-. | |
/ ( o \ | |
'| __ ` || | |
||| ||| -' | |
¯\_(ツ)_/¯ |
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
#!/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' \ |
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
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 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
/* | |
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 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
/* | |
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 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
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 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
(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 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
""" | |
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() |