Skip to content

Instantly share code, notes, and snippets.

@y-yagi
y-yagi / gist:b0504a365625295d6d97
Created December 6, 2014 05:55
minitest-sound test script
require 'minitest/autorun'
require 'minitest/sound'
Minitest::Sound.success = '/home/yaginuma/Dropbox/tmp/music/other/sey.mp3'
Minitest::Sound.failure = '/home/yaginuma/Dropbox/tmp/music/other/mdai.mp3'
Minitest::Sound.during_test = '/home/yaginuma/Dropbox/tmp/music/other/rs1_25_beatthemup.mp3'
class A
def b
sleep 5
@y-yagi
y-yagi / gist:d71c88ca407cc09f28e4
Created December 14, 2014 03:30
pg array parser 性能測定
require 'benchmark'
require 'benchmark/ips'
require 'ruby-prof'
require 'pg_array_parser'
require 'active_record/connection_adapters/postgresql/array_parser'
class MyPgArrayParser
include PgArrayParser
end
@y-yagi
y-yagi / gist:990abd6e084d02f8504f
Created December 29, 2014 22:45
OpenCV install script
# see: https://help.ubuntu.com/community/OpenCV
version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9]+)+' | cut -c2-)"
echo "Installing OpenCV" $version
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"
sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg
echo "Downloading OpenCV" $version
sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall
#!/usr/bin/env ruby
BIT_OR = '\|'
BIT_AND = '\&'
ADD = '\+'
MULTIPLATION = '\*'
input = ARGV[0]
[BIT_OR, BIT_AND, ADD, MULTIPLATION].each do |operator|
@y-yagi
y-yagi / pr.md
Last active August 29, 2015 14:13 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

#!/usr/bin/env ruby
# Tab completion for minitest tests.
#
# INSTALLATION:
#
# 1. Put this file in a directory in your $PATH. Make sure it's executable
# 2. Run this:
#
# $ complete -o bashdefault -f -C /path/to/this/file.rb ruby
require 'openssl'
require 'socket'
KEY = OpenSSL::PKey::RSA.new <<-_end_of_pem_
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDLwsSw1ECnPtT+PkOgHhcGA71nwC2/nL85VBGnRqDxOqjVh7Cx
aKPERYHsk4BPCkE3brtThPWc9kjHEQQ7uf9Y1rbCz0layNqHyywQEVLFmp1cpIt/
Q3geLv8ZD9pihowKJDyMDiN6ArYUmZczvW4976MU3+l54E6lF/JfFEU5hwIDAQAB
AoGBAKSl/MQarye1yOysqX6P8fDFQt68VvtXkNmlSiKOGuzyho0M+UVSFcs6k1L0
maDE25AMZUiGzuWHyaU55d7RXDgeskDMakD1v6ZejYtxJkSXbETOTLDwUWTn618T
-- Control frame information -----------------------------------------------
c:0129 p:---- s:0701 e:000700 CFUNC :deflate
c:0128 p:0020 s:0697 e:000696 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/filters.rb:16
c:0127 p:0044 s:0692 e:000691 BLOCK /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/stream.rb:48 [FINISH]
c:0126 p:---- s:0686 e:000685 CFUNC :call
c:0125 p:0010 s:0682 e:000681 BLOCK /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/filter_list.rb:46 [FINISH]
c:0124 p:---- s:0679 e:000678 CFUNC :each
c:0123 p:0009 s:0676 e:000675 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/filter_list.rb:45
c:0122 p:0035 s:0672 E:000e50 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/stream.rb:46
c:0121 p:0034 s:0669 e:000667 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gem
package main
import (
"bufio"
"fmt"
"os"
"regexp"
)
func parseAndCreateSql(line string) {