This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** The abs Function | |
abs(3) ==> 3 | |
abs(0) ==> 0 | |
abs(-3) ==> 3 | |
** The int Function | |
int(2.7) ==> 2 | |
int(-2.7) ==> -2 | |
** The round() Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor() { | |
super() | |
this.state = {} | |
} | |
static getDerivedStateFromProps(props, state) { | |
// return the new, updated state based upon the props | |
// https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops | |
// https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Binary Search */ | |
/* Typical comparison function */ | |
let defaultCompare = (a, b) => a > b ? 1 : (a < b ? -1 : 0); | |
// Binary Search With Loop | |
let binarySearch = (array, element, compare = defaultCompare) => { | |
let left = 0; | |
let right = array.length - 1; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function range(start, end){ | |
if(end != undefined){ | |
if(start <= end){ | |
return getRange(start, end); | |
}else{ | |
return 0; | |
} | |
}else{ | |
return function innerFunction(innerVariable){ | |
if(start <= innerVariable){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// === Binary to Decimal Conversion Example === | |
var binary = "10"; | |
var digit = parseInt(binary, 2); | |
console.log(' digit --> ',digit); | |
// === Decimal to Binary Conversion Example === | |
var str = "2"; | |
var bin = (+str).toString(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### extract videos as mp3 files | |
youtube-dl -x --audio-format mp3 <video link> | |
### get highest resolution audio & video | |
To download a video, you type the URL after the command like so: | |
youtube-dl <video link> | |
To select the video quality, first use the -F option to list the available formats, here’s an example, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Here is a simple code to use 280 colors on web & app design. Here I focus on "RGBA" format so developer can also control opacity. | |
For example, you can invoke functions as `FlatUI().black` where opacity is by default 1 when argument is blank. | |
You don't need to put floating number; just place a number range [0, 9] to control opacity. | |
*/ | |
const getIntNumber = (getNumber) => { | |
switch(getNumber){ | |
case 0: | |
return 0.0; break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 1. makeFeature | |
###### function makeFeature(geometry, properties) | |
Output --> | |
{ | |
"type": "Feature", | |
"properties": {}, | |
"geometry": { | |
"properties": { | |
"screenPointY": 839, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array = ['a', 'b', 'c', 'd', 'e']; | |
const [first, ,third, ,last] = array; | |
// is similar to this below.. | |
const array = ['a', 'b', 'c', 'd', 'e']; | |
const iterator = array[Symbol.iterator](); | |
const first = iterator.next().value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires Express, as before. | |
let express = require("express"); | |
// Requires Morgan. | |
let morgan = require("morgan"); | |
let app = express(); | |
// Uses the Morgan middleware instead of the one you used to have. | |
let morganMiddleware = morgan("short"); |
NewerOlder