Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Z. Ma zma

View GitHub Profile
@zma
zma / VimInITerm.app
Last active Jun 23, 2020 — forked from cinakyn/Vim.scpt
Open files with iTerm vim
View VimInITerm.app
-- 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
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
View rss2html-example.php
<?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 Dec 25, 2017 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

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 Oct 5, 2017
GetAvailableSpace
View 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 Mar 30, 2015
ambiguous-casting.cc
View 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);
View 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 Jul 21, 2021
rss2html.php
View 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
*/
View Benchcoat.scala
/**
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 Jan 18, 2020
hanoi puzzle
View hanoi puzzle.cpp
// Zhiqiang Ma (http://www.ericzma.com)
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <sys/time.h>