Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View acoard's full-sized avatar

Adam Coard acoard

View GitHub Profile
@acoard
acoard / randomElement.js
Created March 4, 2014 06:53
Adds a .randomElement() method to lists by extending Object.prototype
//This little snippet does the bad practice of overloading default JavaScript objects. I know it's bad taste, sue me.
//It only works on arrays.
//['a', 'b', 'c'].randomElement()
Object.prototype.randomElement = function(){
var randomIndex = Math.floor(Math.random() * this.length);
return randomString = this[randomIndex];
}
@acoard
acoard / gist:a0cc64d4f657312f44e1
Created April 20, 2015 15:22
Javascript promises style
//Question: if you have a function which may or may not do some async, do you use a promise for the non-async path?
//Option A: Only return promise when doing async:
function OptionA(input){
if ( requiresQuery() ){
var defer = Q.deferred();
$.ajax()...
.done(function(asyncData){
defer.resolve(asyncData);
@acoard
acoard / 01-Openshift3-WSL2.md
Created February 3, 2021 19:14 — forked from kekru/01-Openshift3-WSL2.md
Openshift 3.11 in WSL2

Running Openshift 3.11 inside WSL2

This is not running yet, but nearly almost

Install WSL2 and oc client

First install a WSL2 with Ubuntu 20.04 as described at Microsoft

Enter wsl shell