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
/** | |
* Subscribe to data from amplifyJS returning a promise. | |
* @param {string} storeKey key that amplify stores data under. | |
* @param {string} publishKey key that amplify publishes data to. | |
* @returns {Promise} On success the promise will return the drop down data. | |
*/ | |
subscribe: function(storeKey, publishKey) { | |
var deferred = $.Deferred(); | |
var publishCallback = function () { | |
amplify.unsubscribe(publishKey, publishCallback); |
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 enum Animals | |
{ | |
Cat, | |
Dog, | |
Goat, | |
} | |
var animalNames = ((Animals[])Enum.GetValues(typeof(Animals))) | |
.Select(key => Enum.GetName(typeof(Animals), key)); |
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 ReadOnlyDictionaryHelper | |
{ | |
/// <summary> | |
/// Returns a cached version of an empty dictionary so we can avoid the overhead of creating a new dictionary each time. | |
/// </summary> | |
internal class EmptyReadOnlyDictionary<TKey, TValue> | |
{ | |
static volatile ReadOnlyDictionary<TKey, TValue> instance; | |
public static IReadOnlyDictionary<TKey, TValue> Instance | |
{ |
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
// OrderBy | |
Func<IQueryable<Foo>, IOrderedQueryable<Foo>> test = q => q.OrderBy(x => x.Prop1); | |
private static Dictionary<string, Func<IQueryable<Foo>, IOrderedQueryable<Foo>>> orderByLookup | |
= new Dictionary<string, Func<IQueryable<Foo>, IOrderedQueryable<Foo>>>() | |
{ | |
{ "PropA", q => q.OrderBy(x => x.PropA)}, | |
{ "PropB", q => q.OrderByDescending(x => x.PropB)}, | |
{ "PropC", q => q.OrderByDescending(x => x.PropC)}, | |
}; |
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 class SqlDataReaderHelper<T> where T : class | |
{ | |
private const int TIMEOUT = 600; | |
private readonly string sqlCommandText; | |
private readonly string sqlConnectionString; | |
private IList<SqlParameter> parameters = new List<SqlParameter>(); | |
private Func<SqlDataReader, T> mapper; | |
public SqlDataReaderHelper(string sqlCommandText, string sqlConnectionString, Func<SqlDataReader, T> mapper) |
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
// Base View - Used to add "Is a" type functionality that is used by most/all derived views. | |
(function (Backbone, _) { | |
App.views.BaseView = Backbone.View.extend({ | |
initialize: function () { }, | |
//... | |
}); | |
})(Backbone, _); | |
// Mixin - Used to add shared functionality with limited context to objects. | |
(function () { |
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 url1 = "https://example.com/".match(/^https?\:\/\/[^ ]*/); | |
console.log("Url1: ", url1[0]); | |
var url2 = "http://example.com/".match(/^https?\:\/\/[^ ]*/); | |
console.log("Url2: ", url2[0]); | |
var doubleEntry = "This a double double".match(/(\w+) \1/); | |
console.log("Find double entry: ", doubleEntry[1]); | |
var username = 'user3'; | |
var userData = "user1=sad; user2=angry; user3=happy; user4=crazy" |
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 Microsoft.VisualStudio.TestTools.UnitTesting; | |
using System; | |
using System.Text.RegularExpressions; | |
namespace Infrastructure.Tests | |
{ | |
/// <summary> | |
/// Converts how lists of elements are represented in a serialized string. | |
/// </summary> | |
public class SerializedListRepresentationConverter |
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
Some SQL Server Reporting Services Expressions. | |
- Change tablex cell's border style depending on line field. (Cell's property window) | |
=iif(Fields!Type.Value = 2,"Dotted","None") | |
- Change tablex cell's font based on line field. (Cell's property window) | |
=iif(Fields!Type.Value = 2, "Bold", "Default") | |
- Display a specific row's field value | |
=Round(Lookup("SpecialTotal", Fields!RowTitle.Value, Fields!Total.Value, "MyDS")) |
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
// Display properties | |
function Display(id, props) { | |
var frag = document.createDocumentFragment(); | |
var list = document.getElementById(id); | |
console.log("============", id); | |
// Add properties to fragment | |
for (var i = 0; props[i]; i++) { | |
console.log(props[i]); | |
var el = document.createElement("li"); |