Skip to content

Instantly share code, notes, and snippets.

View chrisallenlane's full-sized avatar

Chris Allen Lane chrisallenlane

View GitHub Profile
@chrisallenlane
chrisallenlane / heavy-handed-sanitization.php
Created July 15, 2012 23:21
A Heavy-handed Approach to Sanitization in PHP
<?php
/**
* Chris Allen Lane
* chris@chris-allen-lane.com
* twitter.com/chrisallenlane
*
* This gist is a snippet of companion code for the blog article posted here:
* http://chris-allen-lane.com/2012/05/a-heavy-handed-approach-to-sanitization-in-php/
*/
@chrisallenlane
chrisallenlane / Rakefile
Created September 9, 2012 16:17
Rakefile accompanying bit.ly/NvF4dD
require 'fileutils'
# specify key files
webroot = '/home/ubuntu/www'
srcroot = '/home/ubuntu/src'
# enumerate the LAMP domains
lamp_domains = {
:example1 => 'example-1.com',
:example2 => 'example-2.com',
@chrisallenlane
chrisallenlane / gist:3709006
Last active December 2, 2018 23:26
Dump from a malfunctioning Wordpress spam bot
Submitted on 2012/06/19 at 12:32 am Hello, just wanted to mention, I enjoyed
this blog post. It was practical. Keep on posting!
What’s up, I just wanted to mention, you’re wrong. Your point doesn’t make any
sense.
Hello, how’s it going? Just shared this post with a colleague, we had a good
laugh.
Incredible points. Great arguments. Keep up the amazing effort.
@chrisallenlane
chrisallenlane / gist:3729849
Created September 15, 2012 21:25
An Interesting Spam Email
> From: jtrdelivery@cargo131.jal.co.jp
> Date: Thursday, September 6, 2012 9:27:10 AM
> Subject: JTR-JAL Cargo Tracker Report
>
>
> <Acceptance Message>
>
> We can not accept your request because of following
> reason. Please try again.
>
@chrisallenlane
chrisallenlane / wp-config.php
Created September 27, 2012 20:47
Pathing Wordpress to its Document Root
/** Make sandbox development a little easier */
define('WP_HOME', "http://{$_SERVER['SERVER_NAME']}/");
define('WP_SITEURL', "http://{$_SERVER['SERVER_NAME']}/");
@chrisallenlane
chrisallenlane / presentationtimerpro.java
Created November 8, 2012 23:53
PhoneGap: preventing an Android application's screen from sleeping
package com.chrisallenlane.presentationtimerpro;
import android.app.Activity;
import android.os.Bundle;
import org.apache.cordova.*;
// add the following import statements
import android.view.WindowManager;
import android.view.Window;
@chrisallenlane
chrisallenlane / nginx.conf
Last active March 14, 2020 16:57
This is an nginx configuration that does the following: - Implements a RESTful API using CORS between `example.com` and `api.example.com` - Uses SSL - Reverse-proxies SSL traffic from port 443 to a NodeJS application running on port 8000 Adapted from this page, with thanks to the original author: http://enable-cors.org/server_nginx.html
# Configure the reverse-proxy on port 443
server {
# general configs
keepalive_timeout 30;
listen 127.0.0.1:443 ssl;
server_name api.example.com;
# ssl configs
ssl_certificate /path/to/api.crt;
ssl_certificate_key /path/to/api.key;
@chrisallenlane
chrisallenlane / gist:8292452
Last active January 2, 2016 10:49
This function parses a string representation of an object (written in dot notation) into an actual object.
#!/usr/bin/env node
// Parses a string representation of a nested object (of arbitrary depth) into
// a "proper" object.
function vivify(str) {
return str.split('.').reduceRight(function(a, b) {
var c = {};
if (typeof a === 'string') {
@chrisallenlane
chrisallenlane / preload
Created March 9, 2014 19:17
Preloading
function preload(files) {
var images = [];
for (i = 0; i < files.length; i++) {
images[i] = new Image();
images[i].src = files[i];
}
}
preload([
@chrisallenlane
chrisallenlane / curl-post.sh
Created April 25, 2014 16:59
Use cURL to POST data to a URL
#!/bin/sh
# specify the target URL
url="http://www.example.com"
# spoof a user-agent if you need to
userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36"
# specify the payload data
data="id=12345"