Skip to content

Instantly share code, notes, and snippets.

View jlfwong's full-sized avatar

Jamie Wong jlfwong

View GitHub Profile
@jlfwong
jlfwong / java.vim
Created February 2, 2012 04:22
Java ftplugin for working with eclim
" 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>
@jlfwong
jlfwong / gist:1667581
Created January 24, 2012 03:20
Billboards
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:
@jlfwong
jlfwong / gist:1392387
Created November 24, 2011 21:53
No block scope, no variable hoisting
// 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.
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)
@jlfwong
jlfwong / gist:747692
Created December 19, 2010 21:14
ECE 222 - Restoring Binary Division Algorithm
/*
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]
#include <iostream>
#include <set>
#include <utility>
using namespace std;
int main() {
FILE* fin = fopen("freq.txt","r");
set<double> freqs;
double n;
//TEST AC - CPP (g++)
#include <iostream>
using namespace std;
int main() {
int n;
while(1) {
cin >> n;
if (n == 42) break;
cout << n << endl;
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
http://downloads.wordpress.org/plugin/wp-codebox.zip
<input type='button' value='click me' onclick='solve' />