Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / bundle_everything.py
Last active December 14, 2015 16:49
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.
#!/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 October 2, 2019 13:55
PhoneGap plugin that allows you to modify the WebView font size on Android.

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 December 15, 2015 22:49
Install HON perl dependencies, easily allowing placement of HON-style documents into a CouchDB database.
#!/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 July 11, 2013 13:43
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
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 January 18, 2021 20:48
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 .
/*
* 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 December 29, 2015 23:18
Modifications to the WordPress "Spring Loaded" theme to make it more responsive for larger displays.
.idea
*.css
.sass-cache
@nolanlawson
nolanlawson / _IDB_complex_keys_test.md
Last active January 2, 2016 16:29
Script to test complex keys in IndexedDB.

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 February 1, 2017 01:18
PouchDB map/reduce view specification

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 April 5, 2024 07:43
Gradle tab completion for Bash. Works on both Mac and Linux.

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 February 7, 2014 19:20
XHR obfuscation for web games

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.