This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySqlClass | |
{ | |
public virtual void Transaction(Action action) | |
{ | |
using (var transaction = Connection.BeginTransaction()) | |
{ | |
try | |
{ | |
action(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Data.Odbc; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
namespace Foo | |
{ | |
internal static class OdbcConnectionExtensions { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT name, cnt from ( | |
SELECT 'egr_casemgt_eg' AS name, COUNT(*) AS cnt FROM egr_casemgt_eg LEFT JOIN emp_grp ON emp_grp.emp_grp_id = egr_casemgt_eg.emp_grp_id WHERE emp_grp.emp_grp_id IS NULL UNION | |
SELECT 'egr_casemgt_sg' AS name, COUNT(*) AS cnt FROM egr_casemgt_sg LEFT JOIN emp_subgrp ON emp_subgrp.emp_subgrp_id = egr_casemgt_sg.emp_subgrp_id WHERE emp_subgrp.emp_subgrp_id IS NULL UNION | |
SELECT 'egr_casemgt_cl' AS name, COUNT(*) AS cnt FROM egr_casemgt_cl LEFT JOIN emp_class ON emp_class.emp_class_id = egr_casemgt_cl.emp_class_id WHERE emp_class.emp_class_id IS NULL UNION | |
SELECT 'egr_adhasthma_eg' AS name, COUNT(*) AS cnt FROM egr_adhasthma_eg LEFT JOIN emp_grp ON emp_grp.emp_grp_id = egr_adhasthma_eg.emp_grp_id WHERE emp_grp.emp_grp_id IS NULL UNION | |
SELECT 'egr_adhasthma_sg' AS name, COUNT(*) AS cnt FROM egr_adhasthma_sg LEFT JOIN emp_subgrp ON emp_subgrp.emp_subgrp_id = egr_adhasthma_sg.emp_subgrp_id WHERE emp_subgrp.emp_subgrp_id IS NULL UNION | |
SELECT 'egr_adhasthma_cl' AS name, COUNT(*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected Mock<T> NewMock<T>() where T : class | |
{ | |
var type = typeof(T); | |
var constructors = type.GetConstructors(); | |
if (constructors.Length == 0) constructors = type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); | |
if (constructors.Length == 0) return new Mock<T>(); | |
var constructor = constructors[0]; | |
var parameters = constructor.GetParameters(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>rvm upgrade 1.9.2 1.9.2-p0 | |
Are you sure you wish to upgrade from ruby-1.9.2-p0 to ruby-1.9.2-p136? (Y/n): | |
Installing new ruby ruby-1.9.2-p136 | |
/Users/colthorp/.rvm/rubies/ruby-1.9.2-p136, this may take a while depending on your cpu(s)... | |
ruby-1.9.2-p136 - #fetching | |
ruby-1.9.2-p136 - #downloading ruby-1.9.2-p136, this may take a while depending on your connection... | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 8612k 100 8612k 0 0 91791 0 0:01:36 0:01:36 --:--:-- 4124 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Register .NET 4 framework with IIS 7: | |
● Run cmd.exe | |
● cd C:\windows\microsoft.net\framework\v4.0.30319 | |
● aspnet_regiis.exe -r | |
Install Web Deployment Tool | |
● http://www.iis.net/download/WebDeploy | |
● I chose to install "Complete" instead of the default "Typical" but | |
I'm not sure this is | |
necessary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################ | |
# spec/spec_helper.rb, in RSpec.configure block | |
config.before do | |
MongoidCleaner.start | |
end | |
config.after do | |
MongoidCleaner.clean | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro let-match [matches & code] | |
`(if-match ~matches | |
(do ~@code) | |
(throw (UnsupportedOperationException. "Destructuring failed.")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'lib/static_map_uri' | |
describe StaticMapURI do | |
let(:address){ "123 foo st, grand rapids mi" } | |
let(:width){ 200 } | |
let(:height){ 100 } | |
subject{ StaticMapURI.new address, width, height } | |
its(:host){ should == "maps.google.com" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given %r{I should see these strings in order} do |table| | |
doc = Nokogiri.HTML(response.body) | |
strings = table.raw.flatten | |
# find all instances of the passed in strings | |
escaped_strings = table.raw.flatten.map {|string| Regexp.escape(string)} | |
snippet_regexp = Regexp.new escaped_strings.join("|"), Regexp::MULTILINE | |
snippets = doc.inner_text.scan(snippet_regexp) | |
# look for each string in order |