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
| ############################## | |
| # Formatting | |
| ############################## | |
| # Date を "2013年8月31日 (土)" の形式に | |
| Handlebars.registerHelper "d", (date) -> | |
| return "" unless date | |
| weekdays = ["日", "月", "火", "水", "木", "金", "土"] | |
| "#{date.getFullYear()}年#{date.getMonth() + 1}月#{date.getDate()}日 (#{weekdays[date.getDay()]})" |
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 | |
| # Example: | |
| # # UTF-8 CSV to Excel Compatible TSV | |
| # $ csvconv --output-encoding="bom|utf-16le" --output-col-sep="\t" data.csv > data.txt | |
| # # Excel Compatible TSV to UTF-8 CSV | |
| # $ csvconv --input-encoding="bom|utf-16" --input-col-sep="\t" --output-encoding="utf-8" --output-col-sep="," data.txt > data.csv | |
| require "optparse" | |
| require "csv" |
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 | |
| gem "rest-client", "~> 1.6.6" | |
| require "rest-client" | |
| require "json" | |
| require "time" | |
| unless username = ARGV.first | |
| STDERR.puts "Usage: backup-twitpic username" | |
| exit 1 | |
| 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
| #!/usr/bin/env ruby | |
| unless ARGV.first | |
| STDERR.puts "Usage #{$0} ~/Library/Kobito/Kobito.db" | |
| exit 1 | |
| end | |
| gem "activerecord", "4.1.6" | |
| gem "composite_primary_keys", "7.0.10" | |
| gem "sqlite3", "1.3.9" |
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
| # Synvert snippet to keep foreign key name generated by `foreigner` gem for Rails 4.2 app. | |
| # Usage: | |
| # Save to ~/.synvert/lib/rails/foreigner.rb | |
| # $ cd RAILS_ROOT | |
| # $ synvert --run rails/foreigner | |
| require "active_support/inflector" | |
| load "config/initializers/inflections.rb" | |
| module Synvert::Core |
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 | |
| # Convert ModSecurity audit log to JSON Lines | |
| # | |
| # Usage: | |
| # modsec_audit2jsonl.rb modsed_audit.log | |
| # Or | |
| # cat modsed_audit.log | modsec_audit2jsonl.rb | |
| require "json" |
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 | |
| # Usage: ruby keepassx-to-1passwords.rb keepassx.xml > 1password.csv | |
| # Inspired by: Convert exported XML file from KeepassX that could be imported to 1Password (via CSV comma separated file) | |
| # https://gist.github.com/arudmin/52aec759a8c5d7543e36#file-keepassx-to-1passwords-py | |
| require "csv" | |
| require "nokogiri" | |
| def each_entry(group, super_group_title = nil, &block) |
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 | |
| # Usage: iterm-new-session [-n NAME] [command] | |
| # command should be quoted (e.g. iterm-new-session 'ls -l') | |
| require "optparse" | |
| require "open3" | |
| require "json" | |
| require "shellwords" | |
| require "tmpdir" |
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 | |
| # | |
| # d - Parse and print date time as several formats | |
| # | |
| # Usage: | |
| # | |
| # $ d [DATETIME] | |
| # | |
| # Supported formats: | |
| # |
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
| #compdef example | |
| local state | |
| _example() { | |
| __example | |
| } | |
| __example() { | |
| readonly local DEPTH=2 |