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
class Hash | |
def to_sorted_hash | |
class << self | |
alias_method :__keys, :keys | |
def keys | |
self.__keys.sort_by {|k| k.to_s } | |
end | |
def values | |
self.keys.map {|k| self[k] } | |
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
--- a/vendor/rails/railties/lib/commands/dbconsole.rb | |
+++ b/vendor/rails/railties/lib/commands/dbconsole.rb | |
@@ -45,6 +45,8 @@ def find_cmd(*commands) | |
end | |
case config["adapter"] | |
+when "oracle", "oracle_enhanced" | |
+ exec(find_cmd('sqlplus'), "#{config['username']}/#{config['password']}@#{config['database']}") | |
when "mysql" | |
args = { |
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
# SqlTypeValidation | |
# ================= | |
# | |
# SqlTypeValidation provides validations by sql type of actual columns. | |
# | |
# Usage | |
# ----- | |
# | |
# class Category < ActiveRecord::Base | |
# sql_type_validation :name |
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
# my ~/.termtter/config | |
config.user_name = 'jugyo' | |
config.plugins.keyword.keywords = ["@jugyo", "termtter"] |
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
# | |
# Example: | |
# 100.times {|i| rp i; sleep 0.01} | |
# | |
module Kernel | |
def reprint(*args) | |
print "\e[0G\e[K#{args.join('')}" | |
end | |
alias_method :rp, :reprint | |
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
# -*- coding: utf-8 -*- | |
# == Usage: | |
# | |
# require "pb" | |
# pbcopy "foo" | |
# pbread #=> "foo" | |
# | |
module PB | |
def pbread |
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
class Forker | |
def fork_with_new_connection | |
fork do | |
begin | |
ActiveRecord::Base.establish_connection | |
yield | |
ensure | |
ActiveRecord::Base.remove_connection | |
end | |
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
# utils for console | |
class ActiveRecord::Base | |
class << self | |
alias_method :[], :find | |
end | |
alias_method :attr, :update_attributes | |
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
setMyFonts | |
"A utility method for Pharo." | |
"Preferences setMyFonts" | |
|size font codeFont titleFont fontName| | |
size := UIManager default request: 'Base font size?' initialAnswer: '11'. | |
size isEmptyOrNil ifTrue: [^ self]. | |
size := size asInteger. | |
(size isNil or: [size <= 0]) ifTrue: [^ self]. | |
fontName := UIManager default request: 'Font name?' initialAnswer: 'Osaka Mono'. | |
font := LogicalFont familyName: fontName pointSize: size. |
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
#!/bin/sh | |
# The command for making epub file. | |
cd $1 | |
zip -0 ../$1.epub mimetype | |
zip -r ../$1.epub * -x mimetype |