Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Attila Tóth atesztoth

🚀
  • Working with an inspired group of people
  • Budapest, Hungary.
View GitHub Profile
@atesztoth
atesztoth / vscode-ts-node-debug-config.json
Created May 19, 2020
VSCode debug config for ts-node
View vscode-ts-node-debug-config.json
{
"name": "debug everything",
"type": "node",
"request": "launch",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${workspaceRoot}/src/compile.ts"]
}
View peano.hs
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 Nov 18, 2019
remove tags locally that doesnt exists on remote
View synctags.sh
git fetch --prune origin "+refs/tags/*:refs/tags/*"
@atesztoth
atesztoth / get-child-with-classname.js
Created May 26, 2019
This little scripts looks for children of an element that has a class name
View get-child-with-classname.js
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) // 🚀
}
View failproof-promise-all.js
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 Apr 18, 2019
Object traversal JavaScript
View object-traversal.js
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('.'))
}