Skip to content

Instantly share code, notes, and snippets.

View fujimura's full-sized avatar

Daisuke Fujimura fujimura

View GitHub Profile
Q = require 'q'
total = 0
delay = (ms) =>
deferred = Q.defer()
setTimeout( =>
total = total + ms
console.log "Delayed #{ms} msec. Spent #{total} msec."
deferred.resolve()
module S3.Ls
( ls
) where
import Control.Applicative ((<*))
import Control.Exception (throwIO)
import System.Process (readProcessWithExitCode)
import Text.Parsec
import Text.Parsec.String
@fujimura
fujimura / QueryDocument.hs
Last active August 29, 2015 13:57
MongoDB Query Document in Haskell(WIP)
{-# 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
@fujimura
fujimura / git_log.rb
Created April 19, 2014 12:15
git-log app in sinatra
require 'sinatra'
get '/log' do
"<html><body>#{ `git log --format="<p>%h %an %ad %s</p>"`.each_line.map(&:chomp).join }</body></html>"
end
@fujimura
fujimura / Rakefile
Last active August 29, 2015 14:01
2014年版フロントエンド開発のあたりまえ @ EdTech CTO Night!
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'
if false
x = 1
end
puts "x: #{x.inspect}" #=> x: nil
@fujimura
fujimura / bm.rb
Created July 10, 2014 08:31
Idea of RSpec-ish benchmarking tool
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
{-# 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")]
@fujimura
fujimura / ghq_import.rb
Created August 11, 2014 08:10
Import all git repo from old repositories directory to ghq
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}` }
import System.Environment (getArgs, getProgName)
main1 :: IO ()
main1 = getArgs >>= \args ->
getProgName >>= \progn ->
print $ progn ++ " " ++ show args
main2 :: IO ()
main2 = do
args <- getArgs