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
#!/usr/bin/env ruby
def ask(message)
print "#{message} [Y/n] "
case gets.strip
when /n/i
else
yield
end
end
@jugyo
jugyo / gist:5812587
Created June 19, 2013 08:20
Unicode control characters related Bi-directional text
  • U+200E - left-to-right mark (LRM)
  • U+200F - right-to-left mark (RLM)
  • U+202A - left-to-right embedding (LRE)
  • U+202B - ‭right-to-left embedding (RLE)
  • U+202C - pop directional formatting (PDF)
  • U+202D - left-to-right override (LRO)
  • U+202E - right-to-left override (RLO)
@jugyo
jugyo / RubyTest.sublime-settings
Created June 18, 2013 07:30
RubyTest.sublime-settings for spring with rspec
{
"run_rspec_command": "spring rspec {relative_path} --no-color",
"run_single_rspec_command": "spring rspec {relative_path}:{line_number} --no-color"
}
@jugyo
jugyo / gist:5727487
Last active December 18, 2015 04:39
a fix for performance improvement for the javascript_include_tag
# fix assets loading performance in 3.2.13
# see:
# * https://github.com/rails/rails/commit/687e68d88f5e1a7bb6a2d876fbbc5b8c4571d853
# * https://github.com/rails/rails/issues/9803
if Rails.env.development? && Rails.version == "3.2.13"
module Sprockets
module Helpers
module RailsHelper
class AssetPaths
def rewrite_extension(source, dir, ext)
import scala.tools.nsc.{ast, Settings}
import scala.tools.nsc.interpreter._
import scala.tools.nsc.util.BatchSourceFile
class ScalaParser {
val settings = new Settings()
settings.usejavacp.value = true
val main = new IMain(settings)
import main.global._
@jugyo
jugyo / gist:5547481
Last active December 17, 2015 03:59
import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.{ExprTyper, IMain}
object Example extends App {
val settings = new Settings()
settings.usejavacp.value = true
val main = new IMain(settings)
object exprTyper extends { val repl: main.type = main } with ExprTyper { }
val result = exprTyper.parse(
text = File.open('./UTF-16-with-BOM.txt', 'rb') {|f| f.read}
case text[0..1].bytes
when "\xFE\xFF".bytes
encoding = 'UTF-16BE'
when "\xFF\xFE".bytes
encoding = 'UTF-16LE'
else
encoding = 'US-ASCII'
end
puts text.encode('UTF-8', encoding)
@jugyo
jugyo / screensaver.rb
Created April 19, 2013 03:39
earthquake.gem plugin to start screensaver remotely!
# encoding: utf-8
Earthquake.init do
_ = config[:screensaver] ||= {}
_[:pattern] ||= /screen ?saver|スクリーンセーバー/i
_[:command] ||= %(open -a /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app)
output_filter do |item|
next unless item["_stream"] && item["text"]
next unless item["user"]["screen_name"] == twitter.info["screen_name"]
if item["text"] =~ _[:pattern]
@jugyo
jugyo / gist:5401924
Created April 17, 2013 05:05
`ir b` to start pry session
module Kernel
def ir(binding)
binding.pry
end
alias_method :b, :binding
end
@jugyo
jugyo / Gemfile
Created April 16, 2013 10:01
How to use Rack::RubyProf on ruby 1.9 and rails 3
gem 'ruby-prof'