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 / 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);
@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 / facebook_fql_queries.php
Created January 4, 2012 18:11
Using the PHP SDK to run FQL queries using the Facebook Graph API
<?php
$facebook = new Facebook(array(
'appId' => 'YOUR_API_KEY',
'secret' => 'YOUR_API_SECRET',
'cookie' => true,
));
$fql = "SELECT page_id, name from page where name='Coke'";
@ScottPhillips
ScottPhillips / Terminal_Commands
Created January 20, 2012 22:23
Install Lua on your Mac OSX
# Download and install xCode to install make.
# http://itunes.apple.com/us/app/xcode/id448457090?mt=12
# Don't forget to run "/Applications/Install Xcode.app"
# Open up your terminal, and follow the steps below
# by cutting pasting or typing the below in.
# The number sign indicates a comment.
# Make a temporary directory
mkdir temp
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 07:03
My Default .htaccess File for Running on RackSpace Cloud Sites
########################################
# Adjust Memory/Post/Execution/ Upload Size
########################################
php_value max_execution_time 3600
php_value upload_max_filesize 100M
php_value post_max_size 220M
php_value memory_limit 256M
########################################
# Display Errors: (Comment out for no Errors)
@ScottPhillips
ScottPhillips / example.php
Created March 10, 2012 23:11 — forked from drewjoh/example.php
A Simple Postmark PHP Class with Attachments
<?php
require("postmark.php");
$postmark = new Postmark("your-api-key","from-email","optional-reply-to-address");
$result = $postmark->to("reciver@example.com")
->subject("Email Subject")
->plain_message("This is a plain text message.")
->attachment('File.pdf', $file_as_string, 'application/pdf')