Skip to content

Instantly share code, notes, and snippets.

@cobysy
cobysy / SqlDependencyPermissions.sql
Last active September 12, 2019 00:48
Minimum Database Permissions Required for SqlDependency
GRANT CREATE PROCEDURE TO [SqlUser];
GRANT CREATE SERVICE TO [SqlUser];
GRANT CREATE QUEUE TO [SqlUser];
GRANT REFERENCES ON CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] TO [SqlUser];
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [SqlUser];
GRANT CONTROL ON SCHEMA::[dbo] TO [SqlUser];
GRANT IMPERSONATE ON USER::DBO TO [SqlUser];
-- This acually works
-- https://social.msdn.microsoft.com/Forums/sqlserver/en-US/bd195da8-93b2-43c6-8f59-674f5fb9d618/cannot-find-the-queue-sqlquerynotificationserviceguid?forum=sqlservicebroker&prof=required
@cobysy
cobysy / disablewindowsnarrator.reg
Created April 2, 2016 21:01
Disable Windows narrator
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\narrator.exe]
"Debugger"="%1"
@cobysy
cobysy / Deploy dacpac with Powershell on Build vNext.ps1
Last active August 5, 2019 19:52
Deploy dacpac with Powershell on Build vNext
#
# Powershell script that deploys the dacpac to (localdb)\MSSQLLocalDB that the integration tests can run against.
#
$dbname = "xxx"
$dacpacname = "xxx.dacpac"
# Locate dacpac
$dacpac = gci -Recurse -Filter "$dacpacname" -ErrorAction SilentlyContinue | Select -First 1
[AttributeUsage(AttributeTargets.Method)]
public class ValidationActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
InnerOnActionExecuting(actionContext);
var modelState = actionContext.ModelState;
if (modelState.IsValid)
@cobysy
cobysy / JS-LINQ.js
Created December 18, 2015 15:17 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
@cobysy
cobysy / jscpd
Last active September 17, 2015 21:15
jscpd options for c#
fix by adding following line
-------------
options.exclude = options.exclude.split ','
in cli.coffee
(Windows path: C:\Users\xxx\AppData\Roaming\npm\node_modules\jscpd\src\cli\)
jscpd -g csharp -o report.txt --exclude **/*.Designer.cs,**/XsdGeneratedClasses.cs
@cobysy
cobysy / XJsonMediaTypeFormatter.cs
Last active September 11, 2020 13:31
Fix of JsonMediaTypeFormatter (ASP.net WebAPI) that does not convert JSON to object when Request is in Chunked Transfer Encoding.
/// <summary>
/// Fix of JsonMediaTypeFormatter that does not convert JSON to object when Request is in Chunked Transfer Encoding.
/// </summary>
public class XJsonMediaTypeFormatter : JsonMediaTypeFormatter
{
/// <summary>
/// Replaces web api default JsonMediaTypeFormatter with this instance.
/// Usage:
/// protected void Application_Start()
/// {
@cobysy
cobysy / gist:59afed79262114a7fbed
Created July 14, 2015 11:37
mongodump (to bson) and bsondump (parse bson to json)
mongodump --host mongodb1.example.net \
--db db_name \
--collection collection_name \
--query '{ _id: { $gte: ObjectId("537c3ca7cfefc541c4a41a8e") } }' \
--out /tmp/mongodump
bsondump tmp/mongodump/Historic.bson/db_name/mongodump.bson
/// Ruthlessly inspired by from http://kozmic.net/2014/03/22/strongly-typed-app-settings-with-castle-dictionaryadapter/
public class AppSettingRequiredAttribute : Attribute
{
}
public class AppSettingWrapperAttribute : DictionaryBehaviorAttribute, IDictionaryPropertyGetter, IPropertyDescriptorInitializer
{
object IDictionaryPropertyGetter.GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, object storedValue, PropertyDescriptor property, bool ifExists)
{
/// <summary>
/// "Fast"-implementation of building HashCode
/// </summary>
public static class HashCodeBuilder
{
internal const int Seedingprime = 42;
internal const int Hashingprime = 37;
public static int BuildHashCode(params object[] args)
{