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 FailingFieldFixture(object): | |
| def setUp(self): | |
| self.field = InitialField(full_name=self.full_name, max_length=4) | |
| def test_validation_fails(self): | |
| with self.assertRaises(ValidationError): | |
| self.clean = self.field.clean(self.value) | |
| class WhenFirstInitialIsWrong(FailingFieldFixture, TestCase): |
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 BetterJSONEncoder(json.JSONEncoder): | |
| """`Decimal`-aware JSONEncoder""" | |
| ROUNDING_DECIMAL = decimal.Decimal('0.01') | |
| def default(self, o): | |
| if isinstance(o, decimal.Decimal): | |
| return str(o.quantize(BetterJSONEncoder.ROUNDING_DECIMAL)) | |
| return json.JSONEncoder.default(self, 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
| // Example run: | |
| // $ ./main | |
| // key[373b91dcef162a641052f4fd8f0df10e0e1a1f67feefd01c] -- 24 | |
| // iv[0000000000000000] -- 8 | |
| // 0102030405060708 -- 8 | |
| // 45f7fa13d05b4045 -- 8 | |
| // 0000000000000000 -- 8 | |
| // -- 0 | |
| func main() { |
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
| // file: one_a.c | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <time.h> | |
| #include "one_b.c" | |
| // Compile: | |
| // gcc -Wall -std=c99 one_a.c |
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 | |
| foo = 'Hello' | |
| def frob(): | |
| print "FOO 1", foo | |
| def fish(): | |
| global foo |
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
| syntax enable | |
| filetype plugin indent on | |
| set hls | |
| set nobackup | |
| set noautoindent nosmartindent | |
| set tabstop=4 shiftwidth=4 softtabstop=4 expandtab | |
| setlocal spell spelllang=en_us | |
| set guioptions-=m | |
| set guioptions-=T |
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
| def retry_until_successful(function_to_repeatedly_try): | |
| while True: | |
| try: | |
| function_to_repeatedly_try() | |
| except: | |
| print 'EXCEPTION RACHEL-SAN!' | |
| continue | |
| break | |
| def add_listing(url, price): |
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
| # .bashrc | |
| # source: http://www.ukuug.org/events/linux2003/papers/bash_tips/#S20 | |
| function qgit { | |
| command qgit --all "$@" & | |
| } |
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
| #include <stdio.h> | |
| // Abstract vs. Concrete | |
| // | |
| // Compile: | |
| // gcc -Wall -std=c99 unsigned.c | |
| // Run: | |
| // ./a.out | |
| int main(void) { |
NewerOlder