Skip to content

Instantly share code, notes, and snippets.

View hahmed's full-sized avatar

Haroon Ahmed hahmed

View GitHub Profile
@hahmed
hahmed / gist:1039919
Created June 22, 2011 11:35 — forked from ArnisL/gist:634186
userSession.cs
public class UserSession:IUserSession{
private readonly IAuthenticationService _authenticationService;
private readonly ICryptographer _crypto;
private readonly IUserRepository _repository;
public UserSession(IUserRepository repository,IAuthenticationService authenticationService,ICryptographer crypto){
Guard.AgainstNull(repository);
Guard.AgainstNull(authenticationService);
Guard.AgainstNull(crypto);
_repository=repository;
_crypto=crypto;
@hahmed
hahmed / gist:1042173
Created June 23, 2011 08:52
IUserSession for asp.net mvc application...
My service defintion held inside my services layer - no access to web app
public interface IUserSession
{
void LogOut();
string GetUsername();
LoggedonuserDTO GetCurrentUser();
}
@hahmed
hahmed / msbuilder.py
Created July 19, 2011 19:10 — forked from rcravens/msbuilder.py
Python Script to Automate MSBuild Tasks
import os, shlex, subprocess, re, datetime
class MsBuilder:
def __init__(self, msbuild=None, mstest=None, nuget=None, trx2html=None):
# The following dictionary holds the location of the various
# msbuild.exe paths for the .net framework versions
if msbuild==None:
self.msbuild = r'C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe'
else:
self.msbuild = msbuild
@hahmed
hahmed / UoW.cs
Created July 31, 2011 07:20 — forked from tobinharris/UoW.cs
using System;
using System.Collections.Generic;
using System.IO;
using FluentNHibernate;
using FluentNHibernate.AutoMap;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Context;
using NHibernate.Event;
@hahmed
hahmed / gist:1167789
Created August 24, 2011 11:04
Aloha Text colour plugin sample...
/**
* Text Color Plugin
*/
GENTICS.Aloha.TextColor = new GENTICS.Aloha.Plugin('TextColor');
/**
* Configure the available languages
*/
GENTICS.Aloha.TextColor.languages = ['en', 'ru'];
@hahmed
hahmed / tax.cs
Created September 22, 2011 12:02 — forked from flq/tax.cs
the tax thingy
public decimal GetTaxes(decimal salary)
{
decimal tax = 0;
var progressiveTaxation = new[] { 0.1m, 0.14m, 0.23m, 0.3m, 0.33m, 0.45m };
var progressionSlices = new[] { 5070 - 0, 8660 - 5070, 14070 - 8660, 21240 - 14070, 40230 - 21240, decimal.MaxValue };
var progression = 0;
while (salary > 0)
@hahmed
hahmed / gist:1267450
Created October 6, 2011 13:55
javascript ignore case filter
// custom css expression for a case-insensitive contains()
$.expr[':'].Contains = function(a, i, m) {
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase()) >= 0;
};
$(".search-box").keyup(function(e) {
//get current value
var that = $(this).val();
if (that.length > 0) { //something exists
@hahmed
hahmed / gist:1583674
Created January 9, 2012 16:25
understanding bool operators
[Test]
public void IsApplesOrBannans()
{
bool IsApple = true;
bool IsBannana = false;
if (!IsApple && !IsBannana)
Assert.Fail();
Assert.Pass();
@hahmed
hahmed / gist:2336677
Created April 8, 2012 11:17
Company, Model and its keys
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace dictionary
{
public class CustomerModel
{
public string Model { get; set; }
@hahmed
hahmed / gist:2490907
Created April 25, 2012 16:00
col resizer
<script type="text/javascript">
/**
* Author: Rob Audenaerde
*/
function resetTableSizes (table, change, columnIndex)
{
//calculate new width;
var tableId = table.attr('id');
var myWidth = $('#'+tableId+' TR TH').get(columnIndex).offsetWidth;