Skip to content

Instantly share code, notes, and snippets.

View ssx's full-sized avatar

Scott Robinson ssx

View GitHub Profile
@ssx
ssx / redirect-to-ssl.php
Created May 13, 2012 00:04
Redirect to SSL
<?php
// If your web server is accepting HTTPS connections directly, then the
// request will be directly on port 443. If we aren't on port 443, then
// it's possible we're using a proxy such as Varnish, in which case, most
// modern proxy servers send the HTTP_X_SSL_CIPHER header through with the
// request. You could also test for a custom header from your proxy too.
if (($_SERVER["SERVER_PORT"] != 443) &&
(empty($_SERVER["HTTP_X_SSL_CIPHER"])))
{
Header("Location: https://".$_SERVER["SERVER_NAME"].
@ssx
ssx / .htaccess
Created May 11, 2012 18:36
Apache mod_rewite Force Non SSL Requests to SSL
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R,L]
@ssx
ssx / gist:2649191
Created May 9, 2012 21:53
WordPress: WP_Query $args Ultimate Reference
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@ssx
ssx / example_carpark_data.json
Created March 22, 2011 17:27
example_carpark_data.json
[{
"status":200,
"generated":"Thu, 29 Dec 2011 22:32:06 +0000",
"name":"Charlotte Place",
"image":"\/C07318.jpg",
"updated":"1325197800",
"age":126,
"state":"spaces",
"capacity":"144",
"used":"122",
@ssx
ssx / example_carpark.json
Created March 22, 2011 16:17
example_carpark.json
{
"generated":"Thu, 29 Dec 2011 22:26:05 +0000",
"server":"dor.ky",
"woeid":"24875484",
"locations": [
{
"id":"C07323",
"name":"Bargate Centre",
"image":"\/C07323.jpg"
},
The page you requested does not exist.
The server could not complete your request.
@ssx
ssx / verify_credentials.php
Created February 28, 2011 17:34
Single Account / Verify Credentials
<?php
// OAuth Examples: Twitter
// by Scott Wilcox <[email protected]> http://dor.ky @dordotky
// https://dor.ky/oauth-examples/twitter
//
// This script verifies that the credentials you have are actually valid.
//
// First, require the OAuth library that we're going to use to handle all of the
// OAuth dirty work.
require "../library/EpiCurl.php";
<?
$m = new Mongo();
$h = $m->user->users;
$artist = "Linkin Park";
// lastfm_band_0, lastfm_band_1 or lastfm_band_2 may contain $artist
// I need to get the number of documents where this is the case
$x = $h->find(array("lastfm_band_0" => $artist,
'$or' => array(
<?php
// Firstly we need to load our XML file (test.gpx) into
// a resource that we can use
$xml = simplexml_load_file("test.gpx");
// Put our cache data into a easy to use variable
$data = $xml->wpt->children("http://www.groundspeak.com/cache/1/0");
// You can now do anything you wish with the data,
// like printing out the cache title and size/container
@ssx
ssx / gist:619665
Created October 10, 2010 22:57
GeoCache GPX Example.gpx
<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0" creator="Groundspeak, Inc. All Rights Reserved. http://www.groundspeak.com" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0 http://www.groundspeak.com/cache/1/0/cache.xsd" xmlns="http://www.topografix.com/GPX/1/0">
<name>Cache Listing Generated from Geocaching.com</name>
<desc>This is an individual cache generated from Geocaching.com</desc>
<author>Account "Gb UK" From Geocaching.com</author>
<email>[email protected]</email>
<url>http://www.geocaching.com</url>
<urlname>Geocaching - High Tech Treasure Hunting</urlname>
<time>2010-10-10T22:54:31.1487819Z</time>
<keywords>cache, geocache</keywords>