Skip to content

Instantly share code, notes, and snippets.

View aarontam's full-sized avatar

Aaron T aarontam

  • San Francisco, CA
View GitHub Profile
@aarontam
aarontam / sporcle-answers.js
Last active August 25, 2018 23:48
Retrieve Sporcle answers by reversing the cipher
// Open most Sporcle quizzes, launch the web inspector, and paste and execute this in the console to reveal all of the answers
answers.map(encodedAnswer => {
let decodedAnswer = '';
for (encodedLetter of encodedAnswer) {
const decodedLetter = Object.keys(asta).find(key => asta[key] === encodedLetter);
decodedAnswer += decodedLetter == null ? ' ' : decodedLetter;
}
return decodedAnswer;
});
@aarontam
aarontam / js.js
Last active January 30, 2016 01:58
Random JS quirks, tricks, tips, and hacks.
/*
* Disclaimer: I neither endorse nor necessarily support these techniques. In general, I value readability over brevity, but I found
* some of these to be somewhat interesting and worth noting and sharing, as I have seen them used extensively.
*/
/* Convert any value to a Boolean */
var myVal = null;
!!myVal; // false
@aarontam
aarontam / prune_branches.sh
Last active February 26, 2016 19:27
Remove local branches that have already been merged.
# Excludes master, by default; other branches can be added with an additional pipe i.e. | grep -v dev
# Update "[branch_to_check_against]" to be the branch where the to-be-pruned branches have been merged into (by default, this is master)
# Adapted from http://stackoverflow.com/a/18143078/1569595
git pull && git branch --merged [branch_to_check_against] | grep -v "\*" | grep -v master | grep -v [branch_to_check_against] | xargs -n 1 git branch -d
@aarontam
aarontam / explode-rule
Created June 11, 2015 22:16
For less.js, explodes a set of selectors for a given rule.
/*
This assumes that the mixin is being included inside a selector.
Particularly useful for a set of selectors that have vendor-specific
prefixes, which cannot be mixed in a selector group.
Example usage:
@selectors: bar, baz, ~'::-webkit-input-placeholder', ~'::-moz-placeholder';;
.foo {
.explode-rule({
width: 100%;
enyo.kind({
name: 'GoogleMap',
kind: 'Control',
published: {
zoom: 16,
center: null,
mapTypeId: 0,
useDefaultUI: true,
debugMode: false
},