Skip to content

Instantly share code, notes, and snippets.

View takai's full-sized avatar

Naoto Takai takai

View GitHub Profile
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: mysql_read_timeout_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection('host' => 'localhost',
'user' => 'root',
'adapter' => 'mysql2',
'read_timeout' => 1)
begin
result = ActiveRecord::Base.connection.execute('select sleep(2)')
result.each { |r| p r }
#!/usr/bin/env ruby
$0 = 'daemon-env'
loop {}
require 'rubygems'
require 'bundler/setup'
require 'mysql2'
require 'active_record'
require 'logger'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(:adapter => 'mysql2',
require 'eventmachine'
require 'ruote/worker'
module Ruote
class EMWorker < Worker
def run
EM.add_periodic_timer(1) do
step
end
<!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">
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;
# -*- mode: ruby; coding: utf-8-unix -*-
require 'active_model'
class User
include ActiveModel::Validations
attr_accessor :email
attr_accessor :password
class Array
def odd
select {|f| f % 2 == 0}
end
end
p [].to_a.odd
package app;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class UnsafeCounter {
private int nextValue = 0;
public int getNextValue() {