Skip to content

Instantly share code, notes, and snippets.

View yohm's full-sized avatar

Yohsuke Murase yohm

View GitHub Profile
@yohm
yohm / zsh_ignore_case
Created April 29, 2011 03:47
ignore case completion for zsh
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}'
@yohm
yohm / MyQuickSort_error.cpp
Created May 19, 2011 07:13
MyQuickSort error code
// ---------------------------------------
template <class T>
void Swap( std::vector<T>::iterator it1, std::vector<T>::iterator it2) {
T temp = *it1;
*it1 = *it2;
*it2 = temp;
}
// -----------------------------------------
template <class T>
@yohm
yohm / find_jewels.rb
Created May 23, 2011 00:08
Find jewels to transfer
require "pp"
unless ARGV.size == 1
$stderr.puts <<EOS
# ----------------------------------
# usage : ruby solve.rb input.dat
# ----------------------------------
EOS
raise "Invalid argument"
end
@yohm
yohm / test_random.cpp
Created May 29, 2011 16:08
test random number generators
// The practice of programming
// chapter 3 : problem 3-1
//
// for testing mersenne twister and linear congruential random number generators
// prints normalized frequencies that i'th item is selected.
// statistical errors are printed as well.
#include <iostream>
#include <boost/random.hpp>
const size_t MAX = 1024; // number of elements to be selected
@yohm
yohm / .zshrc
Created July 23, 2011 01:00
dot_zshrc file
# auto change directory
#
setopt auto_cd
# auto directory pushd that you can get dirs list by cd -[tab]
#
setopt auto_pushd
# command correct edition before each completion attempt
#
@yohm
yohm / .emacs
Created July 23, 2011 04:51
.emacs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(global-font-lock-mode t nil (font-core))
'(show-paren-mode t)
'(standard-indent 2)
'(transient-mark-mode t))
(custom-set-faces
@yohm
yohm / measure_cpu_time.cpp
Created July 28, 2011 04:44
measurement of CPU time using clock()
#include <iostream>
#include <time.h>
int main() {
clock_t start, end;
start = clock();
long sum = 0;
@yohm
yohm / performance_arithmetical.cpp
Created August 23, 2011 02:20
performance measurement of basic arithmetical operations
#include <iostream>
#include <ctime>
#include <cmath>
// ----------------------------------------------
size_t CountUpInteger( size_t nMax) {
size_t nSum = 0;
for( size_t i=0; i<nMax; i++) {
nSum += i;
@yohm
yohm / epsplot.rb
Last active September 26, 2015 21:48
convert GNUPLOT .plt file into eps
#!/usr/bin/env ruby
require 'fileutils'
require 'optparse'
if ARGV.size == 0
raise "Usage epsplot plot1.plt (Specify gnuplot files)"
end
def thicken_lines( filename, bl=5, pl=3,point_size=51.5)
require 'rspec'
# ------- OK case ----------
describe "env X=1" do
before(:all) do
ENV['X'] = '1'
end
after(:all) do