Skip to content

Instantly share code, notes, and snippets.

View oguzhaneren's full-sized avatar
🐍
it depends

Oğuzhan Eren oguzhaneren

🐍
it depends
View GitHub Profile
@oguzhaneren
oguzhaneren / gist:5674735
Created May 29, 2013 23:47
Castle Interceptor Caching
class Program
{
static void Main(string[] args)
{
new Program().Run(args);
}
private WindsorContainer _container;
public void Run(string[] args)
{
@oguzhaneren
oguzhaneren / LazySessionContext.cs
Last active December 28, 2015 05:49 — forked from anonymous/gist:852307
NHibernate Session Per Web Request
using System;
using System.Collections.Generic;
using System.Web;
using NHibernate;
using NHibernate.Context;
using NHibernate.Engine;
namespace WebHub.Infrastracture.SessionManagement
{
public class LazySessionContext : ICurrentSessionContext
@oguzhaneren
oguzhaneren / BitWriterReader.cs
Last active January 3, 2016 06:19
Bit Reader and Writer
public class BitWriter
: BinaryWriter
{
public BitWriter(Stream output) : base(output)
{
}
public void Write7BitInt(int value)
{
Write7BitEncodedInt(value);
@oguzhaneren
oguzhaneren / test1.js
Created February 25, 2014 15:58 — forked from jmblog/test1.js
Examples of shim config in RequireJS 2.0 - Backbone and underscore
require.config({
paths: {
underscore: '../underscore-min'
},
shim: {
underscore: {
exports: function() {
return _.noConflict();
}
}
@oguzhaneren
oguzhaneren / 0_reuse_code.js
Created April 25, 2014 09:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@oguzhaneren
oguzhaneren / mapping.cs
Created May 26, 2014 08:42
Fluent NHibernate AutoMapping
static void TreatConfiguration(NHibernate.Cfg.Configuration configuration)
{
var update = new SchemaUpdate(configuration);
update.Execute(false, true);
}
private void Configure()
{
@oguzhaneren
oguzhaneren / NhSessionManagementAttribute.cs
Last active August 29, 2015 14:05
NHibernate Session Management Filter for WebApi
public class NhSessionManagementAttribute : ActionFilterAttribute
{
public NhSessionManagementAttribute()
{
SessionFactory = MvcApplication.SessionFactory;
}
private ISessionFactory SessionFactory { get; set; }
public override void OnActionExecuting(HttpActionContext actionContext)
@oguzhaneren
oguzhaneren / example.html
Created December 10, 2014 18:29
Knockout markdown and ellipsis (less,more) handler , depended to https://code.google.com/p/pagedown/
<p data-bind="markdown: content></p>
or
<p data-bind="markdown: {text:content,options: { maxLength:500 }}></p>
@oguzhaneren
oguzhaneren / jquery-promise.js
Created December 12, 2014 13:50
jquery promise
var deferred = $.Deferred();
promise = deferred.promise();
promise = promise.then(function(){
var t = $.Deferred();
setTimeout(function() {
console.log('rejecting...');
t.reject();
}, 1000);
@oguzhaneren
oguzhaneren / FooEntity.cs
Created January 2, 2015 14:23
NHibernate Domain Event Publisher
public class FooEntity
: IHaveEvents
{
private readonly IList<IEvent> _events = new List<IEvent>();
private readonly ICollection<FooMember> _members = new HashedSet<FooMember>();
public virtual Guid Id { get; protected set; }
public virtual IEnumerable<FooMember> Members { get { return _members; } }
public IList<IEvent> Events { get { return _events; } }