Skip to content

Instantly share code, notes, and snippets.

@karlosRivera
karlosRivera / DatabaseObserver.cs
Created October 29, 2020 18:32 — forked from janderit/DatabaseObserver.cs
C# class to observe SQL Server databases via Service Broker / SqlDependency
public sealed class DatabaseObserver : IDisposable
{
private readonly string _connectionstring;
private readonly string _sqlcommand;
private readonly Action<Observation> _onChange;
private readonly Action<Exception> _onError;
private readonly Action<string> _onWarning;
private SqlConnection _connection;
private SqlCommand _cmd;
private SqlDependency _dependency;
@karlosRivera
karlosRivera / SqlDependency.cs
Created October 29, 2020 18:31 — forked from markwaterman/SqlDependency.cs
ScaleOut SqlDependency Sample
/*
* © Copyright 2003-2017 by ScaleOut Software, Inc.
*
* LICENSE AND DISCLAIMER
* ----------------------
* This material contains sample programming source code ("Sample Code").
* ScaleOut Software, Inc. (SSI) grants you a nonexclusive license to compile,
* link, run, display, reproduce, and prepare derivative works of
* this Sample Code. The Sample Code has not been thoroughly
* tested under all conditions. SSI, therefore, does not guarantee
@karlosRivera
karlosRivera / gist:0462ae211172e03416ba51cfb4c611e7
Created September 9, 2019 13:09 — forked from imranbaloch/gist:10895917
SqlHelper.cs class with async support
// ===============================================================================
// Microsoft Data Access Application Block for .NET
// http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp
//
// cs
//
// This file contains the implementations of the SqlHelper and SqlHelperParameterCache
// classes.
//
// For more information see the Data Access Application Block Implementation Overview.
@karlosRivera
karlosRivera / HangfireService.cs
Created August 25, 2016 10:09 — forked from benhysell/HangfireService.cs
TopShelf - Create a Windows Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using V.RemoteDecodeProcessConsole.Properties;
public class DisableMultipleQueuedItemsFilter : JobFilterAttribute, IClientFilter, IServerFilter
{
private static readonly TimeSpan LockTimeout = TimeSpan.FromSeconds(5);
private static readonly TimeSpan FingerprintTimeout = TimeSpan.FromHours(1);
public void OnCreating(CreatingContext filterContext)
{
if (!AddFingerprintIfNotExists(filterContext.Connection, filterContext.Job))
{
filterContext.Canceled = true;
@karlosRivera
karlosRivera / ui-router-logging.js
Created July 31, 2016 19:38 — forked from mkropat/ui-router-logging.js
Automatic trace logging of Angular.js events and ui-router state transitions
angular.module('your-module').config(['$provide', function ($provide) {
$provide.decorator('$rootScope', ['$delegate', function ($delegate) {
wrapMethod($delegate, '$broadcast', function (method, args) {
if (isNonSystemEvent(args[0]))
logCall('$broadcast', args);
return method.apply(this, args);
});
wrapMethod($delegate, '$emit', function (method, args) {
@karlosRivera
karlosRivera / jquery.infinitescroll.js
Created February 17, 2016 10:38 — forked from rpheath/jquery.infinitescroll.js
A jQuery plugin for bi-directional infinite scrolling
// A bi-directional infinite scrolling jQuery plugin
//
// Usage Example:
// $(window).infiniteScroll({ url: window.location.href })
(function($) {
$.scroller = {
// default settings
settings: {
url: null,