Skip to content

Instantly share code, notes, and snippets.

View dhotson's full-sized avatar

Dennis Hotson dhotson

View GitHub Profile
from __future__ import division
from math import *
from random import random, gauss
def p_smooth(c, n):
return (c + 1) / (n + 2)
def binomial(c, n):
p = p_smooth(c, n)
return 2*sqrt((1/n if n > 0 else 1) * p * (1-p))
<?php
namespace Bernard\Driver;
class BeanstalkDriver implements \Bernard\Driver
{
private
$_beanstalk,
$_config
;
@dhotson
dhotson / hhvm.diff
Created July 31, 2014 13:47
Pheasant patch to make tests pass in HHVM
diff --git a/lib/Pheasant/Database/Mysqli/ResultIterator.php b/lib/Pheasant/Database/Mysqli/ResultIterator.php
index 17efd64..dbcd755 100755
--- a/lib/Pheasant/Database/Mysqli/ResultIterator.php
+++ b/lib/Pheasant/Database/Mysqli/ResultIterator.php
@@ -5,7 +5,7 @@ namespace Pheasant\Database\Mysqli;
class ResultIterator implements \SeekableIterator, \Countable
{
private $_result;
- private $_position;
+ private $_position = 0;
<?php
namespace Bugsnag;
class ErrorHandler
{
private
$client,
$oldExceptionHandler,
$oldErrorHandler,
'-----------< Yet Another 3D Demo/Engine v2.0 >---------
'By Dennis Hotson (djdennie69@hotmail.com)
'
'INSTRUCTIONS:
'* Use the mouse to look around
'* Use arrow keys OR "WASD" to move/strafe
'* Use the - and + keys to move up/down
'* Click left mouse button to rotate cube
'* Click right mouse button to rotate square
'
@dhotson
dhotson / heroku.js
Last active August 29, 2015 14:20
Heroku schema
// curl https://api.heroku.com/schema -H "Accept: application/vnd.heroku+json; version=3"
{
"$schema": "http://interagent.github.io/interagent-hyper-schema",
"definitions": {
"account-feature": {
"description": "An account feature represents a Heroku labs capability that can be enabled or disabled for an account on Heroku.",
"$schema": "http://json-schema.org/draft-04/hyper-schema",
"stability": "production",
"strictProperties": true,
"title": "Heroku Platform API - Account Feature",
@dhotson
dhotson / -
Created August 18, 2015 03:05
hello
require 'eventmachine'
EM.run do
EM.epoll
# Create a channel to push data to
EventChannel = EM::Channel.new
# The server simply subscribes client connections to the channel on connect,
# and unsubscribes them on disconnect.
@dhotson
dhotson / gist:295737
Created February 5, 2010 11:59
A little Object Relational Mapper in PHP
<?php
/**
* A little Object Relational Mapper in PHP
* @author dennis.hotson@gmail.com
*/
class Post
{
public $title;
#!/usr/bin/env php
<?php
chdir(dirname(__FILE__));
require_once '../lib/kelpie/kelpie_init.php';
require_once('../includes/myframework.php');
class MyApp
{
public function __construct()