Skip to content

Instantly share code, notes, and snippets.

@kaiguogit
kaiguogit / index.js
Created February 12, 2021 01:11
filter-combinelatest
const { rxObserver } = require('api/v0.3');
const { timer, combineLatest } = require('rxjs');
const { take, filter } = require('rxjs/operators');
const a$ = timer(0, 10).pipe(
take(5)
);
const b$ = timer(0, 4).pipe(
@kaiguogit
kaiguogit / tmux.md
Created May 18, 2019 01:42 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@kaiguogit
kaiguogit / web-servers.md
Created January 15, 2018 23:46 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@kaiguogit
kaiguogit / normalize.js
Created September 1, 2016 23:45
Javascript hash normalize
var response={
authors:[
{
id: 1,
name: "Monica",
posts: [
{
id: 1,
title: "how to write fast js",
@kaiguogit
kaiguogit / answer.md
Last active August 25, 2016 06:42
Javascript property enumeration

Q: Why don't have to write conditional statement to determine whether input is object or array? A: because Object.keys behave similarly when input is input or object, It returns an array of index when input is an array. See below example from MDN doc.

var arr = ['a', 'b', 'c']; console.log(Object.keys(arr)); // console: ['0', '1', '2']

@kaiguogit
kaiguogit / Javascript scope question
Last active August 24, 2016 06:46
Javascript scope question
1.
Q: A function doesn't have to return in order to be called a closure. Simply accessing variables outside of the immediate lexical scope creates a closure.
A: Nested functions, inner function access the outer function's variable. Then it's a closure, whether or not it return the variable to make it accessible outside.
2.
Q:function getMaxOfArray(numArray) {
return Math.max.apply(null, numArray);
}
A: This apply method takes an array as argument instead of argument list, so that we can use an array like object as argument.
getMaxOfArray([1,2,3]) instead of Math.max(1,2,3)
3.
@kaiguogit
kaiguogit / CSS Specificity.md
Last active August 22, 2016 23:31
CSS Specificity questions

Q: How do you think the word "cascading" in "Cascading Style Sheets" relates to specificity?

A: Cascading means while multiple rules applies to one element, the more specific rule override general rule. The latest applied rule override rules applied earlier.

Q: text in h1 is blank A:

  1. There could be another style sheet applied later, (or closer) to the element that override the style
@kaiguogit
kaiguogit / test.js
Last active August 22, 2016 18:48
w6-d1-arrayoflight
function arrayOfLight(number){
var a = [];
for(i=0; i<=number; i++){
a.push(i);
}
return a;
}
@kaiguogit
kaiguogit / ex.sql
Last active August 1, 2016 20:29
BookStore SQL Exercises
--Exercise 1
--Fetch ISBN of all book editions published by the publisher "Random House". You should have 3 results.
SELECT e.isbn
FROM editions AS e
JOIN publishers AS p ON (e.publisher_id = p.id)
WHERE p.name = 'Random House';
--Exercise 2
--Instead of just their ISBN number, fetch their Book Title as well. You should still have the same 3 results but with more information. But instead of just one column, we should have 2 columns in the result set.
SELECT e.isbn, b.title
@kaiguogit
kaiguogit / test_self_keyword.rb
Created July 26, 2016 17:32
test self keyword
#