Skip to content

Instantly share code, notes, and snippets.

@kennyxcao
kennyxcao / ultimate-ut-cheat-sheet.md
Created August 12, 2019 20:54 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@kennyxcao
kennyxcao / subl-scopes
Created June 18, 2019 06:21 — forked from alehandrof/subl-scopes
scopes for sublime text schemes
comment
comment punctuation
comment.block.documentation
comment.block.preprocessor
comment.documentation
constant
constant.character
constant.character punctuation
constant.character.entity
constant.character.escape
@kennyxcao
kennyxcao / tmux-cheatsheet.markdown
Created November 18, 2018 07:51 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@kennyxcao
kennyxcao / tmux.md
Created November 6, 2018 07:53 — 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

@kennyxcao
kennyxcao / interviewitems.MD
Created December 12, 2017 07:17 — forked from amaxwell01/interviewitems.MD
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go
/**
* @param {number[][]} envelopes
* @return {number}
*/
var maxEnvelopes = function(envelopes) {
// Edge Cases
if ( envelopes === null || envelopes.length === 0) {
return 0;
}
if ( envelopes.length === 1) {
@kennyxcao
kennyxcao / gist:11b99aeece1193f07940bc220d741125
Created November 9, 2017 04:44 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install [email protected]
brew unlink [email protected]
brew link postgresql
// Below are the use cases and functional specification for The Cashinator 3000.
// As a cashier, I can initialize the cash register with a price list in a simple comma-delimited format. The price list contains product names, SKU's (stock-keeping units, i.e., the product id), the price per unit, and whether the product is taxable. (Staple groceries are typically not taxable.)
// As a cashier, I can initialize the register with a starting amount of money.
// As a cashier, I can initialize the register with a sales tax percentage.
// As a cashier, when I am not actively handling a customer transaction, I can choose to view the current balance of cash that the register contains.
// As a cashier, I can start a new transaction. Transactions have id's and are time-stamped upon creation.
// As a cashier, I can scan one item, whereupon that item is added to the transaction.
// As a customer, I can see the last item scanned and a running subtotal of the current transaction cost.
// As a cashier, I can input the money
/**
* @param {number} capacity
*/
var LFUCache = function(capacity) {
this.capacity = capactiy;
this.storage = {};
this.freq = {};
this.lastVisited = [];
};
/**
* @param {string} s
* @return {string}
*/
var frequencySort = function(s) {
let freqObj = {};
let bucket = {};
let output = [];
for (var i = 0; i < s.length; i++) {