Skip to content

Instantly share code, notes, and snippets.

View JasonOffutt's full-sized avatar

Jason Offutt JasonOffutt

  • Infusionsoft
  • Gilbert, AZ
View GitHub Profile
@JasonOffutt
JasonOffutt / EfCodeFirstExample.cs
Created April 20, 2011 17:56
Basic example of EF Code First w/ MVC...
public class Thing
{
[Key]
public int Id { get; set; }
public int ParentThingId { get; set; }
public virtual ParentThing Parent { get; set; }
}
public class ThingConfiguration : EntityTypeConfiguration<Thing>
@JasonOffutt
JasonOffutt / rawline.rb
Created June 28, 2011 17:21
Ruby script to get the RawLine gem included in irb
#!/usr/local/bin/ruby -w
require 'rubygems'
require 'rawline'
puts "*** Inline Editor Test Shell ***"
puts " * Press CTRL+X to exit"
puts " * Press CTRL+C to clear command history"
puts " * Press CTRL+D for line-related information"
puts "Press CTRL+E to view command history"
@JasonOffutt
JasonOffutt / IPersonService.cs
Created October 11, 2011 23:02
WCF REST Service API proposal
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
using Rock.Models.Crm;
[ServiceContract]
public interface IPersonService
{
/// <summary>
/// 'GET' /api/v1/people.json
@JasonOffutt
JasonOffutt / Global.asax.cs
Created October 17, 2011 15:42
First attempt at dynamic web service definition
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
using System.Data.Services;
using System.Linq;
using System.ServiceModel.Activation;
using System.Web;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
@JasonOffutt
JasonOffutt / IRestService.cs
Created October 22, 2011 18:41
Dynamic Rest Service API using MVC Controllers
using System;
using System.Web.Mvc;
public interface IRestService<TEntity>
{
ActionResult List(string format = "");
ActionResult Show(int id, string format = "");
ActionResult Show(Guid guid, string format = "");
ActionResult Create(TEntity entity, string format = "");
ActionResult Update(TEntity entity, int id, string format = "");
@JasonOffutt
JasonOffutt / org-setting.html
Created November 11, 2011 02:45
207 Miles Summary HTML
<ul class="summary-stats">
<li class="odd"><span id="count">0</span>Riders</li>
<li><span id="dollars">0</span>Raised</li>
<li class="odd"><span id="days">0</span>Days Left</li>
<li><a href="http://207miles.com/the-ride" title="Register Here">Register Here</a></li>
</ul>
@JasonOffutt
JasonOffutt / log.sh
Created March 17, 2012 00:00
Nodejitsu Error Log March 16 2012
error module.js:326 throw new Error("Cannot find module '" + request + "'"); ^
error Error: Cannot find module '/usr/local/src/jasonoffutt/Jordan_Rift/jordan_rift/app.js' at Function._resolveFilename (module.js:326:11) at Function.resolve (module.js:359:19) at Object.rewrite (/root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/lib/cli.js:75:36) at EventEmitter.run (/root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/lib/carapace.js:164:16) at runAndReport (/root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/bin/carapace:68:12) at /root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/node_modules/async/lib/async.js:126:25 at /root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/bin/carapace:58:23 at [object Object]. (/root/haibu-orchestra/node_modules/haibu/node_modules/haibu-carapace/lib/plugins/coffee.js:31:11) at [object Object].emit (events.js:64:17) at fs.js:820:12
error node.js:134 throw e; // process.nextTick error, or 'e
@JasonOffutt
JasonOffutt / BlogPost.js
Created April 30, 2012 05:51
Opinionated Backbone MVP Implementation via blogging engine
// Models will house domain specific functionality. They should know how to do thing that are
// within their domain, authorize and validate themselves. Application logic, however, ought
// to be pushed out to the Presenter.
var BlogPost = Backbone.Model.extend({
initialize: function(options) {
this.set({ foo: 'bar' }, { silent: true });
},
// Per Backbone's docs, `validate` should only return something if there is a validation error.
// If so, I've found it useful to return an array of hashes with the key equaling the property
// that threw an error. That way it can later be accessed via indexer.
@JasonOffutt
JasonOffutt / App.config
Created August 2, 2012 16:02
Proposal for adding dependency injection of IRepository<T> into Rock
<configuration>
<appSettings>
<clear/>
<add key="RepositoryType" value="Rock.Tests.Fakes.FakeAttributeRepository,Rock.Tests"/>
</appSettings>
</configuration
@JasonOffutt
JasonOffutt / rock.ui.js
Created December 6, 2012 23:03
JS Event-Driven Block Disabling
$(function () {
$('.disable-on-edit').click(function () {
var id = $(this).parents('.block-instance').attr('id');
$(document).trigger('EDIT_CLICKED', id);
});
$('.save').click(function () {
$(document).trigger('EDIT_COMPLETE');
});