Skip to content

Instantly share code, notes, and snippets.

@LarryStanley
LarryStanley / mnist_beginner.py
Last active September 12, 2016 07:33
Tensorflow Tutorials
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
y = tf.nn.softmax(tf.matmul(x, W) + b)
@LarryStanley
LarryStanley / default.sh
Created November 9, 2016 18:02
Neural Talk Docker
cd vis
python -m SimpleHTTPServer &
th eval.lua -model model_id1-501-1448236541.t7_cpu.t7 -image_folder imgs/ -gpuid -1
@LarryStanley
LarryStanley / index.py
Created February 24, 2017 07:04
客戶字串分隔
# -*- coding: utf-8 -*-
import csv
f = open('Page1-表格 1.csv', 'r')
for row in csv.DictReader(f):
original = row['客戶全稱']
new = original.split("-")
print new[0]
f.close()
@LarryStanley
LarryStanley / activity.php
Created February 28, 2017 05:03
場地查詢
public function getSiteInfo(Request $request) {
$sites = Site::where("site_category_id", $request->site_category_id)->get();
foreach ($sites as $key => $value) {
$sites[$key]->category;
$currentSite = $sites[$key];
$currentRental = $currentSite->currentRental
->where('rental_start_date', '<=', $request->rental_start_date)
@LarryStanley
LarryStanley / ajax.js
Created March 15, 2017 10:09
ajax 基本語法
$.ajax({
url: '',
type: 'GET',
data: {
},
error: function(xhr) {
alert('Ajax request 發生錯誤');
},
success: function(response) {
}
from sklearn.neural_network import MLPClassifier
X = []
y = []
with open('letter-recognition.data') as f:
lines = f.readlines()
for line in lines:
line = line.replace("\n", "")
parseLine = line.split(",")
y.append(parseLine[0])
@LarryStanley
LarryStanley / setup.sh
Last active August 14, 2017 09:38
ryu-sdn-router.sh
#!/bin/bash
# add bridge
ovs-vsctl add-br ovsbr0
#add hosts
docker rm container1
docker run --name=container1 --cap-add=NET_ADMIN --net='none' -itd busybox /bin/sh
docker rm container2
docker run --name=container2 --cap-add=NET_ADMIN --net='none' -itd busybox /bin/sh
@LarryStanley
LarryStanley / card.js
Last active December 28, 2017 12:20
card.js
javascript:(function()%7Bfunction%20callback()%7B(function(%24)%7Bvar%20jQuery%3D%24%3Balert%20%3D%20function()%20%7B%7D%3Bwindow.alert%20%3D%20function()%20%7B%7D%3Bvar%20units%20%3D%20%5B%22200000000A%22%2C%22201000000A%22%2C%22202000000A%22%2C%22202010000A%22%2C%22301000000A%22%2C%22301000100G%22%2C%22301000200G%22%2C%22301020000G%22%2C%22301020700G%22%2C%22301020800G%22%2C%22301020900G%22%2C%22301021000G%22%2C%22301021100G%22%2C%22301021200G%22%2C%22301021300G%22%2C%22301021400G%22%2C%22301023400G%22%2C%22301060000C%22%2C%22301060100C%22%2C%22301060200C%22%2C%22301060300C%22%2C%22301060400C%22%2C%22313000000G%22%2C%22313010000G%22%2C%22313010100G%22%2C%22313020000G%22%2C%2231302101DG%22%2C%22313022000G%22%2C%22313022100G%22%2C%22313022300G%22%2C%22313022400G%22%2C%22313022500G%22%2C%22313022600G%22%2C%22313022700G%22%2C%22313022800G%22%2C%22313022900G%22%2C%22313023000G%22%2C%22313023100G%22%2C%22313023200G%22%2C%22313023300G%22%2C%22313023400G%22%2C%22313023600G%22%2C%22313023700G%22%2C%22313023800G%22%2
@LarryStanley
LarryStanley / parse.py
Last active September 27, 2017 07:38
etc-python-sqlite
from sqlite import Gp2014
from tqdm import tqdm
if __name__ == '__main__':
gp = Gp2014.select().limit(20)
for row in gp:
print(row.gantryfrom) #取得出發點
print(row.gantryto) #取得終點
print(row.vehicletype) #取得車種
@LarryStanley
LarryStanley / DirectionsRenderer.js
Created September 27, 2017 07:46
DirectionsRenderer with color options
"use strict"
Object.defineProperty(exports, "__esModule", {
value: true,
})
exports.DirectionsRenderer = undefined
var _defineProperty2 = require("babel-runtime/helpers/defineProperty")
var _defineProperty3 = _interopRequireDefault(_defineProperty2)