Skip to content

Instantly share code, notes, and snippets.

View jaychsu's full-sized avatar

Jyun Hong Su jaychsu

View GitHub Profile
@jaychsu
jaychsu / setup-janus
Last active January 19, 2019 15:55
Setup [janus-gateway](https://github.com/meetecho/janus-gateway) on ubuntu
#!/bin/bash
# REF: https://github.com/meetecho/janus-gateway/blob/master/README.md
# REF: https://groups.google.com/forum/#!msg/meetecho-janus/RYP4FBaeUi0/bIGSPZlpEQAJ
# Tested enviroment: ubuntu {14.04,16.04} LTS
# Tested Janus version: 0.2.0
# 0. Get infos and params without empty
# ======
set -e
@jaychsu
jaychsu / rspec_rails_cheetsheet.rb
Created February 13, 2017 06:59 — forked from mlr/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet with expect syntax (including capybara matchers)
# Model
expect(@user).to have(1).error_on(:username) # checks whether there is an error in username
expect(@user.errors[:username]).to include("can't be blank") # check for the error message
# Rendering
expect(response).to render_template(:index)
# Redirecting
@jaychsu
jaychsu / country-code-to-currency-code-mapping.csv
Created February 28, 2017 05:33 — forked from HarishChaudhari/country-code-to-currency-code-mapping.csv
Country, Country Code, Currency code mapping in CSV format Taken from https://gist.github.com/304261 Contains 249 countries.
Country CountryCode Currency Code
New Zealand NZ New Zealand Dollars NZD
Cook Islands CK New Zealand Dollars NZD
Niue NU New Zealand Dollars NZD
Pitcairn PN New Zealand Dollars NZD
Tokelau TK New Zealand Dollars NZD
Australian AU Australian Dollars AUD
Christmas Island CX Australian Dollars AUD
Cocos (Keeling) Islands CC Australian Dollars AUD
Heard and Mc Donald Islands HM Australian Dollars AUD
@jaychsu
jaychsu / uri.js
Created May 8, 2017 05:04 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@jaychsu
jaychsu / command-with-short-and-long-param.sh
Last active October 25, 2017 07:59
Collections to show how create shell command
#!/bin/bash
start() {
echo "Starting vnc server with $resolution on Display $display"
#your execute command here mine is below
#vncserver :$display -geometry $resolution
}
stop() {
echo "Killing vncserver on display $display"
#vncserver -kill :$display
@jaychsu
jaychsu / color.less
Last active July 17, 2017 17:52
generate colorful class in `LESS` by given color set
@color-class-prefix: chosen-color-;
@color-list:
#ffc4c6,
#fdeddf,
#fff6c3,
#cdffbe,
#bdf7ef,
#cce7fb,
#dacefc,
#fbc9f1,
@jaychsu
jaychsu / latency.txt
Created October 17, 2017 22:19 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jaychsu
jaychsu / System Design.md
Created November 9, 2017 04:17 — forked from vasanthk/System Design.md
System Design Cheatsheet

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?
@jaychsu
jaychsu / weak-map.js
Created April 16, 2019 01:51 — forked from Gozala/weak-map.js
Harmony WeakMap shim for ES5
/* vim:set ts=2 sw=2 sts=2 expandtab */
/*jshint asi: true undef: true es5: true node: true devel: true
forin: false latedef: false */
/*global define: true */
if (typeof(WeakMap) === 'undefined') WeakMap = (function(global) {
"use strict";
function defineNamespace(object, namespace) {
@jaychsu
jaychsu / native jQuery methods.js
Created September 9, 2019 17:34 — forked from jochemstoel/native jQuery methods.js
Vanilla implementations of commonly used jQuery methods.
/**
* Convenient shortcut
*/
Object.defineProperty(window, 'define', {
value: (property, ...meta) => meta.length == 2 ? Object.defineProperty(meta[0], property, meta[1]) : Object.defineProperty(window, property, meta[0]),
writable: false,
enumerable: true
})