This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| {-# LANGUAGE OverloadedStrings #-} | |
| {- To Run: | |
| Load in ghci | |
| :set -XOverloadedStrings (for convenience) | |
| Execute repl expr -} | |
| import Control.Applicative | |
| import Data.Attoparsec hiding (Result) | |
| import Data.Attoparsec.Char8 (char8, isDigit_w8, isSpace_w8) |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| #include <assert.h> | |
| #include <stdarg.h> | |
| #include <stdbool.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| enum type { | |
| NIL, |
| M[16],X=16,W,k;main(){T(system("stty cbreak") | |
| );puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i | |
| ,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M | |
| [w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<< | |
| (l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k) | |
| ]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d | |
| -1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X] | |
| *i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4; | |
| )s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4|| | |
| puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2 |
| A warning occurred (42 apples) | |
| An error occurred |
| import wave, struct, sys | |
| from math import pow, sin | |
| samples = 100000 | |
| terms = 50 | |
| normalizer = 32768/1.5 | |
| weier = wave.open('weierstrass.wav', 'w') | |
| weier.setparams((1, 2, 44100, 0, 'NONE', 'not compressed')) | |
| print "Progress (%):", | |
| for i in range(samples): | |
| x = float(1000*i)/samples |
| # A guide to prevent pain and suffering while upgrading to OS X Mavericks | |
| # This will vary greatly depending on system set up, so read the instructions carefully | |
| # Back up Virtulenvs | |
| #################### | |
| # Very important! | |
| # For each virtualenv you have, run "pip freeze > requirements.txt" while in the activated virtualenv | |
| # in order to prevent loss of dependencies during the upgrade. |
| from flask import Flask, request, session | |
| from sqlalchemy import create_engine, Table, MetaData | |
| from sqlalchemy.orm import mapper, relationship, sessionmaker, scoped_session | |
| from sqlalchemy.sql import select | |
| app = Flask(__name__) | |
| engine = create_engine('postgresql+psycopg2://kamal@localhost/clinic_dev') | |
| metadata = MetaData(bind=engine) | |
| DBSession = scoped_session(sessionmaker(bind=engine)) |
| # Python OAuth example | |
| import evernote.edam.userstore.constants as UserStoreConstants | |
| import evernote.edam.type.ttypes as Types | |
| from evernote.api.client import EvernoteClient | |
| ## | |
| # Helper function to turn query string parameters into a | |
| # Python dictionary | |
| ## |
| # Inser this snippet into your ~/.bash_profile | |
| # Set up the GPG Agent | |
| # http://fvue.nl/wiki/Debian_4.0:_Installing_gpg-agent | |
| if [ -f ${HOME}/.gpg-agent-info ] && \ | |
| kill -0 $(cut -d: -f 2 ${HOME}/.gpg-agent-info) | |
| then | |
| # Yes, '.gpg-agent-info' points to valid gpg-agent process; | |
| # Indicate gpg-agent process | |
| GPG_AGENT_INFO=$(cat ${HOME}/.gpg-agent-info | cut -c 16-) |