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 / spotify-remote.rb
Created November 20, 2011 01:18
Spotify Remote
require 'sinatra'
get '/' do
head = '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function(e) {
e.preventDefault();
$.get($(this).attr("data"));
if ($(this).attr("data") == "pause") {
@jdan
jdan / listall.py
Created January 13, 2012 03:19
A python script to recursively list all files in a given directory, newline separated
#!/usr/bin/python
import os
import sys
def listdir(d):
if not os.path.isdir(d):
print d
else:
for item in os.listdir(d):
listdir((d + '/' + item) if d != '/' else '/' + item)
@jdan
jdan / wiki-scraper.rb
Created January 21, 2012 21:23
(Nokogiri) Tests the idea that the first link on each wikipedia article will eventually lead to philosophy
#!/usr/bin/env ruby
# wiki-scraper.rb by Jordan Scales
# http://jordanscales.com
# http://programthis.net
#
# Tests the idea that the first link on each wikipedia article
# will eventually lead to philosophy
#
# Usage:
@jdan
jdan / wiki.user.js
Created April 5, 2012 02:55
UserScript to fix the strange blue background issue on Wikipedia (http://code.google.com/p/chromium/issues/detail?id=113711)
// ==UserScript==
// @name WikiBlue
// @description Removes strange blue overlay on Wikipedia
// @include http://en.wikipedia.org/*
// ==/UserScript==
// the guts of this userscript
function main() {
$('#mw-head-base').css('background-image', 'none');
@jdan
jdan / zen-coding.py
Created May 31, 2012 04:46
ZenCoding clone
#!/usr/bin/python
# Zen-Coding clone by Jordan Scales - http://jscal.es
# 5/30/12
# reference: http://whiletruecode.com/post/stop-hand-coding-start-zen-coding
# div>ul>li*5
# expands to
# <div>
# <ul>
@jdan
jdan / bday.py
Created July 21, 2012 04:51
Data Mining my Facebook Birthday Wishes
#!/usr/bin/python
import re
f = file('comments')
contents = f.read()
f.close()
chunks = contents.split('\n\n')
res = []
@jdan
jdan / helloworld.json
Created October 7, 2012 04:39
Cleaver - an easy tool to generate HTML slideshows from JSON
{
"name": "Cleaver",
"author": {
"name": "Jordan Scales",
"twitter": "@prezjordan",
"url": "http://jscal.es"
},
"description": "Hello World example!",
"slides": [
{
-- Binary Tree Module
-- Jordan Scales
-- 2 November 2012
module BinaryTree(BinaryTree(Node, EmptyTree), insert, height, arrayToBST, isLeaf, findMax, removeMax) where
-- we'll treat it as a `binary search tree`
data BinaryTree a = Node a (BinaryTree a) (BinaryTree a) |
EmptyTree
deriving (Show)
-- Huffman Coding Module
-- by Jordan Scales
-- 4 November 2012
module Huffman where
import BinaryTree
type Entry = ([Char], Integer)
type Dictionary = [(Char, [Char])]
-- Complex Numbers Module
-- Jordan Scales (scalesjordan@gmail.com)
-- 21 November 2012
module Complex where
-- Complex consists of a real and imaginary part
-- for our purposes, they are represented as /Floats/
data Complex = Complex Float Float deriving (Eq, Show)