Skip to content

Instantly share code, notes, and snippets.

View dagda1's full-sized avatar

Paul dagda1

View GitHub Profile
@dagda1
dagda1 / gist:860016
Created March 8, 2011 08:04
fakeweb.rb
require 'test_helper'
require 'fake_web'
class LeadControllerTest < ActionController::TestCase
context "given a valid url to preform a search" do
setup do
FakeWeb.register_uri(:any, "http://thesoftwaresimpleton.blogspot.com/", :body => "sample.html")
login_as_standard_user
protected ViewResult SaveItemWithParent<T, U>(string structureName, Guid? uid, Guid? parentUid, string parentStructureType,
Func<Guid, T> loadItem, Action<T, Guid> setParent, Func<ViewResult> all, string structureType)
where T : StructureBase, IParent<U>, new()
where U : StructureBase, new()
public virtual T GetByExpression<T>(Expression<Func<T, bool>> expression) where T : class
{
var session = _sessionManager.OpenSession();
var result = session.QueryOver<T>()
.Where(expression)
.List()
.FirstOrDefault();
return result;
USE [master]
DECLARE @DatabaseName nvarchar(50)
SET @DatabaseName = N'ncontinuity2'
DECLARE @SQL varchar(max)
SET @SQL = ''
SELECT @SQL = @SQL + 'Kill ' + Convert(varchar, SPId) + ';'
FROM MASTER..SysProcesses
WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId
Host git.github.com
User git
IdentityFile ~/.ssh/id_rsa
Host git.assembla.com
User git
IdentityFile ~/.ssh/id_rsa_assembla
[user]
email = paul.cowan@continuity2.com
name = paul.cowan
[core]
autocrlf = false
[merge]
tool = tortoisemerge
[mergetool "tortoisemerge"]
cmd = C:/Program Files/TortoiseGit/bin/TortoiseMerge.exe -base:$BASE -mine:$LOCAL -theirs:$REMOTE -merged:$MERGED
$snapins = Get-PSSnapin -Registered
$snapins | Add-PSSnapin
Get-Module -ListAvailable | Import-Module
Get-PSSnapin | Format-Table -autosize PSVersion, Name
Get-Module | Format-Table -autosize ModuleType, Name
function ff ([string] $glob) { get-childitem -recurse -include $glob }
@dagda1
dagda1 / gist:1053719
Created June 29, 2011 12:14
rails_js_template.rb
<%
dir = Rails.root.join('public/javascripts/app/templates/')
Dir["#{dir}**/*.*"].each do |path|
%>
<%
template = File.read(path)
name = path.gsub(dir.to_s, '').sub(File.extname(path), '')
%>
<script name="<%= name %>" type="text/x-js-template"><%= template.html_safe %></script>
<% end %>
@dagda1
dagda1 / gist:1053720
Created June 29, 2011 12:15
loadtemplates.js
loadTemplates: function() {
var templates = {};
$('*[type="text/x-js-template"]').map(function() {
var name = $(this).attr('name');
var source = $(this).html().replace('&gt;', '>');
if(name.split('/')[1][0] == '_') { Handlebars.registerPartial(name.replace('/', ''), source) }
templates[name] = Handlebars.compile(source);
});
return templates;
},
@dagda1
dagda1 / gist:1056202
Created June 30, 2011 13:12
observations.coffeescript
class Observation extends Backbone.Model
class Observations extends Backbone.Collection
model: Observation
class ObservationsView extends Backbone.View
el: $('#observations')
constructor: ->
@url = _observationsUrl