Skip to content

Instantly share code, notes, and snippets.

View aahung's full-sized avatar
🔨

_sam aahung

🔨
View GitHub Profile
@aahung
aahung / NSDateFormatter cheat sheet
Last active May 25, 2016 15:25 — forked from romaonthego/NSDateFormatter cheat sheet
Date Formats for NSDateFormatter
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
@aahung
aahung / mk_report.sh
Created March 18, 2016 11:26
create public_html/report under each user and assign the right permissions
# this should be ran in the /home directory
# create "public_html/report" folder under their home dir if not exists
for u in *;
do mkdir -p "$u""/public_html";
mkdir -p "$u""/public_html/report";
chown -R $u:combo "$u""/public_html";
chmod -R u+wrx,go+rx "$u""/public_html";
done;
@aahung
aahung / swap.code
Created December 14, 2015 20:58
Describe how the Swap() instruction can be used to provide mutual exclusion that satisfies the bounded-waiting requirement.
do {
waiting[i] = true;
key = true;
while (waiting[i] && key) Swap(&key, &lock);
// critical tasks
j = (i + 1) % n;
while (i != j && !waiting[j]) j = (i + 1) % n;
@aahung
aahung / RECEIPT.java
Created December 14, 2015 18:55
SECTION A - 1
class RECEIPT {
// a)
int receiptInt;
String tableStr;
// b)
private ArrayList<Item> orderedItemList;
public getItemList() { return orderedItemList; }
public setItemList(ArrayList<Item> list) { orderedItemList = list; }
@aahung
aahung / personal_goal.md
Last active December 7, 2015 03:38
Personal Goal

Personal Goal

  • Write simple HTTP server in various languages
  • Learn Lisp
  • Learn LLVM
@aahung
aahung / big_data.md
Last active December 7, 2015 04:32
Review of Cloud Computer (EE4221)

Definition

Volume, Variety, and Velocity

Unstructed

Analytic life cycle

  1. Discovery
  2. Data preparation
@aahung
aahung / onload.js
Created December 4, 2015 16:05
Change external links' target = '_blank'
$(function(argument) {
// set target=_blank for all external links
// credit: http://stackoverflow.com/questions/2910946/test-if-links-are-external-with-jquery-javascript
var nodes = document.getElementsByTagName("a"), i = nodes.length;
var regExp = new RegExp("//" + location.host + "($|/)");
while (i--) {
var href = nodes[i].href;
var isLocal = (href.substring(0,4) === "http") ? regExp.test(href) : true;
if (!isLocal)
nodes[i].target = "_blank";
@aahung
aahung / Difference Between Memory Ballooning and Memory Swapping.md
Created December 4, 2015 07:10
Difference Between Memory Ballooning and Memory Swapping

Difference Between Memory Ballooning and Memory Swapping

When memory scares

  • Memory ballooning will ask the virtual machine to select it's idle memory pages to be swapped.
  • Memory swapping will brutally picks pages at random from the virtual machine.

So memory swapping often occurs when memory ballooning cannot effective free the memory, it will impacts the performance more.

@aahung
aahung / 5723.cpp
Created October 24, 2015 10:43
ICPC Regionals 2011 :: Asia - Phuket
#include <stdio.h>
#define INFINITE 18446744073709551615
typedef unsigned long long ull;
int n;
ull flow[21];
ull cost[21];
ull minimal_cost;
@aahung
aahung / 6113.cpp
Last active October 17, 2015 10:46
ICPC Regionals 2012 :: Asia - Daejeon
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
int case_n;
scanf("%d", &case_n);
while (case_n--) {
int v_a, v_b;