Skip to content

Instantly share code, notes, and snippets.

View gouf's full-sized avatar
😇
I don't know how my life work with.

Go Furuya gouf

😇
I don't know how my life work with.
View GitHub Profile
@gouf
gouf / pplog_to_twitter.js
Created February 13, 2014 16:55
pplog ( https://www.pplog.net ) で きになったひとのTwitter ページを見に行けるブックマークレット。twitter の部分をpplog に変えてもいいかも。
javascript:(function(){window.open('http://twitter.com/' + window.location.href.match(/[a-zA-Z_0-9|-]+$/))})();
@gouf
gouf / ohai.rb
Created February 16, 2014 23:16
Ohai を単体で使ってみる。 Ref: https://wiki.opscode.com/display/chef/Ohai+Installation+and+Use
require 'ohai'
require 'pp'
pp ohai = Ohai::System.new
pp ohai.all_plugins
pp ohai.seen_plugins
pp kernel = ohai.kernel
pp kernel.keys
pp kernel[:name]
pp kernel[:release]
@gouf
gouf / excel_edit.rb
Created February 23, 2014 20:52
xls 形式のファイルを生成してみる。A0 に「test.」が保存されたファイルが作られる。
require 'spreadsheet'
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet
sheet[0,0] = 'test.'
book.write('example.xls')
@gouf
gouf / haskel_and_yesod.hs
Created March 5, 2014 23:16
my first time Yesod. チュートリアルにそって、3ページを巡回するアプリケーションを作成
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}
import Yesod
data Links = Links
mkYesod "Links" [parseRoutes|
/ HomeR GET
/page1R Page1R GET
/page2R Page2R GET
toStr :: Int -> String
toStr x = if x `mod` 15 == 0 then "FizzBuzz"
else if x `mod` 3 == 0 then "Fizz"
else if x `mod` 5 == 0 then "Buzz"
else show x
fizzbuzz :: Int -> [String]
fizzbuzz n = map toStr[1 .. n]
main = do
print (fizzbuzz 15)
@gouf
gouf / div_spec.rb
Created March 10, 2014 00:18
RSpec での量産型テストのれんしゅう。
require 'spec_helper'
describe "always divisible by 9" do
(1..100).each do |x|
first = x.to_s[0]
last = x.to_s[1]
next if first == last
next if first.nil? or last.nil?
swap_x = (last + first).to_i
new_x = (x - swap_x).abs
# Ignore Vim swap files
ignore /~$/
ignore /^(?:.*[\\\/])?\.[^\\\/]+\.sw[p-z]$/
group :unit do
guard 'minitest', test_folders: 'test/unit', test_file_patterns: '*_test.rb' do
watch(%r'^lib/blah/(.+)\.rb$') {|m| "test/unit/#{m[1]}_test.rb"}
watch(%r'^test/unit/.+_test\.rb$')
@gouf
gouf / module.rb
Last active August 29, 2015 13:57
モジュールとインスタンス変数について
module Greeting
def self.hello name
@name = name
"Hello #{name}"
end
def self.name
@name
end
end
puts Greeting.hello('John') #=> Hello John
#===============================================
# BOOT SEQUENCE CONFIGURATIONS START
#===============================================
d-i debian-installer/language string en
d-i debian-installer/country string US
d-i debian-installer/locale string en_US.UTF-8
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
d-i console-setup/charmap select UTF-8
@gouf
gouf / practice.hs
Created April 5, 2014 12:39
Haskell 練習
madam = "Madam, I'm Adam."
remove chr str = [c | c <- str, c /= chr]
removeCommas str = remove ',' str
removeBlanks str = remove ' ' str
removePeriods str = remove '.' str
{--
removeCommas str = [c | c <- str, c /= ',']
removeBlanks str = [c | c <- str, c /= ' ']
removePeriods str = [c | c <- str, c /= '.']