Skip to content

Instantly share code, notes, and snippets.

@tokoroten
tokoroten / kickstarter_crawler.py
Last active August 29, 2015 14:03
kickstarter crawler and convert json result to csv.
#coding: utf-8
import urllib
import json
import datetime
import os
import time
# http://www.kbremner.com/2014/03/15/kickstarter-part1.html
# https://github.com/markolson/kickscraper/wiki/Project
@tokoroten
tokoroten / result.txt
Last active August 29, 2015 14:04
http://brevis.exblog.jp/22236990/ 稼働率100%の施設における在庫量とリードタイムのシミュレーション
days, input_load, worker_stacks, total_stacks, output, ave_lead_time
case 100% input 1...6
0 2 [2, 0, 0, 0, 0] 2 0 5
1 5 [5, 2, 0, 0, 0] 7 0 6
2 2 [2, 5, 2, 0, 0] 9 0 6
3 3 [3, 5, 2, 2, 0] 12 0 6
4 3 [3, 4, 4, 2, 2] 15 0 7
5 6 [6, 3, 4, 5, 1] 19 2 8
6 1 [4, 3, 6, 1, 5] 19 1 8
7 4 [4, 4, 3, 6, 2] 19 4 8
@tokoroten
tokoroten / multiprocess_error_handling.py
Last active August 29, 2015 14:05
python multiprocess_pool error handling
#coding:utf-8
import multiprocessing
import traceback
import random
import time
import sys
def random_error_func(x):
n = random.random()
@tokoroten
tokoroten / reinforcement_slot_machine.py
Created October 12, 2014 15:30
ε-Greedy base multi-armed bandit
#coding:utf-8
# ε-Greedy base multi-armed bandit
import random
slotmachine_rate = [3, 5, 10, 20, 16, 15, 21, 22, 6]
score_map = [[0.0, 0] for i in xrange(len(slotmachine_rate))]
search_rate = 0.1
# https://www.kaggle.com/c/otto-group-product-classification-challenge/details/evaluation
def print_kaggle_score(label_list, proba_result):
label_index = sorted(list(set(label_list)))
score = - 1.0 / len(label_list) * sum(
[
math.log(
max(min(
proba_result[i][label_index.index(label_list[i])]
/ sum(proba_result[i])
@tokoroten
tokoroten / randomforest_compress_test.py
Last active August 29, 2015 14:21
scikit-learn randomforest serialize problem
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os.path
import shutil
import random
import math
import cPickle
import pickle
@tokoroten
tokoroten / gist:1781444
Created February 9, 2012 17:32
particles in Ruby/SDL
require 'sdl'
WINDOW_SIZE = [1280, 768]
PARTICLE_SIZE = 8
EFFECT_LENGTH = 16
class GameManager
def initialize(screen)
@screen = screen
@particles = Array.new
@tokoroten
tokoroten / ipponmichi
Created May 3, 2012 09:09
なでしこで一本道ダンジョン #残パン会
現在レベルは1
最大体力は20。
現在体力は最大体力。
最大攻撃力は4。
現在攻撃力は最大攻撃力。
最大防御力は2。
現在防御力は最大防御力。
最大経験値は10。
現在経験値は0。
最大経験値増加量は1.5。
@tokoroten
tokoroten / dropbox_crawler.py
Created July 28, 2012 06:28
dropbox_crawler
#coding: utf-8
import urllib2
def main():
for i in xrange(1, 264055420):
#http://dl.dropbox.com/u/26405542/index.html
url = "http://dl.dropbox.com/u/%d/index.html" % i
try:
handle = urllib2.urlopen(url)
data = handle.read()
fp = open("%d_index.html" % i, "wb")
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Diagnostics;
namespace ConsoleApplication1