Skip to content

Instantly share code, notes, and snippets.

@miura1729
miura1729 / gist:1991947
Created March 7, 2012 08:37
Visioを抽象化したクラス
#!/usr/local/bin/ruby
# -*- coding: cp932 -*-
require 'win32ole'
require 'delegate'
require 'singleton'
require 'util'
module VISIO
module VisioConsts
@miura1729
miura1729 / gist:1991993
Created March 7, 2012 08:40
JW CAD版
# -*- coding: cp932 -*-
# Graphics Layer for JWCAD
require 'util'
require 'singleton'
module JWCAD
class JwCadDevice
JwcTempDir = "g:/KD/program/jww"
JwcZahyoDir = "c:/tmp"
JwcTempName = "foo.txt"
@miura1729
miura1729 / gist:2204257
Created March 26, 2012 10:03
RegenRubyのベンチマークの結果
((0123456789)_?)*
user system total real
oni 4.898000 0.032000 4.930000 ( 5.840000)
ren 17.706000 0.109000 17.815000 ( 25.846000)
re0 1.311000 0.000000 1.311000 ( 1.359000)
re1 0.889000 0.000000 0.889000 ( 1.237000)
re2 0.733000 0.000000 0.733000 ( 1.341000)
re3 0.640000 0.000000 0.640000 ( 1.110000)
(a?){512}a{512}
user system total real
unsigned int gcd(unsigned int u, unsigned int v)
{
// simple cases (termination)
if (u == v)
return u;
if (u == 0)
return v;
if (v == 0)
return u;
@miura1729
miura1729 / gist:2274249
Created April 1, 2012 10:17
バイナリGCD とりあえず高速化してオリジナルより速くなった
unsigned int gcd(unsigned int u, unsigned int v)
{
// simple cases (termination)
if (u == v)
return u;
if (u == 0)
return v;
if (v == 0)
return u;
@miura1729
miura1729 / gist:2274917
Created April 1, 2012 12:00
また少し改善した
unsigned int gcd(unsigned int u, unsigned int v)
{
// simple cases (termination)
if (u == v)
return u;
if (u == 0)
return v;
if (v == 0)
return u;
@miura1729
miura1729 / gist:2281609
Created April 2, 2012 08:18
新しい方法を考えた
unsigned int gcd(unsigned int u, unsigned int v)
{
// simple cases (termination)
if (u == v)
return u;
if (u == 0)
return v;
if (v == 0)
return u;
@miura1729
miura1729 / gist:2888721
Created June 7, 2012 13:11
ytl profiler sample (benchmark/list.rb)
#from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
1 426866388 NUM = 300
1 1026 SIZE = 10000
1 331 def test_lists()
# create a list of integers (Li1) from 1 to SIZE
600 307773 li1 = (1..SIZE).to_a
# copy the list to li2 (not by individual items)
300 270204 li2 = li1.dup
@miura1729
miura1729 / gist:2888838
Created June 7, 2012 13:38
ytl profiler sample (mandelbroat.rb) Maybe wrong
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
#
# contributed by Karl von Laudermann
# modified by Jeremy Echols
1 353732212 size = 600 # ARGV[0].to_i
1 738 puts "P4\n#{size} #{size}"
1 10125467 ITER = 49 # Iterations - 1 for easy for..in looping
@miura1729
miura1729 / gist:2900047
Created June 9, 2012 07:57
ytl profiler sample (benchmark/matrix.rb)
#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: matrix-ruby.code,v 1.4 2004/11/13 07:42:14 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
1 20 n = 60 #Integer(ARGV.shift || 1)
1 7 size = 40
3 7 def mkmatrix(rows, cols)