Overview
This file contains 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
def calc(b) | |
b.call(3, 2) | |
end | |
#def calc(&block) | |
# block.call | |
#end | |
# calc { |a, b| p a+b } |
This file contains 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
CODE_LENGTH = 8 | |
def generate_code | |
code = SecureRandom.hex(6).hex.to_s(36) | |
code = code[0, CODE_LENGTH] | |
code += ('A'..'Z').to_a.sample(CODE_LENGTH - code.length).join('') | |
code.upcase | |
end | |
def collision_detection(re_count) |
This file contains 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 AddCodeToUsers < ActiveRecord::Migration | |
def change | |
add_column :users, :code, :string, limit: 8, after: :support_code, comment: 'コード' | |
User.reset_column_information | |
reversible do |dir| | |
dir.up do | |
# 衝突するかしないかは運任せな所あり | |
User.find_each do |u| | |
u.update(invited_code: SecureRandom.hex(4).upcase) |
This file contains 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 'RMagick' | |
require 'find' | |
require "FileUtils" | |
# アニメーション GIF が考慮されて画像は配列で読み込まれるので、 | |
# 配列の先頭画像を取得する。 | |
SMALL_SIZE = 150 | |
MEDIUM_SIZE = 200 | |
BIG_SIZE = 300 |
This file contains 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
# ------------------------------ | |
# symlink | |
# ------------------------------ | |
# .oh-my-zsh-custom/ | |
# .gitconfig | |
# .jshintrc | |
# .pryrc | |
# .tigrc | |
# .tmux.conf | |
# .vimrc |
This file contains 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 java.util.Calendar | |
object YearUtil extends App { | |
println(countLeapYear(1989, 2014)) | |
/** | |
* 閏年判定 | |
* | |
* - 西暦年が4で割り切れる年は閏年 |
This file contains 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
#!/bin/sh | |
# parse this format | |
# x3de1b0 HEAD@{0}: checkout: moving from xxxx to yyyyy | |
BEFORE_BRANCH=`git reflog | head -1 | cut -f 6 -d ' '` | |
AFTER_BRANCH=`git reflog | head -1 | cut -f 8 -d ' '` | |
DIFF=`git diff ${BEFORE_BRANCH} ${AFTER_BRANCH} --name-only | grep Podfile` | |
if [ -n "${DIFF}" ]; then | |
bundle exec pod install # pod install |
This file contains 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
(function(global) { | |
"use strict;" | |
// Class ------------------------------------------------ | |
function YourModule() { | |
}; | |
// Header ----------------------------------------------- | |
YourModule["prototype"]["method"] = YourModule_method; // YourModule#method(someArg:any):void |
OlderNewer