Skip to content

Instantly share code, notes, and snippets.

@bwiggs
bwiggs / StockQuote.php
Created October 30, 2012 15:13
Stock Quote Retreiver Model for CakePHP project
<?php
/**
* Model that handles the Stock quote.
*/
class StockQuote extends AppModel {
/**
* update() - main method called by cron jobs and task schedulers to update
* latest stock quote information
@bwiggs
bwiggs / composer.json
Created October 26, 2012 20:51
composer.json
{
"require": {
"twig/twig": "1.6.*",
"twig/extensions": "dev-master",
"slim/slim": "1.6.*",
"slim/extras": "1.0.*"
}
}
@bwiggs
bwiggs / .htaccess
Created July 19, 2012 02:21
CakePHP Filename Cache Busting
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
@bwiggs
bwiggs / html.php
Created June 20, 2012 06:22
html.php
<?php
foreach ($visible as $destinationLink) {
echo
"<li class='selected_list_item' id=" . $destinationLink['Destination']['slug'] . ">
<div class='trip_info'>
<a href='#' class='close_list_item' rel='" . $destinationLink['Destination']['slug'] . "'>X</a>
<span class='insider_carousel_header'>Meet an insider</span>
<div>
<a href='TODO' class='location'>" . $destinationLink['Destination']['name'] . "</a>
@bwiggs
bwiggs / haproxy.config
Created January 22, 2012 10:21
HAProxy Config File Example
global
#debug # uncomment to enable debug mode for HAProxy
defaults
mode http # enable http mode which gives of layer 7 filtering
timeout connect 5000ms # max time to wait for a connection attempt to a server to succeed
timeout client 50000ms # max inactivity time on the client side
timeout server 50000ms # max inactivity time on the server side
backend legacy # define a group of backend servers to handle legacy requests
@bwiggs
bwiggs / SplitABController.cs
Created January 12, 2012 03:10
MVC Split AB Test Controller
using System;
using System.Web;
using System.Web.Mvc;
public abstract class SplitABController : Controller
{
private static readonly Results results = new Results();
private const string B_TEST_SUFFIX = "_B";
private const string SPLIT_TEST_VIEW_COOKIE_NAME = "SPLIT_TEST_VIEW_COOKIE";
private static ViewFilesCache cache;
@bwiggs
bwiggs / DebuggingMacros.vb
Created November 29, 2011 22:16
DebuggingMacros.vb
' original code from Ingo Rammer (http://weblogs.thinktecture.com/ingo/2011/02/attach-to-process-macro-for-visual-studio-2010.html)
' ===== Create the Macro =====
' 1. Tools > Macros > Macro IDE
' 2. Right Click MyMacros > Add > Add Module
' 3. Paste in the code below:
' 4. Rename the Macro file DebuggingMacros
' ==== Add Macros to Debug Toolbar ====
@bwiggs
bwiggs / gist:1367943
Created November 15, 2011 18:49
interpolation.js
(function(window) {
// Constructor
var Interpolation = function() {
this.speed = 0.5;
this.spring = 0.5;
this.target = 1;
this.value = 0;
this.velocity = 0;
this.running = false;
var hbolo = hbolo || {};
hbolo.InputManager = function () {
var keyStates = {
forward: false,
reverse: false,
left: false,
right: false,
class CreatePartsVehiclesJoinTable < ActiveRecord::Migration
def self.up
create_table :parts_vehicles, :id => false do |t|
t.integer :part_id
t.integer :vehicle_id
end
end
def self.down
drop_table :parts_vehicles