Skip to content

Instantly share code, notes, and snippets.

View wilmoore's full-sized avatar
🦄
Proverbs 3:21

Wil (₩) Moore III wilmoore

🦄
Proverbs 3:21
View GitHub Profile
@wilmoore
wilmoore / zf2-mvc-restful-trait.php
Created January 17, 2011 17:44
Using Traits instead of inheritance to build a Restful Dispatcher in ZF2 MVC
// REF: http://framework.zend.com/wiki/display/ZFDEV2/Proposal+for+MVC+Interfaces
trait RestDispatcher
{
public function dispatch(Request $request, Response $response = null)
{
if (!$request instanceof HttpRequest) {
throw new DomainException('REST expects HTTP requests');
}
@wilmoore
wilmoore / gearman-testing.sh
Created January 18, 2011 08:12
Gearman Command-Line Testing (quick job mocking)
# this will submit a job where workers servicing requests for "handleQueue" will receive a QueueID of 1
gearman -f handleQueue 1
@wilmoore
wilmoore / Mongo Mongo Boulder
Created January 21, 2011 17:50
Schema Design
Schema Design
> db.posts.find()
post = {
author: "Herge"
date: new Date(),
text: "Destination Moon",
tags: ['comic", 'adventure"]}
@wilmoore
wilmoore / top3stories.js
Created January 26, 2011 01:52 — forked from DTrejo/top3stories.js
NodeJs Web Scraping w/ JQuery
// Scraping Made Easy with jQuery and SelectorGadget
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga)
// by David Trejo
//
// Install node.js and npm:
// http://joyeur.com/2010/12/10/installing-node-and-npm/
// Then run
// npm install jsdom jquery http-agent
// node numresults.js
//
@wilmoore
wilmoore / original.php
Created January 26, 2011 23:47
Re-factor a setBirthDate method for cleaner code
public function setBirthDate($birthDate) {
// Allow setting with DateTime object or string date
// TODO: Check if object is a subclass of DateTime, watch out for namespaces
$this->birthDate = is_object($birthDate) ? $birthDate : (!empty($birthDate) ? new \DateTime($birthDate) : null);
return $this;
}
@wilmoore
wilmoore / log.js
Created February 1, 2011 22:20
JavaScript Snippets for new projects
// Slightly smaller version of Paul's lightweight log wrapper -- Thanks Paul Irish
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog
window.log=function(){log.history=log.history||[];log.history.push(arguments);this.console&&console.log(Array.prototype.slice.call(arguments))};
<createTable tableName="contact">
<column name="id" type="bigint">
<constraints primaryKey="true"
nullable="false"
autoIncrement="true"/>
</column>
<column name="first_name" type="varchar(50)" />
<column name="middle_initial" type="varchar(5)" />
<column name="last_name" type="varchar(50)" />
<column name="gender" type="varchar(50)" />
@wilmoore
wilmoore / changelog-template.xml
Created February 5, 2011 05:57 — forked from tlberglund/gist:727521
Sample Liquibase Schema Refactorings
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
</databaseChangeLog>
@wilmoore
wilmoore / object-create.js
Created February 9, 2011 21:13
JavaScript Object Create Function
if (typeof Object.create !== 'function') {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
@wilmoore
wilmoore / sass_and_less_compared.markdown
Created February 10, 2011 06:17 — forked from chriseppstein/sass_and_less_compared.markdown
Sass/Less Comparison (updated 2011-02-09) -- thanks to chriseppstein for starting this

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For less, I'm using the ruby version because this is what they suggest on the website. The javascript version may be different.

Variables