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 symbolize_keys(hash) | |
hash.map{|k,v| [k.to_sym, v] }.to_h | |
end | |
hash = {'key':'value', 'key2':'value2'} | |
symbolize_keys(hash) #=> {:key=>"value", :key2=>"value2"} |
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
# Twitterに投稿できるくらい短くしたかったけど無理で諦めた。 | |
# 捨てるのももったいないのでここにメモっておく | |
require'date' | |
n = Time.now | |
l = Date.new(n.year,n.month,-1) | |
puts l.strftime("%B %Y"); | |
puts "ver. 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
ruby -e 's=%|すぐに消せ |;v,h=`stty size`.split.map(&:to_i);puts [s.ljust(h/2,s)]*v' |
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
{ | |
"Sequential Inputs of numbers with 8"=> | |
(1..9).map{|n|"#{[*1..n] * ''} * 8 + #{n}"}, | |
"Sequential 1's with 9"=> | |
(1..9).map{|n|"#{[*1..n] * ''} * 9 + %2d" % (n + 1)}, | |
"Sequential 8's with 9"=> | |
9.downto(2).map{|n|"#{[*9.downto(n)] * ''} * 9 + #{n - 2}"}, |
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 run(){ | |
var SystemEvents = Application("System Events"); | |
// GUIスクリプティングが有効になってなければエラー投げて終了 | |
if (!SystemEvents.uiElementsEnabled()) { | |
throw "GUIにアクセスできないよ。「システム環境設定 > セキュリティとプライバシー > プライバシー > アクセシビリティ」から許可を与えてね。"; | |
// 「スクリプトで開けよ」とか言わない | |
}; | |
// スクリプトエディタを開く |
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 [String, Symbol, Array] | |
def req(*f) | |
f.flatten.map{|s| require s.to_s } | |
end | |
// usage | |
req :yaml | |
req :date, :uri | |
req [:zlib, "open-uri"] |
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
Screen Sharing.app sdef: 487 bytes | |
Bluetooth File Exchange.app sdef: 860 bytes | |
Digital Hub Scripting.osax sdef: 1153 bytes | |
AppleScript Utility.app sdef: 1958 bytes | |
Instruments.app sdef: 3048 bytes | |
Folder Actions Dispatcher.app sdef: 3283 bytes | |
Folder Actions Setup.app sdef: 3361 bytes | |
System Preferences.app sdef: 4049 bytes | |
Notes.app sdef: 5224 bytes | |
Reminders.app sdef: 7094 bytes |
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 String | |
def width | |
length * 2 - chars.count(&:ascii_only?) | |
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
Safari.doJavaScript("location.reload()", {in:tab}); |
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
var tags = $("#piechart text:not(:contains('Others'))"); | |
tags.hover( | |
function(){ $(this).css({"font-weight":"bold", "text-decoration":"underline", cursor:"pointer"}) }, | |
function(){ $(this).css({"font-weight":"normal", "text-decoration":"none"}) } | |
); | |
tags.click(function(){ | |
var user = location.href.match(/[^\/]+$/), | |
tag = $(this).text().match(/\S+$/), |