Skip to content

Instantly share code, notes, and snippets.

View inodaf's full-sized avatar
👨‍🚀
Starfleet Command

Isac Fadoni inodaf

👨‍🚀
Starfleet Command
  • Senior Software Engineer · @n26
  • Berlin, Germany
  • 12:36 (UTC +02:00)
View GitHub Profile
@inodaf
inodaf / getting-started.md
Last active June 24, 2020 19:57
🏖 Pending Responses for Fetch API.

Awaits for a pending response with a single line.

const { status, data, error } = await parseResponse(fetch('/resource')))
@inodaf
inodaf / name-capitals.js
Created April 12, 2020 20:52
Getting Name Capitals in JavaScript
const splitWords = phrase => phrase.split(' ')
const firstLetter = word => word.charAt(0)
const lastLetter = word => word.charAt(word.length - 1)
const initialLetter = words => words
.map(word => word.charAt(0))
.join('')
const firstAndLastLetter = word => [
firstLetter(word),
@inodaf
inodaf / imagefilter.js
Created July 12, 2019 20:48
Grayscale and Inversion Filters for Images
const grayscale = pixel => {
const [r, g, b] = pixel.data
const average = (r + g + b) / 3
pixel.data[0] = average
pixel.data[1] = average
pixel.data[2] = average
return pixel
}
@inodaf
inodaf / intersection.js
Created June 28, 2019 12:20
Find Intersection in Array
const intersection = (a, b) =>
a.map(ai => b.filter(bi => bi === ai)).flat()
intersection(['banana', 'apple'], ['banana', 'mellon']) // ['banana']
intersection(['banana', 'apple'], ['banana', 'mellon', 'apple']) // ['banana', 'apple']
@inodaf
inodaf / h.js
Last active October 9, 2023 21:08
const createElement = name =>
document.createElement(String(name).toUpperCase())
const defineAttributes = (VNode, attributes) =>
Object.keys(attributes).forEach(attr =>
VNode.setAttribute(attr, attributes[attr]))
const defineChildren = (VNode, children) =>
Array.isArray(children) && children.forEach(e => VNode.appendChild(e))
@inodaf
inodaf / Dialog.js
Created June 24, 2019 16:14
Promise Based Dialog Actions
import { Button } from './Button'
export const Dialog = props => h('article', {
id: 'my-dialog',
content: Button({
textContent: 'Hey',
onclick: props.onSuccessClick
})
})
+ app.use('/', cors...)
- app.use(cors...)
@inodaf
inodaf / thacors.js
Last active March 25, 2019 16:32
Falando em Falhas: 2K to rule the life.
// Setting dynamic CORS for non-options Request
app.use(cors((req, cb) => {
const companyDNS = '.mycompany.xyz'
const isTrusted = req.header('Origin').indexOf(companyDNS) >= 1
// Some more business logics...
return cb(null, {
credentials: true,
origin: isTrusted
@inodaf
inodaf / composition.js
Created August 20, 2018 20:35
Function Composition
const Fetch = (fun, fetcher) => fun({
get(endpoint, headers) {
return fetch(endpoint, headers)
},
post(endpoint, body, headers) {
return fetch(endpoint, { body, headers, method: 'POST' })
}
})
/*
Fat Cursor.
This overwrites the "underline thin" style since that is one that can be styled with CSS
So set your settings to:
"editor.cursorStyle": "underline-thin",
*/
.monaco-editor .cursors-layer.cursor-underline-thin-style > .cursor {
border-bottom-width: 0;
border-left-width: 3px;
border-left-style: solid;