Skip to content

Instantly share code, notes, and snippets.

View devjack's full-sized avatar

Jack Skinner devjack

View GitHub Profile
@devjack
devjack / var-docblock
Last active August 29, 2015 13:57
Simple example of @var in docblocks for PHPStorm. Zend Framework 2 Service Locator as an example.
<?php
/** @var \SampleService\Service\UserService $service */
$userService = $serviceLocator->get('my-service\UserService');
@devjack
devjack / zf2-traits-sampleservice-controller
Last active August 29, 2015 13:57
ZF2 traits example: UserServiceAwareTrait
<?php
namespace SampleService\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
// Each 'AwareTrait' is expected to be configured by the controllers factory
use SampleService\Service\Feature\UserServiceAwareTrait;
use SampleService\Service\Feature\UserFilterServiceAwareTrait;
<?php
function colours() {
for($i=0x0; $i<0xffffff; $i++) {
yield $i;
}
}
foreach(colours() as $elePHPant) {
echo sprintf("I want a #%06X elePHPant!".PHP_EOL, $elePHPant);
}
<?php
function factorial($n) {
if($n==0) return 1;
$t=$n--;
while ($n > 0) {
$t*=($n--);
}
return $t;
}
@devjack
devjack / s3-header-hack.sh
Last active August 29, 2015 14:19
Cache-Control headers for S3 Static sites
#!/bin/bash
### USAGE ###
## Sets $1's objects' Cache-control:max-age= header to $2.
## e.g. ./s3-header-hack.sh mybucket 60 // for 60 seconds.
s3Cmd() {
cmd=$1;
if type $cmd 2>/dev/null; then
S3CMD=$cmd;
@devjack
devjack / java_parser.php
Last active August 29, 2015 14:20
A crude lexer and parser for simple operations and expressions
<?php
/**
* This is a very crude file designed to trace the symbol table for simple operations and expressions. Syntax is based on Java
* - assignment operators
* - basic arithmetic
* - apply multiple operators in a single expression (x + y + z etc.)
*
* Not implemented:
* - complex structures (loops, conditions, arrays, classes, packages etc. etc. etc.)
* - does not support type checking, type hinting (ignored in lexer) or anything 'useful'
@devjack
devjack / gist:0a5bde675515b1d5a324
Created August 6, 2015 10:21
Sculpin --url bug?
git clone https://github.com/sculpin/sculpin-blog-skeleton.git
cd sculpin-blog-skeleton/
printf "\nurl: http://mysite.com/" >> app/config/sculpin_site.yml
sculpin generate --server --watch --url=http://127.0.0.1:8000
Note that the URL's still contain mysite.com instead of 127.0.0.1
@devjack
devjack / index.txt
Created January 8, 2016 07:43
OneName Verification
Verifying that +developerjack is my blockchain ID. https://onename.com/developerjack
@devjack
devjack / list_of_languages.md
Last active January 9, 2016 04:17
Open source languages - codes of conduct
@devjack
devjack / keybase.md
Created November 23, 2017 04:08
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object: