Skip to content

Instantly share code, notes, and snippets.

View bingo
#!/usr/bin/env php
<?php
function shuffleBalls(): array
{
$balls = range(1, 90);
shuffle($balls);
return $balls;
}
View gist:5e2998dc5a28034ea726
Verifying that +blongden is my blockchain ID. https://onename.com/blongden
View composer.json
{
"require": {
"php": ">=5.4.0",
"elasticsearch/elasticsearch": "~1.3"
}
}
View Collection.xml
<?xml version="1.0"?>
<resource>
<total>2</total>
<resource rel="errors" logref="50">
<link rel="help" href="http://.../"/>
<message>"username" field validation failed</message>
</resource>
<resource rel="errors" logref="55">
<link rel="help" href="http://.../"/>
<message>"postcode" field validation failed</message>
@blongden
blongden / item-collection.json
Last active Aug 29, 2015
Example todo resource
View item-collection.json
{
"_embedded": {
"todos": [
{
"todoid": 1,
"todoTitle": "Finish coding stuff",
"todoDateDue": "2014-09-25T18:00:00Z",
"todoNotes": "Have you even worked out what you are doing yet?",
"dateCreated": "2014-09-25T10:00:00Z",
"dateUpdated": "2014-09-25T11:30:00Z",
View gist:9930850
### Keybase proof
I hereby claim:
* I am blongden on github.
* I am blongden (https://keybase.io/blongden) on keybase.
* I have a public key whose fingerprint is 6FE5 6F28 B641 70DD AA89 AA70 35CC AC97 BFF8 E9D3
To claim this, I am signing this object:
View gist:5643732
<?php
$array =
[ 'forename' => 'Ben'
, 'lastname' => 'Longden'
, 'company' => 'Inviqa'
, 'purpose' => 'Trying to decide if this sucks or not'
];
View test.html
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="http://ricostacruz.com/jquery.transit/jquery.transit.min.js"></script>
<script type="text/javascript">
$.fn.flip = function(back, duration) {
duration = duration || 200;
front = this;
$(back).css({transform: 'rotateY(270deg)'});
@blongden
blongden / benchmark.php
Created Apr 10, 2012
Benchmark a PHP function
View benchmark.php
<?php
$calibration = benchmark(function() { });
$benchmark = benchmark(function() {
sleep(1);
});
echo "Calibration run: ".number_format($calibration)."/sec\n";
echo "Benchmark run: ".number_format($benchmark)."/sec\n";
echo 'Approximate code execution time (seconds): '.number_format((1/$benchmark) - (1/$calibration), 10);