Skip to content

Instantly share code, notes, and snippets.

@odinserj
odinserj / gist:4ac6014f4a9da099959c
Created July 3, 2015 13:53
FailoverRedisStorage.cs
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Hangfire;
using Hangfire.Logging;
using Hangfire.Redis;
using Hangfire.Storage;
@odinserj
odinserj / OverrideTransactionScopeTimeout.cs
Created May 27, 2015 13:35
OverrideTransactionScopeTimeout
private static void OverrideTransactionScopeTimeout(TimeSpan timeOut)
{
var transactionManager = typeof(TransactionManager);
var cachedMaxTimeout = transactionManager.GetField("_cachedMaxTimeout", BindingFlags.NonPublic | BindingFlags.Static);
var maximumTimeout = transactionManager.GetField("_maximumTimeout", BindingFlags.NonPublic | BindingFlags.Static);
var defaultTimeout = transactionManager.GetField("_defaultTimeout", BindingFlags.NonPublic | BindingFlags.Static);
var defaultTimeoutValidated = transactionManager.GetField("_defaultTimeoutValidated", BindingFlags.NonPublic | BindingFlags.Static);
cachedMaxTimeout.SetValue(null, true);
// Zero-Clause BSD (more permissive than MIT, doesn't require copyright notice)
//
// Permission to use, copy, modify, and/or distribute this software for any purpose
// with or without fee is hereby granted.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
@odinserj
odinserj / FuncJobActivator.cs
Last active August 29, 2015 14:03
Hangfire job activator based on ServiceStack IoC container
public class FuncJobActivator : JobActivator
{
private readonly Container _container;
public FuncJobActivator(Container container)
{
if (container == null) throw new ArgumentNullException("container");
_container = container;
}
@odinserj
odinserj / foo.js
Created October 2, 2012 16:20 — forked from mvasilkov/foo.js
TypeScript as a JS pretty print tool
/* Original code */
var s = 'foo.bar', im = new Image
im.src = s; s = im.src
console.log(s)
/* TypeScript output */
var s = 'foo.bar';
var im = new Image();
@odinserj
odinserj / foo.js
Created October 2, 2012 16:11 — forked from mvasilkov/foo.js
TypeScript as a JS pretty print tool
/* Original code */
var s = 'foo.bar', im = new Image
im.src = s; s = im.src
console.log(s)
/* TypeScript output */
var s = 'foo.bar';
var im = new Image();
jQuery ->
$("#e6").select2
placeholder: "Search for a movie"
minimumInputLength: 1
ajax: # instead of writing the function to execute the request we use Select2's convenient helper
url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json"
dataType: 'jsonp'
data: (term, page) ->
return {
$(function () {
$("#e6").select2({
placeholder: "Search for a movie",
minimumInputLength: 1,
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
dataType: 'jsonp',
data: function (term, page) {
return {
q: term, // search term
@odinserj
odinserj / gist:3793894
Created September 27, 2012 13:09
Coffee
CreditCard =
cleanNumber: (number) -> number.replace /[- ]/g, ""
validNumber: (number) ->
total = 0
number = @cleanNumber(number)
for i in [(number.length-1)..0]
n = +number[i]
if (i+number.length) % 2 == 0
n = if n*2 > 9 then n*2 - 9 else n*2
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using ChessOk.ModelFramework;
using ChessOk.ModelFramework.Web.ClientEvents;
namespace ChessOk.ChessSchool.Web.ClientEvents.Storage