Skip to content

Instantly share code, notes, and snippets.

View ciela's full-sized avatar
🕶️
How fabulous

ciela ciela

🕶️
How fabulous
View GitHub Profile
@ciela
ciela / file0.txt
Created March 14, 2014 06:08
リモートサーバ上のファイルとローカルマシン上のファイルのdiff ref: http://qiita.com/ciela/items/4896287fc0532cf388fe
ssh [remotehost] 'cat /path/to/the/remote/file' | diff - /path/to/the/local/file
@ciela
ciela / file0.java
Created March 25, 2014 14:19
OpenCV2系(Java)でモザイク処理 ref: http://qiita.com/ciela/items/f29fb91e28360b514307
/**
* ROIを指定してモザイク処理
* @param image 元画像となる {@link Mat}
* @param rectangles モザイク対象のROIを指定した {@link MatOfRect}
* @param size モザイクのピクセル幅
* @return モザイク処理後の {@link Mat}
*/
public static Mat drawMosaic(Mat image, MatOfRect rectangles, int size) {
Mat dstImage = image.clone();
for (Rect rect : rectangles.toArray()) {
ps -eo pid,ppid,lstart,cmd
@ciela
ciela / gist:0027c9cdabc809e0d6c7
Last active August 29, 2015 14:04
度数分布的なCSVファイルからヒストグラム表示用のベクトルを取得する
freq.vec <- function(csv, xs = 0, xe = 0) {
d <- read.csv(csv)
vars <- d[[1]]
# if default, apply min and max of vars
xs <- ifelse(xs == 0, min(vars), xs)
xe <- ifelse(xe == 0, max(vars), xe)
d.ext <- d[vars >= xs & vars <= xe, ]
rep(d.ext[[1]], d.ext[[2]])
}
@ciela
ciela / 0_reuse_code.js
Created August 23, 2014 05:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ciela
ciela / goroutine_test.go
Last active August 29, 2015 14:09
goroutine周りのテストコード
package main
import(
"fmt"
"sync"
"time"
"runtime"
)
func main(){
[Unit]
Description=Norikra
After=network.target
[Service]
Type=simple
PIDFile=/var/run/norikra.pid
EnvironmentFile=/etc/sysconfig/norikra
ExecStart=/usr/lib/jruby/jruby-9.0.1.0/bin/norikra start -l /var/log/norikra
ExecStop=/usr/lib/jruby/jruby-9.0.1.0/bin/norikra stop
@ciela
ciela / gist:6146869
Last active December 20, 2015 14:29
Javaで帯域制限かけながらI/Oする
byte[] buff = new byte[length];
int i;
while((i = in.read(buff, 0, length)) != -1){
long start = System.currentTimeMillis();
out.write(buff, 0, i);
long diff = System.currentTimeMillis() - start;
Thread.sleep(1000 - diff);
}
@ciela
ciela / gist:7969287
Created December 15, 2013 05:30
rsyncでsshの鍵認証を使う
rsync -e 'ssh -i [秘密鍵パス]' user@server:/path/to/the/remote/file /path/to/the/local/file
@ciela
ciela / montyhall.py
Last active December 18, 2016 07:39
モンティホール問題シミューレション
#!/usr/bin/env python3
# coding: utf-8
import numpy as np
NUM = 100000 # 試行回数
DOORS = np.array([1, 2, 3]) # ドア