Skip to content

Instantly share code, notes, and snippets.

View bryanforbes's full-sized avatar

Bryan Forbes bryanforbes

View GitHub Profile
define([
'dojo/declare',
'dojo/promise/when'
], function (declare, when) {
var slice = [].slice,
nop = function () {};
function createNotifier(object) {
var listenerMap = {},
objectListeners = [];
var dojoConfig = {
asyc: true,
baseUrl: 'path/to/src',
tlmSiblingOfDojo: false,
packages: [
'dojo',
'dijit',
'dojox',
{ name: 'doh', location: 'util/doh' }
]
# Set the default behavior, in case users don't have core.autocrlf set
* text=auto
# Files that should always be normalized and converted to native line
# endings on checkout.
*.js text
*.json text
*.htm text
*.html text
*.svg text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Button test</title>
<link rel="stylesheet" href="dijit/themes/claro/claro.css">
</head>
<body>
<button id="button" type="button" data-dojo-type="dijit/form/Button">My Button</button>
/// ice/logging/advanced.js
define(function (require, exports) {
exports.log = function (message, options) {
// ...
};
exports.error = function (message, options) {
// ...
};
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
<style>
#test {
width: 300px;
height: 300px;
@bryanforbes
bryanforbes / hostit.zsh
Created March 26, 2013 15:46
Placed in ~/.zsh/functions/hostit
# vim: set filetype=zsh:
if [[ $# -eq 0 ]]; then
echo "Usage: hostit [-l] [[-d -f] hostname]"
return
fi
REMOVE_HOST=0
FORCE_HOST=0
LIST_HOSTS=0
function secretSanta(array) {
var year = (new Date).getYear(),
offset = year % array.length,
map = {};
array.forEach(function (item, index) {
map[item] = array[index + offset] || array[array.length - (index + offset)];
});
return map;
@bryanforbes
bryanforbes / css-user-select.js
Created November 29, 2012 15:22
css-user-select
has.add("css-user-select", function(global, doc, element){
var style = element.style;
if(typeof style.userSelect !== "undefined"){
// Unlikely; user-select is non-standard, but might as well be future-proof...
return "userSelect";
}
var prefixes = ["Khtml", "O", "ms", "Moz", "Webkit"],
i = prefixes.length,
prefix, name;
@bryanforbes
bryanforbes / cmd.js
Created October 23, 2012 16:57
bdLoad Dojo node command line
#!/usr/bin/env node
var repl = require('repl'),
vm = require('vm'),
useGlobal = true;
function evalWithHistory(code, context, file, callback){
// TOOD: write history saving routines
var err, result;
try{
if(useGlobal){