Skip to content

Instantly share code, notes, and snippets.

@daviddesberg
daviddesberg / CreatingAService.php
Last active December 12, 2015 10:38
Creating a Twitter OAuth1 Service
<?php
use OAuth\ServiceFactory;
use OAuth\Common\Storage\Session;
use OAuth\Common\Consumer\Credentials;
// create a factory
// optional constructor argument defines the type of http client to use for the services this factory creates
$factory = new ServiceFactory();
// tokenstorageinterface implementation
@daviddesberg
daviddesberg / JSONRoutingTableDumper.cpp
Created February 5, 2013 23:41
Windows routing table dumper
#include <iostream>
#include <string>
#include <sstream>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
int main()
@daviddesberg
daviddesberg / ClientSideSessionHandler.php
Created September 13, 2012 03:19
Client-side PHP Sessions
<?php
class ClientSideSessionHandler implements SessionHandlerInterface
{
const SESSION_COOKIE_NAME = 'data';
private $cryptor;
private $cookieJar;
private $encryptionKey;
private $signingKey;
@daviddesberg
daviddesberg / OverlapCalculator.php
Created August 24, 2012 03:20
Time Interval Overlap Calculator
<?php
/**
* Calculates the amount of overlap between a source time range and a variable number of compared time ranges.
* Implements a subset of Allen's Interval Algebra.
* With contributions by rdlowery.
*/
class OverlapCalculator {
/**
* @var int