Skip to content

Instantly share code, notes, and snippets.

@acoffman
acoffman / file_downloader.rb
Created September 10, 2008 03:40
Really basic script for downloading a file from the web and saving it to a specified location.
#ruby script to download a file from the command line given a url
#
#works with two arguments:
#argument 1 is the path to the file, you can leave
#the http on or remove it, the script handles both
#
#second argument is the name of the file as you want it to be saved on disk
#i.e. download.zip
#
#KNOWN BUG: will not work given an IP instead of a url
;; Adam Coffman
;; Scheme Assignment 2
;; Jugs Problem
;;Program to solve the "Jugs Problem" from die hard 3.
;;invoked with (Jugs CapacityJugA CapacityJugB GoalFillofA)
;;returns a step by step path to the goal.
;;IE (Jugs 5 3 4) would return
;;((0 0 5 3) (5 0 5 3) (2 3 5 3) (2 0 5 3) (0 2 5 3) (5 2 5 3) (4 3 5 3))
;;Suporting Functions
;; Adam Coffman
;; Scheme assignment 3
;; The PARSE function accepts as argument an infix arithmetic expression in the
;; form of a list and returns a list representation of the corresponding expresion
;; tree. Ex., (parse '(3 + 4))--> (+ (3 4)),
;; (parse '(3 + 4 * 5)) --> (+ (3 (* (4 5)))) and
;; (parse '( 4 + 3 * ( 5 + 6) - 2)) --> (- ((+ (4 (* (3 (+ (5 6)))))) 2))
;; Note that each element of the list must be one of three things: a number; one of +, -, *
;; /; or a sublist (ex., (5 + 6))
set nocompatible
" have command-line completion <Tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <Tab>s cycle through the possibilities:
set wildmode=list:longest,full
" display the current mode and partially-typed commands in the status line:
set showmode
set showcmd
set nocompatible
" have command-line completion <Tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <Tab>s cycle through the possibilities:
set wildmode=list:longest,full
" display the current mode and partially-typed commands in the status line:
set showmode
set showcmd
@acoffman
acoffman / peepopen macvim
Created November 1, 2010 14:46
better directory support than the default
let g:peepopen_loaded = 1
let g:peepopen_cwd = getcwd()
let s:save_cpo = &cpo
set cpo&vim
function s:LaunchPeepOpenViaVim()
let cwd = g:peepopen_cwd
silent exe "!open -a PeepOpen " . shellescape(cwd)
endfunction
@acoffman
acoffman / gist:804687
Created January 31, 2011 19:56
blog entry ideas
switching to jekyll
basic nodejs app using express
using socketio with nodejs
@acoffman
acoffman / bespin.vim
Created February 9, 2011 04:48
vim colorscheme based on mozilla bespin
" Vim color file
" Converted from Textmate theme Bespin using Coloration v0.2.5 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
@acoffman
acoffman / gist:1201988
Last active May 17, 2016 21:13
memoization
public static class Memoization {
public static Func<T,K> MemoizeFunction<T, K>(this Func<T, K> function) {
var table = new Dictionary<T, K>();
return (args) => {
if (table.ContainsKey(args)) return table[args];
var result = function(args);
table[args] = result;
return result;
};
}
#prompt
function parse_git_deleted {
[[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-"
}
function parse_git_added {
[[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+'
}
function parse_git_modified {
[[ $(git status 2> /dev/null | grep modified:) != "" ]] && echo "*"
}