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
heroku | |
toolbelt | |
- install toolbelt -> https://toolbelt.heroku.com/ | |
- login w/ toolbelt | |
$ heroku login | |
- add ssh keys | |
$ heroku keys:add | |
prepare rails |
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 | |
# REQUIREMENTS | |
# 1. ruby - http://rubyinstaller.org/ | |
# 2. vlc - http://www.videolan.org/vlc/index.html | |
# | |
# USAGE | |
# 1. save this file as `randime.rb` (type: `All Files`) | |
# 2. beneath `__END__` below, paste in absolute folder paths containing videos you want played | |
# 3. double click the `randime.rb` icon to play |
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 | |
require 'pathname' | |
input = Pathname.new ARGV[0] | |
output = input.basename.to_s.chomp(input.extname) + '.mp3' | |
%x[avconv -i #{input.to_s.inspect} -ab 192k #{output.inspect}] |
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
# before | |
lyrics.each do |lyric| | |
rules.each do |rule| | |
clip = Clip.new \ | |
song_path: song_path, | |
lyric: lyric, | |
rule: rule | |
arr << clip | |
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
#!/usr/bin/env ruby | |
# ### USAGE ### | |
# | |
# $ ./new_namespace foo/bar_baz [class] | |
# | |
# defaults to generating a module | |
# | |
# expects existing structure to include... | |
# |
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 'pathname' | |
require 'pry' | |
class Object | |
def tap(msg=nil, with:nil, to:nil, &block) | |
if block_given? # original Object#tap functionality | |
return super &block | |
else | |
if msg || with # msg to self e.g. #mkdir #gsub! | |
if msg |
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 db | |
@db ||= SQLite3::Database.new(path.to_s).tap do |db| | |
db.results_as_hash = true | |
db.instance_eval do | |
def tables | |
rows = execute "SELECT name FROM sqlite_master WHERE type='table';" | |
rows.map{|r| r['name']} | |
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 | |
require 'ostruct' | |
require 'pry' | |
CEDict = Struct.new :trad, :simp, :pinyin, :glosses | |
JMDict = Struct.new :kanji, :kana, :glosses | |
module DictResourceable | |
%i[word pronunciation meanings].each do |msg| |
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
# Organization class that acts AR-like (::create, ::all, ::find_by) | |
class Organization | |
attr_reader :name, :api_key, :api_secret, :list | |
def initialize(name:, api_key:, api_secret:, list: []) | |
@name, @api_key, @api_secret, @list= name, api_key, api_secret, list | |
end | |
def self.create(*args) | |
new(*args).tap do |org| | |
all.push org |