Skip to content

Instantly share code, notes, and snippets.

@slifin
slifin / folderphplinting
Created May 7, 2015 12:24
How to lint PHP files recursively in a folder
find ./ \( -name "*.php" \) -print0 | xargs -0 -n 1 php -l
@slifin
slifin / snippet.txt
Created June 8, 2015 08:19
f1 gd news
<p>After last year's F1 2014 arrived a bit late to the party, it feels like barely any time at all <a title="F1 2015 System Requirements" href="http://www.game-debate.com/games/index.php?g_id=20564&game=F1%202015" target="_self">F1 2015</a> has shown off. Codemaster's simulation racer is back for another crack at the world's second fastest sports (Badminton bizarrely takes the top spot), this time taking a generational leap with a swish looking new version of the Ego game engine. </p><p>As we all know, ideal barometer of visual loveliness is how good the rain and puddles look, something we actively despise in real life, and F1 2015 comes up trumps with its authentic weather effects. I've never had the pleasure of driving a Formula 1 car but these in-game screens certainly seem like the real deal. Which is just as well, because Codemasters is claiming F1 2015 is going to be the most authentic game in the series yet. <br><img expandable="true" src="../blog/images/_id1433499726_343178_6.jpg" width="575" height="
<?php
function partial_function() {
$applied_args = func_get_args();
return function() use($applied_args) {
return call_user_func_array('call_user_func', array_merge($applied_args, func_get_args()));
};
}
function foo($a, $b, $c) {
echo "a: {$a} b: {$b} c: {$c}\n";
@slifin
slifin / gist:d0655bc23e006130b958
Created July 11, 2015 21:28
PHP currying with placeholder support
<?php
class Placeholder{}
function curry(callable $func, ... $curriedArgs) {
return function(...$fulfillment) use ($func, $curriedArgs) {
return $func(...array_merge(array_map(function($arg) use ($fulfillment) {
if ($arg instanceof Placeholder)
return array_shift($fulfillment);
return $arg;
}, $curriedArgs), $fulfillment));
};
@slifin
slifin / curryandcompose.php
Last active October 3, 2015 19:37
currying so far
class Placeholder{}
function curry(callable $fn,...$start) {
return function (...$args) use ($fn, $start){
$apply = array_merge($start,$args);
$apply = array_map(function($v) use(&$args){
if ($v instanceof Placeholder)
return array_shift($args);
return $v;
},$apply);
@slifin
slifin / SomaReactV2.js
Created November 18, 2015 19:50
Front end client for Twitch plays The Myth of Soma
(function($){
$(document).ready(function(){
$('.player').click(function(e){
var posX = $(this).offset().left,
posY = $(this).offset().top,
x = e.pageX - posX
y = e.pageY - posY
percentX = x / $(this).width() * 100,
percentY = y / $(this).height() * 100;
$.post('http://82.38.95.234:8080/',{x:percentX,y:percentY},function(){
<?php
function transpose($matrix) {
return (new _)->map(function ($v, $k, $z, $matrix) {
return array_column($matrix, $k);
}, $matrix[0], $matrix);
}
<?php
function transposeC($matrix) {
return array_map(
(new _)->curry(function ($v, $k, $matrix) {
return array_column($matrix, $k);
}, (new _), (new _), $matrix),
$matrix[0], array_keys($matrix[0]));
}
@slifin
slifin / _.js
Last active February 22, 2016 11:21
js underscore
var _ = (function(){
function _(){}
_.prototype.compose = function(){
var args = Array.prototype.slice.call(arguments);
return args.reduce(function(f,g){
return function(){
return f(g.apply(this,arguments));
};
});
};
Accessibility
Hello, I'm Adrian, a web developer helping on the Kitnic project.
We have been working hard to ensure the platform is a responsible web citizen:
Responsive design for mobile clients
Ensuring the platform caters to smart phones and tablets
Accessible content even with JavaScript disabled
This is useful for services like the Internet Archive, Google Translate and more