Skip to content

Instantly share code, notes, and snippets.

View jamsesso's full-sized avatar

Sam Jesso jamsesso

  • Fredericton, Canada
  • 11:55 (UTC -03:00)
View GitHub Profile
/* Usage:
* Return element: elem("name-of-element");
* Value of element: elem("name-of-element").val();
* Any method in jQuery works here since it returns a jQuery object.
* */
var elem = function(selector)
{
return $("*[name="+ selector +"]");
}
<?php
#! Photo resize controller.
#! Class interface.
interface iResize
{
public function __construct($filename);
public function resize($x, $y);
public function save($locale);
}
<?php
/* #!modules/mysql.php
* Bike-This.com - Modules
* By Sam Jesso - [email protected]
* File: mysql.php
* Type: PHP
* Description: A MySQL (PHP 4 mysql_*) wrapper that makes queries visually easier to follow, execute, and debug.
*/
class MySQL
<?php
function toCoordinates($address)
{
$bad = array(
" " => "+",
"," => "",
"?" => "",
"&" => "",
"=" => ""
);
<?php
/* By Sam Jesso - [email protected]
* File: oceansql.php
* License: GNU GPL.
* Type: PHP
* Description: A MySQL (PHP 4 mysql_*) wrapper that makes queries visually easier to follow, execute, and debug. */
defined("SYSTEM") or die("Access denied.");
class MySQL
{
@jamsesso
jamsesso / str_time.php
Created May 30, 2011 21:30
Supply a time stamp, get a time ago statement.
<?php
function str_time($stamp)
{
$difference = time() - $stamp;
$intervals = array(
'minute' => 60,
'hour' => 3600,
'day' => 86400,
'month' => 2628000,
'year' => 31536000
<?php
require '../engine.php';
system::import('blog');
if(http::get('article'))
{
$article = blog::get_article(http::get('article'));
$article or page_not_found();
@jamsesso
jamsesso / mysql.php
Created July 23, 2011 16:57
Class to manage multiple MySQL server connections in an application.
<?php
class mysql extends mysqli
{
public static $servers = array();
public static function ignite_server($name, $host, $username, $password, $db, $port = null, $socket = null)
{
if(is_null($port))
$port = ini_get('mysqli.default_port');
<?php
namespace Scarf\Views;
use Scarf\Models\Contacts;
use Scarf\Library\Layout\Templates;
/* Creates a URL at http://.../contacts */
class Contacts
{
/* The main page when /contacts is visited. */
<?php
namespace Scarf\Views;
class Introduction
{
public function main()
{
write("Scarf is a modern, fast, maintainable,
easy-to-use rapid development PHP framework.");
}
}