Skip to content

Instantly share code, notes, and snippets.

// Nano Loader
(function() {
nano = {
v: "1.0",
load: function(u, cb) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = u;
s.onload = cb;
s.onreadystatechange = function() {
/**
* Script:
* Screensaver.js - Screensaver functionality written in MooTools.
*
* License:
* MIT-style license.
*
* Author:
* Jose Prado
*
@cowlby
cowlby / Cleanclick.js
Created November 19, 2009 05:55
Collection of code snippets
(function() {
var keys = new Hash({ 16: false, 18: false }); // Shift + Option/Alt keys
if (Browser.Platform.win) { keys[17] = false; } // Control key
if (Browser.Platform.mac) { keys[91] = false; } // Command Key
window.addEvent('domready', function() {
$(document.body).addEvents({
'keydown': function(e) {
if (keys.has(e.code)) { keys[e.code] = true; }
},
var el = null;
describe('Element.getRotation', {
before_each: function() { el = new Element('div'); },
'should return correct values': function() {
el.setStyle('-webkit-transform', 'rotate(0deg)');
value_of(el.getRotation()).should_be(0);
javascript:(function(){var b="inurl:reddit.com",a="http://www.searchreddit.com/",c=/\/r\/[\w\.]+\//.exec(document.location.pathname);b=(c)?b+c[0]:"";window.location=a+"?s="+b})();
@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;
<?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 / 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.
@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 / 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 %}