Skip to content

Instantly share code, notes, and snippets.

@mhayes
mhayes / action_item.rb
Created Jun 15, 2010
A Mongoid implementation of meeting minutes
View action_item.rb
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 Jul 1, 2010
Use to collect sort position from jqueryUI
View sortOrder.js
$(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 Jul 16, 2010
ColdFusion migrations idea
View migration.cfm
<!---
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>
View col.cfc
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 Aug 10, 2010
Rails3 application template
View base_template.rb
#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
View articles.rhtml
<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>
View actionView.cfc
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 Sep 3, 2010
ColdFusion array of structs sorting
View dprarray.cfc
component output="no" {
function init() {
variables.itemArray = [];
}
function append(item) {
ArrayAppend(variables.itemArray, arguments.item);
}
function sortBy(key){
@mhayes
mhayes / config.cfc
Created Nov 12, 2010
ColdFusion Environment Configuration Loader
View config.cfc
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 Dec 5, 2010
Converts text to QR Code using Google Charts API
View qr.rb
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
You can’t perform that action at this time.