Skip to content

Instantly share code, notes, and snippets.

View zma's full-sized avatar

Eric Ma zma

View GitHub Profile
@zma
zma / VimInITerm.app
Last active June 23, 2020 06:52 — 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 TerminalVim.app 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
@zma
zma / tmux-cheatsheet.markdown
Created April 22, 2020 02:25 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
<?php
// get a copy of rss2html.php from https://gist.github.com/zma/270b179926971b431e8c and put it at the same directory as this php script
include_once("rss2html.php");
// output RSS feed to HTML
output_rss_feed('http://feeds.systutorials.com/systutorials/', 20, true, true, 200);
?>
@zma
zma / System Design.md
Created December 25, 2017 08:25 — forked from vasanthk/System Design.md
System Design Cheatsheet

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
zma / GetAvailableSpace
Last active October 5, 2017 11:14
GetAvailableSpace
// Get Available Filesystem Space on Linux
// A tutorial on this can be found at
// http://www.systutorials.com/136585/how-to-get-available-filesystem-space-on-linux-a-c-function-and-a-cpp-example/
// header for statvfs
#include <sys/statvfs.h>
// C++ I/O header
#include <iostream>
@zma
zma / ambiguous-casting.cc
Created March 30, 2015 07:16
ambiguous-casting.cc
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);
@zma
zma / casting.cc
Created March 30, 2015 07:15
casting.cc
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
zma / rss2html.php
Last active September 12, 2023 16:36
rss2html.php
<?php
// Check http://www.systutorials.com/136102/a-php-function-for-fetching-rss-feed-and-outputing-feed-items-as-html/ 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
*/
/**
Benchcoat.scala
done:
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
zma / hanoi puzzle.cpp
Last active January 18, 2020 06:52
hanoi puzzle
// Zhiqiang Ma (http://www.ericzma.com)
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <sys/time.h>