This file contains hidden or 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
from flask import Flask, jsonify | |
app = Flask(__name__) | |
@app.route('/api/intro') | |
def intro(): | |
return jsonify(message='Hello, World!') | |
if __name__ == '__main__': | |
app.run(debug=True) |
This file contains hidden or 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 pipe = (...functions) => args => functions.reduce((arg, fn) => fn(arg), args); | |
// const league = [ | |
// { heroe: "superman", power: 'fly' }, | |
// { heroe: "batman", power: 'millionare'}, | |
// { heroe: "flash", power: 'speed' }, | |
// ] | |
// const filter = f => arr => arr.filter(f); | |
// const map = m => arr => arr.map(m); |
This file contains hidden or 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 compose = (...functions) => args => functions.reduceRight((arg, fn) => fn(arg), args); | |
// Example: | |
// const league = [ | |
// { heroe: "superman", power: 'fly' }, | |
// { heroe: "batman", power: 'millionare'}, | |
// { heroe: "flash", power: 'speed' }, | |
//] | |
//const filter = f => arr => arr.filter(f); | |
//const map = m => arr => arr.map(m); |
This file contains hidden or 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
/** | |
* Debounce a method | |
*/ | |
function debounce(ms) { | |
return function(target: any, key: any, descriptor: any) { | |
const oldFunc = descriptor.value | |
const newFunc = _debounce(oldFunc,ms) | |
descriptor.value = function() { | |
return newFunc.apply(this,arguments) |
This file contains hidden or 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
// declaring fetch + async-await + TypeScript | |
export async function get<T>( | |
path: string, | |
args: RequestInit = { method: "get" } | |
): Promise<HttpResponse<T>> { | |
return await http<T>(new Request(path, args)); | |
}; | |
export async function post<T>( | |
path: string, |
This file contains hidden or 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 debounce = (fn, time) => { | |
let timerId; | |
return function(...args) { | |
const functionCall = () => fn.apply(this, args); | |
clearTimeout(timerId); | |
timerId = setTimeout(functionCall, time); | |
}; | |
}; |
This file contains hidden or 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 startCountingForHideAndSeek() { | |
// State for managing cleanup and cancelling | |
let finished = false; | |
let cancel = () => finished = true; | |
const promise = new Promise((resolve, reject) => { | |
// | |
// Custom Promise Logic | |
// | |
// NOTE: This countdown not finish in exactly 10 seconds, don't build timers this way! |
This file contains hidden or 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
'use strict'; | |
function swap(arr, ind1, ind2) { | |
let temp = arr[ind1]; | |
arr[ind1] = arr[ind2]; | |
arr[ind2] = temp; | |
} | |
function quickSortInPlace(arr, left, right) { | |
left = left || 0; |
This file contains hidden or 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
## DFS & BFS: | |
DFS = storing the vertices "stacks", stacks are LIFO (push, pop). | |
BFS = storing the vertices "queue", queues are FIFO (shift, unshift or enqueue and dequeue). | |
## Why to use BFS and DFS? | |
#### DFS = memory requirements than BFS. It will take a lot of memory to traverse deeper trees while it works well with wider trees. | |
commonly used when you need to search the entire tree. | |
#### BFS = is better for deeper trees since it will take a lot more memory to operate on wider trees. | |
## When to use BFS and DFS? |
This file contains hidden or 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
npx create-react-app my-app | |
cd my-app | |
yarn add node-sass -S | |
// Change .css files to .scss | |
// Change any imports to use .scss | |
yarn start |
NewerOlder