Skip to content

Instantly share code, notes, and snippets.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <aio.h>
static void
read_done(union sigval sigval)
require 'benchmark'
#ruby2.1.0
#x64
fixnum_max = 4611686018427387903
bignum_min = fixnum_max + 1
#Fixnum
Benchmark.bm do |b|
class MyError < StandardError; end
def repeat_block(max_repeat, &block)
challange = Proc.new do |cnt|
begin
block.call
puts "success."
rescue MyError => e
if cnt > 0
challange.call(cnt-1)
class BasicObject
def method_missing(method, *args)
args[0].__send__ method, self
end
end
p [1,2,3,4,5].include?(1) #=> true
p 1.include?([1,2,3,4,5]) #=> true
p 1.include([1,2,3,4,5]) #=> endless loop
module Gorilla
attr_accessor :gorilla
#Init variable.
def self.extended(obj)
obj.gorilla = "First Gorilla"
end
end
class Giraffe; end
class SuccProxy
attr_accessor :inner_obj, :succ_block
def initialize(a, &b)
@inner_obj = a
@succ_block = b
end
def succ
SuccProxy.new(@succ_block.call(@inner_obj), &@succ_block)
class MyException < Exception; end
class FizzBuzz < MyException; end
class Fizz < MyException; end
class Buzz < MyException; end
i = 1
j = 100
begin
raise FizzBuzz if i%3 == 0 && i%5 == 0