Skip to content

Instantly share code, notes, and snippets.

View jordanandree's full-sized avatar

Jordan Andree jordanandree

View GitHub Profile
@jordanandree
jordanandree / foo.php
Created September 2, 2010 21:14
what the foo
<?php
$foo = 'foo';
echo $foo == 'foo' ? 'yes' : 'no';
?>
<?php
require 'facebook.php';
function facebook_connect(){
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '145062682199939',
<a class="comments" rel="123" href="http://url-to-real-comments-page.com">View Comments</a>
<script type="text/javascript">
jQuery(document).ready(function($){
$('.comments').click(function(){
$.ajax({
type: 'get',
data: { id: $(this).attr('rel')},
<?php
// needed to load WP core
include '../../../wp-config.php';
if($_GET):
$id = $_GET['id'];
query_posts('p='.$id);
@jordanandree
jordanandree / dump.php
Created December 27, 2010 23:20
dump an object
<?php
function dump( $str ){
echo '<pre>'.print_r($str, false).'</pre>';
exit();
}
?>
<?php
function datetimeFormat( $date, $format )
{
$date = explode('-', $date);
$day = explode(' ', $date[2]);
$time = explode(':', $day[1]);
$day = $day[0];
$mktime = mktime($time[0] , $time[1], $time[2], $date[1], $day, $date[0]);
<?php
function siteroot()
{
global $siteroot;
$siteroot = explode('/', $_SERVER['PHP_SELF']);
$siteroot = 'http://' . $_SERVER['SERVER_NAME'] . '/' . $siteroot[1];
return $siteroot;
}
?>
<?php
function ago($time)
{
$time = strtotime($time);
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60", "60", "24", "7", "4.35", "12", "10");
$now = time();
$difference = $now - $time;
<?php
function paginate( $total, $perpage )
{
$current = $_GET['page'] != '' ? $_GET['page'] : 1;
$paginate = '<div>';
$paginate .= $current > 1 ? '<a href="?page='.($current-1).'"> &laquo; Older |</a>' : '';
$paginate .= '<div>';
for($i = 1; $i <= round($total/$perpage); $i++ ){
<?php
$start = $_GET['page'] == 1 || $_GET['page'] == '' ? 0 : $_GET['page'] * $perpage;
$perpage = 10;
$query = "SELECT * FROM table LIMIT $start, $perpage";
$query = mysql_query($query);
while($row = mysql_fetch_array($query)):
echo '<p>'.$row['id'].' '.$row['data'].'</p>';
endwhile;