Skip to content

Instantly share code, notes, and snippets.

View 2get's full-sized avatar
😌
Think

Mayoto Yoshida 2get

😌
Think
  • GMO Pepabo, Inc.
  • Tokyo, Japan
View GitHub Profile
@2get
2get / ruby_===.rb
Last active August 29, 2015 14:04
Ruby ===
p (1..5) === 3 #=> true レシーバは Range クラスのインスタンスだから、=== 演算子は引数が自身の範囲内に含まれるかを判定
p 3 === (1..5) #=> false レシーバは Fixnum クラスのインスタンスだから、=== 演算子は数値として等しいかを判定
p /おつかれ/ === 'おつかれさまです' #=> true レシーバは Regexp クラスのインスタンスだから、=== 演算子は引数の文字列がマッチするか判定
p 'おつかれさまです' === /おつかれ/ #=> false レシーバは String クラスのインスタンスだから、=== 演算子は同値判定
@2get
2get / ga_link_track_event.html
Last active August 29, 2015 14:03
analytics link track event ( hitCallback )
@2get
2get / konami.coffee
Last active August 29, 2015 14:02
konami.coffee
showKonami = ->
alert 'KONAMI'
inputs = []
input = (e) ->
inputs.push(e.keyCode)
if e.keyCode is 65
len = inputs.length
if inputs[len - 10] is 38 and inputs[len - 1] is 65
if [38, 38, 40, 40, 37, 39, 37, 39, 66, 65].join('') is inputs.slice(len - 10, len).join('')
@2get
2get / date comparison in python.md
Created June 18, 2014 07:29
date comparision in python
Python 3.4.0 (default, Mar 26 2014, 11:08:39)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from time import time
>>> time()
1403076335.497517
>>> time() == time()
False
>>> time() is time()
@2get
2get / ruby_private_and_protected.rb
Created June 18, 2014 03:51
ruby private and protected
class C1
def method
protected_method
self.protected_method
C1.new.protected_method
private_method
self.private_method rescue puts "ERROR self.private_method #{self.class.name}"
C1.new.private_method rescue puts "ERROR C1.new.private_method #{self.class.name}"
end
@2get
2get / mountable engine into application development.md
Created June 3, 2014 07:32
mountable engine into application development
$ bundle config local.GEM_NAME /path/to/local/git/repository

Gemfile

gem 'GEM_NAME', git: '[email protected]:GEM_NAME', branch: 'master'
@2get
2get / add_role_attribute_to_the_form_tag_in_simple_form.html.erb
Created May 30, 2014 06:38
How to add attribute to the form tag in simple_form
<%= simple_form_for(@user, html: { role: 'form' }) do |f| %>
<% end %>
@2get
2get / Public Static Site AWS Policy.md
Created May 29, 2014 11:00
Public Static Site AWS Policy
@2get
2get / Display the configuration file, ignore comments and blank lines.md
Created May 20, 2014 03:31
Display the configuration file, ignore comments and blank lines
@2get
2get / vsftpd.conf
Created May 20, 2014 03:27
Ubuntu 12.10 vsftpd: version 3.0.2 my configuration
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=ftp