Skip to content

Instantly share code, notes, and snippets.

View trevordixon's full-sized avatar

Trevor Dixon trevordixon

  • Google
  • Zürich, Switzerland
View GitHub Profile
@WanghongLin
WanghongLin / SplitApkInstaller.java
Created December 31, 2017 11:46
Install split apk
private static void installMultiple(Context context) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL);
try {
final int sessionId = packageInstaller.createSession(sessionParams);
Log.d(TAG, "installMultiple: sessionId " + sessionId);
@trevordixon
trevordixon / lds_contacts.js
Last active January 17, 2019 23:56
This script downloads all of your lds.org contacts as a vCard file which can be imported into Google Contacts, MacOS Contacts, and many other contact managers. Sign in to lds.org, then open the developer console (http://debugbrowser.com/#chrome) and paste the following code into the console.
// First, get the unit number.
const getUnitNumber = fetch('https://www.lds.org/mobiledirectory/services/ludrs/1.1/mem/mobile/current-user-unitNo', {
credentials: 'include',
})
.then(response => response.json())
.then(response => response.message);
// Then download all contacts.
const getContacts = getUnitNumber.then(unitNumber => fetch(`https://www.lds.org/mobiledirectory/services/v2/ldstools/member-detaillist-with-callings/${unitNumber}`, {
credentials: 'include',
@enil
enil / wait
Created June 5, 2015 17:00
Wait for user to press any key in ZSH
#!/bin/zsh
echo 'Press any key to continue...'; read -k1 -s
@tristanwietsma
tristanwietsma / auth.go
Created May 15, 2014 04:15
Golang web server example
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
@Azeirah
Azeirah / Default (Linux).sublime-keymap
Last active December 17, 2017 18:50
The settings for my sublime text set-up
[
// Use paste and indent as default paste mechanism,
// this conserves your indentation and it's overall better.
// original paste is now ctrl+shift+v
{
"keys": ["ctrl+v"],
"command": "paste_and_indent"
}, {
"keys": ["ctrl+shift+v"],
"command": "paste"
@todgru
todgru / _readme.md
Last active January 30, 2023 04:14 — forked from shime/_readme.md
Installing Tmux on Dreamhost tmux dreamhost
@yrezgui
yrezgui / filesize-filter.js
Created May 26, 2013 18:22
This is a custom filter to show a bytes filesize in better way.
// add the filter to your application module
angular.module('myApp', ['filters']);
/**
* Filesize Filter
* @Param length, default is 0
* @return string
*/
angular.module('filters', [])
.filter('Filesize', function () {
#!/bin/bash
### User Settings (things you must set)
## Location of the dnscurl.pl script
DNSCurl="/path/to/route53DynDNS/dnscurl.pl"
## The host name you wish to update/create
myHostName="*"
## Zone/domain in which host (will) reside(s)
myDomainName="example.com"
@thomseddon
thomseddon / gist:3511330
Last active March 8, 2023 03:39
AngularJS byte format filter
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
@jneira
jneira / express-sample.cljs
Created August 25, 2011 20:07
Clojurescript / node.js basic examples
(ns express_sample
(:require [cljs.nodejs :as node]))
(def express (node/require "express"))
(def app (. express (createServer)))
(defn -main [& args]
(doto app
(.use (. express (logger)))
(.get "/" (fn [req res]