Skip to content

Instantly share code, notes, and snippets.

View iotaweb's full-sized avatar

Rob Anderson iotaweb

  • Auckland, New Zealand
View GitHub Profile
@iotaweb
iotaweb / 0_reuse_code.js
Created February 26, 2016 05:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@iotaweb
iotaweb / Greensock Timeline Demo.markdown
Created July 11, 2015 04:17
Greensock Timeline Demo
@iotaweb
iotaweb / gist:14758ba6d30a741d13d8
Last active August 29, 2015 14:22
Angular.js countdown timer directive
/*
* AngularJS Countdown Timer Directive
* Author: Rob Anderson @iotaweb
* Dependencies: https://github.com/EvanHahn/HumanizeDuration.js
* Example: <span countdown class="pull-right" prefix="Token expires in" expires="{{ token.expiresAt }}"></span>
*/
(function () {
'use strict';
/*
Extended Angular logging
Author: Rob Anderson (@iotaweb)
Adds ability to turn on/off all logging messages
Adds abiity to specify logging levels
Adds support for console.table()
Adds support for using controller name (or alias) as context
Prepends logs with timestamp (nicely padded)
Doesn't mess with array (preserves nascent string substitution), e.g. $log.info('This is a %s', message)
Nicely formatted for easy reading (context padded to consistent width [optional])
@iotaweb
iotaweb / gist:8228276
Created January 2, 2014 22:27
gravatar Image service for AngularJS (uses md5 factory - see other gist)
//! gravatarImageService
.factory('gravatarImageService', function(md5) {
return {
getImageSrc: function(value, size, rating, defaultUrl, secure) {
// convert the value to lower case and then to a md5 hash
var hash = md5.createHash(value.toLowerCase());
var src = (secure ? 'https://secure' : 'http://www') + '.gravatar.com/avatar/' + hash + '?s=' + size + '&r=' + rating + '&d=' + defaultUrl;
return src;
}
};
@iotaweb
iotaweb / gist:8228261
Last active January 2, 2016 01:09
md5 factory for AngularJS
/*
* http://kevin.vanzonneveld.net
* original by: Webtoolkit.info (http://www.webtoolkit.info/)
* namespaced by: Michael White (http://getsprink.com)
* tweaked by: Jack
* improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
* input by: Brett Zamir (http://brett-zamir.me)
* bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
* depends on: utf8_encode
* example 1: md5('Kevin van Zonneveld');
@iotaweb
iotaweb / gist:8228253
Created January 2, 2014 22:25
Base64 encode / decode factory for AngularJS
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
.factory('Base64', function() {
// private property
var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@iotaweb
iotaweb / riak.sh
Last active February 14, 2016 00:59
Script to create a local Riak cluster on Mac OS X.
#!/bin/sh
CWD=$(cd $(dirname $0); pwd)
echo "This script will create a local riak cluster for development purposes only."
echo "Prerequisites: install riak using homebrew (tested with v1.3.1)."
echo "The cluster will be created in the current directory."
echo "Riak admin is enabled with no security.\n"
read -p "Enter a name for your cluster [cluster]: " name
@iotaweb
iotaweb / node-reader.js
Created June 26, 2012 10:39 — forked from dongyuwei/node-reader.js
google reader api for nodejs
/*
This library was developed by Will Honey.
It is licensed under the GPLv3 Open Source License
This library requires the underscore library found at http://documentcloud.github.com/underscore/
This library requires the underscore string library found at http://edtsech.github.com/underscore.string/
This library requires the support of localStorage. Updates could be easily made to change that.
*/
/* jslint adsafe: false, devel: true, regexp: true, browser: true, vars: true, nomen: true, maxerr: 50, indent: 4 */