Skip to content

Instantly share code, notes, and snippets.

@cowlby
cowlby / mount_ebs.sh
Last active August 29, 2015 14:08 — forked from stingh711/mount_ebs.sh
#!/bin/bash
#attach the EBS to /dev/sdf before running it
#format EBS
mkfs -t ext4 /dev/xvdf
#copy original /var to /dev/xvdf
mkdir /mnt/new
mount /dev/xvdf /mnt/new
cd /var
@cowlby
cowlby / generate.php
Created December 3, 2013 20:02
This script can be used for generating PHP model for PDT. It builds PHP functions according to the loaded extensions in running PHP, using complementary information gathered from PHP.net documentation.
<?php
/**
* This script can be used for generating PHP model for PDT.
* It builds PHP functions according to the loaded extensions in running PHP,
* using complementary information gathered from PHP.net documentation
*
* @author Michael Spector <[email protected]>
*/
if (version_compare(phpversion(), "5.0.0") < 0) {
@cowlby
cowlby / gist:1603241
Created January 12, 2012 21:27 — forked from tankchintan/gist:1335220
Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.rpm
# Rename the file downloaded, just to be nice
mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm
# Install Java
sudo rpm -i jdk-7u1-linux-i586.rpm
# Check if the default java version is set to sun jdk
@cowlby
cowlby / reflector.conf.php
Created December 7, 2011 02:12
PHP script that creates PHP stubs for PDT from extensions and docbooc XML
<?php
define('DOCBOOK', '/var/www/Reflector/phpdoc/reference/');
@cowlby
cowlby / CacheInterface.php
Created November 4, 2011 00:47
Write-through caching of session data
<?php
/**
* Cache interface to provide a uniform interface for the SessionStorage classes.
*
* @author Jose Prado <[email protected]>
*/
interface CacheInterface
{
/**
@cowlby
cowlby / collection_widget.twig
Created October 17, 2011 23:32
Customizing form collections in Symfony2
{% block collection_widget %}
{% spaceless %}
<div class="collection">
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form) }}
<ul>
{% for rows in form %}
@cowlby
cowlby / form_div_layout.html.twig
Created October 17, 2011 18:25
Customizing form collections in Symfony2
{% block collection_widget %}
{% spaceless %}
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %}
{% endif %}
<div class="collection" {{ block('widget_container_attributes') }}>
{{ form_errors(form) }}
<table>
<thead>
<tr>
@cowlby
cowlby / PSR-0-final-proposal.md
Created October 17, 2011 18:08 — forked from Thinkscape/PSR-0-final-proposal.md
PSR-0 Final Proposal (PHP Standards Working Group)

PSR-0 Final Proposal (PHP Standards Working Group)

The following describes the mandatory requirements that must be adhered to for autoloader interoperability.

Mandatory:

  • A fully-qualified namespace and class must have the following structure \ <Vendor Name> \ (<Namespace>)* \ <Class Name>
  • Each namespace must have a top-level namespace ("Vendor Name").
  • Each namespace can have as many sub-namespaces as it wishes.
  • Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  • Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
<?php
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
/**
* @ORM\Entity
* @ORM\Table(name="challenges")
@cowlby
cowlby / Schema.sql
Created April 19, 2011 00:29
Scrapes the Potato Counter off the Aperture Science website using Zend_Http_Client as the client, DOMDocument as the DOM browser, and Zend_Db as the interface to a simple database.
CREATE TABLE `potatoes` (
`id` smallint(11) NOT NULL AUTO_INCREMENT,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`count` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=64 DEFAULT CHARSET=latin1;