Skip to content

Instantly share code, notes, and snippets.

View gabrieljoelc's full-sized avatar

Gabriel Chaney gabrieljoelc

View GitHub Profile
@gabrieljoelc
gabrieljoelc / gist:935e98727494fa860533
Last active August 29, 2015 14:22
Sidekiq configuration notes from happy hour session with Mike Perham
* 1X Dyno supports about 5 threads so use 2X Dyno
* DB pool
* Add database.yml for production now
* Unicorn 1
* Puma per web concurrency
* Sidekiq per concurrency
* Remove redis sizes
* PX dyno?
* More dynos
* 1-2 threads can share a database pool
@gabrieljoelc
gabrieljoelc / Global.asax
Created October 31, 2012 19:20
ASP.NET MVC 4 DisplayMode Example
public MvcApp : System.Web.HttpApplication {
protected void Application_Start() {
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf
("iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
});
}
}
@gabrieljoelc
gabrieljoelc / ReflectionTypeLoadExceptionHandler.cs
Created November 1, 2012 15:04
Use this to code to determine the type that can't be loaded on a "ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information." exception
// ripped this off from this stackoverflow.com answer:
// http://stackoverflow.com/a/8824250/34315
using System.IO;
using System.Reflection;
try
{
//The code that causes the error goes here.
}
@gabrieljoelc
gabrieljoelc / applicationhost.config
Last active October 12, 2015 07:48
Configuration that exposes IIS Express website to other devices on the same network and allow DELETE verb
<!--put this in %USERPROFILE%\IISExpress\config-->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="system.applicationHost">
<section name="sites" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />
</sectionGroup>
@gabrieljoelc
gabrieljoelc / SvnBranchesToGitTags
Last active December 12, 2015 08:08
Git sub-prompt commands in PowerShell to convert all Subversion branches to Git branches after a `git svn clone` was already performed.
& git for-each-ref --format='%(refname)' refs/heads/tags | % {
#Extract the 4th field from every line
$_.Split("/")[3]
} | % {
#Foreach value extracted in the previous loop
& git tag $_ "refs/heads/tags/$_"
& git branch -D "tags/$_"
}
@gabrieljoelc
gabrieljoelc / UnixPowerShellCommandEquivalents
Last active December 12, 2015 08:09
Unix/Linux PowerShell command equivalents (Unix/Linux commands come first and then the equivalent PowerShell command.
# Create a directory
mkdir -p site/public
New-Item -ItemType directory -Path site/public
#create filename.txt
touch filename.txt
echo $null > filename
@gabrieljoelc
gabrieljoelc / CreateSymlinkForRuby
Created February 13, 2013 14:26
Windows symlink to deal with some Ruby gems not installing because of spacing in path (i.e. "C:\Program Files (x86)\Ruby-1.9.2").
# create the link
> mklink /d c:\ruby "C:\Program Files (x86)\Ruby-1.9.2"
#run the gem install command
> c:\ruby\bin\gem install rails
# delete the link
> ???
@gabrieljoelc
gabrieljoelc / GitStaticStackAndGotchasDemoTests.cs
Last active December 13, 2015 22:59 — forked from robdmoore/gist:4618493
Tests1-4 are NSubstitute static stack demonstrations by @robdmoore. I added Tests5-6 to demonstrate a class substitution gotcha that happens if the Object#Equals() is overriden in a class used for an method argument match.
using System;
using NSubstitute;
using NSubstitute.Exceptions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Tests
{
[TestClass]
public class Class1
{
@gabrieljoelc
gabrieljoelc / ExpressionFromFunc.cs
Created March 12, 2013 17:18
Create Expression from Func
Func<int> func = () => 1;
Expression<Func<int>> expression = Expression.Lambda<Func<int>>(Expression.Call(func.Method));
@gabrieljoelc
gabrieljoelc / MyActionDescriptorControllerTests
Last active December 15, 2015 01:09
Shows how to use `ReflectedControllerDescriptor` and `ReflectedControllerDescriptor#GetCanonicalActions()` method. It also references the `NonActionAttribute` and a method that returns the default value of a specified type (`GetDefault(Type)`). It leverages of MvcContrib test helpers (i.e. `ActionResultHelper`).
using System;
using System.Linq;
using System.Web.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MvcContrib.TestHelper;
using NSubstitute;