Skip to content

Instantly share code, notes, and snippets.

@fengye
fengye / TestBehaviour.cs
Last active February 18, 2018 01:03
A study on MonoBehaviour's behaviour in the game and in Unity editor.
using UnityEngine;
using System.Collections;
public class TestBehaviour : MonoBehaviour {
TestBehaviour()
{
// Will be called in Editor(play in game view, stop and back to scene) and Game.
// Will also be called when script get recompiled.
Debug.Log("TestBehaviour ctor: " + System.DateTime.Now.Ticks);
@fengye
fengye / .bashrc
Last active February 18, 2018 01:14
# kaggle/python docker .bashrc for linux
kpython(){
docker run -v $PWD:/tmp/working -w=/tmp/working --rm -it kaggle/python python "$@"
}
ikpython() {
docker run -v $PWD:/tmp/working -w=/tmp/working --rm -it kaggle/python ipython
}
kjupyter() {

Based on the instruction here https://github.com/gw0/docker-keras with a few modification on how to run on GPU:

The original snippet:

$ docker run -it --rm $(ls /dev/nvidia* | xargs -I{} echo '--device={}') $(ls /usr/lib/*-linux-gnu/{libcuda,libnvidia}* | xargs -I{} echo '-v {}:{}:ro') -v $(pwd):/srv gw000/keras:2.1.4-py2-tf-gpu /srv/run.py

The idea is to map local NVIDIA devices(/dev/nvidia*) to container environment, and map local NVIDIA drivers and libraries to proper container's /usr/lib/ directories. With NVIDIA driver 387.34(latest when written), this is snippet is no longer sufficient.

Modified snippet:

@fengye
fengye / docker_cheatsheet.md
Created September 7, 2018 23:52
Docker Cheat Sheet

DOCKER CHEAT SHEET

List and Info

List locally stored static docker images

$ docker images

List running containers

$ docker ps

{
"build_command": "$sourcepath $classpath $d \"$file\"",
"java_executables":
{
"build": "nxjc",
"run": "nxjlink",
"version": "nxjc"
},
"jdk_version":
{
@fengye
fengye / CursorMode-karabiner.json
Created November 26, 2018 02:50
CursorMode-karabiner.json
{
"description": "Double click ESC to toggle cursor mode. ",
"manipulators": [
{
"conditions": [
{
"name": "cursor_mode_trigger_key_pressed",
"type": "variable_if",
"value": 1
},
#!/bin/bash
pushd $1
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
git fetch --all
git pull --all
popd
@fengye
fengye / HHKB_for_Human_Being.json
Created July 6, 2019 05:13
Karabiner Complex Modification: HHKB_for_Human_Being
{
"title": "HHKB for Human Being",
"rules": [
{
"description": "Change left_control+ijkl to arrow keys",
"manipulators": [
{
"from": {
"key_code": "j",
"modifiers": {
@fengye
fengye / nuke_folder.bat
Last active July 7, 2019 04:38
Take ownership and assign permission then remove all the files recursively in one folder
@echo off
setlocal
:PROMPT
@echo DELETING %1 !!!
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END
takeown /f %1 /r /d y
icacls %1 /grant Everyone:(OI)(CI)F /T
icacls %1 /grant %username%:F /T