Skip to content

Instantly share code, notes, and snippets.

@davethegr8
davethegr8 / provision.sh
Created November 21, 2016 18:49
update php.ini
php -r '
$matches = array("short_open_tag = Off", ";error_log = syslog", "display_errors = Off", "html_errors = Off");
$replacements = array("short_open_tag = On", "error_log = syslog", "display_errors = On", "html_errors = On");
foreach(glob("/etc/php5/*/php.ini") as $file) { file_put_contents($file, str_replace($matches, $replacements, file_get_contents($file)));}
'
@davethegr8
davethegr8 / deploy.sh
Last active August 29, 2015 14:16 — forked from bettin/deploy.sh
#!/bin/bash
# Requires s3cmd
# https://github.com/s3tools/s3cmd
# Variables
LIVE_BUCKET="s3://$1"
SITE_DIR='_site/' # run this script from your Jekyll root folder.
@davethegr8
davethegr8 / davethegr8.js
Created February 5, 2015 04:32
minecraft plugin
exports.greet = function( player ) {
echo( player, 'Hi ' + player.name);
}
var mine = {
house: function () {
var drone = box(blocks.brick.mossy,7,5,7);
drone.up().fwd(1).right(1);
drone.box(blocks.air,5,4,5);
},
@davethegr8
davethegr8 / ee.js
Last active August 29, 2015 14:05
event emitters from the CJS2014 talk
var ee = createEE()
ee.emit('foo', [1, 2, 3])
ee.on('bar', function (a, b, c) {
console.log('bar: ' + a);
return b;
});
console.log('emit returned: ' + ee.emit('bar', [1, 2, 3]));
@davethegr8
davethegr8 / ratio.less
Last active August 29, 2015 14:01
simple LESS mixin for typographic scales
// Based on the work of Tim Brown from http://alistapart.com/article/more-meaningful-typography
@fontRatioBase: 16; //In pixels
@fontRatioScale: 1.618;
.font-rem(@size) {
font-size: @size * @fontRatioBase * 1px;
font-size: @size * 1rem;
}
module Jekyll
class LessCssFile < StaticFile
attr_accessor :styles
def destination(dest)
File.join(dest, @dir, @name.sub(/less$/, 'css'))
end
def write(dest)
dest_path = destination(dest)
@davethegr8
davethegr8 / BatChannel.js
Last active December 28, 2015 11:19
BatChannel.js - a system for batching ajax requestsassumes (requires) that your server side code can handle routing the urls on it's own, and responds with something like this: { success: (true | false), ...other data.. }
//(c) 2013 Dave Poole zastica.com
//BatChannel.js - a system for batching ajax requests
//
//assumes (requires) that your server side code can handle
//routing the urls on it's own, and responds with something
//like this: { success: (true | false), ...other data.. }
var BatChannel = function(endpoint, interval) {
this.endpoint = endpoint;
this.pending = [];
from PIL import Image
backgroundColor = (0,)*3
pixelSize = 9
image = Image.open('input.png')
image = image.resize((image.size[0]/pixelSize, image.size[1]/pixelSize), Image.NEAREST)
image = image.resize((image.size[0]*pixelSize, image.size[1]*pixelSize), Image.NEAREST)
pixel = image.load()
@davethegr8
davethegr8 / HTML5 Scratch Pad
Last active December 11, 2015 23:18
Bookmarklets I've made the scratch pad is from https://coderwall.com/p/lhsrcq
javascript:(function(){window.open('data:text/html,%20<html%20contenteditable>');})();
@davethegr8
davethegr8 / php-cs-fixer-pre-commit.php
Created September 4, 2012 18:17 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*