Skip to content

Instantly share code, notes, and snippets.

@justinobney
justinobney / wbr.js
Last active August 29, 2015 14:02
Adding "Word Break Opportunity" to content.
/*
-- EXAMPLE USES
<div wbr>long.html?var=one$20two</div>
-- With optional regex to override default
<div wbr regex="/(\&|-|\=|(the)|(20))/gi">
long.html?var=one$20two
</div>
@justinobney
justinobney / $watching.js
Last active March 24, 2016 20:41
Traditional Data Service
app.controller('Ctrl1', function($scope, DataFactory) {
// bind the controller property to the service collection
this.items = DataFactory.items;
// watch the collection for changes
$scope.$watch(watchSource, function(current, previous){
this.items = current;
});
function watchSource(){
@justinobney
justinobney / Index.cshtml
Last active August 29, 2015 14:03
Blog post example
@model Jobney.Casm.Web.Models.ManageDataBootstrapper
<div data-ng-app="Jobney.Casm.ManageApp" data-ng-controller="ManageAppCtrl">
<ul class="tab-bar grey-tab">
<!-- content here -->
</ul>
<div data-ui-view></div>
</div>
@section scripts
var cache = {};
function checkCache(key){
if(cache[key]){
return cache[key];
} else {
// do some long/expensive action
// ex: calculation, ajax, etc...
cache[key] = Math.random();
return cache[key];
}
var data = [{
id: 1,
children: [{
id: 2,
children: [{
id: 3,
children: [{
id: 4,
children: []
}]
@justinobney
justinobney / hn_whose-hiring.js
Last active August 10, 2016 13:43
Hacker News - Who is hiring trends
var clientSide = [
'javascript',
'elm',
'ember',
'angular',
'jquery',
'backbone',
'react',
'reactjs',
'clojurescript',
@justinobney
justinobney / Rx_throttledPromiseObserver.js
Last active August 29, 2015 14:13
Create an observable that accepts a list of callbacks(returning promises) to execute keeping only an optional number in flight at one time
function throttledPromiseObserver(callbacks, maxPending, checkInterval) {
var remainingCalls = callbacks.length;
var pendingCalls = 0;
var callIdx = 0;
var _checkInterval = checkInterval || 100;
var _maxPending = maxPending || 0;
return Rx.Observable.create(bufferedPromiseCalls);
function bufferedPromiseCalls(observer) {
var Game = {
init: init,
draw: draw
}
function init(name){
this.name = name;
}
function draw() {
JSON.stringify((function(){
return Object.keys(window).filter(function(key) {
try {
var versionInfo = getVersionInfo(key)
return versionInfo.version
} catch (e) {
return false
}
}).map(getVersionInfo)
$provide.decorator('$exceptionHandler', [
'$delegate', '$window', '$log', '$stateParams',
function($delegate, $window, $log, $stateParams) {
return function(exception, cause) {
if ($window.trackJs) {
$log.debug('$exceptionHandler ::: $stateParams => ', angular.toJson($stateParams));
$window.trackJs.track(exception);
}
$delegate(exception, cause);
};