Skip to content

Instantly share code, notes, and snippets.

View themattharris's full-sized avatar

Matt Harris themattharris

View GitHub Profile

Keybase proof

I hereby claim:

  • I am themattharris on github.
  • I am themattharris (https://keybase.io/themattharris) on keybase.
  • I have a public key ASBn4FfXf_T-hzDKYTAqyhvqvImlPAOxQ0ywW2jf74yK0Qo

To claim this, I am signing this object:

@themattharris
themattharris / verify_ssl
Last active December 21, 2015 07:39
verify_ssl for v1.1. this requires a valid oauth_token and secret
<?php
$tmhOAuth = new tmhOAuth(array(
'curl_ssl_verifypeer' => true,
'curl_ssl_verifyhost' => 2,
'consumer_key' => 'YOUR_CONSUMER_KEY',
'consumer_secret' => 'YOUR_CONSUMER_SECRET',
'user_token' => 'A_USER_TOKEN',
'user_secret' => 'A_USER_SECRET',
));
$tmhOAuth->request('GET', $tmhOAuth->url('1.1/search/tweets'), array(
'q' => 'themattharris'
));
@themattharris
themattharris / backfill.php
Created February 5, 2012 01:53
Processing nvvotecount from gist https://gist.github.com/1741669
<?php
// incase you miss some data. You might need to increment the page number.
// Remember, the max tweets returned by the Twitter API is 3200.
require '../tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => 'YOUR_CONSUMER_KEY',
'consumer_secret' => 'YOUR_CONSUMER_SECRET',
'user_token' => 'A_USER_TOKEN',
@themattharris
themattharris / nvvotecount.php
Created February 5, 2012 01:02
How @themattharris is following @nvvotecount
<?php
/**
* This script relies on tmhOAuth, which can be downloaded here:
* https://github.com/themattharris/tmhOAuth
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
* https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
@themattharris
themattharris / weekday_diff.php
Created August 12, 2011 21:20
weekday_diff - calculates the number of weekdays between two dates.
<?php
/**
* Calculated the number of weekdays (M-F) between two timestamps (inclusive).
*
* @param string $from the timestamp to start measuring from
* @param string $to the timestamp to stop measuring at
* @param string $normalise whether the time of day should be ignored (forces times to yyyy-mm-ddT00:00:00+00:00)
* @return int the number of weekdays between the two timestamps
* @author Matt Harris
*/
# Thanks to Mark McBride for jsonator syntax
function jsoncurl {
curl -s $@ | jsonator
}
function jsontwurl {
twurl $@ | jsonator
}
function obtwurl {
twurl $@ | objenator
/**
* ellipse()
* ellipses a string using english language rules
*
* @param string $text The original text string
* @param int $maxlen The maximum length of the string to ellipse (this includes the ellipse characters)
* @param string $ellip The string to use as the ellipsis
* @param bool $towords Whether to ellipse to word boundaries or not
*/
function ellipse($text, $maxlen, $ellip='...', $towords=TRUE) {
/**
* makeSalt()
* generates a random salt up to the requested length
*
* @param int $length Length of salt to produce
*/
function makeSalt($length=45) {
$sequence = array_merge(range(0,9), range('A','Z'), range('a','z'), range('!','.'));
// remove unsafe characters
$unsafe = array('"',"'");
@themattharris
themattharris / Flickr Cacher
Created July 4, 2009 10:56
Provides a local caching system for Flickr images to ensure they are viewable when clients have Flickr blocked.
<?php
/*
Flickr Caching Script for WordPress
Description: Provides a local caching system for Flickr images to ensure they
are viewable when clients have Flickr blocked.
Version: 1.0
Author: Matt Harris
Author URI: http://themattharris.com
License: MIT (http://www.opensource.org/licenses/mit-license.php)