Skip to content

Instantly share code, notes, and snippets.

@twmht
twmht / extract.py
Created July 7, 2016 07:43
read opencv vec file
import struct,array
import cv2
import numpy as np
i = 0
def showvec(fn, width=24, height=24, resize=4.0):
f = open(fn,'rb')
HEADERTYP = '<iihh' # img count, img size, min, max
@twmht
twmht / build.sh
Last active June 28, 2016 00:01
Build pyfaster-rcnn in ubuntu 15.04
# for 16.04
# https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide
# caffe dependencies
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
# Caffe requires the CUDA nvcc compiler to compile its GPU code and CUDA driver for GPU operation.
# To install CUDA, go to the NVIDIA CUDA website and follow installation instructions there.
@twmht
twmht / addAttribute.py
Last active January 9, 2016 07:30
add random atrtributes
class Struct:
def __init__(self, **entries):
self.__dict__.update(entries)
a = Struct(x = 5,y = 6)
print a.x
print vars(a)
print a.__dict__
@twmht
twmht / unlock.sh
Created June 11, 2015 05:13
unlock the device
if [ "$(adb shell dumpsys power | grep mScreenOn= | grep -oE '(true|false)')" == false ] ; then
echo "Screen is off. Turning on."
adb shell input keyevent 26 # wakeup
adb shell input keyevent 82 # unlock
echo "OK, should be on now."
else
echo "Screen is already on."
fi
@twmht
twmht / gist:cd4d26455c1a31a9065b
Last active August 29, 2015 14:14
Generate cscope db from android projects
#!/bin/bash
#./genDb.sh `pwd`
#export CSCOPE_EDITOR=`which vim`
CSCOPE_FILE=cscope.out
if [ -n "$1" ]; then
echo "Source code directory: " $1
echo "Create file map : " $CSCOPE_FILE
find $1 -name "*.h" -o -name "*.c" -o -name "*.cpp" -o -name "*.java" -o -name "*.aidl" -o -name "*.mk" > $CSCOPE_FILE
#cscope -bkq -i $CSCOPE_FILE
@twmht
twmht / Person.java
Created December 25, 2014 15:24
Gzip
package org.gradle;
import java.io.PrintWriter;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.zip.GZIPOutputStream;
import java.util.zip.GZIPInputStream;
import org.apache.commons.collections.list.GrowthList;
(function($){
// Settings
var repeat = localStorage.repeat || 0,
shuffle = localStorage.shuffle || 'false',
continous = true,
autoplay = false,
playlist = [];
// Load playlist
for (var i=0; i<playlist.length; i++){
@twmht
twmht / showgit.sh
Created June 29, 2014 09:15
show git branch in bash shell
# show git branch
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}")";
}
PS1="${HOSTNAME}:\w\[\033[1;32m\]\$(git_branch)\[\033[0m\]$";
#!/usr/bin/env python2
# coding: utf-8
import os,socket,threading,time
#import traceback
allow_delete = False
local_ip = socket.gethostbyname(socket.gethostname())
local_port = 8888
currdir=os.path.abspath('.')
@twmht
twmht / pythonbrew.sh
Last active August 29, 2015 13:59
Intsall pythonbrew
sudo apt-get install python-setuptools zlib1g-dev libbz2-dev libreadline-dev libgdbm-dev libssl-dev libsqlite3-dev curl build-essential libxml2-dev libxslt1-dev libreadline5 libreadline6-dev libxml2 tk-dev libexpat1-dev libncursesw5-dev
sudo easy_install pythonbrew
pythonbrew_install