Skip to content

Instantly share code, notes, and snippets.

View heath's full-sized avatar
❄️
λΠ

heath

❄️
λΠ
View GitHub Profile
@heath
heath / schema.js
Created March 27, 2012 06:44
Sample Mongoose Schema
customSchema(function () {
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var Schema = mongoose.Schema, ObjectId = Schema.ObjectId;
var Products = new Schema({
cucumbers : ObjectId
, tomatoes : ObjectId
set ai
set ts =2
set cpoptions+=$
set expandtab
set ls =2
set modeline
set nocompatible
set number
set shiftwidth =2
set softtabstop =2
@heath
heath / gist:3123429
Created July 16, 2012 15:47
jshint.rc
/* jshint browser: true,
* dojo: true,
* es5: true,
* jquery: true,
* regexp: true,
* smarttabs: true */
/* vim: set ft=javascript: */
@heath
heath / gist:3148251
Created July 20, 2012 02:17
My Haskell code, for Project Euler problem #2, translated to JS
var usk = require('UnderscoreKit'),
zipwith = require('zipwith').zipwith;
function recursFib() {
var fibs = [1,1];
fibs.concat(
zipwith( function (a, b) {return a + b;}, fibs.slice(-2))
);
return fibs;
};
@heath
heath / gist:3932795
Created October 22, 2012 17:29
An attempt to avoid a long list of if statements
//all of this is within a pretty long method for handling key events
var groupChoices = {
65 : 'a', 66 : 'b', 67 : 'c',
68 : 'd', 69 : 'e', 70 : 'f',
71 : 'g', 72 : 'h', 73 : 'i',
74 : 'j', 75 : 'k', 96 : '0',
97 : '1', 98 : '2', 99 : '3',
100 : '4', 101 : '5', 102 : '6',
103 : '7', 104 : '8', 105 : '9'
// alternative 1
$(function() {
$('.viator_cancel_link').on('click', function() {
$('.viator_cancel_info').toggle();
})
})
// alternative 2
var toggleInfo = function() {
this.init: function() {
" <div data-dojo-attach-point='pNode' data-dojo-type='dojox.widget.Portlet' data-dojo-props='title:foobar'" +
this.tabContainer.domNode.appendChild(dojo.create('div', {
attrs: {
"onClick": function() {
console.log('making it heeeeeeeeeeeeeeeeeeere');
// this.showTaggingControls;
}
},
className: 'taggingControls',
innerHTML: "Tagging Controls"
}));
<tbody>
<tr>
<td>a</td><!-- temporarily.. -->
<td><input data-dojo-attach-point='editname' value='Group 1'></input></td>
<td dojoAttachPoint='highlightColorPicker' class="default-color-of-groups" dojoAttachEvent='onClick:colorSelectClicked' baseClass='documentHighlightColorDropdown' dojoType='dijit.form.Button'></td>
</tr>
</tbody>
showTaggingControls: function() {
var canvasSettings = new widget.CanvasSettings({
columnView : this.columnView,
groupCollection : this.groupCollection,
parent : this.controlsDialog, //an attempt to reach this.controlsDialog
thumbnailsView : this.thumbnailsView
});
this.controlsDialog = new dijit.Dialog({