Skip to content

Instantly share code, notes, and snippets.

View gabrielgreen's full-sized avatar

Aaron Anodide gabrielgreen

  • Direct Agents
  • New York
View GitHub Profile
private static readonly StringBuilder Sb = new StringBuilder();
private static void ShowResults()
{
const string outputFile = "output.txt";
File.WriteAllText(outputFile, Sb.ToString());
Process.Start("notepad", outputFile);
}
<system.webServer>
<modules>
<add
name="SuppressFormsAuthenticationRedirectModule"
type="SuppressFormsAuthenticationRedirectModule"/>
</modules>
</system.webServer>
@gabrielgreen
gabrielgreen / SuppressFormsAuthenticationRedirectModule.cs
Created April 7, 2013 11:34
SuppressFormsAuthenticationRedirectModule.cs
public class SuppressFormsAuthenticationRedirectModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PostReleaseRequestState += OnPostReleaseRequestState;
}
private void OnPostReleaseRequestState(object source, EventArgs args)
{
var context = (HttpApplication)source;
@gabrielgreen
gabrielgreen / AccountingEntities.cs
Created January 30, 2013 21:30
QuickBooks schema, code first EF
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Text;
namespace Accounting.Domain.Entities
{
@gabrielgreen
gabrielgreen / Security.sql
Created December 6, 2012 23:21
security code
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 07/26/2012 11:32:16
-- Generated from EDMX file: C:\GitHub\da-projects\1\EomTool\EomApp1\Screens\Security\Models\EomToolSecurity.edmx
-- --------------------------------------------------
SET QUOTED_IDENTIFIER OFF;
GO
USE [EomToolSecurity];
@gabrielgreen
gabrielgreen / Hierarchy.cs
Created October 29, 2012 18:36
Nested class examples
namespace WindowsGame1.PhysicalModel
{
public class Body : PhysicalObject
{
public Body() : this("body") { }
public Body(string name)
: base(name)
{
Torso = new torso();
@gabrielgreen
gabrielgreen / CampaignsApiController.cs
Created September 25, 2012 22:52
ApiController vs Controller
using System.Linq;
using System.Web.Http;
using DirectAgents.Domain.Concrete;
using EomToolWeb.Models;
namespace EomToolWeb.Controllers
{
public class CampaignsApiController : ApiController
{
private EFDbContext db = new EFDbContext();
@gabrielgreen
gabrielgreen / EmailUtility.cs
Created September 7, 2012 07:35
EmailUtility
using System;
using System.Net.Mail;
public static class EmailUtility
{
public static void SendEmail(string from, string[] to, string[] cc, string subject, string body, bool isHTML)
{
MailMessage message = new MailMessage
{
Subject = subject,
@gabrielgreen
gabrielgreen / SqlUtility.cs
Created September 6, 2012 05:00
SqlUtility
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.Collections;
public static class SqlUtility
{
public static T ExecuteScalar<T>(string connStr, string query, params object[] queryParams)
{
using (var con = new SqlConnection(connStr))
using (var cmd = new SqlCommand(query, con))
@gabrielgreen
gabrielgreen / CopyProperties.cs
Created August 28, 2012 21:06
CopyProperties
static void CopyProperties(object sourceObject, object targetObject, bool deepCopy = true)
{
if (sourceObject != null && targetObject != null)
{
(from sourceProperty in sourceObject.GetType().GetProperties().AsEnumerable()
from targetProperty in targetObject.GetType().GetProperties().AsEnumerable()
where sourceProperty.Name.ToUpper() == targetProperty.Name.ToUpper()
let sourceValue = sourceProperty.GetValue(sourceObject, null)
where sourceValue != null
select CopyProperty(targetProperty, targetObject, sourceValue, deepCopy))