Skip to content

Instantly share code, notes, and snippets.

View kennyng's full-sized avatar

Kenny Ng kennyng

View GitHub Profile
@kennyng
kennyng / prompt_tmux
Created August 15, 2019 19:12
Add tmux info to shell prompt
# .tmux.conf: Disable status bar
set -g status off
# .bashrc: Update prompt info and styling
PS1='\[\033[33m\]$(prompt tmux)\[\033[00m\]'"$format"' \[\033[35m\]$(prompt git)\[\033[00m\]\[\033[31m\]$(prompt job)\[\033[00m\]\n\$ '
tmux)
# Check for tmux.
if ! hash tmux 2>/dev/null ; then
return 1
@kennyng
kennyng / bash-scripts.sh
Created January 29, 2017 10:22
today-scripts
#!/bin/bash
#-----------------
echo "Calendar: "
#-----------------
cal | grep --before-context 6 --after-context 6 --color -e " $(date +%e)" -e "^$(date +%e)"
#-------------------
echo "Time Zones: "
@kennyng
kennyng / 0_reuse_code.js
Created January 29, 2017 05:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kennyng
kennyng / github-pandoc.css
Created October 2, 2016 03:18 — forked from dashed/github-pandoc.css
GitHub-like CSS for pandoc standalone HTML files (perfect for HTML5 output). Based on Marked.app's GitHub CSS. Added normalize.css (v2.1.3) in the prior to GitHub css.
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@kennyng
kennyng / port_forward.sh
Last active January 29, 2017 04:52
Enable port forwarding for Transmission
#! /bin/bash
######################################################################
# port_forward.sh
# ----------------
# Enable port forwarding for Transmission.
#
# Requirements:
# Private Internet Access user and password as arguments
#
# Usage:
@kennyng
kennyng / README.CanvasRenderer.js
Last active October 23, 2023 17:27
3D Boids Simulation
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.SpriteCanvasMaterial = function ( parameters ) {
THREE.Material.call( this );
this.type = 'SpriteCanvasMaterial';
@kennyng
kennyng / README.md
Last active February 15, 2016 02:13
3D Particles Simulation

This is a 3D particles simulation created using three.js for CME151: Introduction to Data Visualization (Stanford University, Winter 2016).

@kennyng
kennyng / README.md
Last active February 16, 2016 01:25
Data Narrative

This is a data narrative created using C3.js for CME151: Introduction to Data Visualization (Stanford University, Winter 2016).

@kennyng
kennyng / VimTerm.applescript
Last active January 29, 2017 10:25
Open files with Vim (command-line) in default OSX Terminal (VimTerminal) and iTerm (VimTerm).
on run {input, parameters}
if (count of input) > 0 then
tell application "iTerm"
if (count of terminals) = 0 then
activate
end if
tell (current terminal)
tell (launch session "Default")
@kennyng
kennyng / ffmpeg_convert_audio
Created December 1, 2015 08:38
ffmpeg Audio Conversion Notes
for f in *.flac ; do
# Regex for whitespaces in filenames.
# Specify input and output filetypes.
out="${f[@]/%flac/mp3}"
# Use -qscale or -vbr for VBR [0-9].
# 0: slowest & best possible algo
# 1: slow and not as high quality
# 2: recommended (same as -h)
# 5: default; good speed, reasonable quality