Skip to content

Instantly share code, notes, and snippets.

View hagino3000's full-sized avatar

Takashi Nishibayashi hagino3000

View GitHub Profile
@hagino3000
hagino3000 / zmq.test.py
Created March 5, 2014 01:13
ZeroMQ PUSH-PULL Connection test
# -*- coding: utf-8 -*-
import time
import threading
import zmq
def server():
print('Start server')
import socket
import time
import threading
def server():
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind(('localhost', 9999))
server_socket.listen(1)
# -*- coding: utf-8 -*-
import argparse
import json
import urllib
parser = argparse.ArgumentParser(description="Fetch Youtube movie info by movie id",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog='Ex: python fetch_ytmovie.py rMHdqOyp6tc'
)
@hagino3000
hagino3000 / example.js
Last active August 29, 2015 14:02
画像の真ん中をいい感じに切り取るスクリプト
define(['utils', 'template'], function (Utils, JST) {
'use strict';
function render() {
// テンプレート使ってレンダリングする例
$('#target').html(JST['app/templates/fuga.ejs'], {images: [],....});
// 画像を60px * 60pxの枠に納めるとする
var adjustFn = Utils.createImageAdjustFn(60, 60);
$('#target .profile img').on('load', function() {
@hagino3000
hagino3000 / get_screen_capture.sh
Created July 13, 2014 12:07
荒川智則個展運用
#!/opt/local/bin/zsh
IMG_FILENAME=`date +'%Y-%m-%d %H:%M'`.png
/usr/sbin/screencapture -x ~/tmp/capture/$IMG_FILENAME
@hagino3000
hagino3000 / plot_retention_sample.py
Created August 16, 2014 19:33
リテンション率のグラフをmatplotlibで描画する
import numpy as np
import matplotlib.pyplot as plt
# それっぽいデータを作る処理
from datetime import datetime, timedelta
import scipy
import scipy.stats
def create_dummy_data(days):
x = np.linspace(2, 2 + days, days)
y = scipy.stats.norm.pdf(x, loc=0, scale=4) * 4 + 0.15
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@hagino3000
hagino3000 / prml2.3.5.ipynb
Last active August 29, 2015 14:15
PRML 2.3.5
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hagino3000
hagino3000 / 2015311.ipynb
Created March 11, 2015 04:06
Kaggle Titanic Competition
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.