Skip to content

Instantly share code, notes, and snippets.

@jessecravens
jessecravens / basic_db.rb
Created October 15, 2012 20:59
Simple mysql Drupal to Octopress migration script
# inspired by: http://www.infovore.info/blog/2011/09/24/octopress-setup-and-drupal-migration/
# simplified to be dropped in your root Octopress app directory, along with an export (.sql) of your mysql db.
###### Creates post in this basic format ######
# ---
# layout: post
# title: #{title}
# date: #{time}
# comments: true
@jessecravens
jessecravens / yepnope-bad.js
Created March 29, 2012 18:32
JavaScript Modules - yepnope
someLoader('http:/­/ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js', function () {
if (!window.jQuery) {
someLoader('local/jquery.min.js', 'jquery.plugin.js');
} else {
someLoader('jquery.plugin.js');
}
});
@jessecravens
jessecravens / dynamic.js
Created March 29, 2012 17:34
JavaScript Modules - harmony
Loader.load('http://json.org/modules/json2.js',
function(JSON) {
console.log(JSON.stringify([0, {a: true}]));
});
@jessecravens
jessecravens / basic.js
Created March 29, 2012 17:33
JavaScript Modules - commonJS
// defining a module
// making the hello method accessible
exports.hello = function() {
return 'Hello World'
};
// require the module elsewhere such as app.js - application entry point
@jessecravens
jessecravens / index.html
Created March 29, 2012 15:01
JavaScript Modules - yui3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Modules</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
<script>
@jessecravens
jessecravens / one.js
Created March 29, 2012 14:31
JavaScript Modules - requireJS
define(
//The name of this module
"one",
//The function to execute when all dependencies have loaded. The arguments
//to this function are the array of dependencies mentioned above.
function(Three) {
function One () {
this.stuff = [];
@jessecravens
jessecravens / websockets-client.js
Created March 8, 2012 03:45
Basic Web Sockets
var socket = new WebSocket('ws://html5hacks.com/socket');
// Once the socket connection is opened ... send a message to the server
socket.onopen = function(event) {
socket.send('Hello, Html5');
};
// Log any data pushed from the server
socket.onmessage = function(event) {
console.log(event.data);
// Causes problems
// We need synchronous, but bad idea for performance
var Employee = require("types/Employee");
function Manager () {
this.reports = [];
}
//Error if require call is async
@jessecravens
jessecravens / Jade template
Created February 25, 2012 21:22
HTML5 Hacks - HTML5 Boilerplate Jade template
!!! 5
//if lt IE 7
html.no-js.ie6.oldie(lang='en')
//if IE 7
html.no-js.ie7.oldie(lang='en')
//if IE 8
html.no-js.ie8.oldie(lang='en')
//[if gt IE 8]><!
html.no-js(lang='en')
//<![end if]
@jessecravens
jessecravens / ai-library-init.js
Created February 25, 2012 20:47
HTML5 Hacks - Web Workers - highComp.js
// 3. generate DOM movement
var i = -1;
while (i++ < num) {
characters[i] = new Character(400, 300, i);
characters[i].start();
characterMap[characters[i].id] = characters[i];
}