Skip to content

Instantly share code, notes, and snippets.

View dphoebus's full-sized avatar
😏

Daniel Phoebus dphoebus

😏
  • CaptiveAire, Inc.
View GitHub Profile
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];
@dphoebus
dphoebus / angularjs-providers-explained.md
Created November 18, 2015 20:30 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
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

Constant

@dphoebus
dphoebus / Deploy.ps1
Created February 23, 2016 13:25 — forked from rarous/Deploy.ps1
Script for packaging and deployment of ASP.NET applications to IIS via Web Deploment Tools
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'
@dphoebus
dphoebus / README.md
Created March 4, 2016 18:51 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@dphoebus
dphoebus / console.js
Created May 12, 2016 16:57
Simple JavaScript 'console' script for debugging.
(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);
@dphoebus
dphoebus / bytesToSize.js
Created May 27, 2016 20:12 — forked from lanqy/bytesToSize.js
JavaScript To Convert Bytes To MB, KB, Etc
// 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];
};
@dphoebus
dphoebus / js-examples.js
Created June 8, 2016 17:25
JavaScript Quick Hitters
if(fruit === 'apple' || fruit === 'banana' || fruit === 'chikoo'){
doMagic();
}
// can be turned into this:
if({apple:1,banana:1,chikoo:1}[fruit]){
doMagic();
}
@dphoebus
dphoebus / AngularJS Snippets.md
Created November 30, 2016 06:52 — forked from kentcdodds/AngularJS Snippets.md
AngularJS Chrome DevTools Snippets

Angular Snippets

Some snippets for Chrome that I've made or found/modified and thought were useful.

demo

@dphoebus
dphoebus / npm-commands.txt
Last active April 18, 2017 20:03
List of useful NPM commands
// 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
// -------------------------------------------------------
@dphoebus
dphoebus / DomainModelRegistration.cs
Created August 1, 2017 19:22 — forked from andreabalducci/DomainModelRegistration.cs
mapping custom factory for mongodb c# driver deserialization
namespace APP.Domain
{
public class FactoryClassMap : BsonClassMap
{
public FactoryClassMap(Type classType, IDeserializationFactory factory) : base(classType)
{
Func<object> factoryDelegate = factory.Create;
MapCreator(factoryDelegate);
AutoMap();
}