This file contains 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 Nyan | |
def replace_method(a, b) | |
(class << self; self end).module_exec do | |
alias_method "#{a}_backup", a | |
alias_method a, b | |
alias_method b, "#{a}_backup" | |
end | |
end | |
def method1 |
This file contains 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
launch_configuration = auto_scaling.launch_configurations.create( | |
name, | |
ami.id, | |
as_instance_type, | |
key_pair: as_key_pair, | |
security_groups: as_security_groups, | |
) | |
auto_scaling_group = auto_scaling.groups.create( | |
name, |
This file contains 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
// その関数だけ実行するやつ | |
$.fn.onWithCall = function() { | |
var args = Array.prototype.slice.call(arguments), | |
listener = args[args.length - 1]; | |
return this.on.apply(this, args).each(function() { | |
listener.call(this, $.Event(args[0])); | |
}); | |
}; |
This file contains 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
#!/usr/bin/env ruby | |
require 'rack' | |
require 'net/http' | |
require 'uri' | |
def request_test(request_timeout = 3) | |
unused_port = -> do | |
s = TCPServer.open(0) | |
port = s.addr[1] |
This file contains 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
#!/usr/bin/env ruby | |
require 'rack' | |
require 'net/http' | |
require 'uri' | |
unused_port = -> do | |
s = TCPServer.open(0) | |
port = s.addr[1] | |
s.close |
This file contains 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
#!/usr/bin/env ruby | |
require 'rack' | |
require 'net/http' | |
require 'uri' | |
pid = fork do | |
Rack::Handler::WEBrick.run ->(env){ [200, {'Content-Type' => 'plain/text'}, ['Nyan!']] }, Port: 9000 | |
end |
This file contains 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
OmniAuth.config.full_host = ->(env) { | |
scheme = if env['HTTPS'] == 'on' or env['HTTP_X_FORWARDED_SSL'] == 'on' | |
'https' | |
elsif env['HTTP_X_FORWARDED_PROTO'].present? | |
env['HTTP_X_FORWARDED_PROTO'].split(',').first.strip | |
else | |
env['rack.url_scheme'] | |
end | |
hostname = env['HTTP_X_FORWARDED_HOST'].present? ? env['HTTP_X_FORWARDED_HOST'] : env['HTTP_HOST'] |
This file contains 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
require 'active_support' | |
module Definable | |
def definable(name) | |
define_method name do |value| | |
(const_get(:ClassMethods, false) rescue const_set(:ClassMethods, Module.new)) | |
.send(:define_method, name) { value } | |
send(:define_method, name) { self.class.send name } | |
end |
This file contains 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
!function() { | |
var Luhn = {}; | |
Luhn.valid = function(value) { | |
value = '' + value; | |
return this.generate(value.slice(- value.length, -1)) === value; | |
}; | |
Luhn.generate = (function() { |