Skip to content

Instantly share code, notes, and snippets.

View tadd's full-sized avatar

Tadashi Saito tadd

View GitHub Profile
@tadd
tadd / fix-ie.rb
Last active August 29, 2015 14:00
How to fix IE
require 'net/http'
require 'uri'
File.write('firefox.exe', Net::HTTP.get(URI('http://www.dnsbalance.ring.gr.jp/pub/net/www/mozilla/firefox/releases/latest/win32/ja/Firefox%20Setup%2028.0.exe')))
@tadd
tadd / basequery.txt
Last active August 29, 2015 14:01
discounted real estate
(site:homes.co.jp OR site:suumo.jp OR site:athome.co.jp OR site:chintai.net OR site:eheya.net OR site:able.co.jp OR site:apamanshop.com) (告知事項 OR 説明義務)
@tadd
tadd / easy_printf.rb
Last active August 29, 2015 14:02
abusing of local_variable_get
require './variable_table_of_caller'
def easy_printf(template)
keys = template.scan(/%{(.+?)}/).flatten.map(&:to_sym)
printf(template, variable_table_of_caller_with_level(2, *keys))
end
if $0 == __FILE__
foo = 1
bar = 'baz'
@tadd
tadd / segv.log
Created June 2, 2014 23:08
segv log of TestException#test_machine_stackoverflow
$ make test-all TESTS='-v ruby/test_exception.rb'
CC = gcc-4.9
LD = ld
LDSHARED = gcc-4.9 -shared
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -ansi -std=iso9899:199409 -fPIC
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -I. -I.ext/include/x86_64-linux -I../include -I..
DLDFLAGS = -Wl,-soname,libruby2.1.so.2.1 -fstack-protector
SOLIBS = -lpthread -lgmp -ldl -lcrypt -lm
Using built-in specs.
@tadd
tadd / rand.log
Last active August 29, 2015 14:07
Ruby trunk with GMP is slower than without-GMP Ruby
$ for i in 1 2 3; do time ruby2.2 -e 'N=1<<(1<<22); rand(N)*rand(N)'; done
real 0m0.069s
user 0m0.064s
sys 0m0.008s
real 0m0.076s
user 0m0.072s
sys 0m0.000s
@tadd
tadd / memprof.rb
Created November 11, 2009 10:07
super-irresponsible memory profiler
def memprof
def vmsize
IO.readlines("/proc/self/status").grep(/VmSize/)[0].scan(/\d+/)[0].to_i
end
GC.start
GC.disable
before = vmsize
begin
yield
after = vmsize
.file "tmp.c"
.section .rodata
.LC0:
.string "hello world"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
@tadd
tadd / ffsc.c
Created January 4, 2010 15:46
ffsc - far faster Scala compiler
/*
* ffsc - far faster scala compiler, omit booting time of fsc(1)
*
* Copyright (c) 2010 Tadashi Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@tadd
tadd / benchmark-sin.rb
Created July 5, 2010 09:24
benchmark Decimal vs BigDecimal by sin()
require "decimal"
require "bigdecimal"
require "bigdecimal/math"
N = 100
STEP = 10
TRY = 10
result = {
n: (0..N).map{|m|m * STEP},
@tadd
tadd / benchmark-math.csv
Created July 12, 2010 15:24
Math functions benchmark, Decimal vs BigDecimal
sqrt Decimal BigDecimal
0 0 0
30 0.124887 0.028016
60 0.168286 0.050961
90 0.193021 0.089924
120 0.244228 0.120451
150 0.284446 0.152398
180 0.328916 0.18304
210 0.392945 0.316898
240 0.460614 0.386293