Skip to content

Instantly share code, notes, and snippets.

@fengye
fengye / unimap_cpp_v1.c
Last active July 20, 2019 11:09
An remapped HHKB layout for C++ programmers.
#include "unimap_trans.h"
enum macro_id {
CPP_POINTER,
CPP_COMMENT,
};
// L0, for remapped X keycodes
// 1st row
#define AC_L0_LPRN ACTION_MODS_KEY(MOD_LSFT, KC_9)
@fengye
fengye / unimap_human_v1.c
Last active July 18, 2019 16:42
HHKB for Human C source in TMK Keyboard firmware
#include "unimap_trans.h"
#define AC_FN1 ACTION_LAYER_MOMENTARY(1)
#define AC_FN2 ACTION_LAYER_TAP_KEY(2, KC_LCTL)
#define AC_ENT2 ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT)
#define AC_LSOS ACTION_MODS_ONESHOT(MOD_LSFT)
#define AC_RSOS ACTION_MODS_ONESHOT(MOD_RSFT)
#define AC_L2(KEY) ACTION_MODS_KEY(MOD_LCTL, KC_##KEY)
@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
@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": {
#!/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 / find_similarities.py
Last active May 27, 2019 07:52
Using cross correlation to find similarity in two audios. Useful in echo cancellation.
import audio_io
import numpy
audio1, _ = audio_io.ReadWavFile('voice_nodelay.wav')
audio1 = audio1.ravel()
audio2, _ = audio_io.ReadWavFile('voice_mic_blend3.wav')
audio2 = audio2.ravel()
# Truncate all signals same length, then pad to avoid boundary effects.
@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
},
{
"build_command": "$sourcepath $classpath $d \"$file\"",
"java_executables":
{
"build": "nxjc",
"run": "nxjlink",
"version": "nxjc"
},
"jdk_version":
{
@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

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: