Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Nic Bell nicbell

🎯
Focusing
View GitHub Profile
@nicbell
nicbell / Auth0Async.kt
Created Jul 7, 2019
Async wrapper for Auth0.
View Auth0Async.kt
import android.content.Context
import com.auth0.android.Auth0
import com.auth0.android.authentication.AuthenticationAPIClient
import com.auth0.android.authentication.AuthenticationException
import com.auth0.android.callback.BaseCallback
import com.auth0.android.result.Credentials
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import ltd.inja.app.R
@nicbell
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>();
urls.Add(UmbracoContext.Current.RoutingContext.UrlProvider.GetUrl(content.Id));
urls.AddRange(UmbracoContext.Current.RoutingContext.UrlProvider.GetOtherUrls(content.Id));
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 https://github.com/filamentgroup/loadJS/
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"
View node-windows.md

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 https://nodejs.org/en/
    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 https://www.python.org/downloads/
    1. Make sure Python is on path. python -V
@nicbell
nicbell / index.html
Created May 14, 2014
A Pen by Nic Bell.
View index.html
<svg style="display: none; height: 100px; width: 100%" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/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" />
</linearGradient>
</defs>
<text x="0" y="50%" id="text" style="font-size:72px;fill:url(#MyFirstGradient);"></text>
@nicbell
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
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());
};
})(jQuery);
var isHit = $(".something").hitTest(90, 100);
@nicbell
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.