Skip to content

Instantly share code, notes, and snippets.

View yohm's full-sized avatar

Yohsuke Murase yohm

View GitHub Profile
@yohm
yohm / file0.html
Created July 24, 2018 02:46
chart.jsでぐりぐり動くグラフを作る ref: https://qiita.com/yohm/items/586690bf36efa0838e37
<div class="slidecontainer" id="sliders">
<input type="range" min="-1" max="1" value="0" step="0.1" class="slider" id="slider_a">a : <span id="val_a">0</span><br/>
<input type="range" min="-1" max="1" value="0" step="0.1" class="slider" id="slider_b">b : <span id="val_b">0</span><br />
<input type="range" min="-1" max="1" value="0" step="0.1" class="slider" id="slider_c">c : <span id="val_c">0</span><br />
</div>
from keras.datasets import boston_housing
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam
(x_train, y_train), (x_test, y_test) = boston_housing.load_data(test_split=0.0)
def scale_input(data):
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
@yohm
yohm / async_await_fiber.py
Created March 15, 2018 07:26
fiber_sample
import fibers
import time
root_fiber = None
sub_fibers = []
t = 0.1
def async(func, *args, **kwargs):
global root_fiber, sub_fibers
def _f():
import sys
import os.path
import caravan_dump
import numpy as np
from sklearn.linear_model import Ridge
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import PolynomialFeatures
from sklearn.model_selection import train_test_split
@yohm
yohm / MyCpp.cpp
Last active August 28, 2017 09:17
x10 version of pipe_sample
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <x10/lang/Rail.h>
#include <x10/lang/String.h>
int popen2(char*const* argv, int *fd_r, int *fd_w) {
@yohm
yohm / pipe_sample.cpp
Last active August 27, 2017 12:44
communication between cpp process and python process using pipe
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#define READ (0)
#define WRITE (1)
/**
@yohm
yohm / strongly_connected_components.rb
Created May 10, 2017 09:24
Finding strongly connected components for a directed graph using Tarjan's algorithm
require 'pp'
class DirectedGraph
attr_reader :n, :links
def initialize(size)
@n = size
@links = Hash.new {|hsh,key| hsh[key] = Array.new }
end
@yohm
yohm / system_with_timeout_redirect_tempdir.cpp
Created May 2, 2017 08:06
invoking a subprocess using fork&exec in a temporal working directory with redirected stdout and stderr and timeout
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
#include <vector>
@yohm
yohm / wrapper_sample.py
Created March 7, 2017 06:01
wrapper_sample.py
import os, sys, json, subprocess
# Load JSON file
fp = open( '_input.json' )
params = json.load( fp )
# Prepare input file
f = open('configuration.xml', 'w')
param_txt = """<configuration>
<input>
@yohm
yohm / init.lua
Created February 2, 2017 00:06
My configuration of hammerspoon
local function disableAllHotkeys()
for k, v in pairs(hs.hotkey.getHotkeys()) do
v['_hk']:disable()
end
end
local function enableAllHotkeys()
for k, v in pairs(hs.hotkey.getHotkeys()) do
v['_hk']:enable()
end