Skip to content

Instantly share code, notes, and snippets.

View dphoebus's full-sized avatar
😏

Daniel Phoebus dphoebus

😏
  • CaptiveAire, Inc.
View GitHub Profile
@dphoebus
dphoebus / SlackClient.cs
Created August 8, 2017 21:03 — forked from jogleasonjr/SlackClient.cs
A simple C# class to post messages to a Slack channel. You must have the Incoming WebHooks Integration enabled. This class uses the Newtonsoft Json.NET serializer available via NuGet. Scroll down for an example test method and a LinqPad snippet. Enjoy!
using Newtonsoft.Json;
using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
//A simple C# class to post messages to a Slack channel
//Note: This class uses the Newtonsoft Json.NET serializer available via NuGet
public class SlackClient
{
@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();
}
@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 / 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 / README.md
Created March 4, 2016 18:51 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@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 / 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

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];