Skip to content

Instantly share code, notes, and snippets.

[Enter steps to reproduce below:]
1. ...
2. ...
**Atom Version**: 1.6.1
**System**: Mac OS X 10.9.5
**Thrown From**: [keybinding-resolver](https://github.com/atom/keybinding-resolver) package, v0.33.0
@a-laughlin
a-laughlin / index.html
Created March 2, 2016 17:42 — forked from anonymous/index.html
JS Bin 3 ways to do Promise.all(asyncVals) // source http://jsbin.com/wegoha/14
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="3 ways to do Promise.all(asyncVals)">
<script src="https://cdn.rawgit.com/lodash/lodash/3.0.1/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.6/rx.all.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
@a-laughlin
a-laughlin / hide-boston-calendar-events.js
Last active October 13, 2015 16:39
Hide "The Boston Calendar" Events and remember hidden
// simple bookmarklet to hide events and re-hide them when re-activated
javascript:(function($){
var itemsStr = localStorage.getItem('hiddenItems') || '[]';
var itemsArr = JSON.parse(itemsStr);
var $a = $('li.event h3 a');
$(document).off('click');
$('.hider').remove();
$(document).on('click','.hider',hiderClicked);
itemsArr.forEach(hideItem);
@a-laughlin
a-laughlin / stickymenu.js
Last active August 29, 2015 14:11
Consistently Working AngularJS Sticky Menu Bar
.directive("stickyMenu", ['$window', function ($window) {
return {
restrict: 'A',
link: function(scope, $el, attrs) {
var windowTop;
var $win = angular.element($window);
var isFixed = false;
var origElemOffsetTop;
var origWidth;
var origOffsetLeft;
@a-laughlin
a-laughlin / angular.debug.js
Last active August 29, 2015 14:06
Search scope keys and values, including nested objects/arrays, for instances of string or regexp
javascript:(function(){
window.angular.debug = {
searchScope : function(varName,options) {
var registeredScopes = {};
var opts = angular.extend({
includeFns:false,
includeHidden:false,
recurseDepth:20
}, options);
var testFn = function(test,testStr){
@a-laughlin
a-laughlin / angular-watchcount.js
Created August 4, 2014 13:32
Bookmarklet to count AngularJS watches
// Instructions - create a bookmark. Save this code as the url.
// Click the bookmarklet to see watch count output in the console.
// Currently counts watches by nodeName. It would be more useful by class. TBD.
javascript: (function () {
var totalWatches = 0;
var watchesByElem = {};
angular.forEach(angular.element('.ng-scope'), function (elem) {
var s = angular.element(elem).scope();
var w = s.$$watchers;
if (s.$$watchers) {
@a-laughlin
a-laughlin / gist:1035d616c666271e1fe3
Created June 18, 2014 01:23
Bookmarklet to quickly switch between a repo and the gh-pages (github.io) view.
// Instructions. Save as a bookmark. Click when on a repo or github.io (gh-pages branch) site.
javascript:(function(h,p){
location = /io$/.test(h) ?
'https://github.com/' + h.split('.')[0] + p:
'http://'+ p.split('/')[1]+'.github.io'+ '/' + p.split('/').slice(2).join('/')
})(location.host,location.pathname);
@a-laughlin
a-laughlin / gist:6a009b290909b0d33de9
Created May 27, 2014 01:33
AngularJS - simple example of how services, factories, and values work
// how services, factories, and values work
var foo = {
providers:{},
instances:{},
provider:function(name,fn){
var pName = name + 'Provider';
foo.providers[pName] = foo.providers[pName] || new fn();
foo.instances[name] = foo.instances[name] || foo.providers[pName].$get();
return foo.providers[pName];
@a-laughlin
a-laughlin / gist:7065031
Created October 20, 2013 04:19
Simple utility to get selected text in a page
;(function(win,doc){
function _getSelectedText (){
_getSelectedText = win.getSelection ? // redefine itself when first run
win.getSelection :
doc.getSelection ?
doc.getSelection:
doc.selection ?
function(){return doc.selection.createRange().text;} :
function(){return '';};
@a-laughlin
a-laughlin / jquery.multi-pubsub.js
Created December 2, 2011 06:28
Multi-dependency pubsub with jQuery.Callbacks() and jQuery.Deferreds()
/*!
* jQuery multi-dependency pubsub v0.01
* Copyright 2011, Adam Laughlin
* http://a-laughlin.com
* Licensed under MIT & GPL version 2
* http://static.a-laughlin.com/mit_license.txt
* http://static.a-laughlin.com/gpl_license.txt
*
* inspired by Addy Osmani's example at:
* http://addyosmani.com/blog/jquery-1-7s-callbacks-feature-demystified/