Skip to content

Instantly share code, notes, and snippets.

@trev
trev / WSO2.2.php
Created December 14, 2011 23:11
WSO 2.2
/*ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f8907182ef665ac560d2043d7dee9ac1f89071
@trev
trev / prepdev.rb
Created January 19, 2012 05:00
Prepdev
#!/usr/bin/env ruby
# A script to setup a PHP dev. environment on a local MacOSX 10.6.8+ machine
require 'optparse'
# This hash will hold all of the options
# parsed from the command-line by
# OptionParser.
options = {}
optparse = OptionParser.new do |opts|
@trev
trev / filter.phtml
Created April 13, 2012 06:11
Magento Color Attribute Swatches Implementation
<ol>
<?php foreach ($this->getItems() as $_item): ?>
<li>
<?php if ($_item->getCount() > 0): ?>
// Add attribute option image before label
<?php if($_item->getName() == "Color") : ?>
<img src="<?php echo Mage::helper('attributeoptionimage')->getAttributeOptionImage($_item->getValue()); ?>" alt="" />
<?php endif; ?>
<a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
<?php else: echo $_item->getLabel() ?>
@trev
trev / jquery_plugin_pattern.js
Created August 18, 2012 07:38
Lightweight jQuery Plugin Pattern
/*!
* jQuery lightweight plugin boilerplate
* Original author: @ajpiano
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
// the semi-colon before the function invocation is a safety
// net against concatenated scripts and/or other plugins
// This modified snippet is from a function that accepts the current month(currentmonth) and period(period) and adds the period to the current month and lists every month within the new period. It can accept negative or positive periods.
function iterveningMonths(year, month, period) {
var movement = period < 0 ? -1 : 1; //Which way are we going?
var out = [];
var result;
for (var i = Math.abs(period); i !== 0; i--) {
month += movement; //Increment or decrement month
result = month % 12; //Check to see where that month is on a 12 month[0..11] period
@trev
trev / datecompare.js
Created September 4, 2012 04:50
Date comparison function
// How to refactor this bitch?
var dateCompare = function(date1, date2, operator) {
if(operator === ">") return date1.getTime() > date2.getTime();
if(operator === "<") return date1.getTime() < date2.getTime();
if(operator === "==") return date1.getTime() == date2.getTime();
//And so on and so forth with the other operators (>=, <=)
}
// Different approach but moves the conditional logic out
<script type="text/javascript" src="statics/js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#fire').click(function() { // This event fires when a button is clicked
var obj = $('#inputext').val();
$.ajax({ // ajax call starts
url: '/activity/', // JQuery loads serverside
data: 'obj=' + obj, // Send value of the clicked button
dataType: 'json', // Choosing a JSON datatype
success: function(data) // Variable data contains the data we get from serverside
// Version: v1.0.0-pre.2-378-g2e2b4ec
// Last commit: 2e2b4ec (2013-01-12 15:56:53 -0800)
(function() {
/*global __fail__*/
/**
Ember Debug
// Version: v1.0.0-pre.2-291-g0bec74f
// Last commit: 0bec74f (2013-01-05 12:03:02 -0600)
(function() {
/*global __fail__*/
/**
Ember Debug
// Version: v1.0.0-pre.2-347-gf187ea8
// Last commit: f187ea8 (2013-01-09 16:25:00 -0800)
(function() {
/*global __fail__*/
/**
Ember Debug