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 | |
| from jinja2 import evalcontextfilter, Undefined, Markup, escape | |
| paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}') | |
| @app.template_filter() | |
| @evalcontextfilter | |
| def linebreaks(eval_ctx, value): | |
| if value is None or isinstance(value, Undefined): | |
| return '' |
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
| require(['module', 'gevents'], function(module, gevents) { | |
| var userView = new module.UserView(); | |
| var commentsView = new module.CommentsView({ el: $('#comments'), collection: [] }); | |
| var chris = new module.User({ | |
| first_name: 'Chris', | |
| last_name: 'Lyon', | |
| email: '[email protected]', | |
| comments: [ |
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
| fact = lambda n: n * fact(n - 1) if n > 0 else 1 |
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 | |
| os=`uname` | |
| user= | |
| if [ "$os" == "Darwin" ]; then | |
| # osx | |
| user=`stat -f '%Su' /dev/console` | |
| elif [ "$os" == "Linux" ]; then | |
| # linux | |
| user=`who -s | awk '/^[^\s]+? :0 / { print $1 }' | head -n1` | |
| fi |
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/sh | |
| out_file=output.gif | |
| cut_in="00:00:00.000" | |
| cut_out="00:00:10.000" | |
| [ -f $out_file ] && rm -f $out_file | |
| ffmpeg -ss $cut_in -i $1 -vf scale=320:-1 -r 10 -f image2pipe -vcodec ppm -t $cut_out - | convert -delay 5 -loop 0 -layers optimize - $out_file |
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/sh | |
| out_file=output.gif | |
| cut_in="00:00:00.000" | |
| cut_out="00:00:10.000" | |
| [ -f $out_file ] && rm -f $out_file | |
| ffmpeg -ss $cut_in -i $1 -qmax 10 -vb 400k -ar 22050 -ab 32 -f flv -r 15 -s 320x240 -aspect 4:3 -t $cut_out $out_file |
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 ones_complement(x): | |
| return x ^ ((1 << x.bit_length()) - 1) |
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 php | |
| <?php | |
| $_emit_shutdown_function_registered = false; | |
| /** | |
| * Emits (using echo()) the return value of a closure function. | |
| * Keeps a clean separation between legitimate content and error messages. | |
| * | |
| * If any type of fatal error or Exception was encountered during evaluation, |
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 re | |
| primePat = re.compile(r'^1?$|^(11+?)\1+$') | |
| # http://primes.utm.edu/lists/small/1000.txt | |
| primes = [int(x.strip()) for x in ''' | |
| 2 3 5 7 11 13 17 19 23 29 | |
| 31 37 41 43 47 53 59 61 67 71 | |
| 73 79 83 89 97 101 103 107 109 113 |