Skip to content

Instantly share code, notes, and snippets.


Eric Z. Ma zma

View GitHub Profile
zma /
Last active Jun 23, 2020 — forked from cinakyn/Vim.scpt
Open files with iTerm vim
-- This creates a shim Application that will enable you to open files from the Finder in vim using iTerm
-- To use this script:
-- 1. Open Automator and create a new Application
-- 2. Add the "Run Applescript" action
-- 3. Paste this script into the Run Applescript section
-- 4. Save the application as in your Applications folder
-- 5. In the Finder, right click on a file and select "Open With". In that window you can set TerminalVim as a default
-- Improved with chaning PWD
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname
View rss2html-example.php
// get a copy of rss2html.php from and put it at the same directory as this php script
// output RSS feed to HTML
output_rss_feed('', 20, true, true, 200);
zma / System
Created Dec 25, 2017 — forked from vasanthk/System
System Design Cheatsheet
View System

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
zma / GetAvailableSpace
Last active Oct 5, 2017
View GetAvailableSpace
// Get Available Filesystem Space on Linux
// A tutorial on this can be found at
// header for statvfs
#include <sys/statvfs.h>
// C++ I/O header
#include <iostream>
zma /
Created Mar 30, 2015
class A { };
class B { };
class C: public A { };
class D: private C, public A, public B { };
int main ()
D *d = new D;
A *a1 = dynamic_cast<A *>(d);
A *a2 = static_cast<A *>(d);
class A { };
class B { };
class C: public A { };
class D: private A, public B { };
int main ()
D *d = new D;
A *a1 = dynamic_cast<A *>(d);
A *a2 = static_cast<A *>(d);
zma / rss2html.php
Last active Jul 21, 2021
View rss2html.php
// Check for description
// RSS to HTML
$tiem_cnt: max number of feed items to be displayed
$max_words: max number of words (not real words, HTML words)
if <= 0: no limitation, if > 0 display at most $max_words words
View Benchcoat.scala
2011-11-17 v.4: improvement in plot-code
x-axis and y-axis needs description (how many units measured, time in second)
2011-11-17 v.3: minor improvement in plot-code
2011-10-22 v.2: improvement in plot-code and renaming prettyPrint
extend Benchcoat by
providing a List of (
zma / hanoi puzzle.cpp
Last active Jan 18, 2020
hanoi puzzle
View hanoi puzzle.cpp
// Zhiqiang Ma (
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <sys/time.h>