Skip to content

Instantly share code, notes, and snippets.

View jugyo's full-sized avatar
🏠
Working from home

Kaz jugyo

🏠
Working from home
  • The League
  • New Jersey
View GitHub Profile
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
--- 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 = {
# SqlTypeValidation
# =================
#
# SqlTypeValidation provides validations by sql type of actual columns.
#
# Usage
# -----
#
# class Category < ActiveRecord::Base
# sql_type_validation :name
# my ~/.termtter/config
config.user_name = 'jugyo'
config.plugins.keyword.keywords = ["@jugyo", "termtter"]
#
# 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
# -*- coding: utf-8 -*-
# == Usage:
#
# require "pb"
# pbcopy "foo"
# pbread #=> "foo"
#
module PB
def pbread
class Forker
def fork_with_new_connection
fork do
begin
ActiveRecord::Base.establish_connection
yield
ensure
ActiveRecord::Base.remove_connection
end
end
# utils for console
class ActiveRecord::Base
class << self
alias_method :[], :find
end
alias_method :attr, :update_attributes
end
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.
#!/bin/sh
# The command for making epub file.
cd $1
zip -0 ../$1.epub mimetype
zip -r ../$1.epub * -x mimetype