Skip to content

Instantly share code, notes, and snippets.

View jiayuzhou's full-sized avatar
🎯
Focusing

Jiayu Zhou jiayuzhou

🎯
Focusing
View GitHub Profile
@jiayuzhou
jiayuzhou / uninstall-GHfM.sh
Created May 27, 2017 22:16
Completely uninstall GitHub for Mac
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}
@jiayuzhou
jiayuzhou / TMAC1900_Merlin.md
Last active June 12, 2023 18:30
Flash Merlin to TM-AC1900

Flash Merlin (https://asuswrt.lostrealm.ca) experience

Bought TMobile Cellspot (TM-AC1900) and would like to flash Merlin firmware.

  1. Purchased router equipped with TMobile firmware version: 3.0.0.4.376_2827 Gateway address: 192.168.27.1

  2. Downgrade TMoble firmware to enable TELNET 1.1 Get into recovery mode (hold reset and power up, until ping TTL=100) 1.2 Downgrade to Tmobile firmware version: 3.0.0.4_376_1703 TRX use tftp binary transfer.

@jiayuzhou
jiayuzhou / pg-pong.py
Created June 24, 2016 17:58 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@jiayuzhou
jiayuzhou / check_grad.m
Last active September 18, 2017 01:28
The simple gradient check function.
function check_grad(f, x0, varargin)
% a simple function that checks the correctness of gradient.
% INPUT
% f - a function handle of f(x) that returns function values and gradients given parameter x
% x0 - the location near which the gradient will be evaluted.
% For a correct gradiet, the displayed ratio should be near 1.0
%
% to check why the code works there is a useful link:
% http://ufldl.stanford.edu/tutorial/supervised/DebuggingGradientChecking/
@jiayuzhou
jiayuzhou / mexopts.sh
Created July 3, 2015 23:28
Matlab R2012b MEX configuration for Mac OSX.
#
# mexopts.sh Shell script for configuring MEX-file creation script,
# mex. These options were tested with the specified compiler.
#
# usage: Do not call this file directly; it is sourced by the
# mex shell script. Modify only if you don't like the
# defaults after running mex. No spaces are allowed
# around the '=' in the variable assignment.
#
# Note: For the version of system compiler supported with this release,
@jiayuzhou
jiayuzhou / caffe_proto_.cc
Last active August 29, 2015 14:24 — forked from kyamagu/caffe_proto_.cc
Caffe Protobuf converter
// Caffe proto converter.
//
// Build
//
// mex -I/path/to/mexplus ...
// -I/path/to/build/src/caffe/proto/ ...
// caffe_proto_.cc ...
// /path/to/build/src/caffe/proto/caffe.pb.o ...
// -lprotobuf
//
// Caffe proto converter.
//
// Build
//
// mex -I/path/to/mexplus ...
// -I/path/to/build/src/caffe/proto/ ...
// caffe_proto_.cc ...
// /path/to/build/src/caffe/proto/caffe.pb.o ...
// -lprotobuf ...
// -L/usr/local/lib
@jiayuzhou
jiayuzhou / SparkProfileEMR.md
Last active March 26, 2016 00:37
Spark Memory Profile in Amazon EMR
  1. How to log into slaves

One can log into the slave nodes using Agent Forwarding by SSH. Suppose that I find in the YARN log

java.nio.channels.CancelledKeyException
14/09/25 23:12:58 ERROR SendingConnection: Exception while reading SendingConnection to ConnectionManagerId(ip-172-31-xx-xx.ec2.internal,49972)
java.io.IOException: Connection reset by peer
...

I would like to SSH to the slave ip-172-31-xx-xx.ec2.internal to check the logs. To do so, firstly we have to add EMR identity to the agent

NERDTree

o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|

O.......Recursively open the selected directory..................|NERDTree-O|

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname