This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
/* Keybindings for emacs emulation. Compiled by Jacob Rus. | |
* | |
* To use: copy this file to ~/Library/KeyBindings/ | |
* after that any Cocoa applications you launch will inherit these bindings | |
* | |
* This is a pretty good set, especially considering that many emacs bindings | |
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and | |
* perhaps a few more, are already built into the system. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn yummly-api [auth] | |
{:endpoint "http://api.yummly.com/v1" | |
:resources {:recipe-search "/api/recipes"} | |
:params ["q", "requirePictures", "allowedIngredient[]", "excludedIngredient[]", | |
"allowedDiet[]", "allowedAllergy[]", "allowedCuisine[]", | |
"allowedCourse[]", "allowedHoliday[]", "excludedCuisine[]", | |
"excludedCourse[]", "excludedHoliday[]", "maxTotalTimeInSeconds", | |
"nutrition.ATTR.{min|max}", "maxResult", "start", | |
"flavor.ATTR.{min|max}", "facetField[]"] | |
:auth {"_app_id" (:app-id auth), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import log, floor, pow | |
class MinMaxHeap(object): | |
"""an implementation of min-max heap using an array, | |
which starts at 1 (ignores 0th element) | |
""" | |
def __init__(self, array=[]): | |
super(MinMaxHeap, self).__init__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns euler.three | |
(require [clojure.core.reducers :as r])) | |
(declare largest-prime-factor-for) | |
(declare factors-of) | |
(declare source-factors) | |
(declare source-naturals) | |
(declare factor?) | |
(declare prime?) | |
(declare certainty) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- turn an Integer into a list of digits | |
digits = map (read . (:[])) . show | |
-- is a given fraction special? | |
special :: Integer -> Integer -> Bool | |
special n d | |
| (n_rf / d_rf) == ((realToFrac (head ns)) / (realToFrac (head ds))) = True | |
| otherwise = False | |
where n_rf = realToFrac n | |
d_rf = realToFrac d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"user": { | |
"contributors_enabled": false, | |
"created_at": "Wed Sep 23 18:48:46 +0000 2009", | |
"default_profile": false, | |
"default_profile_image": false, | |
"description": "Mura is a Japanese Fusion Restaurant serving steak, sushi, seafood. Located in North Hills. Serving lunch and dinner.", | |
"favourites_count": 0, | |
"follow_request_sent": null, | |
"followers_count": 665, | |
"following": null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In Clojure, hash-maps are truly functions of keys to values. | |
# So you can do `(:a {:a 1})` and get `1` as the result | |
# Why not put this in Ruby? | |
# access keys of a hash like a function | |
class Object | |
def respond_to?(method) | |
if (method.to_s =~ /^_.*/) == 0 | |
true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ruby1.9.3 | |
def defn name, &b | |
Object.send :define_method, name, &b | |
end | |
# this also works (surprisingly), albeit with a warning | |
# def defn name | |
# Object.send(:define_method, name) | |
# end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# piping example in Ruby | |
def foo(data) | |
data[:a] += 1 | |
data | |
end | |
def bar(data) | |
data[:b] += 10 | |
data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run `compass watch` at pwd | |
# run `coffee -o scripts/ -cw coffee/` at pwd | |
type -P compass &>/dev/null || { echo "Compass command not found."; exit 1; } | |
type -P coffee &>/dev/null || { echo "Coffee command not found."; exit 1; } | |
if [ ! -d sass/ ] || [ ! -d scripts/ ] | |
then | |
echo "Project not setup correctly! Put sass files in sass/ and coffee in coffee/" | |
else |