Skip to content

Instantly share code, notes, and snippets.

View luis-fss's full-sized avatar
:octocat:
Hey

Luis Fernando de Souza Santos luis-fss

:octocat:
Hey
View GitHub Profile
@haacked
haacked / TestHelper.cs
Created January 14, 2012 07:25
String Comparison Unit Test Helper
public static class TestHelpers
{
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue)
{
ShouldEqualWithDiff(actualValue, expectedValue, DiffStyle.Full, Console.Out);
}
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue, DiffStyle diffStyle)
{
ShouldEqualWithDiff(actualValue, expectedValue, diffStyle, Console.Out);
@giggio
giggio / BindingEstaticoDinamico.cs
Created February 16, 2012 01:14
Exemplo de binding estático e dinâmico em C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestProject3
{
[TestClass]
public class BindingTest
{
[TestMethod]
public void EstaticoString()
{
@NOtherDev
NOtherDev / LoquaciousXml.cs
Created February 18, 2012 21:32
Loquacious XML builder
internal class NodeBuilder
{
private readonly XmlDocument _doc;
private readonly XmlNode _node;
public NodeBuilder(XmlDocument doc, XmlNode node)
{
_doc = doc;
_node = node;
}
@philipmat
philipmat / json_entity_converter.cs
Created February 20, 2012 10:17
JSON Entity Converter
void Main()
{
var co = new Company { Id = 1, Name = "Moof Inc." };
var clarus = new Contact { Id = 1, Name = "Clarus" };
var mark = new Contact { Id = 2, Name = "Mark" };
co.AddContact(clarus);
co.AddContact(mark);
co.MainContact = clarus;
// Attempt #1: Straight up, no converter
@phillip-haydon
phillip-haydon / Blobbed.cs
Created February 28, 2012 23:35
NHibernate Custom User Type for serializing a property to JSON
[Serializable]
public class Blobbed<T> : IUserType where T : class
{
public new bool Equals(object x, object y)
{
if (x == null && y == null)
return true;
if (x == null || y == null)
return false;
@jonnii
jonnii / default.ps1
Created May 7, 2012 14:41
Creating a click once package using mage and powershell
task PrepareClickOnce {
write-host 'Add mage to our path'
$env:path += ";C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools"
write-host "Preparing install directory"
$installersRoot = '..\installers\app'
if (test-path $installersRoot) {
Write-Host "Cleaning installers root"
rm -r -force $installersRoot > $null
@liammclennan
liammclennan / blog_connascence_methods.md
Created July 5, 2012 22:36
Named Method Arguments: From connascence of position to connascence of name

From wikipedia:

Two software components are connascent if a change in one would require the other to be modified in order to maintain the overall correctness of the system.

Connascence is a useful tool for discussing different types of coupling that occur within software.

Again from wikipedia, "connascence of name is when multiple components must agree on the name of an entity". Connascence of name one is of the list harmful and most unavoidable types of connascence because it is simple to reason about and change. While connascence of name is still connascence, and therefore bad, it is among the most amenable to refactoring. If the name of something changes then everything that refers to that thing by name must also change. This is a simple change that can be mostly statically determined and applied by tools.

Connascence of position is present when changing the order of something necessitates a change elsewhere. An example is the order of function arguments. If the order of a function's arguments is

@NOtherDev
NOtherDev / ControllerActionInvokerWithDefaultJsonResult.cs
Created September 22, 2012 17:26
ASP.NET MVC: Replacing the default ActionInvoker to do something useful with non-ActionResult return types
// ASP.NET MVC: Replacing the default ActionInvoker to do something useful with non-ActionResult return types
// See more: http://notherdev.blogspot.com/2012/09/non-actionresult-return-type-aspnet-mvc.html
public class MyControllerFactory : DefaultControllerFactory
{
public override IController CreateController(RequestContext context, string controllerName)
{
var controller = base.CreateController(context, controllerName);
return ReplaceActionInvoker(controller);
}
@JulianRooze
JulianRooze / Expressions.cs
Created November 26, 2012 17:12
Build expressions
class Employee
{
public IList<Order> Orders { get; set; }
}
class Order
{
public int OrderID { get; set; }
public IList<Customer> Customers { get; set; }
@Jelby-John
Jelby-John / glyphicons.files.css
Last active December 22, 2017 15:02
Glyphicons Pro in Twitter Bootstrap 3
@font-face { font-family: 'Glyphicons files'; src: url('../fonts/glyphicons-filetypes-regular.eot'); src: url('../fonts/glyphicons-filetypes-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-filetypes-regular.woff') format('woff'), url('../fonts/glyphicons-filetypes-regular.ttf') format('truetype'), url('../fonts/glyphicons-filetypes-regular.svg#glyphicons-filetypes-regular') format('svg'); } .glyphfiles { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons files'; font-style: normal; font-weight: normal; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }.glyphfiles-txt:before {content: "\e001"; }.glyphfiles-doc:before {content: "\e002"; }.glyphfiles-rtf:before {content: "\e003"; }.glyphfiles-log:before {content: "\e004"; }.glyphfiles-tex:before {content: "\e005"; }.glyphfiles-msg:before {content: "\e006"; }.glyphfiles-text:before {content: "\e007"; }.glyphfiles-wpd:before {content: "\e008"; }.glyphfiles-wps:before {con