Skip to content

Instantly share code, notes, and snippets.

Trevor Dixon trevordixon

Block or report user

Report or block trevordixon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
trevordixon / test.babel.js
Created May 23, 2019
Test async/await/Promise order
View test.babel.js
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "ne
trevordixon / im.go
Last active Nov 24, 2017
Simple command line XMPP instant messaging program that opens a conversation with a single contact
View im.go
// Adapted from
package main
import (
trevordixon / pbcopy
Created Jan 20, 2017
pbcopy from remote host in iTerm2
View pbcopy
alias pbcopy="(printf '\033]1337;CopyToClipboard=\7'; cat -; printf '\033]1337;EndCopy\7')"
View index.js
const CSS = require('css');
function scopeCSS(css, scope) {
const ast = CSS.parse(css);
for (let rule of ast.stylesheet.rules) {
if (rule.type == 'rule') {
rule.selectors = => `${scope} ${selector}`);
return CSS.stringify(ast);
trevordixon / lds_contacts.js
Last active Jan 17, 2019
This script downloads all of your contacts as a vCard file which can be imported into Google Contacts, MacOS Contacts, and many other contact managers. Sign in to, then open the developer console ( and paste the following code into the console.
View lds_contacts.js
// First, get the unit number.
const getUnitNumber = fetch('', {
credentials: 'include',
.then(response => response.json())
.then(response => response.message);
// Then download all contacts.
const getContacts = getUnitNumber.then(unitNumber => fetch(`${unitNumber}`, {
credentials: 'include',
trevordixon /
Created Jul 3, 2016
Make signed-in requests to from Google Apps Scripts
function example() {
// This cookie is good for many subsequent requests (until it expires)
var cookie = getCookie('[username]', '[password]');
var response = ldsGet(cookie, '');
function getCookie(username, password) {
var response = UrlFetchApp.fetch('', {
View aes.hs
-- AES encryption in Haskell using Simple AES (
-- Example encryption and decryption:
import Codec.Crypto.SimpleAES
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as BL
import Data.Hex
key = B.pack "Thisismykey....."
trevordixon /
Created Feb 1, 2016
Sublime command that replaces repeated lines with a single instance prefixed with a count (much like uniq -c).
import sublime, sublime_plugin
class CountConsecutiveDuplicateLinesCommand(sublime_plugin.TextCommand):
def run(self, edit):
# end and start mark the beginning and end of the current region to replace,
# working backwards.
start = end = self.view.size()
# Preserve trailing newline if last line is empty.
if self.view.line(end).empty():
trevordixon /
Last active Jan 13, 2016 — forked from koraysaritas/
Installing Tmux on Dreamhost tmux dreamhost
trevordixon / convert.js
Created May 15, 2015
Convert LilyBin MongoDB dump to new DB
View convert.js
var Promise = require('bluebird');
const scores = require('./lib/db');
var LineByLineReader = require('line-by-line'),
lr = new LineByLineReader('scores.json');
lr.on('line', function(line) {
var data = JSON.parse(line);
var id = data['_id'];
console.log(id, data.revisions.length);
You can’t perform that action at this time.