Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
@henrybear327
henrybear327 / Google IO 2012.md
Created April 30, 2018 06:40 — forked from jdh747/Google IO 2012.md
Go Concurrency Patterns: Google IO 2012

Concurrency Patterns in Go

Notes taken from Rob Pike's presentation 'Google I/O 2012 - Go Concurrency Patterns'.

1. Generator: function that returns a channel

The code is as follows:

c := boring("boring!")  // function returning a channel

for i := 0; i < 5; i++ {
@henrybear327
henrybear327 / chinese.md
Last active October 18, 2017 14:56 — forked from BeMg/chinese.md
Statement of purpose

進修計劃書

在大學期間的選修課程選擇,令我廣泛的接觸了多個不同的資訊研究領域。在這其中,我對於電腦視覺與圖形識別的發展特別有興趣,接下來也打算朝著這個方面進行探索,期許自己可以在進入研究所前,有更明確的研究方向。

短程- 進入研究所前

在取得入學許可之後,會盡速與相關實驗室進行聯絡,尋求意見與協助,以利未來入學做準備。並且複習電腦科學的基本課程,重新溫習一些重要的概念,不忘記基本的準則,為此後的研究進行準備。準備複習的內容為下表:

  • 線性代數
  • 離散數學
@henrybear327
henrybear327 / README.md
Created April 24, 2017 23:53 — forked from magnetikonline/README.md
Bookmarklet to pretty print Gist pages without the usual page chrome, just content. Handy for Markdown document printing.

Pretty print bookmarklet helper for Gist pages

Create a new bookmark somewhere handy in your browser with the following URL:

javascript:var el=document.createElement('style');el.media='print';el.innerHTML='#header,.pagehead.repohead,.gist-description.container,.file-box .meta,#comments,.js-comment-form,#footer{display:none;}.file-box{border:0!important;}';document.getElementsByTagName('head')[0].appendChild(el);alert('Please consider the environment before printing :)');
  • Navigate to your Gist of choice
  • Hit the bookmarklet
  • Now print
@henrybear327
henrybear327 / 1_query_timestamp.js
Created March 23, 2017 14:06 — forked from katowulf/1_query_timestamp.js
Get only new items from Firebase
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP)
// pros: fast and done server-side (less bandwidth, faster response), simple
// cons: a few bytes on each record for the timestamp
var ref = new Firebase(...);
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) {
console.log('new record', snap.key());
});
/*
使用前调用init静态建树,然后模仿query进行类Binary Search Tree式的访问即可
Obj是点的类型,如果追求效率或者在点上除了坐标还有其它信息,可以自己写一个Obj类,然后重载[]运算符
*/
namespace KDTree {
int K;
typedef vector <int> Obj;
template <int T> bool cmpT(const Obj &a, const Obj &b) { return a[T] < b[T]; }
bool (*cmp[])(const Obj &, const Obj &) = {cmpT <0>, cmpT <1>, cmpT <2>}; //填到所需要的最大维度数目为止,这里表示的是最大3维
struct Filter {
@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 / 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

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 / 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>