Skip to content

Instantly share code, notes, and snippets.

View stevequinn's full-sized avatar

Steve Quinn stevequinn

View GitHub Profile
@stevequinn
stevequinn / timezones
Created April 20, 2021 03:28 — forked from ykessler/timezones
JSON list of time zones (Based on Olson tz database)
[
{"group":"US (Common)",
"zones":[
{"value":"America/Puerto_Rico","name":"Puerto Rico (Atlantic)"},
{"value":"America/New_York","name":"New York (Eastern)"},
{"value":"America/Chicago","name":"Chicago (Central)"},
{"value":"America/Denver","name":"Denver (Mountain)"},
{"value":"America/Phoenix","name":"Phoenix (MST)"},
{"value":"America/Los_Angeles","name":"Los Angeles (Pacific)"},
{"value":"America/Anchorage","name":"Anchorage (Alaska)"},
@stevequinn
stevequinn / Shrink.md
Created February 5, 2021 05:06 — forked from umardx/Shrink.md
How to Shrink the Cloned Raspberry Pi Image (Linux-only)

How to Shrink the Cloned Raspberry Pi Image (Linux-only)

These methods create an image file that is equal to the total capacity of the SD card. For example, cloning an SD card with a capacity of 32GB will create an image file of 32 GB, even if only 5 GB is actually in use on the card. This is fine if you only have one or two such images, but any more than that (especially if you use an SSD) will cause you to run out of space. Unfortunately, this tool is only available on Linux. If you do not have Linux installed, you can install the latest version of Ubuntu or Linux Mint in a virtual machine, and run this script there:

shrink.sh

#!/bin/bash
@stevequinn
stevequinn / androidEmulator.sh
Created March 5, 2018 23:54
Launch Android Emulator
#!/bin/sh
#
# Shortcut script to launch an Android Emulator.
# Assumes osX and android SDK location has not been changed from default.
#
if [ $# -eq 0 ]
then
echo "Usage: androidEmulator.sh @emulatorName. Emulators available:"
~/Library/Android/sdk/tools/emulator -list-avds
else
/**
* This is the first point of entry for requests if no getDisposition hook
* has been defined. If getDisposition does not set a proxy then requests will
* subsequently be passed here.
* Edits to content should be done here.
* This is a promise function that should return a promise.
*
* @param {object} request The request object that gets passed in from the system.
* @return {object} response A response object or a Promise for one.
*/
let xpath = "//*";
let html = `<html><body><h1>Header</h1>
<div><p>top</p></div>
</body></html>`;
let doc = parseHTML(html);
let el = doc.parse("<p>tail</p>");
let extraction = el.evaluate(xpath);
print(extraction[0].str());
// The doc.parse function appears to fail parsing a string that
// starts with a comment.
let doc = parseHTML("<html><body>doc.parse bug</body></html>");
let s = "<!-- After this comment the rest of the doc is removed. --><p>This will be removed</p>";
let e = doc.parse(s);
print(e.str());
// ./js_demo domcomment.js
@stevequinn
stevequinn / gist:6349587
Last active December 21, 2015 18:48
Renegade: CDN Template
<?xml version="1.0" ?>
<resource xmlns="http://schema.modapt.com/pub/modapt-resource/1.0" ttl="14400">
<rule name="rules.init">
<set-cache aggressive="true" cookies="ignore" insecure="true" maximum-age="86400"/>
<prerequisite>
<defmac name="origin_site_hostname" value="www.boingboing.net"/>
<defmac name="asset_path" expr="request.path" />
</prerequisite>
</rule>
@stevequinn
stevequinn / gist:6247981
Created August 16, 2013 07:30
Renegade: Replace Variables
<compose priority="1200">
<!--
Here is a cool way to enable casual variable insertions as a "final step" after the page is
construction. Make sure variables are set at earlier priorities, then simply use {{var}}
anywhere on the page to insert a variable.
-->
<script>
function var_replacer(match, varname) { return eval('variables.'+varname); } dombuf.value = dombuf.value.replace(/{{([a-z0-9_]+)}}/gi, var_replacer);
</script>
</compose>
@stevequinn
stevequinn / gist:5590230
Last active December 17, 2015 09:49
Renegade: lib.content_tags
<!--
Implements several tags for use in pages:
<cond expr="js-expression">
this content appears ONLY if expression is TRUE
</cond>
<insert expr="js-expression-to-insert">
this OPTIONAL content appears only if expression is empty
</insert>
@stevequinn
stevequinn / gist:5565722
Created May 13, 2013 01:56
Renegade: Static Routing Rule
<!-- Return all imagea/js/css requests. -->
<rule match-path="/static/*" comment="Static Files">
<set-cache aggressive="true" cookies="ignore" insecure="true" />
<prerequisite>
<!-- Populate the static_res variable with the current request path -->
<setvar name="static_res" expr="request.path.substr(1)"/>
</prerequisite>
<compose>
<!-- Fetch and return the static resource -->
<fetch type="local" url="${static_res}"/>