Provider | Singleton | Instantiable | Configurable |
---|---|---|---|
Constant | Yes | No | No |
Value | Yes | No | No |
Service | Yes | No | No |
Factory | Yes | Yes | No |
Decorator | Yes | No? | No |
Provider | Yes | Yes | Yes |
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 bool SameAs(this BsonDocument source, BsonDocument other, params string[] ignoreFields) | |
{ | |
var elements = source.Elements.Where(x => !ignoreFields.Contains(x.Name)).ToArray(); | |
if (elements.Length == 0 && other.Elements.Where(x => !ignoreFields.Contains(x.Name)).Any()) return false; | |
foreach (var element in source.Elements) | |
{ | |
if (ignoreFields.Contains(element.Name)) continue; | |
if (!other.Names.Contains(element.Name)) return false; | |
var value = element.Value; | |
var otherValue = other[element.Name]; |
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
Properties { | |
$Build_dir = Split-Path $psake.build_script_file | |
$Packages_dir = Join-Path $build_dir 'Packages' | |
$MsDeploy_dir = Join-Path $env:ProgramFiles 'IIS\Microsoft Web Deploy' | |
$SiteName = 'www.example.com' | |
$Package = "$SiteName.zip" | |
$Dest = 'hosting.com' | |
$UserName = 'IIS User Name' | |
$Pwd = 'Secret Password' |
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
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
(function($, undefined){ | |
window.kendoConsole = { | |
log: function(message, isError, container) { | |
var lastContainer = $(".console div:first", container), | |
counter = lastContainer.find(".count").detach(), | |
lastMessage = lastContainer.text(), | |
count = 1 * (counter.text() || 1); | |
lastContainer.append(counter); |
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
// from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/ | |
function bytesToSize(bytes) { | |
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | |
if (bytes == 0) return 'n/a'; | |
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); | |
if (i == 0) return bytes + ' ' + sizes[i]; | |
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]; | |
}; |
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
if(fruit === 'apple' || fruit === 'banana' || fruit === 'chikoo'){ | |
doMagic(); | |
} | |
// can be turned into this: | |
if({apple:1,banana:1,chikoo:1}[fruit]){ | |
doMagic(); | |
} |
Some snippets for Chrome that I've made or found/modified and thought were useful.
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
// List globally installed packages and their versions | |
// ------------------------------------------------------- | |
npm list -g --depth=0 | |
// List outdated globally installed packages | |
// ------------------------------------------------------- | |
npm outdated -g | |
// Reduce duplication in global packages | |
// ------------------------------------------------------- |
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
namespace APP.Domain | |
{ | |
public class FactoryClassMap : BsonClassMap | |
{ | |
public FactoryClassMap(Type classType, IDeserializationFactory factory) : base(classType) | |
{ | |
Func<object> factoryDelegate = factory.Create; | |
MapCreator(factoryDelegate); | |
AutoMap(); | |
} |
OlderNewer