Skip to content

Instantly share code, notes, and snippets.

Annual Subway Ridership By Station
Source: http://web.mta.info/nyct/facts/ridership/ridership_sub_annual.htm (MTA) (2013)
The Bronx
38, 161 St-Yankee Stadium, 8,766,012
54, 3 Av-149 St, 7,310,115
86, Parkchester, 5,215,409
110, 149 St-Grand Concourse, 4,427,399
122, Fordham Rd, 3,946,955
125, Fordham Rd, 3,876,601
@naush
naush / cors.js
Last active August 29, 2015 13:57
CORS Example
$.ajaxSetup({
dataType: "json",
beforeSend: function(xhr) {
xhr.setRequestHeader("accept", "application/json");
}
});
$.fetchJSON = function(path) {
return $.ajax({
url: path,
@naush
naush / sony
Created February 18, 2014 07:18
Purpose of Incorporation: creating an ideal workplace, free, dynamic, and joyous, where dedicated engineers will be able to realize their craft and skills at the highest possible level.
require 'date'
birthday = Date.new(1985, 11, 21)
today = Date.today
move = Date.new(2000, 8, 8)
since_birthday = (today - birthday).to_i
since_move = (today - move).to_i
puts "You are #{since_birthday} days old!"
puts "You've been in the USA for #{since_move} days!"
@naush
naush / order.hs
Last active December 12, 2015 09:19
-- http://xkcd.com/287/
import Data.List
order menu amount items
| amount < 0 = []
| amount == 0 = [items]
| otherwise = foldl (\meals (item, price) ->
meals ++ order menu (amount - price) (item : items)) [] menu
@naush
naush / order.clj
Last active December 12, 2015 09:19
;; http://xkcd.com/287/
(defn order [menu amount items]
(cond
(< amount 0) []
(= amount 0) [items]
:else (reduce
(fn [meals, [item price]]
(concat meals (order menu (- amount price) (into [item] items)))) [] menu)))
@naush
naush / order.rb
Last active December 12, 2015 08:49
# http://xkcd.com/287/
def order(menu, amount, items)
return [] if amount < 0
return [items] if amount == 0
menu.inject([]) do |meals, (item, price)|
meals += order(menu, amount - price, items + [item])
end
end
I18n.backend.store_translations :en, :thanks => 'Thanks %{name}!'
I18n.translate :thanks, :name => 'Jeremy'
# => 'Thanks Jeremy!'
I18n.t :missing, :default => 'Not here'
# => 'Not here'
# config/locales/en.yml
en:
welcome: <b>welcome!</b>
if (self.name.split.size < 2)
self.errors.add :name, "must have first and last name"
end
body:lang(en) {
font-size: 62.5%;
font-family: en;
}
body:lang(zh-cn) {
font-family: zh-cn;
}
@font-face {