Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / bundle_everything.py
Last active Dec 14, 2015
Automatic bundling! Input a js directory, a css directory, and an HTML file, and this script will bundle it all into three groups: head (css), head (js), and body (js). Works for inline scripts as well.
View bundle_everything.py
#!/usr/bin/env python
#
# Input a js directory, a css directory, and an HTML file, and this script will bundle
# it all into three groups: head (css), head (js), and body (js). Skips inline scripts.
# Deletes the original JS and CSS folders, optionally
#
# usage: bundle_everything.py my/html/file output/js/folder output/css/folder delete_originals
#
import sys,re,os.path,os
@nolanlawson
nolanlawson / 00_Font_Size_Adjust_PhoneGap_Plugin.md
Last active Oct 2, 2019
PhoneGap plugin that allows you to modify the WebView font size on Android.
View 00_Font_Size_Adjust_PhoneGap_Plugin.md

Font size adjustment plugin for PhoneGap on Android: a simple PhoneGap plugin that allows you to dynamically modify the WebView's textSize property in order to make the text larger/smaller.

Usage:

// increase the font size by one unit (units are [50%,75%,100%,150%,200%])
window.plugins.fontSizeAdjust.increase(myCallback(newFontSizeAsPercent){});

// decrease the font size by one unit
window.plugins.fontSizeAdjust.decrease(myCallback(newFontSizeAsPercent){});
@nolanlawson
nolanlawson / install_hon_dependencies.sh
Last active Dec 15, 2015
Install HON perl dependencies, easily allowing placement of HON-style documents into a CouchDB database.
View install_hon_dependencies.sh
#!/bin/bash
for package in HON-Utils HON-Http-MediaWiki HON-Http-ImageExtractor HON-WWW-Robot HON-Http-Mirror HON-EUHP HON-Http-SectionClassifier HON-Http-ContentExtractor HON-Http-Store ; do
svn co "http://svn.honservices.org/SearchEngine/trunk/$package"
cd $package
perl Build.PL
./Build
./Build installdeps
./Build install
cd ..
@nolanlawson
nolanlawson / ActionBarNavigationFixABS.java
Created Jul 11, 2013
Fix for Android's ActionBar, where navigational tabs don't work if the tabs are reduced to a dropdown (Spinner). This version is designed to work with Action Bar Sherlock. Based on the original discussion here: http://stackoverflow.com/questions/15409330/action-bar-selecttab-and-setselectednavigationitem-not-working
View ActionBarNavigationFixABS.java
public void onPageSelected(int position) {
// When swiping between different app sections, select the corresponding tab.
// We can also use ActionBar.Tab#select() to do this if we have a reference to the
// Tab.
actionBar.setSelectedNavigationItem(position);
/*
*
* When paging between tabs, normally the dropdown list (spinnerAdapter) won't change properly. This
@nolanlawson
nolanlawson / AddContactIntentBuilder.java
Last active Jan 18, 2021
Helper class for adding contacts with multiple fields (e.g. phone numbers and email addresses) in Android. See this blog post for details: http://wp.me/p1t8Ca-IM .
View AddContactIntentBuilder.java
/*
* Copyright (c) 2012 Nolan Lawson <nolan@nolanlawson.com>
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
*/
package com.your.app.helper;
import java.lang.reflect.Field;
import java.util.ArrayList;
@nolanlawson
nolanlawson / .gitignore
Last active Dec 29, 2015
Modifications to the WordPress "Spring Loaded" theme to make it more responsive for larger displays.
View .gitignore
.idea
*.css
.sass-cache
@nolanlawson
nolanlawson / _IDB_complex_keys_test.md
Last active Jan 2, 2016
Script to test complex keys in IndexedDB.
View _IDB_complex_keys_test.md

IndexedDB complex key test

This script tests complex keys in IndexedDB (i.e. arrays instead of simple numbers, strings, booleans). It was motivated by a SO post claiming IE doesn't support complex keys.

This test seems to confirm that indeed IE 10 and 11 do not support complex IndexedDB keys (as of January 2014).

Chrome/Opera/Firefox correctly show:

@nolanlawson
nolanlawson / README.md
Last active Feb 1, 2017
PouchDB map/reduce view specification
View README.md

PouchDB map/reduce view specification

This document describes the proposed implementation for persisted map/reduce views in PouchDB. This is based on the ongoing discussion in pouchdb/mapreduce#12.

I decided to make this a formal-ish spec, because the dicussion was starting to go long and it was becoming unclear what implementation we were talking about.

Required API

@nolanlawson
nolanlawson / completion-for-gradle.md
Last active Sep 4, 2021
Gradle tab completion for Bash. Works on both Mac and Linux.
View completion-for-gradle.md

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
@nolanlawson
nolanlawson / xhr_obfuscation.md
Created Feb 7, 2014
XHR obfuscation for web games
View xhr_obfuscation.md

XHR obfuscation for web games

This is just a Gist to remind myself to start implementing this at some point. This would be a cool library.