Skip to content

Instantly share code, notes, and snippets.

View daviddoran's full-sized avatar

David Doran daviddoran

  • Stripe
  • Dublin, Ireland
View GitHub Profile
@daviddoran
daviddoran / short-random.sh
Created February 19, 2013 15:22
Needed to generate a few random-looking strings for a spec document. For OSX (pbcopy).
# Generate 7-char string and copy to pasteboard (e.g. "ff757eb" and "41d0a9a")
head -c 10 /dev/urandom | shasum | head -c 7 | pbcopy
# Use date as input
date | shasum | head -c 7 | pbcopy
@daviddoran
daviddoran / backup-dokuwiki.sh
Created September 24, 2013 10:40
Easily back up the content of a dokuwiki site to a git repository each hour. Only commits when there are changes.
#!/bin/sh
cd /var/www/dokuwiki/data && git add . && git add -u && git commit -a -m "Content update `date +'%H:%M %d/%m/%Y %Z'`" && git push origin master
@daviddoran
daviddoran / Post BeforeSave.js
Created July 30, 2014 16:56
A Parse beforeSave callback that can be used to check that an uploaded image is not empty.
//Change 'Post' to the name of your class
Parse.Cloud.beforeSave('Post', function(request, response) {
//Change 'file' to the name of the column containing the image
var imageUrl = request.object.get('file').url();
Parse.Cloud.httpRequest({
url: imageUrl
}).then(function(httpResponse) {
if (!(httpResponse.buffer && httpResponse.buffer.length)) {
response.error('Uploaded image was empty or invalid');
} else {
@daviddoran
daviddoran / unidecode-concat.js
Created March 19, 2015 12:36
A small script to concatenate the unidecode data modules into a single module
// You can use this script to generate xall.js like so:
// node unidecode-concat.js > xall.js
var xfiles = require('require-all')({
dirname : __dirname + '/data/',
filter : /x(.*?)\.js$/,
excludeDirs : /^\.(git|svn)$/
});
process.stdout.write('module.exports = ');
guides/hack/25-typechecker/05-modes-examples/call-into-decl.php:16:10,22: Unbound name (typing): Hack\UserDocumentation\TypeChecker\Modes\Examples\CallIntoDecl\Decl\php_func (Typing[4107])
guides/hack/25-typechecker/05-modes-examples/call-into-decl.php:16:10,22: Unbound name: Hack\UserDocumentation\TypeChecker\Modes\Examples\CallIntoDecl\Decl\php_func (a global constant) (Naming[2049])
guides/hack/25-typechecker/05-modes-examples/call-into-decl.php:16:10,22: Unbound name: Hack\UserDocumentation\TypeChecker\Modes\Examples\CallIntoDecl\Decl\php_func (a global function) (Naming[2049])
<?hh // strict
namespace Hack\UserDocumentation\TypeChecker\Modes\Examples\CallIntoDecl;
require __DIR__ . '/decl.inc.php';
// This actually makes the call to calling_into_decl() since we cannot have
// top level functions in strict mode
require __DIR__ . '/main-function.inc.php';
// use \Hack\UserDocumentation\TypeChecker\Modes\Examples\Decl as Decl;
<?hh // strict
$m = Map {
0 => 'one',
1 => 'two',
2 => 'three',
3 => 'four',
4 => 'five',
};