import json | |
import logging | |
import os | |
import time | |
from datetime import datetime, timedelta | |
import httplib2 | |
import requests | |
import voluptuous as vol | |
from apiclient.discovery import build |
Redux has brought the notion of reducer back into the awareness of many developers for whom they are a novel concept. In fact they are quite simple, and used all the time in such things as SUM
aggregations in databases, where they compute a single value from many.
It's great that Redux has made reducers known to a broader audience, though they are relatively ancient concepts in programming, in fact. But the particular way Redux illustrates a reducer in its documentaion is, in my opinion, with a coding style that is harder to extend and read than it should be. Let's distill reducers down to their essensce, and build up Redux reducers in a way that lowers complexity, and helps separate Redux idioms from your business logic.
A reducer is a pure function that accepts more arguments than it returns. That is to say - one whose "arity" is greater than 1. It 'reduces' the two things you pass it down to a single value. Here are two reducers, in a map
var slackTeam = "YOUR_SLACK_TEAM_NAME "; | |
var token = 'YOUR_ADMIN_TEST_TOKEN'; | |
// A test token will suffice. | |
// You can generate one at https://api.slack.com/docs/oauth-test-tokens | |
// Just make sure that the user issuing the test token is an admin. | |
var url = 'https://'+ slackTeam + '.slack.com/api/users.admin.invite'; | |
fetch(url, { | |
method: 'POST', | |
headers: {'Content-Type': 'application/x-www-form-urlencoded'}, |
HISTFILE=~/.history | |
HISTSIZE=1000 | |
SAVEHIST=1000 | |
setopt share_history autocd no_beep | |
bindkey -e | |
zstyle :compinstall filename '/home/picard/.zshrc' | |
zstyle ':completion:*' menu select=2 | |
autoload -Uz compinit && compinit |
// paste in your console | |
speechSynthesis.onvoiceschanged = function() { | |
var msg = new SpeechSynthesisUtterance(); | |
msg.voice = this.getVoices().filter(v => v.name == 'Cellos')[0]; | |
msg.text = Object.keys(window).join(' '); | |
this.speak(msg); | |
}; |
#!/bin/bash | |
# | |
# Created by Felipe Machado - 2016/02/14 | |
# | |
# A retry command for bash | |
# Retries the given command up to MAX_RETRIES, with an interval of SLEEP_TIME | |
# between each retry. Just put it on your bash_profile and be happy :) | |
# Usage: | |
# retry [-s SLEEP_TIME] [-m MAX_RETRIES] COMMAND_WITH_ARGUMENTS | |
# |
Normally, when you diff an [Ansible vault][], all you see is gibberish.
$ git diff -- group_vars/all/vault.yml
diff --git a/group_vars/all/vault.yml b/group_vars/all/vault.yml
index 245ccf4..90bf9ee 100644
--- a/group_vars/all/vault.yml
+++ b/group_vars/all/vault.yml
@@ -1,111 +1,111 @@
$ANSIBLE_VAULT;1.1;AES256
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
Get Git log in JSON format
git log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},'
The only information that aren't fetched are:
%B
: raw body (unwrapped subject and body)%GG
: raw verification message from GPG for a signed commit