Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
@henrybear327
henrybear327 / POJ 3050.cpp
Created November 4, 2016 09:43
POJ 3050.cpp
#include <stdio.h>
#include <set>
#include <string>
using namespace std;
int m[5][5];
inline bool inBound(int x, int y)
{
@henrybear327
henrybear327 / latency.markdown
Created October 9, 2016 03:27 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@henrybear327
henrybear327 / a.cpp
Created October 1, 2016 11:27
2016 NCPC Preliminary Round
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
@henrybear327
henrybear327 / Iðunn.cpp
Created September 25, 2016 06:47
2016 ACM-ICPC Taiwan Online Practice Contests 2: NCTU Problemset
#include <bits/stdc++.h>
using namespace std;
int main()
{
int ncase;
scanf("%d", &ncase);
while(ncase--) {
@henrybear327
henrybear327 / bound.rb
Created August 6, 2016 14:01 — forked from kanetai/bound.rb
cpp-like lower_bound, upper_bound in Ruby
def lowerBound(a, key)
lb = -1; ub = a.length
while ub - lb > 1
mid = (lb + ub) / 2
if a[mid] >= key
ub = mid
else
lb = mid
end
end
#include <bits/stdc++.h>
using namespace std;
vector<int> g[26];
bool has[26];
int tree, acorn;
bool has_cycle, visited[26];
void dfs(int u, int par)

RTAI installation for ubuntu 14.04

Preparation

Switch user mode

sudo su

download and unzip

@henrybear327
henrybear327 / launch_sublime_from_terminal.markdown
Created January 4, 2016 11:55 — forked from artero/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@henrybear327
henrybear327 / AR08.c
Created December 21, 2015 12:38
AR08.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
int tmp, globalmax = 0, suffixmax = 0;
while (scanf("%d", &tmp) != EOF) {
if (suffixmax + tmp > globalmax) {
suffixmax += tmp;
globalmax = suffixmax;
@henrybear327
henrybear327 / InfixToPostfix.cpp
Created December 13, 2015 17:44 — forked from mycodeschool/InfixToPostfix.cpp
Infix to Postfix conversion in C++ using stack. We are assuming that both operators and operands in input will be single character.
/*
Infix to postfix conversion in C++
Input Postfix expression must be in a desired format.
Operands and operator, both must be single character.
Only '+' , '-' , '*', '/' and '$' (for exponentiation) operators are expected.
*/
#include<iostream>
#include<stack>
#include<string>