Skip to content

Instantly share code, notes, and snippets.

<h1><%= @path %></h1>
<ul>
<% if archives.length > 0 %>
<% archives.sort! {|x,y| y[:date] <=> x[:date] } %>
<% archives.collect {|a| a[:date].year }.uniq.each do |year| %>
<h3><%= year %></h3>
<% archives.select {|e| e[:date].year == year }.each do |entry| %>
<li>
component output="no" {
public function fileAnchorTag(
required relativePath,
displayName,
fileType) {
// determine file details
var fileInfo = GetFileInfo(ExpandPath(relativePath));
// set default params
@mhayes
mhayes / inheritance.js
Last active September 15, 2015 22:59
Simple javascript inheritance (as i currently understand it)
var Mammal = function (name) {
this.name = name;
};
Mammal.prototype.sayHello = function () {
return "Hello, I'm a " + this.name;
}
var Cow = function (name) {
Mammal.apply(this, arguments);
@mhayes
mhayes / dprarray.cfc
Created September 3, 2010 17:58
ColdFusion array of structs sorting
component output="no" {
function init() {
variables.itemArray = [];
}
function append(item) {
ArrayAppend(variables.itemArray, arguments.item);
}
function sortBy(key){
@mhayes
mhayes / config.cfc
Created November 12, 2010 22:05
ColdFusion Environment Configuration Loader
component {
function init(required string configFile) {
variables.configFile = arguments.configFile;
variables.loadSections = ["common", CGI.SERVER_NAME];
return getConfig();
}
private function getConfig() {
var config = StructNew();
@mhayes
mhayes / qr.rb
Created December 5, 2010 04:27
Converts text to QR Code using Google Charts API
require 'net/http'
require 'uri'
print <<INFO
QR Code Generator
Generated codes will be saved to "label.png" in the current directory
INFO
print "Text to encode: "
label_contents = gets.strip
@mhayes
mhayes / geocode-autocomplete.js
Created December 14, 2010 17:16
uses Google Maps API for jQuery autocomplete
$(function(){
var geocoder = new google.maps.Geocoder();
/* use Google Geocoder in jQueryUI autocomplete widget */
$("#search").autocomplete({
minLength:8,
source:function(request,response) {
geocoder.geocode({address:request.term}, function(result,status){
var addresses = jQuery.map(result, function(address){ return address.formatted_address; });
@mhayes
mhayes / qr.cfc
Created December 16, 2010 18:31
Creates image tag that contains QR Code
component output="no" name="qr" {
function encode(required string message) {
var url = "http://chart.apis.google.com/chart";
url &= "?cht=qr&chs=200x200";
url &= "&chl=#message#";
return image_tag(url,200,200,message);
}
function image_tag(url,w,h,alt) {
@mhayes
mhayes / common_table_expression.sql
Created December 21, 2010 19:10
Common table expression usage in SQL Server
USE AdventureWorks2008;
WITH ShippingTime(OrderDate,ShipDate,DaysToShip) AS
(
SELECT OrderDate, ShipDate,DATEDIFF(day,OrderDate,ShipDate)
FROM Sales.SalesOrderHeader
)
SELECT *
FROM ShippingTime;
@mhayes
mhayes / 960.html
Created January 3, 2011 22:40
Simple grid layout using 960.gs
<!DOCTYPE html>
<html>
<head>
<link href="grid.css" type="text/css" rel="stylesheet" />
<style type="text/css">
p {border:1px solid black;}
.container_12 {background:#ddd; }
body{background:#ccc; }
</style>
</head>