Skip to content

Instantly share code, notes, and snippets.

View dhotson's full-sized avatar

Dennis Hotson dhotson

View GitHub Profile
<?php
namespace Bernard\Driver;
class BeanstalkDriver implements \Bernard\Driver
{
private
$_beanstalk,
$_config
;
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
// Find files of all classes loaded..
$loader = require('vendor/autoload.php');
$files = array_filter(array_map(function($c) use ($loader) {
return $loader->findfile($c);
}, get_declared_classes()));
// Better solution.. find all required files
array_map(function($f) use ($i) {
<?php
function wilson($p, $n) {
$z = 1.9599;
$z2 = pow($z, 2);
return array(
($p + $z2/(2*$n) - $z * sqrt(($p*(1-$p) + $z2/(4*$n)) / $n)) / (1 + $z2/$n),
($p + $z2/(2*$n) + $z * sqrt(($p*(1-$p) + $z2/(4*$n)) / $n)) / (1 + $z2/$n),
);
<?php
// Parse HTTP HOST header hostname and port according to http://tools.ietf.org/html/rfc3986.html
$h16 = '[[:xdigit:]]{1,4}';
$subDelims = "[!$&'()*+,;=]";
$pctEncoded = '%[[:xdigit]][[:xdigit]]';
$unreserved = '[-._~[:alpha:][:digit:]]';
$decOctet = <<<EOS
(?:
diff --git a/lib/Pheasant/DomainObject.php b/lib/Pheasant/DomainObject.php
index 41a103c..be04890 100755
--- a/lib/Pheasant/DomainObject.php
+++ b/lib/Pheasant/DomainObject.php
@@ -65,9 +65,9 @@ class DomainObject
* Used by the default initialize() method, returns the table name to use
* @return string
*/
- public function tableName()
+ public static function tableName()
@dhotson
dhotson / screensaver.jl
Created February 25, 2013 03:19
A screensaver in Julia
pallete = Array(String, 93)
i = 1
for bg = 232:(255-1)
for char in [" ", "░", "▒", "▓"]
pallete[i] = "\e[38;5;$(bg+1)m\e[48;5;$(bg)m$(char)\e[0m"
i += 1
end
end
pallete[93] = "\e[48;5;$(255)m \e[0m"
# ccv_dense_matrix_t* image = 0
image = Array(Ptr{Void},0)
# int ccv_read_impl(const void* in, ccv_dense_matrix_t** x, int type, int rows, int cols, int scanline);
r = ccall(
(:ccv_read_impl, "libccv"),
Int32,
(Ptr{Uint8}, Ptr{Ptr{Void}}, Int, Int, Int, Int),
"/home/vagrant/dev/julia/test.png", image, 0x100 | 0x020, 0, 0, 0)
<?php
// Instructions: save this file to the base diretory of the kumite-moa repo..
require 'vendor/autoload.php';
/**
* Calculates the statistical significance of a boolean experiment over
* multiple events (e.g. contests), where the result for each event is
* a true/false outcome (e.g. contest was or was not refunded).
<?php
use Symfony\Component\HttpFoundation\Request;
class KelpieSymfonyAdaptor
{
public function __construct($app)
{
$this->_app = $app;
}