(C-x means ctrl+x, M-x means alt+x)
The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf
:
http://www.thecloudavenue.com/2011/11/passing-parameters-to-mappers-and.html | |
There might be a requirement to pass additional parameters to the mapper and reducers, besides the the inputs which they process. Lets say we are interested in Matrix multiplication and there are multiple ways/algorithms of doing it. We could send an input parameter to the mapper and reducers, based on which the appropriate way/algorithm is picked. There are multiple ways of doing this | |
Setting the parameter: | |
1. Use the -D command line option to set the parameter while running the job. | |
2. Before launching the job using the old MR API |
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
Redis supports mass insert via redis-cli --pipe
, but commands need to be written in redis protocol. For more details, check out the Redis mass insertion page. This script takes care of converting ordinary redis commands to redis protocol.
#!/usr/bin/env bash
while read CMD; do
# each command begins with *{number arguments in command}\r\n
XS=($CMD); printf "*${#XS[@]}\r\n"
# for each argument, we append ${length}\r\n{argument}\r\n
for X in $CMD; do printf "\$${#X}\r\n$X\r\n"; done
"""parse a csv address-book export from thunderbird and create mutt-aliases for each contact""" | |
import csv | |
import collections | |
import argparse | |
Contact = collections.namedtuple("Contact", ["first", "last", "email"]) | |
def line_to_contact(line): | |
"""return: Contact based on csv line""" |
filter = [:] | |
key = 'example' | |
if (filter.containsKey(key)) { | |
// do if the key is contained | |
// e.g. filter[key] << 'hello_again' | |
} else { | |
// do if key is not contained | |
// e.g. filter[key] = ['hello'] | |
} |
import groovy.json.JsonOutput | |
import java.io.BufferedWriter | |
import java.io.OutputStreamWriter | |
import java.net.URL | |
import java.util.Scanner | |
def url = new URL("https://${github}/api/v3/repos/${org}/${repo}/git/refs") | |
def urlConnection = url.openConnection() | |
urlConnection.setDoOutput(true) |
# Typical use-case is decoding an AWS STS message. The DecodedMessage key contains escaped JSON. | |
jq '.DecodedMessage | fromjson | .' message.json |