This file contains hidden or 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
# -*- mode: ruby; coding: utf-8-unix -*- | |
require 'benchmark' | |
Benchmark.bm(10) do |bm| | |
a = nil | |
bm.report 'ternary op' do | |
10000.times { a ? a.name : 'unknown' } | |
end | |
bm.report 'rescue' do |
This file contains hidden or 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
まず言及すると必ずリプライがもらえるアカウントをつくる。 | |
それに気がついた@takkanmはツイートしてリプライをもらうようになる。 | |
リプライされたい分だけツイートをしたら、そのアカウントには興味を無くす。 | |
さみしくなったら、またそのアカウントのところに戻ってくる。 | |
ツイートしても、そのアカウントからリプライが全くもらえなくなると、@takkanmはそのアカウントに興味をなくす。 | |
ところが、ツイートして、リプライがもらえたりもらえなかったりするように設定すると、 | |
@takkanmは一生懸命ツイートするようになる。 |
This file contains hidden or 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 app; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
public class UnsafeCounter { | |
private int nextValue = 0; | |
public int getNextValue() { |
This file contains hidden or 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 Array | |
def odd | |
select {|f| f % 2 == 0} | |
end | |
end | |
p [].to_a.odd |
This file contains hidden or 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
# -*- mode: ruby; coding: utf-8-unix -*- | |
require 'active_model' | |
class User | |
include ActiveModel::Validations | |
attr_accessor :email | |
attr_accessor :password |
This file contains hidden or 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 app; | |
import static org.hamcrest.CoreMatchers.*; | |
import static org.junit.Assert.*; | |
import static org.junit.Assume.*; | |
import org.junit.experimental.theories.DataPoints; | |
import org.junit.experimental.theories.Theories; | |
import org.junit.experimental.theories.Theory; | |
import org.junit.runner.RunWith; |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello, Processing.js.</title> | |
<script type="application/javascript" src="processing-1.2.3.min.js"> | |
</script> | |
<script type="application/javascript"> | |
/* | |
* This code searches for all the <script type="application/processing" target="canvasid"> |
This file contains hidden or 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 'eventmachine' | |
require 'ruote/worker' | |
module Ruote | |
class EMWorker < Worker | |
def run | |
EM.add_periodic_timer(1) do | |
step | |
end |
This file contains hidden or 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 'rubygems' | |
require 'bundler/setup' | |
require 'mysql2' | |
require 'active_record' | |
require 'logger' | |
ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.establish_connection(:adapter => 'mysql2', |
This file contains hidden or 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 | |
$0 = 'daemon-env' | |
loop {} |