Skip to content

Instantly share code, notes, and snippets.

View bittercoder's full-sized avatar
:shipit:
CTO @ Zoolibrary

Alex Henderson bittercoder

:shipit:
CTO @ Zoolibrary
View GitHub Profile
public abstract class Thing
{
}
public interface IMarker {}
public interface IUseful<T> : IMarker where T : Thing
{
T DoSomething();
}
@bittercoder
bittercoder / gist:1047404
Created June 26, 2011 08:27
3.1 GA Upgrade commit
Commit:427165be593dbf9f1c561eca5cb1570da7dfcef6
* Upgrading everything so we can use NHibernate 3.1 GA
First successful compile after upgrading dependencies to these new versions:
Lucene.Net - 2.9.2.2
Newtonson.Json - 3.5.0.0
NHibernate - 3.1.0.4000 (3.1 GA)
NHibernate Search - 0.0.0.0 (Built against NHibernate 3.1 GA + Lucene.Net 2.9.2.2)
@bittercoder
bittercoder / UnionQueryBuilder.cs
Created July 26, 2011 13:06
UnionQueryBuilder for NHibernate
public class UnionQueryBuilder : IUnionQueryBuilder
{
public IQuery BuildQuery(UnionDefinition definition)
{
Dialect dialect = GetDialect();
var builder = new SqlStringBuilder();
builder.Add("select ")
.Add("u.Id")
@bittercoder
bittercoder / DeMorgansExprVisitor.cs
Created September 15, 2011 12:04
My first stab at a DeMorgans visitor + tests
// ---------------------------------------------------------------
// Uses DeMorgans Law of formal logic to remove NOT's from the AST
// (This is advantageous when running queries against Lucene)
// http://en.wikipedia.org/wiki/De_Morgans_laws
// ---------------------------------------------------------------
public class DeMorgansExprVisitor : IExprVisitor<Expr>
{
int _notCount;
@bittercoder
bittercoder / HttpRequestMessageExtensions.cs
Created February 15, 2012 10:28
A really hacky way to grab the HttpContext from the request of a WCF Web API DelegatingHandler...
using System;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.ServiceModel;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
[WcfSerialization::DataMember(Name = "Value", IsRequired = false, Order = 1)]
public string Value
{
get { return value; }
set { value = value; }
}
@bittercoder
bittercoder / Down
Created August 28, 2012 08:19
Creating Quartz tables using Migrator.Net
Database.RemoveForeignKey("QRTZ_CRON_TRIGGERS", "FK_QRTZ_CRON_TRIGGERS_QRTZ_TRIGGERS");
Database.RemoveForeignKey("QRTZ_SIMPLE_TRIGGERS", "FK_QRTZ_SIMPLE_TRIGGERS_QRTZ_TRIGGERS");
Database.RemoveForeignKey("QRTZ_SIMPROP_TRIGGERS", "FK_QRTZ_SIMPROP_TRIGGERS_QRTZ_TRIGGERS");
Database.RemoveForeignKey("QRTZ_TRIGGERS", "FK_QRTZ_TRIGGERS_QRTZ_JOB_DETAILS");
Database.RemoveTable("qrtz_calendars");
Database.RemoveTable("qrtz_cron_triggers");
Database.RemoveTable("qrtz_fired_triggers");
@bittercoder
bittercoder / create_users.py
Created August 31, 2012 01:22
Using Python requests library to generate 15,000 ET users
#!/usr/bin/env python
# Generate 15,000 users in Enterprise Tester with admin permissions...
import json
import requests
from requests.auth import HTTPBasicAuth
server = 'http://localhost:8080/EnterpriseTester'
proxyDict = { 'http': '127.0.0.1:8888'} # so we can capture requests in fiddler
auth = HTTPBasicAuth('Administrator', 'password')
@bittercoder
bittercoder / Program.cs
Created September 1, 2012 20:42
Monkey Coconuts Brute Force
namespace MonkeyCoconuts
{
class Program
{
static void Main(string[] args)
{
for (int i=0; i<10000000; i++)
{
if (test(i))
{
@bittercoder
bittercoder / MemoryTributary.cs
Created September 1, 2012 21:33
MemoryTributary
/// <summary>
/// MemoryTributary is a re-implementation of MemoryStream that uses a dynamic list of byte arrays as a backing store, instead of a single byte array, the allocation
/// of which will fail for relatively small streams as it requires contiguous memory.
/// </summary>
public class MemoryTributary : Stream /* http://msdn.microsoft.com/en-us/library/system.io.stream.aspx */
{
#region Constructors
public MemoryTributary()
{