Skip to content

Instantly share code, notes, and snippets.

View tushuhei's full-sized avatar

Shuhei Iitsuka tushuhei

View GitHub Profile
@tushuhei
tushuhei / segmentger.js
Last active November 8, 2018 00:56
Word segmentation with pure V8 engine.
let segment = (text) => {
let it = Intl.v8BreakIterator('ja');
it.adoptText(text);
let result = [];
let curr, next;
while (true) {
curr = it.current();
next = it.next();
if (next == -1) break;
result.push(text.slice(curr, next));
@tushuhei
tushuhei / dooog.py
Created January 3, 2018 22:26
Art for new year card 2018
# coding: utf-8
import random
stroke_width = 4
radius = 10
glyphs = {
'd': f'<circle cx="{radius}" cy="{radius}" r="{radius}" /><line x1="{radius*2}" y1="{radius}" x2="{radius*2}" y2="{-radius * 0.6}" />',
'o': f'<circle cx="{radius}" cy="{radius}" r="{radius}" />',
'g': f'<circle cx="{radius}" cy="{radius}" r="{radius}" /><path d="M {radius*2} {radius} C {radius*2} {radius*2}, {radius*2} {radius*2.8}, {radius} {radius*2.8}" />',
# coding: utf-8
#
# Simulation program for unplugged neural network model.
# Reference:
# https://www.1101.com/morikawa/2001-03-12.html
# https://www.1101.com/morikawa/2001-04-02.html
import itertools
import random
import numpy as np
# coding: utf-8
# Dynamic programing: knapsack problem.
# Rewrote the program in the webpage below in Python.
# 動的計画法(ナップサック問題)
# 下記のサイトのコードを Python にて書き直した。
# reference: http://dai1741.github.io/maximum-algo-2012/docs/dynamic-programming/
VALUES = [15, 3, 1, 8, 2, 4]
WEIGHTS = [11, 2, 3, 5, 1, 4]
MAX_WEIGHT = 15
@tushuhei
tushuhei / sample.js
Created August 29, 2017 15:47
Getting Website Title with Headless Chrome
const CDP = require('chrome-remote-interface');
const chromeLauncher = require('lighthouse/chrome-launcher/chrome-launcher');
function onPageLoad(Runtime) {
const js = "document.querySelector('title').textContent";
return Runtime.evaluate({expression: js}).then(result => {
console.log('Title of page: ' + result.result.value);
});
}
@tushuhei
tushuhei / steepest_gradient_and_newton_method.ipynb
Created July 20, 2017 01:23
最急降下法とニュートン法の比較
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tushuhei
tushuhei / mlp-light.ipynb
Created July 14, 2017 11:44
ニューラルネットワークで関数近似
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tushuhei
tushuhei / LinUCB.ipynb
Last active August 13, 2020 12:47
LinUCB implementation based on Chu, Wei, et al. "Contextual Bandits with Linear Payoff Functions." AISTATS. Vol. 15. 2011.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tushuhei
tushuhei / Bayesian_Statistics_MCMC.ipynb
Created January 29, 2017 02:53
道具としてのベイズ統計(涌井 良幸 著)の Python での MCMC 実装例
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.