Generates the Mandelbrot Set using @jashkenas's ruby-processing.
$ sudo gem install ruby-processing
$ rp5 run mandelbrot.rb
Generates the Mandelbrot Set using @jashkenas's ruby-processing.
$ sudo gem install ruby-processing
$ rp5 run mandelbrot.rb
# 1 Jan 2013 | |
if __name__ == '__main__': | |
s = raw_input() | |
# f(char) counts the instances of `char` in `s` | |
f = lambda c: len(filter(lambda i: i == c, s)) | |
print ' '.join(map(str, [f('A'), f('C'), f('G'), f('T')])) |
Enter a number of iterations (try and keep it low) to see the generated dragon curve. The above image shows generation 4.
by Jordan Scales (@prezjordan)
#!/usr/bin/env ruby | |
# ps1rb | |
# Jordan Scales (http://jordanscales.com) | |
# | |
# Writing a PS1 in ruby is probably a bad idea. | |
# | |
# In ~/.bash_profile: | |
# PS1="\`ps1rb\`" |
#!/usr/bin/python | |
# | |
# Jordan Scales (http://jordanscales.com) | |
# 5/1/13 | |
# | |
# A walkthrough of a simple (but useful!) use of decorators to memoize functions | |
def memoize(f): | |
if not hasattr(f, 'cache'): # define a `cache` property on our function | |
f.cache = {} # if we haven't already |
% http://www.brainbashers.com/showpuzzles.asp?puzzle=ZZPN | |
% | |
% Solution by Jordan Scales (http://jordanscales.com) | |
% 23 May 2013 | |
% | |
% At a recent bowling match, two games were played. | |
% | |
% Kev beat Stuart in both games, also Richard beat John in both games. | |
% The winner in game 1 came second in game 2. Richard won game 2 and | |
% John beat Stuart in game 1. No player got the same placing twice. |
require './fraction' | |
# Returns an array representing the elements in the continued | |
# fraction expansion of a given fraction | |
def continued_fraction q | |
# Base case | |
# return the numeration if we are a whole number | |
return [q.numer] if q.denom == 1 | |
# Get leading digit |
/** | |
* We have an array, and we only want the first N elements. | |
*/ | |
var arr = [...]; | |
var num = 10; | |
// attempt #1 | |
return arr.slice(0, num) | |
// Issue: creates a new array |
title: Cleaver author: name: "Jordan Scales" twitter: "@jdan" url: "http://jordanscales.com" output: gh-pages.html style: intro.css
--
#!/usr/bin/env python | |
# cal implementation | |
# by Adam Cotenoff (@acotenoff) | |
# Jordan Scales (@jdan) | |
# 18 September 2013 | |
from datetime import date | |
from sys import argv | |
# Takes an array of dates (maybe with spaces) |