Skip to content

Instantly share code, notes, and snippets.

View ali-k-h's full-sized avatar

Ali Kosar Hosseinkhani ali-k-h

  • Los Angeles, CA
View GitHub Profile
@ali-k-h
ali-k-h / curl.md
Created July 26, 2023 19:38 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@ali-k-h
ali-k-h / binary_search_tree_es6.js
Created October 2, 2017 17:32
Binary search Tree Javascript ES6 ECHMAScript 2015
class BST{
constructor(){
this.root = undefined;
}
_nodeProto (data = undefined){
return {
data:data,
left:undefined,
right:undefined
@ali-k-h
ali-k-h / Matrix_Print_spiral.js
Last active September 30, 2017 00:24
Print a mxn matrix in spiral form
function printMatrixSpiral(m) {
if (!Array.isArray(m) || !m.length || !m[0].length || !m.length > 0 || !m[0].length > 0) {
throw new Error('m is not a matrix');
}
let row_l = m.length - 1;
let col_l = m[0].length - 1;
let col = 0;
let row = 0;
let i = 0;
while (row <= row_l && col <= col_l) {
@ali-k-h
ali-k-h / string_permutations_es6.js
Last active April 11, 2018 15:59
All permutations of a string and removing duplicates - Javascript
//get all permutations of a string removing duplicates
function permutation(str, prefix = "", results = new Set()) {
if (str === undefined || str.length === undefined) {
throw new Error('Wrong input');
}
if (str.length === 1) {
results.add(prefix + str);
} else {
for (let i = 0; i < str.length; i++) {
@ali-k-h
ali-k-h / trie-implementation-es6.js
Created September 29, 2017 02:03
Trie Implementation Javascript ES6
class Trie{
_TrieNodeProto(){
return {
children: new Map(),
endOfWord: false
}
}
constructor(){
this.root = this._TrieNodeProto();
@ali-k-h
ali-k-h / shortest_path_in_maze_javascrit.js
Last active September 26, 2017 02:09
Find shortest path in a matrix (maze) using BFS algorithm
//Given a MxN matrix where each element can either be 0 or 1.
//We need to find the shortest path between a given source cell to a destination cell.
//The path can only be created out of a cell if its value is 1.
//Expected time complexity is O(M + N).
function findPath(maze, src, dest) {
const checkNode = (node) => {
if (!node || !Number.isInteger(node.row) ||
node.row < 0 || !Number.isInteger(node.col) ||
node.col < 0) {
@ali-k-h
ali-k-h / graph_implementation_es6.js
Created August 1, 2017 21:10
graph_implementation ES6 Javascript Ecmascript 2015
class Graph{
constructor(){
this.nodes = new Set()
this.edges = new Map()
}
addNode(node){
this.nodes.add(node)
}
hasNode(node){
@ali-k-h
ali-k-h / DoublyLinkedList_es6.js
Created June 19, 2017 21:16
Doubly Linked List basic implementation ES6 ECMAPScript 6
class DoublyLinkedList{
constructor(){
this.head = null
this.tail = null
this.count = 0
}
size(){
return this.count
}
@ali-k-h
ali-k-h / fibonacci_recursive_es6.js
Created June 19, 2017 21:14
Fibonacci implementation recursive es6 ECMAPScript 6
function fibonacci(n, arr){
if(n===0 || n===1) return n
if(!arr) arr = []
if(!arr[n]) arr[n] = fibonacci(n-1, arr) + fibonacci(n-2, arr)
return arr[n]
}
fibonacci(6) //8
@ali-k-h
ali-k-h / hashtable_es6.js
Created June 19, 2017 18:04
Hash Table Implementation ES6 ECMAPScript 6
class LinkedList{
constructor(){
this.head = null
this.tail = null
this.count = 0
}
size(){
return this.count
}