View gist:5c20939f8ef80048190d70448a422bc0
Running Wild - Death or Glory
Mobb Deep - The Infamous
Basic Channel - s/t
Carnage - Dark Recollections
Buffalo Springfield - Again
Os Mutantes - s/t
Bulldoze - The Final Beatdown
Archimedes Badkar - s/t
クラムボン - まちわび まちさび
Lip Cream - s/t
View resize.js
const fileToDataUrl = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader
reader.onload = (e) => {
resolve(e.target.result)
};
reader.readAsDataURL(file);
});
}
View sigaction.hs
import System.Posix.Signals
import Control.Concurrent
main :: IO ()
main = do
m <- newEmptyMVar
installHandler sigKILL (Catch (putMVar m "Hi")) Nothing
installHandler keyboardSignal (Catch (putMVar m "Hi")) Nothing
takeMVar m >>= print
View json_include.rb
def json_include x, y
case x
when Hash
return false unless y.is_a? Hash
y.all? { |k, v| json_include(x[k], v) }
when Array
return false unless y.is_a? Array
y.all? { |y_| x.any? { |x_| json_include(x_, y_) } }
else
x == y
View b.rb
class Client
def initialize
@all_entries = [*1..30].map { |i| "Hello this is #{i}" }
end
def get(option)
from = option[:from_id] || 0
@all_entries[from..(from + 5)]
end
end
View pre-commit
#!/bin/bash -e
set -x
# If there are whitespace errors, print the offending file names and fail.
git diff-index --check --cached HEAD
exec git diff --cached --name-only --diff-filter=AM | grep '\.rb$' | xargs rubocop
View json_with_indifferent_access.rb
def json_response
json_with_indifferent_access JSON.parse response.body
end
def json_with_indifferent_access(json)
traverse_json(json) {|j| j.is_a?(Hash) ? j.with_indifferent_access : j }
end
def traverse_json(json, &block)
View PatternGuard.hs
import Data.List
main = IO ()
main = do
f ["one"]
f ["one", "two", "three"]
f ["ein", "zwei", "drei"]
f []
f :: [String] -> IO ()
View runwithstdin.hs
import Control.Exception
import GHC.IO.Handle
import System.IO
import System.IO.Temp
main :: IO ()
main = do
runWithStdin "Ornette Coleman Trio\nAt the Golden Circle Stockholm" $ do
getLine >>= putStrLn
getLine >>= putStrLn
View a.hs
import System.IO
import System.IO.Temp
main :: IO ()
main = do
withSystemTempFile "uuu" $ \path handle -> do
hPutStrLn handle "hello\nbye"
hClose handle
handle' <- openFile path ReadMode
go handle' stdout