Skip to content

Instantly share code, notes, and snippets.

@mhayes
mhayes / action_item.rb
Created June 15, 2010 23:28
A Mongoid implementation of meeting minutes
class ActionItem
field :due_date, :type => Date
field :completed, :type => Boolean
field :description
has_one_related :person
embedded_in :meeting, :inverse_of => :action_items
@mhayes
mhayes / sortOrder.js
Created July 1, 2010 18:14
Use to collect sort position from jqueryUI
$(function() {
$(".multiselect").multiselect();
$('#sortFields').sortable({
update:function(event,ui) {
var arr = $('#sortFields').sortable('toArray');
var newVal = "";
for(i=1; i<arr.length; i++) { newVal += arr[i] + ","; }
$('#sortOrderIds').val(newVal);
}
});
@mhayes
mhayes / migration.cfm
Created July 16, 2010 17:28
ColdFusion migrations idea
<!---
Database Migration Script:
Instructions here
--->
<cfsavecontent variable="up">
<!--- The contents in this section will be used to apply your update --->
CREATE VIEW [ats].[VW_R_T1]
AS
SELECT TOP 3 * FROM ats.vw_r
</cfsavecontent>
component name="col" {
function init(
required string name,
required string displayName,
required string dataType="string",
required boolean canSort=false,
required boolean canDisplay=false
) {
variables.tbl = "";
variables.name = arguments.name;
@mhayes
mhayes / base_template.rb
Created August 10, 2010 04:59
Rails3 application template
#base_template.rb
#sets up basic rails3 application structure with jquery-ujs
#remove index page
run "rm public/index.html"
@jquery_link = "http://code.jquery.com/jquery-1.4.1.min.js"
@jquery_ujs_link = "http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
#setup Gemfile
<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 / 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