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
from itertools import permutations | |
WORD_FILE = '.../words' | |
words = set(x.strip() for x in open(WORD_FILE).readlines()) | |
LETTERS = 'abcdefg' | |
perms = set((''.join(x).split())[0] for x in permutations(LETTERS+' ')) |
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
Mirroring a Git repostory | |
The firm I recently stated working at just moved to Git and I am the only resource then knows Git. I get asked so many times a day on how to mirror a git repostory. | |
From the birds eyes very its very easy: | |
git clone --mirror git@git.com:project project | |
cd project | |
git remote add github git@github.com:username/project.git |
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
#!/bin/bash | |
JP2A=$(dirname "$0")/jp2a | |
declare -a jp2aopts | |
while [[ $# -gt 0 ]] ; do | |
case "$1" in | |
-) break ;; | |
--) shift ; break ;; | |
-*) jp2aopts+=( "$1" ) ; shift ;; |
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
#!/bin/bash | |
for d in "$@" ; do | |
echo | |
echo "${d}" | |
find "${d}" -type f -printf '%T+ %P\n' | sort | cat -n | tail -3 | |
done |
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
# Github API token, so that homebrew doesn't hit such a low rate limit | |
if [ -r ${HOME}/.github/api_token ] ; then | |
export HOMEBREW_GITHUB_API_TOKEN=$(< ${HOME}/.github/api_token) | |
fi | |
# Per-user python modules-installed executables | |
export PATH=${HOME}/Library/Python/$(python -c 'from sys import version_info as v; print(".".join(map(str,v[0:2])))')/bin${PATH+:${PATH}} | |
# Need a readlink that works like on linux |
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
name=box | |
cat "$name.gltf" \ | |
| jq -r 'leaf_paths | if .[length-1] == "uri" then join(".") else empty end' \ | |
| while read p ; do | |
cat "$name.gltf" \ | |
| jq -r ".$p" \ | |
| sed -e 's/^[^,]*,//' \ | |
| base64 -d \ | |
> "$name.$p.out" | |
done |
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
public class Application implements EntryPoint { | |
... | |
public void onModuleLoad() { | |
... | |
final MapWidget map = new MapWidget("mapMain", "app") { | |
@Override | |
protected void initializationCallback(GetMapConfigurationResponse r) { | |
super.initializationCallback(r); | |
Map<String, MapAddon> mapAddons = getMapAddons(); | |
for (MapAddon addon : mapAddons.values()) { |
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
// http://stackoverflow.com/a/4320620 | |
// merge object properties | |
// earlier objects override later objects | |
function merge () { | |
var o = {} | |
for (var i = arguments.length - 1; i >= 0; i --) { | |
var s = arguments[i] | |
for (var k in s) o[k] = s[k] | |
} | |
return o |
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
/** | |
* Download a resource from a URL and save as a file in the current directory. | |
* (no overwrite, no timestamp checking, assumes URL has a sensible filename-like path) | |
*/ | |
File grabRemoteUrlAsLocalFile(String remote) throws MalformedURLException, IOException { | |
URL remoteUrl = new URL(remote); | |
String localName = url2filename(remoteUrl); | |
File localFile = new File(localName); | |
Path localPath = localFile.toPath(); | |
if (!localFile.exists()) { |
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
XMLReader tagSoupReader = new org.ccil.cowan.tagsoup.Parser(); | |
Transformer identityTransformer = TransformerFactory.newInstance().newTransformer(); | |
Reader sourceReader = new FileReader(sourceFile); | |
InputSource sourceInputSource = new InputSource(sourceReader); | |
Source xmlSource = new SAXSource(tagSoupReader, sourceInputSource); | |
Result outputTarget = new StreamResult(outputFile); | |
identityTransformer.transform(xmlSource, outputTarget); |
OlderNewer