This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isDeliverable = async address => { | |
if (disableEcommerce) { | |
return false | |
} | |
const api = Api.init() | |
const { deliverable } = await api.post( | |
'/location?delivery_type=all', | |
{ | |
...address, | |
tentative: undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\n\[\033[38;5;247m\]\w\[\033[34m\]\$(parse_git_branch)\n🐻 \[\033[0m\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkPageVisibility() { | |
let eventName = 'visibilitychange' | |
let hiddenProp = 'hidden' | |
// set proper event name for other browsers | |
if (typeof document.msHidden !== 'undefined') { | |
hiddenProp = 'msHidden' | |
eventName = 'msvisibilitychange' | |
} else if (typeof document.webkitHidden !== "undefined") { | |
hiddenProp = 'webkitHidden' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compose fns together | |
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))) | |
// If `fn` evaluates to true call fn2 passing args through | |
const middleware = fn => fn2 => (...args) => fn(...args) && fn2(...args) | |
// | |
// Example usage and tests | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It's composable | |
const compose = (a,b) => v => a(b(v)) | |
const isValid = valid => fn => (...p) => valid(...p) && fn(...p) | |
const hasTwoParams = isValid((...params) => params.length === 2) | |
const firstParamIsArray = isValid(a => Array.isArray(a)) | |
const hasTwoFirstArray = compose(hasTwoParams, firstParamIsArray) | |
const myValidatedFn = hasTwoFirstArray((a, b) => console.log('It worked', a, b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/csv', (req, res) => { | |
let data = "name,age,status\nderek,30,online\nsarah,28,offline\nDan,36,online" | |
let filename = 'cool.csv' | |
res.setHeader('Content-disposition', `attachment; filename=${filename}`) | |
res.set('Content-Type', 'text/csv') | |
res.send(data) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const request = require('request') | |
// APP 1 (the proxy server) | |
const app1 = express() | |
app.use('/proxy', (req, res) => { | |
let target = req.url.replace('/', 'http://') | |
req.pipe(request(target)).pipe(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function repeat(n = 1) { | |
let i = 0; | |
return fn => { | |
while(n--) { | |
i++; | |
fn(i) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CREATE = 0 | |
const READ = 1 | |
const UPDATE = 2 | |
const DELETE = 3 | |
const add = (a, b) => a |= (1 << b) | |
const remove = (a, b) => a &= ~(1 << b) | |
const has = (a, b) => ((a & (1 << b)) > 0) | |
const bin = (a) => (s).toString(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://twitone.bandcamp.com/album/hi-hat-club-vol-1-testiculo-y-uno |
NewerOlder