Skip to content

Instantly share code, notes, and snippets.

View evansolomon's full-sized avatar

Evan Solomon evansolomon

View GitHub Profile
@evansolomon
evansolomon / nfl_players.php
Created November 26, 2010 07:31
Find links for all active NFL player profiles on nfl.com
<?php
$results = array();
$r_players = '/\/players\/(.+?)\/profile\?id\=[A-Z0-9]+/';
for($i='a';$i!='c';$i++){
$base = 'http://www.nfl.com/players/search?category=lastName&filter='.$i.'&playerType=current';
$url = $base;
$d = 2;
$page_check = 1;
@evansolomon
evansolomon / gist:945513
Created April 28, 2011 00:00
French Laundry Alerts
<?php
//number of people in the reservation
$people = 2;
//time, just the hour, pm
$time = 7;
$url = 'http://www.opentable.com/nextavailabletable.aspx?hpu=1025002033&shpu=1&rid=1180&m=4&d=8/13/2010+'.$time.':00:00+PM&p='.$people;
$data = file_get_contents($url);
$regex = '/\[\'\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}\:\d{2}\:\d{2} PM/';
@evansolomon
evansolomon / optimizely.php
Created October 10, 2011 17:37
WordPress.com plugin for running Optimizely experiments
<?php
/*
Plugin Name: Optimizely
Description: Runs Optimizely experiments.
Author: koop, evansolomon
Version: 0.2
*/
class WPCOM_Optimizely {
public $version;
@evansolomon
evansolomon / kissmetrics.php
Created December 3, 2011 23:11
Kissmetrics plugin for WordPress with a simplified class based on their default library
<?php
/*
Plugin Name: WP Kissmetrics
Description: Record events using Kissmetrics' PHP API. Intended to be used by developers only.
Author: evansolomon
Version: 1.0
*/
/* Forked from https://github.com/kissmetrics/KISSmetrics/blob/master/km.php */
@evansolomon
evansolomon / gist:1453969
Created December 10, 2011 00:22
Do something when a WordPress user uploads a video
<?php
/**
* User uploads a video
*/
function user_uploads_video( $args, $upload ) {
if( 'upload' != $upload )
return;
if( 0 === strpos( $args['type'], 'video' ) ) {
//do cool stuff
@evansolomon
evansolomon / privacy-please.php
Created December 30, 2011 05:20
A more private way to use WordPress without the hassle of passwords and such. Logged out users can only single posts, and only if they know the exact URL.
<?php
/*
Plugin Name: Privacy Please
Description: A more private way to use WordPress without the hassle of passwords and such. Logged out users can only access single posts, and only if they know the exact URL.
Author: Evan Solomon
*/
/* Only allow singe page views */
function only_singular_requests_for_you() {
if( ! is_user_logged_in() && ! is_singular() )
@evansolomon
evansolomon / .bashrc
Created April 1, 2012 08:36
Bash prompt
PROMPT_COMMAND='DIR=`pwd|sed -e "s!$HOME!~!"`; if [ ${#DIR} -gt 30 ]; then CurDir=${DIR:0:12}...${DIR:${#DIR}-15}; else CurDir=$DIR; fi'
# show git branch name in prompt
PS1='\[\e[1;32m\]\u: $CurDir $(__git_ps1 " (%s)")\$\[\e[0m\] '
# make bash autocomplete with up arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
# make tab cycle through commands instead of listing
@evansolomon
evansolomon / git-completion.sh
Created April 1, 2012 08:36
Git auto-complete script
#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@evansolomon
evansolomon / gist:2273882
Created April 1, 2012 09:03
Dotdeb repo setup
cd ~
wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | sudo apt-key add -
rm dotdeb.gpg
sudo apt-get update
sudo apt-get upgrade
@evansolomon
evansolomon / www.conf
Created April 1, 2012 09:10
PHP-FPM config
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'