Skip to content

Instantly share code, notes, and snippets.

View jdan's full-sized avatar
🐫
- : int -> int -> int = <fun>

Jordan Scales jdan

🐫
- : int -> int -> int = <fun>
View GitHub Profile
@jdan
jdan / README.md
Created December 27, 2012 19:37
Mandelbrot Set using ruby-processing

mandelbrot.rb

Generates the Mandelbrot Set using @jashkenas's ruby-processing.

Run it

$ sudo gem install ruby-processing
$ rp5 run mandelbrot.rb

Screen Shot 2012-12-27 at 2 32 50 PM

@jdan
jdan / 1_DNA.py
Created January 2, 2013 03:50
Solutions to the first 6 ROSALIND (http://rosalind.info) problems in Python
# 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')]))
@jdan
jdan / README.md
Created March 24, 2013 19:52
Visualizing Dragon Curves

Dragon Curve

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)

@jdan
jdan / ps1rb.rb
Created March 30, 2013 19:17
A nifty PS1 written in Ruby
#!/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.
@jdan
jdan / continued-fraction.rb
Created July 23, 2013 05:17
Continued fractions with ruby
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
@jdan
jdan / length.js
Last active December 20, 2015 09:19
Array length bunnies
/**
* 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
@jdan
jdan / gh-pages.md
Last active December 21, 2015 21:59

title: Cleaver author: name: "Jordan Scales" twitter: "@jdan" url: "http://jordanscales.com" output: gh-pages.html style: intro.css

--

@jdan
jdan / cal
Created September 19, 2013 02:05
#!/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)