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
from functools import wraps | |
import sys | |
import pdb | |
import traceback | |
def pdb_on_error(func): | |
@wraps(func) | |
def pdbd(*args, **kwargs): | |
try: | |
func(*args, **kwargs) |
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
" Stick this in ~/.vim/ftplugin/java.vim | |
" eclim goodness | |
call SuperTabSetDefaultCompletionType("<c-x><c-u>") | |
augroup eclim | |
autocmd! | |
autocmd BufWrite *.java :JavaImportMissing | |
autocmd BufWrite *.java :JavaImportClean | |
augroup END | |
nnoremap <buffer> <Leader>r :Java<CR> |
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 sys | |
case = 1 | |
def fits_at_size(W, H, size, words): | |
cur_row = 0 | |
cur_col = 0 | |
for word in S: | |
if len(word) * size > W: |
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
// Let's assume we have neither block scope nor variable hoisting. | |
if (foo) { | |
var x = 7; | |
} | |
console.log(x); | |
// We now either have a 7 printed or a Reference error. |
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
keepDiv :: Int -> Int -> Int | |
keepDiv x n | |
| x `mod` n == 0 = keepDiv (x `div` n) n | |
| otherwise = x | |
nfacts' :: Int -> Int -> Int | |
nfacts' 1 _ = 0 | |
nfacts' x n | |
| x `mod` n == 0 = 1 + nfacts' (x `keepDiv` n) (n + 1) | |
| otherwise = nfacts' x (n + 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
/* | |
Output: | |
Q: 17, A: 0, M: 5 [00000000 00010001] | |
Q: 34, A: 0, M: 5 [00000000 00100010] | |
Q: 68, A: 0, M: 5 [00000000 01000100] | |
Q: 136, A: 0, M: 5 [00000000 10001000] | |
Q: 16, A: 1, M: 5 [00000001 00010000] | |
Q: 32, A: 2, M: 5 [00000010 00100000] | |
Q: 64, A: 4, M: 5 [00000100 01000000] |
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 <iostream> | |
#include <set> | |
#include <utility> | |
using namespace std; | |
int main() { | |
FILE* fin = fopen("freq.txt","r"); | |
set<double> freqs; | |
double n; |
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 AC - CPP (g++) | |
#include <iostream> | |
using namespace std; | |
int main() { | |
int n; | |
while(1) { | |
cin >> n; | |
if (n == 42) break; | |
cout << n << endl; |
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 on | |
set backspace=2 "Make backspace work as expected on Mac OS X | |
set autoindent "Auto Indent code - This simply retains indentation level | |
set tabstop=2 "Set space width of tabs | |
set sw=2 | |
set noexpandtab "I like my tabs to stay as tabs | |
set splitright "By default, split to the right | |
set number "Add line numbers |
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
http://downloads.wordpress.org/plugin/wp-codebox.zip |