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
#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) |
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' | |
#ruby2.1.0 | |
#x64 | |
fixnum_max = 4611686018427387903 | |
bignum_min = fixnum_max + 1 | |
#Fixnum | |
Benchmark.bm do |b| |
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 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) |
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 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 |
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
module Gorilla | |
attr_accessor :gorilla | |
#Init variable. | |
def self.extended(obj) | |
obj.gorilla = "First Gorilla" | |
end | |
end | |
class Giraffe; 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
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) |
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 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 |