Skip to content

Instantly share code, notes, and snippets.

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 Feb 13, 2014
pplog ( https://www.pplog.net ) で きになったひとのTwitter ページを見に行けるブックマークレット。twitter の部分をpplog に変えてもいいかも。
View pplog_to_twitter.js
javascript:(function(){window.open('http://twitter.com/' + window.location.href.match(/[a-zA-Z_0-9|-]+$/))})();
View ohai.rb
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 Feb 23, 2014
xls 形式のファイルを生成してみる。A0 に「test.」が保存されたファイルが作られる。
View excel_edit.rb
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 Mar 5, 2014
my first time Yesod. チュートリアルにそって、3ページを巡回するアプリケーションを作成
View haskel_and_yesod.hs
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}
import Yesod
data Links = Links
mkYesod "Links" [parseRoutes|
/ HomeR GET
/page1R Page1R GET
/page2R Page2R GET
View fizzbuzz.hs
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 Mar 10, 2014
RSpec での量産型テストのれんしゅう。
View div_spec.rb
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
View Guardfile
# 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 Aug 29, 2015
モジュールとインスタンス変数について
View module.rb
module Greeting
def self.hello name
@name = name
"Hello #{name}"
end
def self.name
@name
end
end
puts Greeting.hello('John') #=> Hello John
View preceed.cfg
#===============================================
# 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 Apr 5, 2014
Haskell 練習
View practice.hs
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 /= '.']