Skip to content

Instantly share code, notes, and snippets.

View dhotson's full-sized avatar

Dennis Hotson dhotson

View GitHub Profile
<?php
// Define the 'class' class
$class = Obj()
->fn('new', function ($class) {
$newClass = Obj($class->methods)
->fn('new', function($class) {
$obj = Obj($class->imethods);
$args = func_get_args();
array_shift($args);
# require 'ap'
def months_between(d1, d2)
(d2.year * 12 + d2.month) - (d1.year * 12 + d1.month)
end
today = Date.today
first = (today - 10.weeks).beginning_of_month
last = today.end_of_month
require "set"
class Batch
def initialize(results = {}, &blk)
@ids = ::Set.new
@blk = blk
@promises = {}
@results = results
end
@dhotson
dhotson / main.go
Last active August 14, 2020 04:00
package main
import (
"fmt"
"image"
"math"
"os"
"sync"
"github.com/disintegration/gift"
@dhotson
dhotson / hiptext.rb
Created October 16, 2018 14:25
Homebrew formula for jart/hiptext (https://github.com/jart/hiptext)
require "formula"
class Hiptext < Formula
homepage "https://github.com/jart/hiptext"
head "https://github.com/jart/hiptext.git", :branch => "master"
depends_on "pkg-config" => :build
depends_on "ragel" => :build
# depends_on :libpng
depends_on "jpeg"
Learn tab in launcher, free examples.
moving camera:
l+r at same time
Hold right, + wasd+qe move camera
fog: quickest way to get a basic background
light: atmosphere option -> sun
<?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()