Skip to content

Instantly share code, notes, and snippets.


Nic Bell nicbell

View GitHub Profile
nicbell / Auth0Async.kt
Created Jul 7, 2019
Async wrapper for Auth0.
View Auth0Async.kt
import android.content.Context
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
nicbell / PublishedContentWrappedExtensions.cs
Created Sep 26, 2016
Umbraco multiple hostnames, get correct url for a page, based on the domain of the current page.
View PublishedContentWrappedExtensions.cs
public static class PublishedContentWrappedExtensions
public static string GetContextAwareUrl(this PublishedContentWrapped content)
var urls = new List<string>();
var url = urls.FirstOrDefault(x => x.Contains(UmbracoContext.Current.HttpContext.Request.Url.Host));
View mustard.js
var win = window, doc = win.document, docElem = doc.documentElement;
// Replace 'no-js'/'js' class on <html>
docElem.className = docElem.className.replace(/\bno-js\b/g, '') + ' js ';
// loadJS: load a JS file asynchronously. From
function loadJS(e,t){"use strict";var n=doc.getElementsByTagName("script")[0],o=doc.createElement("script");return o.src=e,o.async=!0,n.parentNode.insertBefore(o,n),t&&"function"==typeof t&&(o.onload=t),o}
win.loadJS = loadJS;
// Enhancements for qualified browsers - "Cutting the Mustard"

This should not take more than 15 minutes, you will need to use command line or powershell to run the commands.

Sometimes you may need to close and reopen your shell window after a change to see the change.

    1. Install node 5.x.x available at
    1. Make sure it's on path. Run node -v
    1. Upgrade npm npm i npm -g -f
    1. Check npm version npm -v needs to be 3.x.x
    1. Install Python 2.x.x (make sure to choose add to path) available at
    1. Make sure Python is on path. python -V
nicbell / index.html
Created May 14, 2014
A Pen by Nic Bell.
View index.html
<svg style="display: none; height: 100px; width: 100%" xmlns="" xmlns:svg="" xmlns:xlink="" version="1.1">
<defs id="FooDefs">
<linearGradient id="MyFirstGradient" x1="0" y1="0" x2="0" y2="50" gradientUnits="userSpaceOnUse">
<stop id="stop1" style="stop-color:#1acf86;" offset="0" />
<stop id="stop2" style="stop-color:#ff0051;" offset="0.25" />
<stop id="stop3" style="stop-color:#1da1c9;"offset="0.625" />
<stop id="stop4" style="stop-color:#e45f25;" offset="1" />
<text x="0" y="50%" id="text" style="font-size:72px;fill:url(#MyFirstGradient);"></text>
nicbell / 1_primitive_comparison.js
Last active Aug 18, 2020
JavaScript object deep comparison. Comparing x === y, where x and y are values, return true or false. Comparing x === y, where x and y are objects, returns true if x and y refer to the same object. Otherwise, returns false even if the objects appear identical. Here is a solution to check if two objects are the same.
View 1_primitive_comparison.js
//Primitive Type Comparison
var a = 1;
var b = 1;
var c = a;
console.log(a == b); //true
console.log(a === b); //true
console.log(a == c); //true
console.log(a === c); //true
nicbell / jquery.hittest.js
Created Mar 5, 2013
The purpose of this plugin is to be able to detect if a point (X,Y) falls within an element.
View jquery.hittest.js
(function ($) {
$.fn.hitTest = function (x, y) {
return (x > this.offset().left && x < this.offset().left + this.width()) && (y > this.offset().top && y < this.offset().top + this.height());
var isHit = $(".something").hitTest(90, 100);
nicbell / NHibernateSessionManager.cs
Last active Dec 14, 2015
NHibernate Session Manager with SysCache
View NHibernateSessionManager.cs
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Caches.SysCache2;
using NHibernate.Context;
using NHibernate.Tool.hbm2ddl;
using System;
using System.Web;
namespace Ixoxo.NHib
You can’t perform that action at this time.