Skip to content

Instantly share code, notes, and snippets.

View ScottPhillips's full-sized avatar

Scott Phillips ScottPhillips

  • Los Angeles, CA
View GitHub Profile
@ScottPhillips
ScottPhillips / fiddle.html
Created September 2, 2011 04:08
Find out how many years old someone is using jQuery
Day: <input type="text" name="day" id="day" value ="5" />
<hr>
Month: <input type="text" name="month" id="month" value ="12" />
<hr>
Year: <input type="text" name="year" id="year" value ="1972" />
<hr>
Birthday: <span id="birthday">?</span>
<hr>
Today: <span id="todayIs">?</span>
<hr>
@ScottPhillips
ScottPhillips / percent_change.php
Created January 1, 2012 05:16
Get the % Change between 2 numbers in PHP
<?php
function percentChange($oldNos = 0, $newNos = 0) {
$scratchSheet = ($newNos + 0) - ($oldNos + 0);
return round((($scratchSheet / $oldNos) * 100),2);
}
?>
@ScottPhillips
ScottPhillips / header_using_apache.php
Created January 3, 2012 07:08
Get the headers of incoming requests using PHP
<?php
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
?>
@ScottPhillips
ScottPhillips / fan_count.php
Created January 4, 2012 07:12
Faceboook SDK PHP : Get Number of Fans
<?php
require('facebook.php');
$facebook = new Facebook(array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
));
$cokeFans = $facebook->api('/cocacola');
@ScottPhillips
ScottPhillips / createqrcode.php
Created February 1, 2011 20:55
Create a QR Code using PHP and Google
function createQR($url,$size ='150',$evLevel='L',$margin='0') {
$url = urlencode($url);
return '<img src="http://chart.apis.google.com/chart?chs=' . $size . 'x' . $size . '&cht=qr&chld=' . $evLevel . '|' . $margin . '&chl=' . $url . '" alt="QR code" width="' . $size . '" height="' . $size . '"/>';
}
echo createQR('http://www.wickedbrilliant.com',150);
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
* $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');
#!/usr/bin/env bash
echo ">>> Installing Mailhog"
# Download binary from github
wget --quiet -O ~/mailhog https://github.com/mailhog/MailHog/releases/download/v0.2.1/MailHog_linux_amd64
# Make it executable
chmod +x ~/mailhog
@ScottPhillips
ScottPhillips / text-logger.php
Created August 6, 2012 14:00
Log to Text File
/* eZLog class very slightly modified from eZ Publish 4.3 */
class eZLog {
const MAX_LOGROTATE_FILES = 3;
const MAX_LOGFILE_SIZE = 204800; // 200*1024
/*!
Creates a new log object.
*/
function eZLog( )
{
}
@ScottPhillips
ScottPhillips / comments-as-xml.php
Created August 6, 2012 04:36
Output Wordpress Comments as XML
<?php
// Load WordPress functions
require('wp-load.php');
$post = get_page($_REQUEST["id"]);
$id = $post->ID;
$withcomments = true;
$comments = getWPcomments();
@ScottPhillips
ScottPhillips / custom_wordpress_columns.php
Created July 29, 2012 15:12
Add Custom Columns to WordPress Post List Page
<?php
add_filter( 'manage_posts_columns', 'your_custom_cols' ); //Filter out Post Columns with 2 custom columns
function your_custom_cols($defaults) {
$defaults['language'] = __('Language'); //Language and Films is name of column
$defaults['film'] = __('Films');
return $defaults;
}