Skip to content

Instantly share code, notes, and snippets.

View joshuaadickerson's full-sized avatar

Joshua Dickerson joshuaadickerson

View GitHub Profile
@joshuaadickerson
joshuaadickerson / gist:23c4bf9d5b6ce83a3db2
Last active August 29, 2015 14:05
Trying to figure out the routes
/users (get/post) # lists the users / adds a new user
/login (get/post)
/logout (get/post)
/{id} (get/patch/delete) # show the profile, update the user, delete the user
/activity (get) # show the activity for a user
/notifications (get) # gets the notifications for this user
/topics (get/post) # list all of the recent topics, add a new topic
/{id} (get/patch/delete) # show a topic / update a topic / delete a topic
/resources (get) # get the resources (attachments) associated with the topic
<?php
// @todo implement ArrayAccess and Traversable?
class OnlineLog
{
/**
* How often, in seconds, to run the database garbage collection
*/
const DB_GC_TIME = 30;
<?php
/**
* Every method is chainable
* Instead of throwing errors, it throws exceptions
* All exceptions should show the name of the method throwing it to make it easier to debug
*
* @todo throw exceptions if argument is not the appropriate type
*/
class ArrayChainable extends \ArrayObject
@joshuaadickerson
joshuaadickerson / Event.php
Created March 4, 2014 14:13
Hooker: The Plugin Pimp
<?php
class Event
{
protected $name;
protected $parameters = array();
/** @var EventDispatcher **/
protected $dispatcher;
/** @var Pimple dependency injection container */
protected $container;
<?php
/**
* This file has all the main functions in it that relate to the mysql database.
*
* @name ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause
*
* This file contains code covered by:
@joshuaadickerson
joshuaadickerson / ptdtsn.txt
Created February 26, 2014 03:12
Portable DateTime and Schedule Notation
Portable DateTime and Schedule Notation
There are two types of PDTSN objects: iterator and check
The iterator allows you to iterate the date and time from start to end
The check checks the conditions against the supplied value
Both objects have an object for a date clause and a time clause.
@joshuaadickerson
joshuaadickerson / check.json
Last active August 29, 2015 13:56
Date and Time Query
// This checks for US President's elections
// With a hypothetical reporting of election results every other hour between 8 AM and 8 PM
{'check': {
'value': 'now',
'date': [
{'year': {$gt: 1775}},
{'year': 'leapyear'},
{'month': 'november'},
{'dayofweek': 'tuesday'},
<?php
/*
CREATE TABLE {$db_prefix}plugin_hooks (
id_hook smallint(6) unsigned NOT NULL auto_increment,
id_plugin smallint(6) unsigned NOT NULL,
event varchar(100) NOT NULL,
class varchar(100) NOT NULL DEFAULT '',
method varchar(255) NOT NULL,
<?php
class admin_info_files
{
protected $id_file;
protected $filename;
protected $path;
protected $parameters;
protected $data;
protected $filetype;
<?php
function adjustBoardCounts(array $boards)
{
$db = database();
foreach ($boards as $id_board => $stats)
{
if (function_exists('apache_reset_timeout'))
@apache_reset_timeout();