Skip to content

Instantly share code, notes, and snippets.

View jabbett's full-sized avatar

Jonathan Abbett jabbett

View GitHub Profile
@jabbett
jabbett / backbone_pushstate_router.js
Last active December 15, 2015 04:09 — forked from tbranyen/backbone_pushstate_router.js
Updated protocol check to respect javascript: pseudo-protocol and hash links (#foo) Updated to support IE
// Use absolute URLs to navigate to anything not in your Router.
// Note: this version works with IE. Backbone.history.navigate will automatically route the IE user to the appropriate hash URL
// Use delegation to avoid initial DOM selection and allow all matching elements to bubble
$(document).delegate("a", "click", function(evt) {
// Get the anchor href and protcol
var href = $(this).attr("href");
var protocol = this.protocol + "//";
// Ensure the protocol is not part of URL, meaning its relative.
@jabbett
jabbett / instiki.css
Last active August 29, 2015 13:58
Jabbett's Responsive Instiki Stylesheet
/*
** Jabbett's Responsive Instiki Stylesheet
** Make Instiki feel like a modern web application (almost).
** Replace public/stylesheets/instiki.css with this file.
*/
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
/* http://meyerweb.com/eric/tools/css/reset/
v2.0b1 | 201101
@jabbett
jabbett / actmd_js_excerise.md
Last active May 19, 2016 21:46
JavaScript exercise for ACT.md UI Engineer position

JavaScript exercise for ACT.md UI Engineer position

Your task is to implement a view that is able to display a list of video titles using a paginated search API; in this case, Google's YouTube API.

You may use any JavaScript framework you like. At ACT.md we use Backbone and Marionette, but choose Angular, Ember, etc., if that's more comfortable.

There are also many ways to approach the UX of this problem -- you can pick your favorite. For example:

@jabbett
jabbett / show.yml
Created November 23, 2016 01:02
Product tour definition for Abraham
intro:
steps:
1:
text: "Welcome to your dashboard! This is where we'll highlight key information to manage your day."
2:
title: "Events"
text: "If you're participating in any events today, we'll show that here."
attachTo:
element: ".dashboard-events"
placement: "right"
@jabbett
jabbett / bootstrap-4-popover.js
Created November 29, 2016 18:11
Managing popovers in Bootstrap 4
/*
** This gist shows how to implement Bootstrap 4 popovers that:
** a) disappear automatically when the user clicks outside the popover
** b) only appear one at a time
*/
// Hide other popover when new one appears
$('[data-original-title]').on('show.bs.popover', function () {
$('[data-original-title]').not(this).popover("hide");
});
@jabbett
jabbett / ahoy_base.rb
Last active April 12, 2019 03:00
Setting up Ahoy models to use a separate datastore
module Ahoy
class AhoyBase < ActiveRecord::Base
establish_connection DB_STATS
self.abstract_class = true
end
end
@jabbett
jabbett / _form.html.erb
Last active February 22, 2019 14:30
ActsAsTaggableOn with collection_check_boxes
<%= form_for(@sundae) do |f| %>
<!--
collection_check_boxes requires 4 parameters, the last two are methods that access
the value and text from the collection, respectively. Hence the need for
SundaesHelper.valid_flavors!
-->
<%= f.collection_check_boxes(:flavor_list, valid_flavors, :first, :first) do |b| %>
<!-- FYI: I use Bootstrap 4, so I customized how the checkboxes would render -->
<div class="form-check">
<label class="form-check-label"><%= b.check_box class: 'form-check-input' %> <%= b.value %></label>