Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
tsu-nera / cartpole_random.py
Created June 9, 2017 07:06
CartPole Random
import gym
from gym import wrappers
env = gym.make('CartPole-v0')
env = wrappers.Monitor(env, '/tmp/cartpole-experiment-1')
for i_episode in range(20):
observation = env.reset()
for t in range(100):
env.render()
print(observation)
action = env.action_space.sample()
@tsu-nera
tsu-nera / nazokake.ipynb
Created May 13, 2017 09:07
gensimで謎かけ
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tsu-nera
tsu-nera / twitter_analytics.ipynb
Last active May 25, 2017 16:34
tsu_neraのtwitterアカウント分析
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tsu-nera
tsu-nera / get_actress_img.py
Created April 12, 2017 11:53
月間AV女優ランキング ベスト100から画像をダウンロード
from os.path import basename
import urllib.request
import requests
from bs4 import BeautifulSoup
from time import sleep
pages = ['http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=1_20/',
'http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=21_40/',
'http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=41_60/',
'http://www.dmm.co.jp/mono/dvd/-/ranking/=/term=monthly/mode=actress/rank=61_80/',
@tsu-nera
tsu-nera / tflearn_mnist.py
Created April 7, 2017 09:44
TFLearn and MNIST
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
# MNISTデータのダウンロード
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
# おまじない
tf.reset_default_graph()
@tsu-nera
tsu-nera / twitter.rb
Created January 3, 2017 11:48
twitter client
#!/usr/bin/ruby
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end
client.update(ARGV[0])
@tsu-nera
tsu-nera / ChessMetric.py
Last active December 13, 2015 09:28
TCCC 2003 Round 4 Level1
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class ChessMetric:
def howMany(self, size, start, end, numMoves):
dx = [1, 1, 1, 0, -1, -1, -1, 0, 2, 1, -1, -2, -2, -1, 1, 2]
dy = [1, 0, -1, -1, -1, 0, 1, 1, -1, -2, -2, -1, 1, 2, 2, 1]
dp = [[[0 for i in range(55)] for j in range(100)] for k in range(100)]
dp[start[0]][start[1]][0] = 1
@tsu-nera
tsu-nera / ShortestPathWithMagic.py
Last active December 11, 2015 14:53
SRM 675 Div2 500
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class ShortestPathWithMagic:
def getTime(self, adj, k):
n = len(adj)
d = [[0 for i in range(n)] for j in range(n)]
# convert string to number
@tsu-nera
tsu-nera / LengthUnitCalculator.py
Created December 10, 2015 15:20
SRM 675 Div2 250
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class LengthUnitCalculator:
def calc(self, amount, fromUnit, toUnit):
if fromUnit == toUnit:
return amount
if fromUnit == "in":
if toUnit == "ft":
@tsu-nera
tsu-nera / FriendScore.py
Last active December 6, 2015 11:09
SRM 436 Div2 250
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
class FriendScore:
def highestScore(self, friends):
n = len(friends)
ans = 0
for i in range(n):
cnt = 0