Skip to content

Instantly share code, notes, and snippets.

View stevehorn's full-sized avatar

Steve Horn stevehorn

  • Columbus, OH, USA
View GitHub Profile
s = "sample string"
replacements = { "a" => "i", "tring" => "ubstitution" }
#why is the "&" necessary before the s variable?
replacements.collect(&s.method(:gsub))
# => ["simple string", "sample substitution"]
//PassParametersDuringRedirectAttribute.cs
// ~Line 25
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
//Fair to say you'd only want this behavior on a GET request?
//I did this because it was hijacking properties on my model that was populated by a model binder.
if(filterContext.RequestContext.HttpContext.Request.HttpMethod == "GET")
CREATE TABLE [dbo].[Job](
[JobId] [int] IDENTITY(1,1) NOT NULL,
etc...
--One or more Splits per Job
CREATE TABLE [dbo].[Split](
[SplitId] [int] IDENTITY(1,1) NOT NULL,
[JobId] [int] NOT NULL,
etc...
Public Class CrazyVBTypingTests
<Test()>
Public Sub Test_crazy_crap()
Dim anObject As New Object
anObject = New DoStuff
'This compiles, WTH?
Dim someInteger As Integer = anObject.GiveMeAnInteger()
someInteger.ShouldEqual(1)
Public Class CrazyVBTypingTests
<Test()>
Public Sub Test_crazy_crap()
Dim anObject As New Object
anObject = New DoStuff
'This compiles, WTH?
Dim someInteger As Integer = anObject.GiveMeAnInteger()
someInteger.ShouldEqual(1)
public class Compare_To_VB_Object_Weirdness
{
[Test]
public void Something()
{
var someObject = new Object();
someObject = new DoStuff();
//This does not compile, as expected
int result = someObject.GiveMeAnInteger();
Public Function GetById(ByVal id As Integer) As T Implements IDataLayer(Of T).GetById
Dim entityType As Type = GetType(T)
Dim entityTypeName As String = entityType.ToString
Dim keyProperty As String = entityTypeName.Substring(entityTypeName.LastIndexOf(".") + 1) + "Id"
Dim container = Context.MetadataWorkspace.GetEntityContainer(Context.DefaultContainerName, Metadata.Edm.DataSpace.CSpace)
Dim entitySetName As String = (From meta In container.BaseEntitySets _
Where meta.ElementType.Name = entityType.Name _
Select meta.Name).First()
balsamiq = 'C:/Program Files (x86)/Balsamiq Mockups/Balsamiq Mockups.exe'
mockup_directory = 'C:/Mockups'
output_directory = 'C:/Mockups/Images'
require 'find'
files = Array.new
Find.find(mockup_directory) do |f|
if /.bmml$/.match(f)
files << f
end
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript">
$().ready(function() {
var options = $("select").find("option").get();
var dupesRemoved = $.unique(options);
//This pops up a deuce... any idea why?
<Test()>
public sub Test_getting_by_Type
Dim newTypeInstance As Type = GetType(ModelBinder.ModelBinder(Of Models.Query.Query))
'Fails...why?
Dim retrievedByType = ObjectFactory.GetInstance(newTypeInstance)()
retrievedByType.ShouldNotBeNull()
'Passes
Dim retrievedByExplicit = ObjectFactory.GetInstance(Of ModelBinder.ModelBinder(Of Models.Query.Query))()