Skip to content

Instantly share code, notes, and snippets.

View kengos's full-sized avatar

Kengo Suzuki kengos

  • Hamamatsu Japan
View GitHub Profile
@kengos
kengos / shuffle!
Last active November 12, 2015 12:20
浜松ruby#58 その1
#!/usr/bin/env ruby
class Model
attr_accessor :a, :b, :c, :d, :e, :f, :g, :h
def attributes(arr)
@a = arr[0]
@b = arr[1]
@c = arr[2]
@d = arr[3]
@kengos
kengos / Usage.md
Created September 30, 2015 03:50
phpdebug
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
SSH=33843
HTTP=80,443
IDENT=113
NTP=123
MYSQL=3306
DHCP=67,68
initialize()
@kengos
kengos / sample1.rb
Last active May 6, 2019 01:50
Ruby benchmark
require 'benchmark'
n = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
Benchmark.bm do |bm|
bm.report("each_with_index:") {
100000.times do
n.each_with_index do |o,i|
x = [o, i]
end
end
<script type="text/javascript">
//<![CDATA[
$(function(){
$("body a[href^='http://']").on("click", function(){
url = $(this).attr('href');
if(url.indexOf($(location).attr('hostname')) == -1)
{
_gaq.push(['_trackEvent', 'Link', $(location).attr('href'), url]);
}
});
@kengos
kengos / gist:2464207
Created April 22, 2012 13:47
ActiveEnum i18n support patch
# In your config/initializers/active_enum.rb
# @see https://github.com/adzap/active_enum/pull/4
# @example
# * ja.yml
# active_enum:
# user:
# sex:
# male: '男性'
# female: '女性'
# * user.rb