Skip to content

Instantly share code, notes, and snippets.

View leemengtw's full-sized avatar
🤖
I write random stuffs about AI/ML/DS @ leemeng.tw (in Chinese)

Meng Lee leemengtw

🤖
I write random stuffs about AI/ML/DS @ leemeng.tw (in Chinese)
View GitHub Profile
{% block head %}
{{ super() }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.css" />
{% endblock %}
...
{% block content %}
<div class="container">
{% block content %}
<div class="container">
{% block page_content %}{% endblock %}
<button onclick="myFunction()">Click Me</button>
<div id="upload" class="row">
Some text
</div>
</div>
import os.path, time
UPLOAD_FOLDER = 'static/uploaded_images'
# exclude .json file
files = ['/'.join((UPLOAD_FOLDER, file)) \
for file in os.listdir(UPLOAD_FOLDER) if 'json' not in file]
last_modified_files = [(file, os.path.getmtime(file)) for file in files]
last_modified_files = sorted(last_modified_files, key=lambda t: t[1], reverse=True)
@leemengtw
leemengtw / bootstrap_gallery.css
Last active December 21, 2017 01:15
Bootstrap Gallery
@leemengtw
leemengtw / form.html
Last active December 21, 2017 01:14
form利用按鈕取得使用者feedback, 在flask app裡頭取得使用者按的按鈕的值
<form action="{{ url_for('save_user_feedback') }}" method=post>
<div class='form-group'>
<button type="submit" name='y' value="cat" class="btn btn-success">Cat</button>
<button type="submit" name='y' value="dog" class="btn btn-success">Dog</button>
<button type="submit" name='y' value="others" class="btn btn-success">Others</button>
</div>
</form>
<h3>Upload new Images</h3>
<form method=post enctype=multipart/form-data>
<div class='form-group'>
<label class="btn btn-default btn-file">
Browse <input type="file" name=file style="display: none;">
</label>
<button type="submit" class="btn btn-success">Upload</button>
</div>
</form>
#Pickle save:
import cPickle as pickle
with open('data.p', 'wb') as fp:
pickle.dump(data, fp)
#Pickle load:
with open('data.p', 'rb') as fp:
data = pickle.load(fp)
# encoding: utf-8
from __future__ import print_function
from __future__ import unicode_literals
import os
import json
import boto3
import logging
import gspread
from oauth2client.service_account import ServiceAccountCredentials
@leemengtw
leemengtw / acc_on_tensorboard.md
Last active October 15, 2017 01:40
要自訂metric的計算, 因為tf跟np有很多相同函示, 很多時候可以先建立兩個np.ndarray 然後想辦法使用 numpy 兜出一個算式再轉乘對應的tf算式
We couldn’t find that file to show.
with tf.Session(graph=graph) as sess:
# initialize weights
tf.global_variables_initializer().run()
# write to log for tensorboard
writer = tf.summary.FileWriter(LOG_DIR)
writer.add_graph(sess.graph)