Skip to content

Instantly share code, notes, and snippets.

View atesztoth's full-sized avatar
🚀
Always decides to sleep enough, but never manages.

Attila Tóth atesztoth

🚀
Always decides to sleep enough, but never manages.
  • VIRGO, LHSYS HU, AERQ
  • Budapest, Hungary
  • 11:39 (UTC +02:00)
View GitHub Profile
@atesztoth
atesztoth / vscode-ts-node-debug-config.json
Created May 19, 2020 15:01
VSCode debug config for ts-node
{
"name": "debug everything",
"type": "node",
"request": "launch",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${workspaceRoot}/src/compile.ts"]
}
data Nat = Zero | Suc Nat deriving (Show)
data List a = Nil | Cons a (List a) deriving (Show)
addNat :: Nat -> Nat -> Nat
addNat Zero x = x
addNat (Suc x) y = Suc (addNat x y)
mulNat :: Nat -> Nat -> Nat
mulNat Zero _ = Zero
mulNat (Suc x) y = addNat y (mulNat x y)
@atesztoth
atesztoth / synctags.sh
Last active November 18, 2019 19:55
remove tags locally that doesnt exists on remote
git fetch --prune origin "+refs/tags/*:refs/tags/*"
@atesztoth
atesztoth / get-child-with-classname.js
Created May 26, 2019 22:27
This little scripts looks for children of an element that has a class name
function getChildWithClassName(element, className) {
if (!element || !className) return null;
const toIterable = elemList => (elemList ? [...elemList] : [])
const searcher = nodes => {
if (!nodes || nodes.length < 1) return null;
return nodes.find(node => toIterable(node.classList).includes(className))
|| nodes.map(node => searcher(toIterable(node.childNodes))).find(x => x) // 🚀
}
@atesztoth
atesztoth / failproof-promise-all.js
Created April 18, 2019 10:46
Failproof promise all
console.time('start')
async function myFunction() {
const success = Promise.resolve('Yaaay')
const promise = new Promise((_, reject) => setTimeout(() => {
console.timeEnd('start')
reject('Rejection reason')
}, 200))
const autoCatchedPromise = promise.catch(error => {
console.info('Error caught:', error)
@atesztoth
atesztoth / object-traversal.js
Last active April 18, 2019 10:51
Object traversal JavaScript
const getPropertyDeep = function(rootObject, queryString) {
if (queryString.indexOf('.') === -1) return rootObject[queryString]
const partialQueryString = queryString.split('.')
const partialObject = rootObject[partialQueryString[0]]
return getPropertyDeep(partialObject, partialQueryString.slice(1).join('.'))
}