Skip to content

Instantly share code, notes, and snippets.

View smokinjoe's full-sized avatar

Joe smokinjoe

View GitHub Profile
"month in months track by $index".match(/^\s*(.+)\s+in\s+(.*?)(?:\s+track\s+by\s+(.+?))?\s*$/);
@smokinjoe
smokinjoe / anchor_smooth_scroll.js
Created January 26, 2016 18:20 — forked from justinmc/anchor_smooth_scroll.js
Anchor Smooth Scroll - Angular Directive
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
angular.module('yourapp').directive('anchorSmoothScroll', function($location) {
'use strict';
return {
restrict: 'A',
replace: false,
@smokinjoe
smokinjoe / gist:aecc398e53500cbb7907
Last active March 8, 2016 06:47
Debugging Hubot
# From https://github.com/github/hubot/issues/648#issuecomment-78796436
The book Automation and Monitoring with Hubot has a section on debugging.
I've just tested that myself, and it seems to work well. Basically, the steps are:
npm install -g node-inspector
node-inspector --no-preload --web-port 8123
Then, we can insert debugger in our code somewhere to setup a breakpoint. Then we run Hubot:
@smokinjoe
smokinjoe / gist:28e02357c0ca8aca3fc5
Created July 22, 2015 23:56
my star wars constructor dealie [...that I borrowed]
/*
* Star Wars opening crawl from 1977
*
* I freaking love Star Wars, but could not find
* a web version of the original opening crawl from 1977.
* So I created this one.
*
* I wrote an article where I explain how this works:
* http://timpietrusky.com/star-wars-opening-crawl-from-1977
*
@smokinjoe
smokinjoe / gist:8979111dd90b2f2d0bd5
Created April 12, 2015 04:34
Amazing example of async waterfall and map for cheating in nested result queries
// Use waterfall so that you can easily disconnect at the end of your code.
// It also makes node.js callbacks less confusing.
async.waterfall([
function (wCb) {
connection.connect();
// wCB is a callback function. Call it when you want to move to the
// next function in the waterfall
wCb();
},
function (wCB) {
@smokinjoe
smokinjoe / gist:5542209ce4d80b20b75c
Created January 23, 2015 00:41
mithril.js sandbox
<!doctype html>
<title>My Appola</title>
<script src="lodash.js"></script>
<script src="JocalStorage.js"></script>
<script src="mithril.js"></script>
<script>
JocalStorage.init();
// create mithril module
var todo = {};
@smokinjoe
smokinjoe / gist:ccf599bf3b0a87055d24
Created May 3, 2014 01:12
function to find the next/prev value in an array (circular)
return function (_array, _id) {
var _result = {};
var _clean_array = _.compact(_array);
_result.next = _clean_array[($.inArray(_id, _clean_array) + 1) % _clean_array.length];
_result.prev = _clean_array[($.inArray(_id, _clean_array) - 1 + _clean_array.length) % _clean_array.length];
return _result;
};
@smokinjoe
smokinjoe / js_module
Last active August 29, 2015 14:00
Nice module pattern
// http://yuiblog.com/blog/2007/06/12/module-pattern/
//Self-Executing Anonymous Func: Part 2 (Public & Private)
(function( skillet, $, undefined ) {
//Private Property
var isHot = true;
//Public Property
skillet.ingredient = 'Bacon Strips';
@smokinjoe
smokinjoe / html5 boilerplate
Last active February 12, 2022 09:46
basic html5 boilerplate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
@smokinjoe
smokinjoe / ajax_template
Last active December 24, 2015 08:59
AJAX Template
$.ajax({
type: "POST",
url: "/route/to/dealie",
dataType: 'json',
data: {
var1 : var1,
var2 : var2
},
// given a json object with result property
success: function(response) {