Skip to content

Instantly share code, notes, and snippets.

View aktowns's full-sized avatar
👾

Ashley Towns aktowns

👾
View GitHub Profile
@aktowns
aktowns / gist:661934
Created November 4, 2010 00:18
vim homebrew latest
require 'formula'
class Vim <Formula
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
homepage 'http://www.vim.org'
md5 '5b9510a17074e2b37d8bb38ae09edbf2'
depends_on 'ncursesw'
depends_on 'cscope'
let rec omNoms start op from nto =
if from > nto then start
else op from (omNoms start op (from + 1) nto)
printfn "%d" (omNoms 0 (+) 1 100)
(*
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
*)
[1..1000]
|> List.filter (fun n -> (n%3) = 0 || (n%5) = 0)
|> List.fold (+) 0
> let rec fib (start,step,list) =
if (start > 4000001) then (1,start, start::list)
else fib (start+step, start, (start::list))
val fib : int * int * int list -> int * int * int list
> let start,max,list = fib (1,1,[])
val start : int = 1
(*
Problem 3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
*)
let rec find_factors (count, target, list) =
if count < 2L then (1L,target,count::list)
else if (target % count = 0L) then find_factors((count-1L), target, count::list)
else find_factors((count-1L),target, list)
#!/usr/bin/env ruby
# This script converts xccolorthemes to dtvcolorthemes for porting xcode 3.x themes to xcode 4.x
# created by ashley towns <[email protected]>
# Public domain.
# ./dvtcolorconvert <inputfile>
# spits out a .dtvcolortheme file
require 'plist'
raise "Error: need a source file #{__FILE__} [file.xccolortheme]" if ARGV.length == 0
parseInt('005')
// => 5
parseInt('006')
// => 6
parseInt('007')
// => 7
parseInt('008')
// => 0
parseInt('009')
// => 0
@aktowns
aktowns / internode-usage.js
Created April 26, 2011 12:24
Wrapper around the internode api, for node.js
// internode-usage.js
// written by ashley towns <[email protected]>
var _ = require("underscore");
var request = require("request");
var xml2js = require("xml2js-expat");
//
var account_id = null;
var auth = null;
@aktowns
aktowns / gist:949522
Created April 30, 2011 07:51
Magic nyan-cat
javascript:i=0;setInterval(function(){i++;if(i==360){i=0;};document.getElementsByClassName('nyan-cat')[0].setAttribute("style","-webkit-transform:rotate("+i+"deg)")},50);
javascript:i=0;setInterval(function(){i++;if(i==window.document.width){i=0;};document.getElementsByClassName('nyan-cat')[0].setAttribute("style","position: absolute; left:"+i+"px");},10);