Skip to content

Instantly share code, notes, and snippets.

View jwpage's full-sized avatar

Johnson Page jwpage

View GitHub Profile
#!/usr/bin/env node
var LifxClient = require('node-lifx').Client;
var series = require('async').series;
var range = require('range').range;
function calculateColor(i) {
var h = Math.min((40 * i) + 20, 40);
var s = (1.0 - Math.max((i - 0.5) * 2, 0)) * 100;
var b = i * 100;
@jwpage
jwpage / v2
Created June 23, 2015 10:36
avetmiss benchmarks
<?php
// 46.961s
// 684.50Mb
require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/Ubench.php';
ini_set('memory_limit', '-1');
@jwpage
jwpage / gist:d722b9c830788f38071c
Created August 28, 2014 03:57
BinaryReader optimisation test
<?php
use \PhpBinaryReader\BinaryReader;
require_once __DIR__.'/vendor/autoload.php';
include_once('/Users/johnson/Sites/xhgui/external/header.php');
$bytes = openssl_random_pseudo_bytes(100000);
$br = new BinaryReader($bytes);
while (!$br->isEof()) {
@jwpage
jwpage / test.php
Created August 21, 2014 12:22
BinaryReader string/resource memory usage comparison
<?php
require_once __DIR__.'/vendor/autoload.php';
$file = 'test.mp3';
// Load class into memory
class_exists('\PhpBinaryReader\BinaryReader');
echo "Test file size: ".filesize($file)."\n\n";
@jwpage
jwpage / Blueprint.php.patch
Last active August 29, 2015 14:00
Check for conflicting commands
diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php
index 9a6ffeb..260acca 100755
--- a/src/Illuminate/Database/Schema/Blueprint.php
+++ b/src/Illuminate/Database/Schema/Blueprint.php
@@ -60,9 +60,28 @@ class Blueprint {
{
foreach ($this->toSql($connection, $grammar) as $statement)
{
$connection->statement($statement);
}
@jwpage
jwpage / Blueprint.php.patch
Created April 17, 2014 22:43
Move implied commands to the end
diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php
index 836d013..888599b 100755
--- a/src/Illuminate/Database/Schema/Blueprint.php
+++ b/src/Illuminate/Database/Schema/Blueprint.php
@@ -105,7 +105,7 @@ class Blueprint {
{
if (count($this->columns) > 0 && ! $this->creating())
{
- array_unshift($this->commands, $this->createCommand('add'));
+ array_push($this->commands, $this->createCommand('add'));
@jwpage
jwpage / Blueprint.php.patch
Created April 17, 2014 07:05
Blueprint SQL Execution
diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php
index 836d013..035dc71 100755
--- a/src/Illuminate/Database/Schema/Blueprint.php
+++ b/src/Illuminate/Database/Schema/Blueprint.php
@@ -58,10 +58,22 @@ class Blueprint {
*/
public function build(Connection $connection, Grammar $grammar)
{
- foreach ($this->toSql($connection, $grammar) as $statement)
- {
@jwpage
jwpage / composer.json
Created April 7, 2014 02:10
Namespacer proof-of-concept
{
"require": {
"nikic/php-parser": "1.0.0-beta1"
}
}
@jwpage
jwpage / gist:4701622
Created February 3, 2013 12:38
Script to output the public method signatures for a class.
<?php
$class = new ReflectionClass('MY_CLASS');
$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
$signature = implode(' ', Reflection::getModifierNames($method->getModifiers()));
$signature.= ' function';
$signature.= ' '.$method->getName().' (';
@jwpage
jwpage / gist:4701603
Created February 3, 2013 12:34
Alllll the functions in Zend_Date
<?php
abstract class Zend_Date
{
public function __construct ($date = null, $part = null, $locale = null);
public static function setOptions (array $options = array ());
public function getTimestamp ();
public function setTimestamp ($timestamp);
public function addTimestamp ($timestamp);
public function subTimestamp ($timestamp);