Skip to content

Instantly share code, notes, and snippets.

View Hironsan's full-sized avatar
💤
Zzz

Hiroki Nakayama Hironsan

💤
Zzz
View GitHub Profile
print('Hello Gist!')
@Hironsan
Hironsan / flask_like_decorator.py
Created June 22, 2016 06:43
flask like decorator example
def route(rule, **options):
def decorator(f):
print(options)
print('do something')
return f
return decorator
@route('/index', method='POST')
def index():
import os
# import cv2
def read_image(file_path):
# cv2.read(file_path, 1) # grayscale
pass
def traverse_dir(path):
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
sess = tf.InteractiveSession()
x = tf.placeholder(tf.float32, shape=[None, 784])
y_ = tf.placeholder(tf.float32, shape=[None, 10])
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
# -*- coding: utf-8 -*-
import datetime
from collections import defaultdict
import dateutil.parser
from application.google_calendar import get_upcoming_events
def extract_intervals(events_list):
intervals = defaultdict(list)
# -*- coding: utf-8 -*-
import datetime
from collections import defaultdict
import dateutil.parser
from application.google_calendar import get_upcoming_events
def extract_intervals(events_list):
intervals = defaultdict(list)
@Hironsan
Hironsan / corpus_reader.py
Created September 11, 2018 20:46
chABSA-dataset corpus reader
# -*- coding: utf-8 -*-
import json
from collections import defaultdict
from pathlib import Path
def find_corpus_fileids(root, regexp):
p = Path(root)
return list(p.glob(regexp))
1444062497
284862083
762630884
1188614369
1104161854
1280855887
586449534
1206728554
468429333
566799704
#!/bin/bash
REGION=us-east-1
RUNTIME=python3.7
while getopts :n:r:p: OPT
do
case $OPT in
n) PACKAGE=$OPTARG;;
r) REGION=$OPTARG;;
p) RUNTIME=$OPTARG;;
@Hironsan
Hironsan / lambda_function.py
Created June 30, 2020 08:59
spaCy for Lambda
import os
import urllib.request
import spacy
import tarfile
from pathlib import Path
def maybe_download(model, dest):
save_path = Path(dest) / model
if not os.path.exists(save_path):