Skip to content

Instantly share code, notes, and snippets.

View ssx's full-sized avatar

Scott Robinson ssx

View GitHub Profile
@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 / .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 / 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 / week-timestamps.php
Created May 13, 2012 10:25
Week Start & End Timestamps
<?php
// This creates a date string in the format YYYY-WNN, which is
// a four digit year followed by a hyphen and letter W then the
// two digit week number
$strtotime = date("o-\WW");
// The $start timestamp contains the timestamp at 0:00 on the
// Monday at the beginning of the week
$start = strtotime($strtotime);
Scotts-MacBook-Air:~ scott$ traceroute google.com
traceroute: Warning: google.com has multiple addresses; using 173.194.34.136
traceroute to google.com (173.194.34.136), 64 hops max, 52 byte packets
1 192.168.0.1 (192.168.0.1) 6.925 ms 6.713 ms 7.589 ms
2 10.93.176.1 (10.93.176.1) 45.988 ms
bagu-core-2b-ae3-2365.network.virginmedia.net (80.5.167.229) 60.279 ms 33.725 ms
3 leed-bb-1b-ae7-0.network.virginmedia.net (80.5.161.245) 60.188 ms 31.955 ms 27.104 ms
4 leed-bb-1c-ae1-0.network.virginmedia.net (62.253.174.26) 81.292 ms 156.878 ms 134.829 ms
5 teln-ic-2-ae1-0.network.virginmedia.net (212.250.14.146) 176.878 ms 266.475 ms 381.205 ms
6 72.14.195.206 (72.14.195.206) 446.911 ms
@ssx
ssx / gist:5338826
Created April 8, 2013 17:44
Chrome + JS: Harlem Shake
Using Google Chrome.
Go to a website.
Right click on the page somewhere.
Click inspect element
Click the console tab
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
#!/bin/bash
unload() {
kextstat | grep "org.virtualbox.kext.VBoxUSB" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxUSB
kextstat | grep "org.virtualbox.kext.VBoxNetFlt" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
kextstat | grep "org.virtualbox.kext.VBoxNetAdp" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
kextstat | grep "org.virtualbox.kext.VBoxDrv" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxDrv
}
load() {
@ssx
ssx / interfaces.php
Created September 7, 2013 16:57
An introduction taken from Taylor's Laravel book and extended to display the useful nature of interfaces.
<?php
header("Content-Type: text/plain");
interface BillerInterface {
public function bill(array $user, $amount);
}
interface BillingNotifierInterface {
public function notify(array $user, $amount);
}
<?php
$code = \Input::get('go');
$twitterService = OAuth::consumer('twitter');
if (\Input::get('oauth_token')) {
$token = $twitterService->getStorage()->retrieveAccessToken('twitter');
$twitterService->requestAccessToken(
\Input::get('oauth_token'),
\Input::get('oauth_verifier'),
$token->getRequestTokenSecret()