Fujimura Daisuke fujimura

View entries.hs
1 2 3 4 5 6 7 8 9 10
import Control.Applicative ((<$>))
import Control.Monad
import System.Directory (doesDirectoryExist, doesFileExist,
getCurrentDirectory, getDirectoryContents)
 
entries :: FilePath -> IO [FilePath]
entries path = do
contents <- getDirectoryContents path
files <- filterM doesFileExist' contents
directories <- filter isSubDirectory <$> filterM doesDirectoryExist' contents
View spaghetti_and_neapolitan.hs
1 2 3 4 5 6 7 8 9 10
spaghetti :: String
spaghetti = "gtgtsgipgttptinggipsppaigsesgpetgstpatetisiesagaeaigttetepitiatsegssieeeeatepaaiagtpieataatppiitgiapsteitatiiatpetetetttgpetpaasipttssstpeeeggtiagtttegtiipestsasgpsepaasapttgattgiatppegitiatpasgatgepttggapesaeetaeissttggieietgspagesiipestipggstttpateptitiaetottissgggtttaipappgstsptttgtpispattgegstltiappseisapgistaiagteeiptptpisaieisagstapeteietgteiisgtiptstgtstasspeatspptitttatteastsgtptgtasggpniaaeteaisett"
neapolitan :: String
neapolitan = "neapolitan"
solve :: String -> String -> String
solve [] _ = ""
solve xs [] = xs
solve (x:xs) (y:ys)
View spaghetti_and_neapolitan.rb
1 2 3 4 5 6 7 8
spaghetti = "gtgtsgipgttptinggipsppaigsesgpetgstpatetisiesagaeaigttetepitiatsegssieeeeatepaaiagtpieataatppiitgiapsteitatiiatpetetetttgpetpaasipttssstpeeeggtiagtttegtiipestsasgpsepaasapttgattgiatppegitiatpasgatgepttggapesaeetaeissttggieietgspagesiipestipggstttpateptitiaetottissgggtttaipappgstsptttgtpispattgegstltiappseisapgistaiagteeiptptpisaieisagstapeteietgteiisgtiptstgtstasspeatspptitttatteastsgtptgtasggpniaaeteaisett"
 
neapolitan = "neapolitan"
 
s = spaghetti.dup
n = neapolitan.dup.chars
 
p s.chars.inject("") {|acc, x| x == n.first ? (n.shift and acc << "[#{x}]") : acc << x}
View listen_cabal.rb
1 2 3 4 5 6 7 8 9 10
require 'listen'
 
Listen.to! 'test', 'src', filter: /.*\.hs/ do |modified, added, removed|
system %|clear|
p modified
p added
p removed
if File.exists? "Rakefile"
system %|rake|
else
View color.rb
1 2 3 4 5 6 7 8 9 10
class String
# Originally from http://stackoverflow.com/questions/1489183/colorized-ruby-output/11482430#11482430
def self.colorize color, code
define_method color do
"\e[#{code}m#{self}\e[0m"
end
end
 
colorize :red, 31
colorize :green, 32
View clone.hs
1 2 3 4 5 6 7 8 9
import Control.Exception (bracket_)
import System.Directory
import System.Exit (ExitCode)
import System.IO.Temp (withSystemTempDirectory)
import System.Process (system)
 
inTemporaryDirectory :: String -> IO a -> IO a
inTemporaryDirectory name cb =
withSystemTempDirectory name $ flip inDirectory cb
View current-branches.rb
1 2 3 4 5 6 7 8 9 10
#! /usr/bin/env ruby
 
# Pull all directory under current directory, if it's on master, has no local changes, can be pulled fast-forward.
 
def git_repo?
`git status`.chomp !~ /Not a git repository/
end
 
def not_changed?
`git status -s`.chomp.empty?
View masspull.rb
1 2 3 4 5 6 7 8 9 10
#! /usr/bin/env ruby
 
# Pull all directory under current directory, if it's on master, has no local changes, can be pulled fast-forward.
 
def git_repo?
`git status`.chomp !~ /Not a git repository/
end
 
def not_changed?
`git status -s`.chomp.empty?
View README.md

Output mass exports.

How to use

$ git grep -h require app | ./module_exports.rb > all.coffee
$ cat all.coffee
module.exports = {
  "Application"    : require 'application',
  "Chaplin"        : require 'chaplin',
View pipe.rb
1 2 3 4 5 6 7 8 9 10
class Object
def pipe
yield self
end
end
 
# From https://github.com/rspec/rspec-rails/pull/766/files
 
# Without Object#pipe
types = begin
Something went wrong with that request. Please try again.