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 NilClass | |
def method_missing(method, *args) | |
case self.class | |
when Foo | |
# do something about foo is nil | |
when Bar | |
# do something about bar is nil | |
# ... | |
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
package main | |
import ( | |
"fmt" | |
"golang.org/x/net/http2" | |
"log" | |
"net/http" | |
) | |
func main() { |
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
Capybara.server do |app, port| | |
Unicorn::Configurator::RACKUP[:port] = port | |
Unicorn::Configurator::RACKUP[:set_listener] = true | |
server = Unicorn::HttpServer.new(app, worker_processes: 2) | |
at_exit do | |
server.stop(false) | |
end | |
server.start |
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
[93] pry(main)> t = Thread.new { sleep(1) } | |
#<Thread:0x007f3e3f1f43f0 sleep> | |
[94] pry(main)> t.join(0) | |
#<Thread:0x007f3e3f1f43f0 dead> | |
[95] pry(main)> t = Thread.new { sleep(1000) } | |
#<Thread:0x007f3e3f224b40 sleep> | |
[96] pry(main)> t.join(0) | |
nil |
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
package main | |
/* | |
#cgo CFLAGS: -mavx | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <immintrin.h>//AVX: -mavx | |
void avx_add(const size_t n, float *x, float *y, float *z) | |
{ |
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 'benchmark/ips' | |
begin | |
class CreateModels < ActiveRecord::Migration | |
def change | |
create_table :books do |t| | |
t.string :attribute1 | |
t.integer :attribute2 | |
t.float :attribute3 |
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 'benchmark/ips' | |
begin | |
class CreateModels < ActiveRecord::Migration | |
def change | |
create_table :items do |t| | |
end | |
create_table :events do |t| | |
t.belongs_to :item |
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
begin | |
class CreateModels < ActiveRecord::Migration | |
def change | |
create_table :items do |t| | |
end | |
create_table :events do |t| | |
t.belongs_to :item | |
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
jobs = jenkins.model.Jenkins.instance.items | |
jobs.each {job -> | |
job.removeProperty(jenkins.plugins.slack.SlackNotifier.SlackJobProperty) | |
jp = new jenkins.plugins.slack.SlackNotifier.SlackJobProperty( | |
null, // String teamDomain, | |
null, // String token, | |
"#channel_to_notified", // String room, | |
false, // boolean startNotification, |
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
# Hash#deep_slice | |
# | |
# h = { | |
# :a => 1, | |
# :b => 2, | |
# :c => { | |
# :ca => 31, | |
# :cb => 32, | |
# :cc => 33 | |
# }, |