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
#!/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 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 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 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 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 "rubygems" | |
require "zipruby" # gem install zipruby | |
require "rexml/document" | |
require "fileutils" | |
class Zip::Archive | |
def index | |
i = 0 | |
each do |f| | |
if yield f |
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
#!/usr/bin/env ruby | |
# Convert TSV to WikiTable (TextMate Bundle Command) | |
# | |
# Input: Selected Text or Line | |
# Output: Replace Selected Text | |
s = STDIN.readlines.map{|line| line.gsub(/\t/, " || ").gsub(/^/, "| ").strip }.join("\n|-\n") | |
puts "{|class=\"wikitable\"\n#{s}\n|}" |
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
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# Footwork trainer for fencer | |
# for Mac OS X | |
class Footwork | |
attr_accessor :name, :weight, :duration | |
def initialize(attrs = {}) | |
attrs.each do |k, 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
0 * * * * ruby -e 'puts "#{Time.now.hour} o\x27clock"' | /usr/local/bin/growlnotify |
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
* O'reilly Japan Ebook Store で販売されている「プログラミング言語 Ruby (http://www.oreilly.co.jp/books/9784873113944/)」の目次です。 | |
* Gist の仕様上 UTF-8 になってるので、Shift JIS に変換してください。 | |
* JPdfBookmarks (http://sourceforge.net/projects/jpdfbookmarks/) で対象の PDF を開き、[Tools]-[Load] から目次ファイルを指定、[File]-[Save] で保存してください。 |
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
$LOAD_PATH << File.expand_path("lib") # carrierwave/lib path | |
require "carrierwave" | |
require "benchmark" | |
CarrierWave.configure do |config| | |
config.fog_credentials = { | |
:provider => 'AWS', | |
:aws_access_key_id => 'foo', | |
:aws_secret_access_key => 'bar', | |
} |
OlderNewer