Skip to content

Instantly share code, notes, and snippets.

var __extend = new Extender();
var Robot = function(robot) {
};
__extend( Robot.prototype, {
onIdle: function(e) {
var robot = e.robot;
@jonjaques
jonjaques / dialog-reset.css
Last active December 22, 2015 04:18
jQuery UI Dialog Reset
.ui-dialog-reset.ui-dialog {
padding: 0;
}
.ui-dialog-reset.ui-dialog .ui-dialog-titlebar,
.ui-dialog-reset.ui-dialog .ui-dialog-content,
.ui-dialog-reset.ui-dialog .ui-dialog-buttonpane,
.ui-dialog-reset.ui-dialog .ui-dialog-buttonpane button,
.ui-dialog-reset.ui-dialog .ui-button-text {
padding: 0;
margin: 0;
@jonjaques
jonjaques / checklist-serialize.js
Last active December 20, 2015 15:59
Serialize Confluence Checklists (like a boss)
(function() {
var els = $('#main-content').children().filter(function() {
var el = $(this);
return (el.is('h3') || el.is('h3 + ul')) ? true : false;
})
var queue = []
els.each(function() {
var el = $(this);
if (el.is('h3')) {
queue.push(el.text());
@jonjaques
jonjaques / index.html
Created August 2, 2013 19:08
Dream Mode
<script>
(function($) {
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(konami) >= 0) {
$(document).unbind('keydown', arguments.callee);
$.getScript('http://www.cornify.com/js/cornify.js', function() {
cornify_add();
$(document).keydown(cornify_add);
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-mincss');
grunt.loadNpmTasks('grunt-contrib-uglify');
@jonjaques
jonjaques / replaceseer.js
Last active December 18, 2015 15:09
Replace Seer
(function($) {
var Memcache = function(hash) {
var self = this,
this.lookupCache = [],
this.valueCache = [];
$.map(hash, function(val, key) {
self.lookupCache.push(key);
self.valueCache.push(val);
@jonjaques
jonjaques / bindings.js
Last active December 17, 2015 16:39
Super-simple touch event bindings for Knockout.js
// Uses Hammer-jquery | https://github.com/EightMedia/hammer.js/blob/master/dist/jquery.hammer.js
$.extend(ko.bindingHandlers, {
touchEvent: {
defaults: {},
init: function(el, valueAccessor, allBindingsAccessor) {
var self = ko.bindingHandlers.touchEvent,
events = ko.utils.unwrapObservable(valueAccessor()),
allOptions = allBindingsAccessor(),
opts = allOptions.touchEventOptions ? allOptions.touchEventOptions : {};
@jonjaques
jonjaques / fbapp.js
Last active December 17, 2015 04:19
Abstracting async ops with promises
// So let's say you have an async operation that doesn't
// use a jQuery-ajax method. In my example, I'll use a call
// to the FB API, which just takes a callback function
// which gets called with a ```resp``` object.
FB.api('/platform', function(resp) {
if (resp.data) {
success();
} else if (resp.error) {
error();
@jonjaques
jonjaques / main.js
Created December 4, 2012 06:55
Knockout Bookmarklet template, w/ html template loading
// You create your bookmarklet by instantiating
// a new Bookmarklet function, then pass in the options like so.
// This example checks to see if the var is already defined, and makes
// sure not to overwrite it. This could happen if the user clicks on
// the bookmarklet more than once.
(function(global) {
global.Doublestock = new Bookmarklet({
css: [
'css/styles.css'
@jonjaques
jonjaques / dog.js
Created July 20, 2012 20:56
Prototypical Inheritance Pattern
var Dog = function(name){
var name = name,
numberOfBarks = function(volume){
for(var i = 10; volume >= i; i--){
if(volume % 3 === 0){
return volume / 3;
}
}