- Github flow には関係ない
- push権限を与えるために Github の ID確認のために。
- https://github.com/great-h/great-h.github.io/issues?milestone=3&state=open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/all' | |
datetime = DateTime.new 2013, 2, 7 | |
date = Date.new 2013, 2, 7 | |
time = Time.new 2013, 2, 7 | |
datetime # => Thu, 07 Feb 2013 00:00:00 +0000 | |
date # => Thu, 07 Feb 2013 | |
time # => 2013-02-07 00:00:00 +0900 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class Player | |
attr_reader :position | |
# Cで言うenum的なやつ | |
module MOVING_MODE | |
NORMAL = 1 | |
FAST = 2 | |
KANI = 3 #蟹モードが増えた | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class Player | |
class Normal | |
# move の内容をもってきて、いらない caseを削除 | |
# return を追加 | |
# x_speed, y_speed を展開すれば 03のコードに向う | |
def move(direction, position) | |
x_speed = 10 | |
y_speed = 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Colour.CIE | |
import Data.Colour.SRGB | |
import Data.Colour.CIE.Illuminant | |
import Data.Colour.SRGB.Linear | |
cieLCH :: (Ord a, Floating a) => Chromaticity a -> a -> a -> a -> Colour a | |
cieLCH white_ch l c h = cieLAB white_ch l a b | |
where | |
radius = pi * h / 180 | |
a = cos radius * c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ gem install active_record sqlite3 | |
require 'active_record' | |
require 'sqlite3' | |
DATABASE_FILE = File.join(File.dirname(__FILE__), "convert.sqlite") | |
`rm #{DATABASE_FILE}` | |
ActiveRecord::Base.establish_connection( | |
adapter: "sqlite3", | |
database: DATABASE_FILE, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# >> を * | |
# >>= を bind | |
# return を self.new | |
# mplus を + | |
# mzero を self.zero | |
# | |
# に見立てて Maybe モナド書いてみた | |
# bind に渡す block で Maybe と書きたくないので第二引数に型情報を付加してみた。 | |
class Monad | |
def *(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
message = ARGV.join(" ") | |
if message.empty? | |
message = 'なにか終わったかも'end | |
system "terminal-notifier -message #{message} -execute 'open -a iTerm.app'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FizzBuzz | |
def fizzbuzz(n) | |
if n % 3 == 0 and n % 5 == 0 | |
'fizzbuzz' | |
elsif n % 3 == 0 | |
'fizz' | |
elsif n % 5 == 0 | |
'buzz' | |
else | |
n.to_s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun ruby-mode-hook-init () | |
"encodingを自動挿入しないようにする" | |
(remove-hook 'before-save-hook 'ruby-mode-set-encoding) | |
(define-key ruby-mode-map "\C-ce" 'my-ruby-mode-set-encoding)) | |
(add-hook 'ruby-mode-hook 'ruby-mode-hook-init) | |
(defun my-ruby-mode-set-encoding () | |
"set-encoding ruby-mode" | |
(interactive) |