Skip to content

Instantly share code, notes, and snippets.

View tjlytle's full-sized avatar

Tim Lytle tjlytle

View GitHub Profile
@tjlytle
tjlytle / test-email.php
Created March 12, 2011 21:03
Test the PHP mail() function.
<?php
mail('user@example.com', 'Testing PHP Mail Function', 'It Works');
@tjlytle
tjlytle / select.php
Created March 19, 2011 17:54
Example of using PHP's Date objects to generate a select element.
<select name="time" id="time">
<?php
$now = new DateTime();
$select = new DateTime();
$select->setTime(0,0);
$tomorrow = new DateTime('tomorrow');
$tomorrow->setTime(0,0);
?>
<?php while($select < $tomorrow): ?>
<?php $diff = $select->diff($now) ?>
@tjlytle
tjlytle / account.php
Created May 11, 2011 02:45
Sample of In-Progress Twilio Library
<?php
require_once 'Twilio/Client.php';
require_once 'auth.php';
//setup client
$twilio = new Twilio_Client(ACCOUNT_SID, ACCOUNT_TOKEN);
//get account information
echo 'Account: ' . $twilio->accounts->getAccount(ACCOUNT_SID)->getFriendlyName() . PHP_EOL;
@tjlytle
tjlytle / oauth.php
Created June 8, 2011 16:32
Command Line Script to get Access Token using Zend_Twitter
#!/usr/bin/php
<?php
require_once 'Zend/Oauth/Consumer.php';
require_once 'Zend/Console/Getopt.php';
//set valid config file types/extensions
$configTypes = array('ini', 'xml', 'json', 'yaml');
//setup command line opts
$opts = new Zend_Console_Getopt(array(
@tjlytle
tjlytle / gist:1041899
Created June 23, 2011 04:22
Example singleton
<?php
class Singleton
{
public static function getInstance()
{
static $instance;
if(empty($instance)){
$class = get_called_class();
$instance = new $class;
}
@tjlytle
tjlytle / gist:1293424
Created October 17, 2011 18:44
SendGrid Configuration for Zend Framework
<?php
$config = array(
'username' => 'sendgridusername',
'password' => 'sendgridpassword',
'auth' => 'plain'
);
$transport = new Zend_Mail_Transport_Smtp('smtp.sendgrid.net', $config);
$mail = new Zend_Mail();
@tjlytle
tjlytle / CloudMine.php
Created January 8, 2012 05:00
API Wrapper for CloudMine that can be used as a Zend_Auth Adapter
<?php
class CloudMine implements Zend_Auth_Adapter_Interface
{
const API_BASE = 'https://api.cloudmine.me/v1/app/';
const FORMAT_JSON = 'json';
const FORMAT_BINARY = 'binary';
const FORMAT_EMPTY = null;
/**
* HTTP Client
@tjlytle
tjlytle / gist:2710216
Created May 16, 2012 13:08
Deadline for PHP Contest
<?php
$tek = new DateTime('11:59 PM May 22 2012', new DateTimeZone('America/Chicago'));
$deadline = clone $tek;
$deadline->setTime(23, 59);
$deadline->add(new DateInterval('P8D'));
echo $deadline->format('r');
@tjlytle
tjlytle / Script.js
Created July 17, 2012 23:21
on{X} script to check traffic
//check route to work and alret for problems
var checkRoute = function(showSummery){
//TODO: get device location
var wps = [];
// get the traffic on 78
wps[0] = '40.55697, -75.99809';
wps[1] = '40.56785, -75.51876';
// get the traffic feed
console.info('about to call traffic feeds');
feeds.traffic.get(
@tjlytle
tjlytle / gist:3244355
Created August 3, 2012 04:26
#DevFriday: King of Code [Aug '12]

The game starts at 3:30PM - if you stumble across this before, good for you, just don't write code until it starts - and entries will be accepted via tweets with the [#devfriday][2] hashtag until the next Developer Friday. In the case that no entries are made before then, [Mark][4] will win by default. To participate you need to have been to at least one [Developer Friday][3].

Goal: Webservice to encrypt/decrypt data using the [Four-square][1] cipher. Any character not matching [a-pr-z] should be removed. For example quick test should be treated as uicktest.