Skip to content

Instantly share code, notes, and snippets.

* Promise vs Observable
* Promise
* Single async event that can either complete or fail once.
* Can be used with async/await keywords.
* Observable
* Can emit multiple events async.
* Offers a bit more control over the async task, for example cancelling.
* Cannot be used with async/await keywords.
* Think of Observables as a stream of data instead of an async task.
* Observable is the default used in Angular, but promises are still fine to use.
{
"workbench.iconTheme": "material-icon-theme",
"workbench.editor.showTabs": false,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.minimap.enabled": false,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"files.exclude": {
"**/.git": true,
/**
* Provides the ability to fetch global plugin objects.
*/
class PluginService {
static $inject = ['$ionicPlatform', '$window', '$q', '$log'];
constructor(private $ionicPlatform: ionic.platform.IonicPlatformService,
private $window: ng.IWindowService,
private $q: ng.IQService,
private $log: ng.ILogService) {
package com.dkellycollins.ioc;
import java.util.HashMap;
import java.util.Map;
/**
* Manages class instances.
*/
public abstract class Module {
@dkellycollins
dkellycollins / BaseForm.cs
Last active March 8, 2018 20:49
Example of how you might use Ninject within a WinForms application.
/// <summary>
/// Non-Generic BaseForm. Provides functionality for retrieving the controller.
/// </summary>
public class BaseForm : Form
{
/// <summary>
/// Gets the controller for the given type.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
@dkellycollins
dkellycollins / ng-table.d.ts
Last active September 10, 2015 14:43
ng-table.d.ts
declare module ngTable {
class ngTableParams {
data:any[];
constructor(parameters:any, settings:any);
parameters(newParameters:string, parseParamsFromUrl:string):any;
settings(newSettings:string):any;
class Program
{
static void Main(string[] args)
{
int numOfCoPrimes = 0;
for (int i = 1; i < 1225; i++)
{
int g = gdc(i, 1225);
if (g == 1)
numOfCoPrimes++;
using System;
namespace Sum
{
class Program
{
//Estimates the perimeter of a circle of radius 1 using Archimededes formulas
static void Main(string[] args)
{
int n = 96; //n-polygon to estimate with.
@dkellycollins
dkellycollins / Create.cshtml
Last active August 24, 2016 21:44
A generic model controller for ASP.NET MVC framework.
@using BootstrapSupport
@model Object
<div class="container">
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset class="form-horizontal">
<legend>@Model.GetLabel() <small>Details</small></legend>
@foreach (var property in Model.VisibleProperties())
@dkellycollins
dkellycollins / QueueProcessor
Last active December 12, 2015 03:09
QueueProccessor for processing data. This class is meant to be inherited and have the sub class handle actually processing the data. Currently implemented with BackgroundWorker and is untested.
///<summary>
///Handles processing data of type T. Subclass implements process and handles storing results.
///</summary>
public abstract class QueueProcessor<T>
{
private Queue<T> _data;
private BackgroundWorker _worker;
private bool _stopOnEmpty;
public delegate ErrorHandler(Exception e);