Skip to content

Instantly share code, notes, and snippets.

View markmarkoh's full-sized avatar

Mark DiMarco markmarkoh

View GitHub Profile
@markmarkoh
markmarkoh / gist:2341576
Created April 9, 2012 05:10
Example Ember.StateManager
App.stateManager = Ember.StateManager.create({
//Swap state within this element
rootElement: "#appRoot",
//Simple State
overview: Ember.ViewState.create({
view: App.Overview
}),
@markmarkoh
markmarkoh / gist:2341574
Created April 9, 2012 05:09
Director example
/* Director's routes config
routes that have segments that start with colons,
like /lists/:listType, will pass in the variable to
the callback.
*/
var routes = {
'/app': function() {
;
@markmarkoh
markmarkoh / gist:1593764
Created January 11, 2012 08:44
javascript dev training
/*
Javascript is an incredibly fun and (relatively) easy language. It's also
really easy to do badly... in some ways js is out to get you, so if you're
ready for it, you can avoid the pitfalls and have a great time.
Ideally this talk gets you thinking of Javascript as the unique,
quasi-dangerous little beast that is. If you respect the ways in which it
is your enemy, it will become one of your best friends.
This presentation isn't intended to teach javascript (though you'll probably
@markmarkoh
markmarkoh / gist:1308233
Created October 24, 2011 02:16
sinatra
require 'rubygems'
require 'sinatra'
require 'json'
mime_type :manifest, 'text/cache-manifest'
get '/*.*' do
#content_type :manifest
send_file('./' + params[:splat].join('.'))
end
$BV.configure("global", {
... old stuff ...,
onEvent: function(json) {
if (json.bvProduct === "Stories" && eType === "Read") {
//your resize function for SY
} else if (json.bvProduct === "RatingsAndReview" && eType === "Read") {
// your resize function for RR
}
}
> npm install . -g
#check to see if everything is working
> watchjs
Starting server on... #great
@markmarkoh
markmarkoh / gist:1106131
Created July 26, 2011 06:39
watch.bin.js
#!/usr/bin/env node
var app = require('../watch');
var static_dir = '.';
if (process.argv.length > 2) {
static_dir = process.argv[2];
}
app.init(static_dir);
@markmarkoh
markmarkoh / gist:1106127
Created July 26, 2011 06:37
package.json
{
"name": "watch.js",
"description": "A script and stylesheet reloader. Less browser refreshing.",
"version": "0.0.5",
"author": "Mark DiMarco (@markmarkoh)",
"engines": {
"node": ">= 0.4.0"
},
"dependencies": {
"socket.io": "0.7.7"
$(function() {
var tocWrapper = $("#toc .wrapper");
$("#mainContainer h1").each(function(i,item) {
$("<a />")
.text( $(item).text() )
.attr("href","#")
.data("scrollTo",item)
@markmarkoh
markmarkoh / gist:900237
Created April 3, 2011 06:26
Javascript Regex Shorthand trick
//In Javascript, a Regex object can be called like a function
//like: /test/("is test in here")
searchText = "padding 1234 rocket str austin TX 78704 more padding"
/\d+.+\n{0,2}.+\s+[A-Z]{2}\s+\d{5}/m(searchText)
//returns: ["1234 rocket str austin TX 78704"]
//As opposed to the more verbose(but sometimes more appropriate in cases that you are reusing the Regex):