Skip to content

Instantly share code, notes, and snippets.

View erizhang's full-sized avatar
🎯
Focusing

Eric Zhang erizhang

🎯
Focusing
View GitHub Profile
@erizhang
erizhang / commands-of-install-emacs24
Created October 22, 2013 07:57
Install emacs24 ppa version under ubuntu
sudo apt-get purge emacs-snapshot-common emacs-snapshot-bin-common emacs-snapshot emacs-snapshot-el emacs-snapshot-gtk emacs23 emacs23-bin-common emacs23-common emacs23-el emacs23-nox emacs23-lucid auctex emacs24 emacs24-bin-common emacs24-common
sudo add-apt-repository ppa:cassou/emacs
sudo apt-get update
sudo apt-get install emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot
sudo apt-get install emacs24 emacs24-el
emacs --version
@erizhang
erizhang / table_driven.c
Last active December 27, 2015 13:28
This code snippet illustrate how validate members value a specific structure. It's implemented in table driven way. One hand, it separate the content definition and mechanism, on the other hand, it can reduce the complexity of structure comparing once there are too much members were defined in the structure.
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
typedef struct __sample_t {
int a;
int b;
}sample_t;
typedef struct __structure_threshold_t
@erizhang
erizhang / build.csv
Last active August 29, 2015 14:02
d3js StackedBar
build waiting duration
001 3 5
002 6 6
003 13 12
005 7 2
006 5 10
@erizhang
erizhang / donut.html
Last active August 29, 2015 14:04
Generate a donut chart in d3js
<!DOCTYPE HTML>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<script>
var data = [21, 32, 35, 64, 83];
var color = d3.scale.category10();
var pie = d3.layout.pie();
@erizhang
erizhang / plotarea.html
Created July 30, 2014 08:01
Plotarea implementation in d3js
<!DOCTYPE HTML>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
path{stroke: white; strok-width; 2; fill: steelblue;}
.plot{fill: none; stroke: #aec7e8; stroke-width: 2;}
circle{fill: steelblue; stroke: white;}
</style>
</head>
<!DOCTYPE HTML>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
path {stroke: black; storke-width: 2; fill: none;}
.plot {fill: none; stroke: #aec7e8; stroke-width: 2;}
circle {fill: steelblue; stroke: white;}
</style>
</head>
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
body {margin: 0;}
circle {fill: orange; stroke: #333;}
path {fill: steelblue; stroke: #333; stroke-width: 4;}
</style>
</head>
<!DOCTYPE HTML>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
path {stroke: white; stroke-width: 2; fill:black;}
body, svg {background-color: black;}
</style>
</head>
<body>
@erizhang
erizhang / .emacs
Last active November 12, 2019 14:58
emacs configuration for c/c++
; start package.el with emacs
(require 'package)
; add MELPA to repository list
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
; initialize package.el
(package-initialize)
;start auto-complete with emacs
(require 'auto-complete)
; do default config for auto-complete
C_SRCS:=$(foreach d, $(SRC_DIRS), $(wildcard $d/*.c))
CXX_SRCS:=$(foreach d,$(SRC_DIRS), $(wildcard $d/*.cpp))
C_OBJS:=$(C_SRCS:.c=.o)
CXX_OBJS:=$(CXX_SRCS:.cpp=.o)
FLAGS:=-I$(CPPUTEST_INCLUDE) -I src -I .
LDFLAGS:=-L$(CPPUTEST_LIB) -lCppUTest -lstdc++
$(TARGET) : $(CXX_OBJS) $(C_OBJS)
echo $(LDFLAGS)
gcc -o $@ $^ $(LDFLAGS)