Skip to content

Instantly share code, notes, and snippets.

View hagino3000's full-sized avatar

Takashi Nishibayashi hagino3000

View GitHub Profile
@hagino3000
hagino3000 / publisher.py
Created August 11, 2013 13:36
pika test
import random
import pika
def get_connection():
mq_clusters = ['rabbit1', 'rabbit2']
random.shuffle(mq_clusters)
for mq in mq_clusters:
try:
params = pika.ConnectionParameters(mq)
connection = pika.BlockingConnection(params)
@hagino3000
hagino3000 / Vagrantfile
Created August 11, 2013 09:57
Vagrant file for RabbitMQ Cluster testing
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu-12.04-x64"
config.vm.define :ap_server1 do |ap|
ap.vm.hostname = "ap1"
@hagino3000
hagino3000 / capture.js
Last active January 21, 2020 22:21
Capture screenshot using phantom.js
var page = new WebPage(),
address, output, size;
if (phantom.args.length != 2) {
console.log('Give me URL and filename');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 1024, height: 768 };
@hagino3000
hagino3000 / aggregate_all_date.js.sh
Created May 20, 2013 01:21
Use shell script parameter to generate js code
#!/bin/bash
#Code for generate JavaScript code, to aggregate mongo
if [ $# -ne 2 ]; then
cat <<__EOT__
Give me two parameters
- Decimal place of Resolution (If set 2, output resolution is 0.01)
- Aggregate collection name
Usage:
@hagino3000
hagino3000 / gist:5482052
Last active December 16, 2015 19:00
Summary of aggregated data.
> scores <- read.delim('./alldate_scale1.csv', sep = ',', header = TRUE)
> summary(scores)
value.loc.lat value.loc.lon value.score value.low
Min. :20.0 Min. :120.0 Min. :0.0844 Min. :0.0000
1st Qu.:27.5 1st Qu.:127.5 1st Qu.:0.2466 1st Qu.:0.0000
Median :35.0 Median :135.0 Median :0.3043 Median :0.0000
Mean :35.0 Mean :135.0 Mean :0.3054 Mean :0.7569
3rd Qu.:42.5 3rd Qu.:142.5 3rd Qu.:0.3612 3rd Qu.:1.8016
Max. :50.0 Max. :150.0 Max. :0.5777 Max. :3.0000
@hagino3000
hagino3000 / fibonacci.js
Last active December 28, 2016 21:11
asm.js sample
function fast_fib_module(stdlib, foreign, heap) {
"use asm";
function fib(n) {
n = n|0;
// nはint(符号の有無が不明の状態)
// 3はfixnum(0~2^31)
// 比較するためにnをシフト演算でunsignedに変換する
if (n >>> 0 < 3) {
@hagino3000
hagino3000 / makefile
Last active December 12, 2015 02:48
makefile for JavaScrpt project
SRC_DIR = src
.PHONY: test
FILES = ${SRC_DIR}/api.js ${SRC_DIR}/trap.js ${SRC_DIR}/typechecker.js ${SRC_DIR}/all.js
CONCAT_FILE = struct.js
MINIFY_FILE = struct.min.js
default_target: all
TARGET = clean concat minify
@hagino3000
hagino3000 / Box-Muller.matlab
Last active April 13, 2016 10:47
Check box-muller transform
clear;
alpha = rand(1, 1000);
beta = rand(1, 1000);
val1 = sqrt(-2 * log(alpha)) .* sin(2 * pi * beta);
val2 = sqrt(-2 * log(alpha)) .* cos(2 * pi * beta);
hist([val1,val2], 20);
@hagino3000
hagino3000 / AppDelegate.h
Last active December 9, 2015 23:39
Use NotificationCenter for Cybozu Garoon3 schedules.
// AppDelegate.h
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate>
// Windowはいらないのでxibファイルから消しておく
@property (assign) IBOutlet NSWindow *window;
@end
@hagino3000
hagino3000 / hist.php
Created September 3, 2012 05:05
Create Histgram (without normalize)
<?php
main();
// 終了
exit;
function zero_array() {
$ret = array();
for ($i = 0; $i < 255; $i++) {
$ret[$i] = 0;