Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / XmlElement.php
Created August 26, 2015 16:50
Simple XML Element Builder (Proxies to SimpleXMLElement class)
<?php
use \SimpleXMLElement;
use \BadMethodCallException;
class XmlElement
{
/**
* The default XML DOCTYPE.
*
* @var string
@ziadoz
ziadoz / footer.php
Created February 6, 2014 17:34
Perch Bug — When using the perch_content_create() function to create a region and then the perch_content() method to retrieve it, two regions get created — a shared one and one for the page.
@ziadoz
ziadoz / console.php
Last active August 29, 2015 14:06
Add PHPMig Commands to Custom Symfony Console
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Phpmig\Console\Command\CheckCommand;
use Phpmig\Console\Command\DownCommand;
@ziadoz
ziadoz / AbstractForm.php
Created September 24, 2014 17:57
Aura Input / Filter Wrapper
<?php
/**
* A simple wrapper around Aura Input.
*/
use Aura\Input\Form;
use Aura\Input\Builder;
use Aura\Input\Filter;
use Aura\Html\HelperLocatorFactory;
use Aura\Filter\FilterFactory;
@ziadoz
ziadoz / Preferences.sublime-settings
Last active August 29, 2015 14:08
Sublime Text 3 Settings
{
"auto_close_tags": true,
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"create_window_at_startup": false,
"font_face": "Menlo",
"font_size": 12,
"highlight_line": true,
"ignored_packages":
[
"Vintage",
@ziadoz
ziadoz / fixvcs.rb
Last active August 29, 2015 14:10
Reset Mecurial and Git Repositories
#! /usr/bin/env ruby
Dir.glob("~/Projects/**").each do |dir|
next unless File.directory?(dir)
is_hg = File.directory?(File.join(dir, '.hg'))
is_git = File.directory?(File.join(dir, '.git'))
puts "Fixing " + File.basename(dir)
Dir.chdir(dir)
@ziadoz
ziadoz / reloadvhosts.rb
Last active August 29, 2015 14:10
Update Sites-Available / Sites-Enabled Symlinks (Ubuntu 14.04 + Apache)
#! /usr/bin/env ruby
$VEBOSE = nil
class String
def colourise(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
@ziadoz
ziadoz / index.php
Last active August 29, 2015 14:16
Simple PHP HTTP Handling
<?php
// See Error Handling in PHP: https://nomadphp.com/2015/02/25/nomadphp-2015-02-us-lt2/#
$display = function ($status, $headers = array(), $content = '') {
http_response_code($status);
foreach ($headers as $key => $value) {
header($key . ': ' . $value);
}
@ziadoz
ziadoz / sf-components.js
Created July 18, 2015 17:41
Extract Symfony Components as Markdown
// http://symfony.com/components
var components = [];
$('.components-list tr').each(function() {
var name = $.trim($(this).find('td.name').text()),
link = 'http://' + document.domain + $(this).find('td.name a').attr('href'),
desc = $.trim($(this).find('td:eq(1)').text());
if (name && link && desc) {
@ziadoz
ziadoz / setup.sh
Created July 20, 2015 22:39
Ubuntu 12.10 Setup
# Update Ubuntu
sudo apt-get install build-essential
sudo apt-get update
sudo apt-get upgrade
# Version Control
sudo apt-get install git mercurial subversion
# Mobile Shell (MOSH)
# See: http://mosh.mit.edu/