Skip to content

Instantly share code, notes, and snippets.

View moondef's full-sized avatar
:octocat:

Stepan Samko moondef

:octocat:
View GitHub Profile
from concurrent.futures import Future
from datetime import datetime
import queue
import threading
from time import sleep
import weakref
all_threads_queues = weakref.WeakKeyDictionary()
shutdown_happened = False
@moondef
moondef / floyd-warshall.js
Last active December 7, 2019 15:19
Floyd Warshall algorithm implementation
// Floyd Warshall algorithm implementation
/* Floyd Warshall algorithm is an algorithm for finding shortest paths in a weighted graph */
const min = (a, b) => a < b ? a : b
const warshall = graph => {
const len = graph.length
const myGraph = []
console.log('\x1b[36m%s\x1b[0m', 'I am cyan'); // cyan
Colors reference:
Reset = "\x1b[0m"
Bright = "\x1b[1m"
Dim = "\x1b[2m"
Underscore = "\x1b[4m"
Blink = "\x1b[5m"
Reverse = "\x1b[7m"
Hidden = "\x1b[8m"
now scale your-deployment-url 1
@moondef
moondef / weirdReverse.js
Last active July 30, 2018 16:09
reverse in 28 symbols
weirdReverse=a=>a.sort(_=>1)
{
"presets": ["flow"],
"plugins": [
["react-flow-props-to-prop-types"]
]
}
@moondef
moondef / qsort.js
Created July 18, 2018 03:05
quick sort
const arr = [1, 4, 2, 5, 200, 6, 9]
const qsort = (arr) => {
if (arr.length < 2) {
return arr
} else {
const pivot = arr[Math.floor(Math.random() * arr.length)]
const less = arr.filter(value => value < pivot)
const greater = arr.filter(value => value > pivot)
const addToCart = (cart, pokemon) => {
if (inCart(cart, pokemon)) {
cart.find(item => item.name === pokemon.name).count += 1;
} else {
pokemon['count'] = 1
cart.push(pokemon)
}
return cart
}
{
"data": [
{
"id": 0,
"name": "Bulbasaur",
"price": 30,
"image": "https://img.pokemondb.net/artwork/bulbasaur.jpg",
"type": ["grass", "poison"],
"species": "Seed Pokemon",
"abilities": [
{
"title": "test json",
"data": [
{ "name": "firstName1", "price": 300 },
{ "name": "firstName2", "price": 400 },
{ "name": "firstName3", "price": 500 }
]
}