Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Leong leodotng

View GitHub Profile
@leodotng
leodotng / substring.js
Created Jun 3, 2018 — forked from primaryobjects/substring.js
Longest Substring Without Repeating Characters in javascript.
View substring.js
/**
* @param {string} s
* @return {number}
*/
var lengthOfLongestSubstring = function(s) {
var max = 0;
var str = '';
var i = 0;
var cache = [];
@leodotng
leodotng / Install_tmux
Created Feb 17, 2018 — forked from simme/Install_tmux
Install and configure tmux on Mac OS X
View Install_tmux
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
View gist:bfdde95eabfbe3769a521c8622712cc5
git reset --hard <old-commit-id>
git push -f
View Heroku with DB
In project:
1. Double check that package.json has a start script
In command line, in PROJECT folder - add Heroku:
2. which heroku
3. heroku create herokuSiteName
4. git remote -v (shows you the heroku remote)
In command line, in PROJECT folder - add DB to Heroku:
5. heroku addons:create heroku-postgresql
@leodotng
leodotng / LICENSE
Created Sep 21, 2017 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
View LICENSE
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@leodotng
leodotng / let Promise.js
Created Aug 31, 2017 — forked from anonymous/let Promise.js
let Promise created by leodotng - https://repl.it/K9Di/2
View let Promise.js
// Here is the video https://www.youtube.com/watch?v=490Hhpqaho4
let promise = new Promise((resolve, reject) => {
//always put resolve and reject in there
let value = true;
setTimeout(() => {
if (value) {
@leodotng
leodotng / 0_reuse_code.js
Created Aug 30, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View DOM functions&Solutions.js
// Define a function named getTextById
// The function should accept 1 parameter: id
// The function should select the element with the given id
// The function should return the element's textContent
function getTextById (id) {
let el = document.getElementById(id);
return el.innerText;
}
// Define a function named setTextById
@leodotng
leodotng / waitUntil.js
Created Aug 29, 2017 — forked from anonymous/waitUntil.js
waitUntil created by leodotng - https://repl.it/K6U9/1
View waitUntil.js
function waitUntil(num, str) {
//inside here we'll do a standard set time document
var promise = new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(str);
}, num);
});