Skip to content

Instantly share code, notes, and snippets.

View kenzotakahashi's full-sized avatar

Kenzo Takahashi kenzotakahashi

  • Tokyo, Japan
View GitHub Profile
from sklearn import datasets
import csv, math, random
import pandas as pd
import numpy as np
from collections import defaultdict
def customer_count(status, gender)
Customer.where(status: status, gender: gender).size
end
# Specify the provider and access details
provider "aws" {
region = "ap-northeast-1"
}
resource "aws_instance" "web" {
ami = "ami-374db956"
instance_type = "t2.micro"
tags {
Name = "NomadAgent"
require 'rails_helper'
RSpec.describe User, type: :model do
describe ".is_gmail_user?" do
context "given a gmail address" do
it "returns true" do
user1 = User.new({email: 'kenzotakahashi@gmail.com'})
expect(user1.is_gmail_user?).to eql(true)
end
require 'rails_helper'
RSpec.describe "the signin process", :type => :feature do
# before :each do
# User.new(:email => 'user@example.com', :password => 'password')
# end
it "signs me in" do
visit '/login'
within(".row") do
require "redis"
redis = Redis.new
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
#week3/plactice/app/jobs/pokemon/pokemon_job.rb
module Pokemon
class PokemonJob < ApplicationJob
queue_as :default
def perform(*args)
puts "ポケモンGO!"
end
end
end
yamanote = ["大崎","五反田","目黒","恵比寿","渋谷","原宿","代々木","新宿","新大久保","高田馬場","目白","池袋","大塚","巣鴨","駒込","田端","西日暮里","日暮里","鶯谷","上野","御徒町","秋葉原","神田","東京","有楽町","新橋","浜松町","田町","品川"]
class ArrayIterator
def initialize(array)
@array = array
@index = 0
end
def item
@kenzotakahashi
kenzotakahashi / get_xpath.py
Last active February 21, 2017 05:58
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
"""
REINFORCE with Baseline
"""
import collections
import gym
import numpy as np
import tensorflow as tf
from keras.models import Model