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
## | |
#getHttpJpg.rb | |
# | |
#使い方 | |
# | |
# 例 | |
# ruby getHttpJpg.rb http://himasoku.com/archives/51824048.html | |
# JPGフォルダにjpgがダウンロードされる。 | |
# | |
## |
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
# LS_COLORS | |
# git clone https://github.com/seebi/dircolors-solarized.git ~/.dir_colors-solarized | |
# 切り替えるようにする。 | |
alias dircolors-256dark="ln -fs ~/.dir_colors-solarized/dircolors.256dark ~/.dir_colors" | |
alias dircolors-ansi-dark="ln -fs ~/.dir_colors-solarized/dircolors.ansi-dark ~/.dir_colors" | |
alias dircolors-ansi-light="ln -fs ~/.dir_colors-solarized/dircolors.ansi-light ~/.dir_colors" | |
alias dircolors-ansi-universal="ln -fs ~/.dir_colors-solarized/dircolors.ansi-universal ~/.dir_colors" |
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
# | |
# Face 曜日によって顔を変える。 | |
# | |
day=`date +%u` | |
case $day in | |
1 ) FACE="月꒰⌯͒•ɷ•⌯͒꒱ $";; | |
2 ) FACE="火٩꒰ʘʚʘ๑꒱۶ $";; | |
3 ) FACE="水( •̀ω•́ )σ $";; | |
4 ) FACE="木(ΘεΘ;) $";; | |
5 ) FACE="金ʕ•ӫ̫͡•ʔ $";; |
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
# Finderの隠しファイルを表示非表示 | |
alias appleFindershowAll='defaults write com.apple.finder AppleShowAllFiles TRUE' | |
alias appleFindershowDefault='defaults write com.apple.finder AppleShowAllFiles FALSE' |
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 'zip' | |
require 'json' | |
require 'kconv' | |
module ZipData | |
def self.read(file_path) | |
content = get_file_content(file_path) | |
json = JSON.parser.new(content) | |
return json.parse() | |
end |
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
## | |
# jpgがあればURLをセーブする。 | |
## | |
def save_extract_jpg(doc) | |
(doc/:img).each do |link| | |
->(url){ save_file(url) }.call(link[:src].to_s) if link[:src] =~ /.jpg/ | |
end | |
end | |
save_extract_jpg(doc) |
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 'tempfile' | |
# bad | |
def with_tmp_dir | |
Dir.mktmpdir do |tmp_dir| | |
Dir.chdir(tmp_dir) { |dir| yield dir } # block just passes arguments | |
end | |
end | |
# good |
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
# bad | |
result = hash.map { |k, v| v + 1 } | |
def something(x) | |
unused_var, used_var = something_else(x) | |
# ... | |
end | |
# good | |
result = hash.map { |_k, v| v + 1 } |
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
# bad | |
def compute_thing(thing) | |
if thing[:foo] | |
update_with_bar(thing) | |
if thing[:foo][:bar] | |
partial_compute(thing) | |
else | |
re_compute(thing) | |
end | |
end |
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 = <<-END.gsub(/^\s+\|/, '') | |
|def test | |
| some_method | |
| other_method | |
|end | |
END |
OlderNewer