Skip to content

Instantly share code, notes, and snippets.

Huy Nguyen huyng

Block or report user

Report or block huyng

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@huyng
huyng / search.py
Last active Aug 29, 2015
depth first search
View search.py
# list of nodes ot visit
visit_stack = deque([tree])
while len(visit_stack) > 0:
node = visit_stack.popleft()
if node is None:
continue
for child in node.children:
visit_stack.append(child)
# do something with node here
@huyng
huyng / infercaffe.py
Created May 19, 2015
simple inference for caffe
View infercaffe.py
import sys
import caffe
from PIL import Image
import numpy as np
pimga = Image.open("a.jpg")
pimgb = Image.open("b.jpg")
nimga = np.array(pimga).reshape(1,256,256,3).transpose(0,3,1,2)
nimgb = np.array(pimgb).reshape(1,256,256,3).transpose(0,3,1,2)
View index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>D3 Hello World</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.js"></script>
@huyng
huyng / main.rs
Last active Nov 4, 2016
Rust symbolic algebra system
View main.rs
enum Node {
TVector(&'static str),
TScalar(f32),
Add(Box<Node>, Box<Node>),
Sub(Box<Node>, Box<Node>),
Mul(Box<Node>, Box<Node>),
Div(Box<Node>, Box<Node>),
Pow(Box<Node>, Box<Node>),
}
View gist:9b9a54e30143d5ecca22
uwsgi -w main:app \
--http 127.0.0.1:8080 \
--processes 4 \
--master \
--env=AUTOTAGS=/home/huyng/STORM_PACKAGE_8/autotags-v4.3.0.pkl \
--env=FACE_MODEL=/home/huyng/vision-autotags/data/models/face/detect/haarcascade_frontalface_alt2.xml \
-b 65535
@huyng
huyng / minisgd.py
Created Aug 22, 2014
Minibatch gradient descent
View minisgd.py
import pickle
import gzip
import theano
import theano.tensor as T
import numpy as np
import pylab as P
# load the dataset
with gzip.open('mnist.pkl.gz', 'rb') as fh:
train_set, valid_set, test_set = pickle.load(fh)
@huyng
huyng / Dockerfile
Created Jul 24, 2014
Dockerfile to setup and build a linux machine compatible for running bvlc/caffe
View Dockerfile
FROM ubuntu:12.04
RUN apt-get -y update
RUN apt-get -y install wget git curl python-dev libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev protobuf-compiler libatlas-dev libatlas-base-dev
RUN wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz -O /tmp/glog-0.3.3.tar.gz && tar -C /tmp -xzvf /tmp/glog-0.3.3.tar.gz && rm /tmp/glog-0.3.3.tar.gz
RUN cd /tmp/glog-0.3.3 && ./configure && make && make install && cd -
RUN curl http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.0-37_amd64.deb -o /tmp/cuda_install.deb && dpkg -i /tmp/cuda_install.deb && rm /tmp/cuda_install.deb
RUN apt-get -y update && apt-get -y install cuda
RUN curl https://gitorious.org/mdb/mdb/archive/7f038d0f15bec57b4c07aa3f31cd5564c88a1897.tar.gz -o /tmp/mdb.tar.gz && tar -C /tmp -xzvf /tmp/mdb.tar.gz && rm /tmp/mdb.tar.gz
RUN cd /tmp/mdb-mdb/libraries/liblmdb/ && make && make install
View gist:7e18bf96c8409f2d6bf6
18 the
10 of
8 a
7 to
5 were
5 by
5 North
5 Korean
4 troops
4 U.S.
View Python-CDATA.py
import xml.etree.ElementTree as ET
def CDATA(text=None):
element = ET.Element('![CDATA[')
element.text = text
return element
ET._original_serialize_xml = ET._serialize_xml
You can’t perform that action at this time.