Skip to content

Instantly share code, notes, and snippets.

@meirish
meirish / backbone.snippets
Created May 6, 2011 22:00
backbone snippet for snipmate w/vim
snippet model
var ${1:model} = Backbone.Model.extend({
initialize: function () {
}
});
var ${2:$1}s = Backbone.Collection.extend({
model: ${3:$1},
url: "${4}"
});
var setTextMeasure = function (contentElement, targetMeasure, maxSize, minSize) {
if (!contentElement) contentElement = $(document.createElement('p'));
if (!targetMeasure) targetMeasure = 66;
if (!maxSize) maxSize = 16;
if (!minSize) minSize = 9;
var body = $('body');
var sizer = contentElement.clone();
var App = {
init: function(){
this.setup();
this.doOtherStuff();
},
setup: function(){
//
},
doOtherStuff: function(){
//
@meirish
meirish / transloadit.py
Created August 14, 2011 01:26
Transloadit.com wrapper by @redneckbeard
{% extends "base.html" %}
{% block extra_head %}
<script type="text/javascript" charset="utf-8" src="{{ MEDIA_URL }}js/jquery.tools.date.min.js"></script>
<script type="text/javascript">
var tlProtocol = (('https:' == document.location.protocol) ? 'https://' : 'http://');
document.write(unescape("%3Cscript src='" + tlProtocol + "assets.transloadit.com/js/jquery.transloadit2.js' type='text/javascript'%3E%3C/script%3E"));
</script>
{% endblock %}
var self = this,
baseUrl = '/myGCS/sw/tracker/gtuSettings/',
idString = '?unitId='+this.model.id,
noCacheString = '&a='+(+new Date),
urls = {
'settings': [baseUrl, idString, 'deviceSettings', noCacheString].join(''),
'battery': [baseUrl, idString, 'batteryUsage', noCacheString].join(''),
'notifications': [baseUrl, idString, 'deviceNotifications', noCacheString].join(''),
'continuous-tracking': [baseUrl, idString, 'batteryUsage', noCacheString].join(''),
'check-ins': [baseUrl, idString, 'batteryUsage', noCacheString].join(''),
@meirish
meirish / rdio.json
Created October 12, 2011 05:29
rdio api output
{
"status": "ok",
"result": [{
"baseIcon": "album/0/5/2/00000000000ed250/square-200.jpg",
"releaseDate": "2011-08-29",
"displayDate": "Aug 29, 2011",
"duration": 4299,
"isClean": false,
"shortUrl": "http://rd.io/x/QFtyPk2NAg",
"canStream": true,
@meirish
meirish / home.html
Created October 15, 2011 18:52
under _.template on both
<!DOCTYPE html>
<html>
<head>
<title>Rdio-Simple Example</title>
</head>
<body>
<a href="/logout">Log out of Rdio</a>
<p>Logged in as <%= firstName %></p>
<div id="player">
<div id="rdioSwf"></div>
@meirish
meirish / gist:1298469
Created October 19, 2011 14:32
Lstn Search View
Lstn.Views.SearchView = Backbone.View.extend({
el: '#search',
events:{
'focus':'bindToReset',
'blur':'unbindReset'
},
initialize: function(options){
@meirish
meirish / DashboardProductView.js
Created October 27, 2011 15:35 — forked from hollowmyth/DashboardProductView.js
backbone view with draggable events should work on iOS but doesn't
Garmin.msc.Views.DashboardProductView = Backbone.View.extend({
//this is the view for a single selected product in
//the dashboard (the dashboardCollection) and should.
className:"product-dashboard",
events: {
// "mouseenter .display":"goOver",
// "mouseleave .display":"goOut",
"dragstart":"startDrag",
"dragstop":"stopDrag",
"drag":"whileDragging",
@meirish
meirish / view.js
Created November 15, 2011 17:35
require.js view
define([
'jquery',
'underscore',
'backbone',
'collections/widget-list',
'text!templates/widget-list.html',
'ui'
], function($,_,Backbone, WidgetCollection, widgetTemplate){
var WidgetList = Backbone.View.extend({