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
  • 13:31 (UTC +02:00)
  • X @o_inodaf
View GitHub Profile
@inodaf
inodaf / is-uri.js
Last active September 25, 2016 01:36
Check if a string is an URI.
;(function(obj) {
'use strict';
/*
* @name: isURL
* @description: Checks if a String is an URI
*
* @param String : The string to be checked
*/
@inodaf
inodaf / create-observable.js
Last active June 24, 2020 20:05
👀 Object Observable using ES6 Proxies.
function createObservable(observable, { onGet, onSet }) {
const interceptor = {
get(target, key, receiver) {
onGet(key)
return target[key]
},
set(target, prop, value) {
onSet(prop, value)
return true
}
@inodaf
inodaf / def.js
Last active March 6, 2018 22:15
Simple way to define your functional modules. Just for study purposes.
(function simpleFp() {
const Utils = {
getFunctionArity(fn) {
return fn.length
},
getFunctionModule(fnName, fnArity) {
const fnPath = fnName.split('.')
const isOuter = fnPath.length > 1
if (isOuter) {
@inodaf
inodaf / deftest.js
Last active March 20, 2018 13:28
Testing Defy.js
defmodule('Contestation', ({ def, run, callbacks }) => {
const { Http } = Defy.Plugins
const storageURL = `${process.env.SANDFILE_URL}/document`
const graphQLURL = process.env.GRAPHQL_URL
def('post_document', doc => {
const requestPayload = {
query: mutationBuilder(doc, 'addDocument', 'errors { code path description } }')
}
/*
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;
@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' })
}
})
@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
+ app.use('/', cors...)
- app.use(cors...)
@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
})
})
@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))