Skip to content

Instantly share code, notes, and snippets.


Kenzo Takahashi kenzotakahashi

View GitHub Profile
View app.js
const { GraphQLServer } = require('graphql-yoga')
const mongoose = require('mongoose')
const resolvers = require('./resolvers')
const db = mongoose.connection
db.on("error", console.error.bind(console, "connection error"))
db.once("open", function(callback){
console.log("Connection Succeeded")
kenzotakahashi / constructWallOutline.js
Last active Apr 3, 2018
Construct outlines of walls.
View constructWallOutline.js
function magnitude(vx, vy) {
return Math.sqrt(vx**2 + vy**2)
function slope(x1, y1, x2, y2) {
return (y2 - y1) / (x2 - x1)
function isParallel(l1, l2) {
const [[x1,y1],[x2,y2]] = l1
REINFORCE with Baseline
import collections
import gym
import numpy as np
import tensorflow as tf
from keras.models import Model
REINFORCE(Policy Gradient)
import collections
import gym
import numpy as np
import tensorflow as tf
from keras.models import Model
kenzotakahashi /
Last active Feb 4, 2020
PyTorch GRU example with a Keras-like interface.
import numpy as np
from sklearn.model_selection import train_test_split
import torch
import torch.nn as nn
from torch.autograd import Variable
MAX_LEN = 30
kenzotakahashi /
Last active Feb 21, 2017
HTML elementのXpathを取得するスクリプト
from urllib import request
from lxml import etree
import re
def get_index(e):
tag = e.tag
prev_list = [i for i in e.itersiblings(preceding=True) if i.tag == tag]
next_list = [i for i in e.itersiblings() if i.tag == tag]
if len(prev_list + next_list) == 0:
return None
View week7_kadai4.rb
yamanote = ["大崎","五反田","目黒","恵比寿","渋谷","原宿","代々木","新宿","新大久保","高田馬場","目白","池袋","大塚","巣鴨","駒込","田端","西日暮里","日暮里","鶯谷","上野","御徒町","秋葉原","神田","東京","有楽町","新橋","浜松町","田町","品川"]
class ArrayIterator
def initialize(array)
@array = array
@index = 0
def item
View kadai3_4.rb
module Pokemon
class PokemonJob < ApplicationJob
queue_as :default
def perform(*args)
puts "ポケモンGO!"
View redis.rb
require "redis"
redis =
redis.zadd "date:2016-8-5", 214, 1
redis.zadd "date:2016-8-5", 252, 2
redis.zadd "date:2016-8-5", 5222, 3
redis.zadd "date:2016-8-5", 2231, 4
redis.zadd "date:2016-8-5", 442, 5
View week3_kadai2.rb
require 'rails_helper'
RSpec.describe "the signin process", :type => :feature do
# before :each do
# => '', :password => 'password')
# end
it "signs me in" do
visit '/login'
within(".row") do