Skip to content

Instantly share code, notes, and snippets.

# clone it under jupyter extension path
mkdir -p $(jupyter --data-dir)/nbextensions
git clone https://github.com/lambdalisue/jupyter-vim-binding $(jupyter --data-dir)/nbextensions/vim_binding

# enable it permanently
jupyter nbextension enable vim_binding/vim_binding
@jhjin
jhjin / Makefile.latex
Created November 10, 2018 01:56
Makefile for latex on Mac
# LaTex Makefile dependency
# brew update
# brew cask install mactex
SRC_FULLNAME=$(wildcard *.tex)
SRC_BASENAME=$(basename $(SRC_FULLNAME))
all:
pdflatex $(SRC_FULLNAME)
bibtex $(SRC_BASENAME)
@jhjin
jhjin / fastexp.cpp
Created December 13, 2016 22:14
A Fast, Compact Approximation of the Exponential Function (double precision)
// A Fast, Compact Approximation of the Exponential Function
// http://www.schraudolph.org/pubs/Schraudolph99.pdf
inline double fast_exp(double y) {
double d;
*(reinterpret_cast<int*>(&d) + 0) = 0;
*(reinterpret_cast<int*>(&d) + 1) = static_cast<int>(1512775 * y + 1072632447);
return d;
}
@jhjin
jhjin / CMakeLists.txt
Last active February 3, 2017 06:08
tensorflow
cmake_minimum_required(VERSION 2.8.3)
project(tensorflow)
include(ExternalProject)
find_package(PythonInterp 2.7)
find_package(PythonLibs 2.7)
get_filename_component(PYTHON_LIBRARIES_DIR ${PYTHON_LIBRARIES} PATH)
# sudo apt-get install bazel python-numpy swig python-dev python-wheel
find_package(CUDA)
@jhjin
jhjin / rosvim.sh
Created September 22, 2016 17:01
a convenient shell script to vim a file under ROS package
function rosvim {
ROSVIM_FNAME=$1
if [ ! -f $ROSVIM_FNAME ]; then
ROSVIM_PKGS="package1 package2 package3"
for PKG_NAME in $ROSVIM_PKGS; do
ROSVIM_PKG_PATH=$(rospack find $PKG_NAME 2> /dev/null)
if [ $? -eq 0 ]; then
ROSVIM_FNAME_FULL=$(find -L $ROSVIM_PKG_PATH -name "$ROSVIM_FNAME" | head -n1)
if [ ! -z $ROSVIM_FNAME_FULL ]; then
ROSVIM_FNAME=$ROSVIM_FNAME_FULL
@jhjin
jhjin / timestamp.cpp
Created September 19, 2016 04:01
Timestamp conversion
// 2016-08-26T21:10:13.167Z -> 1472245813167
namespace bpt = boost::posix_time;
uint64_t ISOdate2ms_boost(const std::string timestamp_) {
std::string timestamp = timestamp_;
if (timestamp[10] == 'T') timestamp[10] = ' ';
if (timestamp[timestamp.size()-1] == 'Z') timestamp.resize(timestamp.size()-1);
bpt::ptime epoch = bpt::time_from_string("1970-01-01 00:00:00.000");
bpt::ptime birthdate = bpt::time_from_string(timestamp);
bpt::time_duration const diff = birthdate - epoch;
uint64_t timestamp_numeric = diff.total_milliseconds();
@jhjin
jhjin / spatialize-net.py
Created August 29, 2016 23:31
simple script to spatialize caffe model
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import caffe
caffe.set_mode_cpu()
path_src = 'src.caffemodel'
path_dst = 'dst.caffemodel'
net_src = caffe.Net('src.prototxt', path_src, caffe.TEST)
@jhjin
jhjin / install-caffe-on-mac.sh
Last active October 20, 2016 05:30
a quick script for installing Caffe on Mac
brew install python
brew install wget
brew install protobuf
brew install boost-python
brew install lmdb
brew install leveldb
brew install snappy
brew install gflags
brew install glog
brew tap homebrew/science
@jhjin
jhjin / Makefile.config
Last active October 20, 2016 05:30
Caffe Makefile config for Mac without opencv3 + no NVIDIA GPU
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
@jhjin
jhjin / deeplearningbook.bash
Created May 31, 2016 03:47
Easy downloading script for deep learning book
#!/usr/bin/bash
iterator=1
url="http://www.deeplearningbook.org/contents/"
array=(
TOC.html
acknowledgements.html
notation.html
intro.html
part_basics.html
linear_algebra.html