This file contains hidden or 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
output = dict() | |
for element in input: | |
output[element["owner"]] = output.get(element["owner"], ()) + (element["pet"],) |
This file contains hidden or 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
output = dict([[e["owner"], []] for e in input]) | |
for element in input: | |
output[element["owner"]].append(element["pet"]) |
This file contains hidden or 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
// requires lodash.js | |
var output = {} | |
_.each(input, function(element){ | |
a = _.get(output, element.owner, []) | |
a.push(element.pet) | |
output[element.owner] = a | |
}) |
This file contains hidden or 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
package main | |
import "fmt" | |
type Pet struct { | |
Owner string `json:"owner"` | |
Pet string `json:"pet"` | |
} | |
func main() { |
This file contains hidden or 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
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
data := bytes.NewBuffer([]byte(`[ |
This file contains hidden or 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
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
) | |
type Pet struct { | |
Owner string `json:"owner"` |
This file contains hidden or 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
# oneline | |
output = dict([(o, [e["pet"] for e in input if e["owner"] == o]) for o in set((i["owner"] for i in input))]) |
This file contains hidden or 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
# broken down for "readability" | |
output = dict( | |
[ | |
(o, [e["pet"] for e in input if e["owner"] == o]) | |
for o in | |
set([i["owner"] for i in input]) | |
]) |
This file contains hidden or 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
#! /bin/bash | |
# checks status in all the git repositories below this one | |
# only prints status for those that aren't on master with no changes since the last tag | |
alltags() { | |
git tag | egrep "v[0-9]+\.[0-9]+\.[0-9]+(-.+)?" |tr '.-' ' *' |sort --numeric-sort --key 1.1 --key 2 --key 3 |tr ' *' '.-' | |
} | |
lasttag() { | |
alltags |tail -1 |
This file contains hidden or 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
export JAVA_HOME="$(/usr/libexec/java_home)" | |
export ANDROID_HOME=/usr/local/opt/android-sdk | |
export GOPATH=$HOME/go | |
export PATH_FIRST=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${JAVA_HOME} | |
export PATH_LAST=/usr/local/opt/go/libexec/bin:$GOPATH/bin | |
export PATH=$(fixpath.py) | |
export PATH_FIRST= | |
export PATH_LAST= |