Skip to content

Instantly share code, notes, and snippets.

View papayasoft's full-sized avatar

David Weinraub papayasoft

View GitHub Profile
@papayasoft
papayasoft / DataUri.php
Created June 28, 2016 08:55
A convenient class for working with Data URIs in PHP
<?php
/* The MIT License (MIT)
* Copyright (c) 2015 FlyingTopHat (lucas@flyingtophat.co.uk)
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
@papayasoft
papayasoft / test-zipcode-regex.js
Last active January 15, 2016 18:44
regex for pattern 00501 - 99999
var myTest = {
// Attempted test for pattern accepting anything 00501 - 999999
pattern: /^(0050[1-9]|005[1-9][0-9]|00[6-9][0-9]{2}|0[1-9]{4}|[1-9][0-9]{4})$/,
// Some sample good string
good: ['00501', '00502', '00509', '00590', '00599', '00600', '00699', '09999', '12345', '54321'],
// Some sample bad strings
@papayasoft
papayasoft / test_static.php
Last active August 29, 2015 13:58
Late static binding in PHP 5.3: The difference between self:: and static::
<?php
class MyBase
{
public static function myMethod()
{
return 'Called MyBase::myMethod()';
}
public static function doSomethingSelf()
@papayasoft
papayasoft / list_ummerged_branches
Created May 12, 2013 06:22
List branches merged into branch A, but not yet merged into branch B
# List branches merged into branch A, but not yet merged into branch B
# see http://stackoverflow.com/questions/8071079/git-list-branches-merged-into-a-branch-but-not-into-another
$ comm -12 --nocheck-order <(git branch --merged qa) <(git branch --no-merged master)

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

Vagrant::Config.run do |config|
# ...
config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
@papayasoft
papayasoft / index.php
Created May 29, 2012 04:12
Zend Framework bootstrap without Zend_Application
<?php
// A first run at a Zend Framework pre-1.8 bootstrap file that does not use Zend_Application
// Not tested, just thinking out loud...
// Do your PHP settings like timezone, error reporting
// ..
// Define path to application directory
defined('APPLICATION_PATH')