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
type Maybe<A> = { | |
type: string; | |
map: <B>(f: (x: A) => B) => Maybe<B | A>; | |
flatMap: <B>(f: (x: A) => Maybe<B>) => Maybe<B | A>; | |
valueOrDefault: <C>(x: C) => A | C; | |
}; | |
function none<A>(x: A): Maybe<A> { | |
return { | |
type: "none", |
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
Oh, you know, don't forget to add a security group which do not block outgoing mail traffic :) | |
For future reference (and my own memory): if you think that Amazon or Mailgun are not working on port 25, 465 or 587 and are running on some kind of cloud server, remember to check if ports are blocked on the server! |
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
// A common redux pattern when dealing with async functions is to use thunk. | |
// This usually means your action returns a new function instead of an action object, | |
// and the thunk middleware will make it all work. Example: | |
const asyncAction = () => dispatch => setTimeout(() => dispatch(someOtherAction()), 10000); | |
// Now: maybe that async stuff going on is calling some API which you don't want to overload | |
// with request, and that's what debounce is for. | |
// This is an example of a debounced function which will only be calleable once every second. | |
import { debounce } from 'lodash'; | |
const debouncedFn = debounce(() => callApi(), 1000, { leading: true, trailing: false }); |
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
// Let's say you have a collection like this one: | |
// [{ name: 'Kristoffer', IQ: 120 }, { name: 'Steve', IQ: 88 }, { name: 'Jim', IQ: 142 }] | |
// And you want to get the person with the highest IQ. It's very simple. You can just do this: | |
const findElementByHighestKey = (collection, key) => | |
collection.reduce((memo, el) => el[key] > memo[key] ? el : memo, { [key]: 0 }); | |
// A version with somem more safety (empty array? No problem!) | |
const findElementByHighestKey = (collection, key) => | |
// Make sure we have a collection with items and a key… | |
!collection || !key || collection.length < 1 |
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
# First store all of your apps in a file | |
heroku apps > heroku-apps.txt | |
# Manually remove everything which is not an app name from the file, for example the first line ("=== [email protected] Apps") | |
# (Now you should have a file with only one appname per line) | |
# Pipe the text file into xargs -n1, which in turn passes every line into the "heroku-config -a $1" command, and then | |
# pass the result of that into the heroku-apps-with-config.txt | |
cat heroku-apps.txt | xargs -n1 heroku config -a $1 > heroku-apps-with-config.txt | |
# Get all of the env vars! |
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
// We have this array of people, we want to get a new array sorted using the names in the order array below. | |
const collection = [{ name: 'carol' }, { name: 'stewie' }, { name: 'steve' }, { name: 'carl' }]; | |
const order = ['carl', 'steve', 'carol', 'horseboy', 'stewie']; | |
// Just map over the order, and find the corresponding item in the collection. | |
const sortedCollection = order.map(orderName => collection.find(({ name }) => name === orderName )); | |
// To also remove undefindes, if the order element isn't found in the collection, | |
// do this (filter out any falsy elements) | |
sortedCollection.filter(x => x); |
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
# So, what we want to accomplish is this: add a uploads.ini file to the conf.d path (right now it's here: /usr/local/etc/php/conf.d) | |
# Go to the folder | |
cd /usr/local/etc/php/conf.d | |
# Create the file | |
touch upload.ini | |
# Add the required config stuff into the file | |
echo "file_uploads = On |