Flask is a Python web framework that's steadily increasing in popularity within the webdev world. After reading so many great things about Flask, I decided to try it out myself. I personally find testing out a new framework difficult, because you must find a project complex enough to reveal the framework's quirks, but not so daunting as to take the fun out of the project. Luckily, my PHP/Wordpress powered website filled this role quite nicely - the website simply consists of static content, a contact page, and a blog. If I could not convert such a simple site over to Flask, I would immediately know that Flask and I would not make a good team.
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
| <html> | |
| <head> | |
| <title>Stupid jQuery table sort</title> | |
| <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
| <script type="text/javascript" src="stupidtable.js?dev"></script> | |
| <script type="text/javascript"> | |
| $(function(){ | |
| $("table").stupidtable(); | |
| console.log($("table tbody tr td").eq(0)) | |
| $("table th").bind("click", function(){ |
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
| # How long to brute force keys | |
| ks = 1000000000 # A billion keys per second | |
| clusters = 10 # How many computers in the cluster attacking our key? | |
| numChars = 38 # We have 38 characters available to use in the key | |
| n = 100 # Length of the key string | |
| combinations = numChars ** n # This ignores variable length too | |
| # How many years it would take a single computer to brute force. |
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
| # encode a video | |
| # arg1: video origin | |
| # arg2: destination | |
| function encode_video(){ | |
| ffmpeg -y -i $1 -pass 1 -vcodec libx264 -b 756k -g 15 -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -acodec libfaac -ab 64k $2 | |
| ffmpeg -y -i $1 -pass 2 -vcodec libx264 -b 756k -g 15 -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -acodec libfaac -ab 64k $2 | |
| } |
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
| # Add a necessary repository. | |
| sudo apt-get install python-software-properties | |
| sudo add-apt-repository ppa:brianmercer/php | |
| sudo apt-get update | |
| sudo apt-get install nginx | |
| sudo apt-get install php5-cli php5-common php5-mysql php5-suhosin php5-gd php5-dev | |
| sudo apt-get install php5-fpm php5-cgi php-pear php5-memcache php-apc |
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
| 1.9.2-p290 :001 > def mytest | |
| 1.9.2-p290 :002?> return @someval = 10 | |
| 1.9.2-p290 :003?> end | |
| => nil | |
| 1.9.2-p290 :004 > mytest | |
| => 10 | |
| 1.9.2-p290 :005 > @someval | |
| => 10 | |
| 1.9.2-p290 :006 > def mytest2 | |
| 1.9.2-p290 :007?> return @someval ||= 30 |
This is a small instruction guide for installing git-dude on OSX. Git dude is a convenient git repo monitoring service.
Ensure you have Homebrew installed.
Install growlnotify via brew install growlnotify.
If you are a Lion user and are getting No formula available, then you can just
download growlnotify as a package
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
| ############################################################## | |
| # Upstream must have unique name and unique socket. # | |
| # The socket must match what is in the app's unicorn.rb file # | |
| ############################################################## | |
| upstream railsapp1_server { | |
| server unix:/tmp/railsapp1.sock fail_timeout=0; | |
| } | |
| ############################## | |
| # Rewrite www to non-www # |
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
| worker_processes 1; | |
| user nobody nogroup; | |
| pid /tmp/nginx.pid; | |
| error_log /tmp/nginx.error.log; | |
| events { | |
| worker_connections 1024; | |
| accept_mutex off; | |
| } | |
| http { | |
| default_type application/octet-stream; |
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
| # Kill and restart nginx | |
| function restart_nginx(){ | |
| pids=$(pidof nginx) | |
| if [[ -n $pids ]]; | |
| then | |
| sudo kill -9 $pids | |
| sudo service nginx restart | |
| fi | |
| } |