This file contains 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
Q = require 'q' | |
total = 0 | |
delay = (ms) => | |
deferred = Q.defer() | |
setTimeout( => | |
total = total + ms | |
console.log "Delayed #{ms} msec. Spent #{total} msec." | |
deferred.resolve() |
This file contains 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
module S3.Ls | |
( ls | |
) where | |
import Control.Applicative ((<*)) | |
import Control.Exception (throwIO) | |
import System.Process (readProcessWithExitCode) | |
import Text.Parsec | |
import Text.Parsec.String |
This file contains 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
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
module MongoDB.QueryDocument where | |
import Data.List (intercalate) | |
import Data.Monoid | |
import Data.Set | |
import Prelude hiding (map) | |
import qualified Prelude |
This file contains 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
require 'sinatra' | |
get '/log' do | |
"<html><body>#{ `git log --format="<p>%h %an %ad %s</p>"`.each_line.map(&:chomp).join }</body></html>" | |
end |
This file contains 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
task :compile do | |
`pandoc -t slidy -s edtech_cto_night.md -o slide.html` | |
end | |
task :open do | |
`open slide.html` | |
end | |
task :watch do | |
require 'listen' |
This file contains 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
if false | |
x = 1 | |
end | |
puts "x: #{x.inspect}" #=> x: nil |
This file contains 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
require 'benchmark_helper' | |
# Describe performance like RSpec-ish DSL | |
describe Api::Notifications do | |
before do | |
# Can use FactoryGirl to populate data | |
@me = create :user | |
create :post, author: @user | |
1000.times do |
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Network.Wai | |
import Network.HTTP.Types | |
import Network.Wai.Handler.Warp (run) | |
app :: Application | |
app _ respond = do | |
respond $ responseLBS | |
status200 | |
[("Content-Type", "text/plain")] |
This file contains 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
Dir['./*'] | |
.select {|d|File.directory? (d + "/.git") } | |
.map {|d| `cd #{d} ; git config remote.origin.url ; cd ../ `.chomp } | |
.reject {|u| u.empty? } | |
.each {|u| `ghq get #{u}` } |
This file contains 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
import System.Environment (getArgs, getProgName) | |
main1 :: IO () | |
main1 = getArgs >>= \args -> | |
getProgName >>= \progn -> | |
print $ progn ++ " " ++ show args | |
main2 :: IO () | |
main2 = do | |
args <- getArgs |
OlderNewer