Skip to content

Instantly share code, notes, and snippets.

View khalid32's full-sized avatar
🤩
enthusiastic

Khalid Syfullah Zaman khalid32

🤩
enthusiastic
View GitHub Profile
** 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
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
}
@khalid32
khalid32 / Algorithm in Javascript
Last active March 26, 2020 10:18
Famous algorithms in javascript...
/* 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;
@khalid32
khalid32 / Practicing Closure
Last active February 15, 2020 07:56
From "You Don't Know JS Yet" Appendix B
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){
// === 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);
### 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,
@khalid32
khalid32 / Flat-UI-Palette
Last active August 1, 2019 05:51
"Flat-UI-Palette" is a total set of 14 color palettes and 280 colors for your designs, projects, presentations and other needs. Link: https://flatuicolors.com/
/*
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;
## 1. makeFeature
###### function makeFeature(geometry, properties)
Output -->
{
"type": "Feature",
"properties": {},
"geometry": {
"properties": {
"screenPointY": 839,
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
@khalid32
khalid32 / Static file app using morgan
Last active September 23, 2018 17:29
nodeJS example using Express...
// 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");