Skip to content

Instantly share code, notes, and snippets.

View IMSoP's full-sized avatar

Rowan Tommins IMSoP

View GitHub Profile
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
<?php
function memdiff() {
static $int = null;
$current = memory_get_usage();
if ($int === null) {
$int = $current;
} else {
print ($current - $int) . "\n";
/*
table activities
activity_id int (auto-increment) primary key
name varchar
description varchar
table cabins
cabin_id int (auto-increment) primary key
name varchar
<?php
$source = 'echo "Hello World!\\n";';
$gz = addslashes(gzdeflate($source,9));
$a = "<?php \$var='"; $b = "'; eval(gzinflate(stripslashes(\$var)));";
$result = $a.$gz.$b;
$fp = fopen('so-26316521-out.php', 'wb');
fwrite($fp, $result);
@IMSoP
IMSoP / gist:4ea904203eadf8d5859a
Created March 2, 2015 10:40
Simplified Sortable Interface
<?php
/**
* This Interface allows to hook into the global Xsort() functions.
* @ingroup SPL
* @since PHP 7.0
*/
interface Sortable
{
/**
<?php
public function insert_booking_date_match(Array $dates, $rule_id)
{
$sql = "-- insert_booking_date_match
BEGIN;
DELETE FROM
rule_booking_date_match
WHERE
rule_id = ".$rule_id."
<?php
class Closable_PDO
{
private $pdo;
public function __construct($dsn, $username, $password, $options) {
$this->pdo = new PDO($dsn, $username, $password, $options);
}
@IMSoP
IMSoP / Lazy_PDO.php
Last active January 22, 2016 19:11 — forked from anonymous/Lazy_PDO.php
<?php
class Lazy_PDO
{
private $pdo;
private $dsn, $username, $password, $options;
public function __construct($dsn, $username, $password, $options) {
$this->dsn = $dsn;
$this->username = $username;
Create Table test ( testjson jsonb );
Insert Into test ( testjson ) Values ( '[{"sid":"12345284239407942"}]'::jsonb );
Select testjson->>'sid' From test;
<?php
$options = [
'http' => [
'protocol_version' => '1.1',
'header' => 'Connection: Close'
],
];
$ctx = stream_context_create($options);
echo file_get_contents('https://http2.golang.org/reqinfo', false, $ctx);