Skip to content

Instantly share code, notes, and snippets.

View joshtronic's full-sized avatar
🪦
Most forks are graves, not gardens

Josh Sherman joshtronic

🪦
Most forks are graves, not gardens
View GitHub Profile
@joshtronic
joshtronic / gist:721068
Created November 30, 2010 02:57
pickles module without the parent template
<?php
class home extends Module
{
protected $template = false;
public function __default()
{
}
<?php
class logout extends Module
{
public function __default()
{
// Saves the error
if (isset($_SESSION['__error']))
{
$error = $_SESSION['__error'];
// Display any errors that may be available
if ($('#error_type').length == 1)
{
var error_type = $('#error_type').val();
var launch_invite = $('#error_code').length == 1
// Pulls up the invite dialog
if (launch_invite && error_type != 'user_exists')
{
$('#claim-form input[name=code]').val($('#error_code').val());
<?php
require_once 'pickles.php';
// Includes our vendor paths
set_include_path(
get_include_path()
. PATH_SEPARATOR . SITE_PATH . 'vendors/abraham/twitteroauth/twitteroauth/'
// . PATH_SEPARATOR . SITE_PATH . 'vendors/openid/openid/'
);
<?php
$date = strtotime('2009-12-29');
while ($date <= strtotime('2011-01-11'))
{
// Stuffs...
$date = strtotime(date('r', $date) . ' +1 day');
}
<?php
class Utilities
{
public static function sortAssociativeArray(&$array, $sort_key)
{
usort(
$array,
create_function(
'$a, $b',
<?php
class event_vote extends UserModule
{
public function __default()
{
if (isset($_POST['id']))
{
$vote = new Vote(array('event_id' => $_POST['id'], 'user_id' => $_SESSION['__user']['id']));
@joshtronic
joshtronic / gist:810752
Created February 4, 2011 04:52
where's the bug?
<?php
$comment = new Comment(array('event_id' => $_POST['event_id'], 'user_id' => $_SESSION['__user']['id'], 'comment' => $comment));
if ($comment->count() == 0)
{
$comment->record['event_id'] = $_POST['event_id'];
//$comment->record['parent_id'] = $_POST['comment_id'];
$comment->record['user_id'] = $_SESSION['__user']['id'];
$comment->record['comment'] = $comment;
<?php
// Pulls the comments
$comment = new Comment(array('conditions' => array('event_id' => $_GET['id']), 'order' => array('id DESC')));
$comments = array();
// Extracts the user IDs for the comments and creates index values
while ($comment->record)
{
$user_ids[] = $comment->record['user_id'];
<?php
class Utility
{
/**
* Get Time
*
* Sets the timezone to Eastern time, grabs the date/time and resets the
* timezone setting. Helps out by normalizing timestamps across multiple
* timezones since the site sets the timezone to local time.