Skip to content

Instantly share code, notes, and snippets.

@asciimo
asciimo / .htaccess
Created August 26, 2016 21:16
Simulate a slow-loading GIF with a redirect to a PHP script.
# Slow GIF
RewriteRule ^slowfile.gif$ slowfile.php [L]
@asciimo
asciimo / requirements.txt
Created October 5, 2016 17:44
Little utility to resize globbed images
Pillow==3.4.1
python-resize-image==1.1.3
@asciimo
asciimo / configure_httpd.sh
Last active March 30, 2017 18:07
Shell script to modify httpd.conf to allow mod_rewrite in .htaccess files
# Update the 2nd instance of AllowOverride, which is in the docroot Directory directive
perl -pi -e 's{AllowOverride None}{++$n == 1 ? "AllowOverride All" : $&}ge' /usr/local/apache2/conf/httpd.conf
# Tack the mod_rewrite module load on to the end of the file
echo 'LoadModule rewrite_module modules/mod_rewrite.so' >> /usr/local/apache2/conf/httpd.conf
The company maintains similar offices in Cape Town, South Africa, and outside Portland, Maine, and gives employees a $250-a-month stipend if they want to use commercial co-working offices elsewhere.
A single, continuous slider from Zillow’s Affordability Calculator — allowing the customer to explore various options quickly. Fixed values, such as annual income, monthly debts and down payment are defined once.
@asciimo
asciimo / mapdemo.html
Created October 1, 2017 06:29
A demo of using the GOogle Maps Javascript API, and toggling groups of markers on and off.
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
@asciimo
asciimo / interested.js
Created October 18, 2017 18:15
How to use Javascript to get a list of everyone who selected "Interested" on a Facebook event
// First, click on the event link that looks like "0 Going · 28 Interested" and then "inspect element" on the modal
const list = document.getElementsByClassName("uiScrollableAreaBody")[6] // Your markup may vary. The One I wanted was index 6
const people = list.getElementsByTagName("span") // HTMLCollection
const peopleArray = [].slice.call(people) // Convert to an array we can map()
peopleArray.map(personEl => personEl.innerText) // Copy the results and clean up in Vim :D
@asciimo
asciimo / gateway.js
Last active November 3, 2017 21:35
Get the server's gateway ip address in a node script.
const util = require('util')
const execFile = util.promisify(require('child_process').execFile); // node 8+
const getGatewayIp = () =>
new Promise((resolve, reject) => {
execFile('/sbin/ip', ["route"])
.then(result => {
if (result.stdout) {
const ip_pattern = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/;
const ip = result.stdout.match(ip_pattern)[0];
@asciimo
asciimo / texmextacos.json
Last active February 4, 2018 22:29
Recipe Schema Example
{
"_id": "6c5cfc1c77bfa802c55f2a8561005f34",
"_rev": "2-8abc0d63720e5f85b74a5af0342b41c3",
"publication_timestmap": "1516779903",
"title": "Vegan Tex-Mex Tacos",
"author": "Brian L. Patton",
"packs": [
{
"id": "a1b2c3",
"name": "Amazing Breakfasts"
@asciimo
asciimo / circles.pde
Created February 5, 2018 23:36
Processing sketch for generating grayscale, interlocking circles suitable for a desktop background.
// Pressing Control-R will render this sketch.
int x = 50;
int y = 50;
void setup() { // this is run once.
// set the background color
background(255);