Skip to content

Instantly share code, notes, and snippets.

View denkiwakame's full-sized avatar
:octocat:
Working from home

Mai Nishimura denkiwakame

:octocat:
Working from home
View GitHub Profile
@denkiwakame
denkiwakame / gist:8578413
Created January 23, 2014 13:28
ヘッダ依存関係をなんtか
GCC = g++
CFLAGS = -O2 -MMD -Wall -Wextra
SRCS = main.cpp sample.cpp
TARGET = main
OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)
.cpp.o:
$(GCC) $(CFLAGS) -c $< -o $@
@denkiwakame
denkiwakame / gist:8578530
Created January 23, 2014 13:36
sortしてrenameするだけ
#!/usr/bin/ruby -Ks
# -Ks:convert code to Shift_JIS
dirpath = ARGV[0] # directory path XXX/
def rename_files(_dirpath)
fnames = Dir.glob _dirpath+'**'
fnames_created = fnames.map { |fname|
[fname, File.mtime(fname)]
@denkiwakame
denkiwakame / gist:8667025
Last active January 4, 2016 19:19
グレイコードデコーダ
#include <highgui.h>
#include <cv.h>
#include <cxcore.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include "fileio_util.hpp"
@denkiwakame
denkiwakame / gist:8911609
Created February 10, 2014 07:09
mean, variance, standard dev
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <numeric>
template <template<class T, class Allocator = std::allocator<T> > class Container>
double mean(Container<double> & x)
{
return std::accumulate(x.begin(), x.end(), 0.0) / x.size();
@denkiwakame
denkiwakame / gist:8934163
Created February 11, 2014 12:42
greaterでソートしたけど捨てた
std::map< uchar, cv::Point, std::greater<uchar> > reliabilities;
int max_size = this->reliabilities.size() * percent/100.0;
std::map<uchar,cv::Point>::iterator map_itr = reliabilities.begin();
for(int i=0; i<max_size; i++){
// map_itr.first;
// draw
cv::Point img_pt = (*map_itr).second;
int graycode_x = this->decoded_dataX.at<unsigned short>(img_pt.y, img_pt.x);
int graycode_y = this->decoded_dataY.at<unsigned short>(img_pt.y, img_pt.x);
@denkiwakame
denkiwakame / gist:9466549
Created March 10, 2014 14:57
てきとーに
#!/usr/bin/ruby
def merge(ary1,ary2)
idx1 = 0
idx2 = 0
result = Array.new
while result.length < ary1.length + ary2.length
ary1val = idx1 <= ary1.length-1 ? ary1[idx1] : -1
ary2val = idx2 <= ary2.length-1 ? ary2[idx2] : -1
@denkiwakame
denkiwakame / gist:9466863
Last active August 29, 2015 13:57
てきとうだった
#!/usr/bin/ruby
def qsort(first,last,ary)
if first >= last
return
end
target = ary[first]
buf1 = Array.new
@denkiwakame
denkiwakame / gist:10576238
Created April 13, 2014 09:26
GCJ 2014 ProblemA
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <utility>
@denkiwakame
denkiwakame / gist:10576281
Created April 13, 2014 09:27
GCJ 2014 problemB
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <utility>
@denkiwakame
denkiwakame / gist:10576319
Created April 13, 2014 09:28
GCJ2014 problemC (fails)
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <utility>