Skip to content

Instantly share code, notes, and snippets.

View nickangtc's full-sized avatar

Nick Ang nickangtc

View GitHub Profile
@nickangtc
nickangtc / multi-git-win.md
Created December 2, 2018 08:33 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer on Mac OS. Now with a guide for Windows 10.

Setting up github and bitbucket on the same computer (Windows)

Guide for Windows

mix3d asked for some help using this guide with windows so here we go. This was tested with Windows 10. Run all commands in Git Bash once it's installed.

Github will be the main account and bitbucket the secondary.

Git for Windows

  • Download and install Git for Windows
    • In the installer, select everything but decide if you want a desktop icon (2nd step)
@nickangtc
nickangtc / iterm2-solarized.md
Created May 11, 2018 02:02 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@nickangtc
nickangtc / nativeJavaScript.js
Created May 10, 2018 08:14 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@nickangtc
nickangtc / homemade-each-reduce.js
Last active April 26, 2018 08:35
Homemade version of the built-in forEach() and reduce() in JavaScript
/**
* each()
*
* Apply an action to every item in an array.
*/
const list = [1, 2, 3];
const each = function (array, action) {
for (let i = 0; i < array.length; i++) {
action(array[i]);
@nickangtc
nickangtc / type-error-handling-conditional-vs-try-except.py
Last active April 16, 2018 06:19
For discussing the best approach for handling type errors in Python 3
def increment_list_by(list, num):
'''Increment all items in a list by `num`
provided all items are `int` types.
Return modified list if successful, or original list otherwise.'''
incremented_list = []
# =============
# Note: below are 2 separate approaches to implement this function
# =============
@nickangtc
nickangtc / layout-engine.js
Last active February 6, 2018 15:33
Layout Engine (coding challenge)
/*
* Complete the function below.
*
* Sample input 1: ['10 0 0 I love monkeys.']
* Sample output 1 (dashes denote trailing spaces):
* ---I love ---
* ---monkeys. -
*
* Sample input 2: ['10 0 0 I love monkeys.', '20 0 0 Good times and bad times.']
* Sample output 2 (dashes denote trailing spaces):
@nickangtc
nickangtc / queue.js
Created December 25, 2017 04:33
Simple implementation of a Queue in JavaScript - with performance tests
/**
* ============================================
* CUSTOM IMPLEMENTATION OF QUEUE CLASS
* ============================================
*/
/**
* Implementation of Queue.
*/
class Queue {
@nickangtc
nickangtc / bubble-sort-javascript.js
Created December 3, 2017 14:01
Bubble sort implementation in JavaScript
/**
* Sort an array in ascending order.
* Delete null values before output.
* @param {number[]} array
* @return {number[]}
*/
function bubbleSort (array) {
var count = 0
var length = array.length
@nickangtc
nickangtc / binary-search-tree-javascript.js
Last active November 21, 2017 13:26
Binary search tree implemented in JavaScript (tree not balanced)
/**
* Binary search tree implementation in JavaScript.
*
* Note: the BST created here is a BST that is not "balanced,"
* meaning it has a lot of nodes on one side,
* which degrades the BST's O(log n) time complexity.
*
* Note 2: I'll be adding a balancing function in another snippet.
*/
@nickangtc
nickangtc / binary-search-javascript.js
Last active October 24, 2018 19:32
Binary search in JavaScript
/**
* Binary search in JavaScript.
*
* For detailed explanation about binary search
* read my original blog post:
* http://www.nickang.com/binary-search-javascript/
*/
function binarySearch(array, key) {
var lower = 0;