This file contains 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
//////////// model ////////////// | |
interface IWidgetModel { | |
constructor: WidgetModelCtor; | |
} | |
type WidgetModelCtor = Function & { | |
readonly widgetType?: string; | |
serviceClass?: new (...args: any[]) => IWidgetService; | |
} |
This file contains 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
abstract class Widget { | |
abstract readonly widgetType: string; | |
public display: { [key: string]: string; }; | |
constructor(data?: any) { | |
this.display = { | |
a: 'a' in data ? data.a : 'a-parentClass', | |
b: 'b' in data ? data.b : 'b-parentClass', | |
c: 'c' in data ? data.c : 'c-parentClass' |
This file contains 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
abstract class A { | |
p: string = 'A.p'; | |
q: string; | |
r: string; | |
s = 'A.s' | |
c: C; | |
constructor(dto: any) { | |
console.log('A.constructor') |
This file contains 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
documentation?("jQuery.fn.order", { | |
Description: "jQuery plugin for client-side list sorting" | |
Usage: (foo, selector = null, sortBy = null, options = null) -> [ | |
$(foo).order(selector, sortBy, options) | |
$(foo).order(selector, sortBy) | |
$(foo).order(selector, options) | |
$(foo).order(options) | |
$(foo).order() | |
] | |
Parameters: |
This file contains 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.RegularExpressions; | |
using Newtonsoft.Json; | |
using System.Text; | |
public static class JsonDumperSimple | |
{ | |
public static string Stringify(object obj) |
This file contains 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
//used as an example DTO type. | |
class Crosslink | |
{ | |
public string Code { get; set; } | |
public string FullDescription { get; set; } | |
} | |
public async Task<Crosslink[]> QueryAsync(CommandType commandType, string query, params DbParameter[] parameters) | |
{ | |
var list = new List<Crosslink>(); |
This file contains 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
//--------------------------- Context-Binding Lambda Expressions ------------------------------------ | |
// Expression bodies | |
var evens = [2,4,6,8,10]; | |
var odds = evens.map(v => v + 1); | |
var nums = evens.map((v, i) => v + i); | |
var fives = []; | |
// Statement bodies | |
nums.forEach(v => { | |
if (v % 5 === 0) |
This file contains 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; | |
namespace Extensions | |
{ | |
public static class DictionaryExtensions | |
{ | |
public static void ForEach<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, Action<TKey, TValue> action) | |
{ |
This file contains 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
function weekNumber(date) { | |
var currYear = date.getFullYear(); | |
var jan1 = new Date(currYear,0,1); | |
return Math.ceil((((date - jan1) / 86400000) + jan1.getDay() + 1)/7); | |
} | |
function weekNumberUTC(date) { | |
var currYear = date.getUTCFullYear(); | |
var jan1 = new Date(currYear,0,1); | |
return Math.ceil((((date - jan1) / 86400000) + jan1.getUTCDay() + 1)/7); | |
} |
This file contains 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 Shuffle | |
{ | |
static Random r = new Random(); | |
public static void swap(ref int a, ref int b) | |
{ | |
if (a != b) | |
{ | |
a ^= b; | |
b ^= a; |
NewerOlder