View app.js
const { GraphQLServer } = require('graphql-yoga') | |
const mongoose = require('mongoose') | |
require('dotenv').config() | |
const resolvers = require('./resolvers') | |
mongoose.connect(process.env.MONGODB_URI) | |
const db = mongoose.connection | |
db.on("error", console.error.bind(console, "connection error")) | |
db.once("open", function(callback){ | |
console.log("Connection Succeeded") |
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 |
View baseline.py
""" | |
REINFORCE with Baseline | |
""" | |
import collections | |
import gym | |
import numpy as np | |
import tensorflow as tf | |
from keras.models import Model |
View policy_gradient.py
""" | |
REINFORCE(Policy Gradient) | |
""" | |
import collections | |
import gym | |
import numpy as np | |
import tensorflow as tf | |
from keras.models import Model |
View pytorch_gru.py
import numpy as np | |
from sklearn.model_selection import train_test_split | |
import torch | |
import torch.nn as nn | |
from torch.autograd import Variable | |
np.random.seed(1337) | |
MAX_LEN = 30 |
View get_xpath.py
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 | |
end | |
def item |
View kadai3_4.rb
#week3/plactice/app/jobs/pokemon/pokemon_job.rb | |
module Pokemon | |
class PokemonJob < ApplicationJob | |
queue_as :default | |
def perform(*args) | |
puts "ポケモンGO!" | |
end | |
end | |
end |
View redis.rb
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 |
View week3_kadai2.rb
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 |
NewerOlder