This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
//Database connection | |
var uristring = 'mongodb://localhost/test'; | |
var mongoOptions = { }; | |
mongoose.connect(uristring, mongoOptions, function (err, res) { | |
if (err) { | |
console.log('Error when connecting to: ' + uristring + '. ' + err); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SQL TO JSON | |
SELECT | |
'{"<Code>k__BackingField":"' + [Code] + | |
'","<Name>k__BackingField":"' + [Name] + | |
'","<Description>k__BackingField":"' + [Description] + | |
'","<Parent>k__BackingField":"' + ISNULL([Parent], '') + | |
'"}, ' | |
FROM [ISOValues].[dbo].[FuntionalSections] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Generating a deterministic GUID | |
Although a new GUID is typically created in order to provide a unique ID, there are occasions when it’s useful for two different systems to generate the same GUID independently. RFC 4122 provides an algorithm for deterministic creation of a GUID based on a namespace ID (itself a GUID) and a name within that namespace. These name- based GUIDs will never collide with GUIDs from other sources (e.g., Guid.NewGuid), and have a very (very) small chance of colliding with other name-based GUIDs. As per section 4.3: | |
The UUIDs generated at different times from the same name in the same namespace MUST be equal. | |
The UUIDs generated from two different names in the same namespace should be different (with very high probability). | |
The UUIDs generated from the same name in two different namespaces should be different with (very high probability). | |
If two UUIDs that were generated from names are equal, then they were generated from the same name in the same namespace (with very high probabil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Found this snippet to be useful when using unique identifier in a database for federated distribution | |
public static Guid ToGuid(string src) | |
{ | |
byte[] stringbytes = Encoding.UTF8.GetBytes(src); | |
byte[] hashedBytes = new System.Security.Cryptography | |
.SHA1CryptoServiceProvider() | |
.ComputeHash(stringbytes); | |
Array.Resize(ref hashedBytes, 16); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using System.Windows.Threading; | |
public static class AsyncPump | |
{ | |
public static void Run(Func<Task> func) | |
{ | |
if (func == null) throw new ArgumentNullException("func"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Disposables; | |
using System.Linq; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Diagnostics; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JsonFormatHelper | |
{ | |
private const string INDENT_STRING = " "; | |
public static string FormatJson(string str) | |
{ | |
//if(ConfigHelper.GetAppSetting<bool>("Console", false)) | |
return FormatStrJson(str); | |
//return String.Empty; | |
} | |
public static string FormatStrJson(string str) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Guid Int2Guid(int value) | |
{ | |
byte[] bytes = new byte[16]; | |
BitConverter.GetBytes(value).CopyTo(bytes, 0); | |
return new Guid(bytes); | |
} | |
public static int Guid2Int(Guid value) | |
{ | |
byte[] b = value.ToByteArray(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Data; | |
using System.Data.SqlClient; | |
namespace MichaelKappel.Net.Repositories.Interfaces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Concorde.AzurePack.Domain.Websites.Preallocation.Settings; | |
using Concorde.Contracts.Processes; | |
using Concorde.Infrastructure.Messaging; | |
using Microsoft.ServiceBus.Messaging; | |
namespace Allocation |