Skip to content

Instantly share code, notes, and snippets.

View mcotton's full-sized avatar

Mark Cotton mcotton

View GitHub Profile
@mcotton
mcotton / gist:3170324
Created July 24, 2012 14:43
Installing VMWare tools on ubuntu

Installing VMWare tools on Ubuntu

> sudo apt-get install build-essential
> mkdir tmp
> sudo mount /dev/cdrom tmp
> mkdir vmware
> cd vmware
> cp -R ../tmp/ .
> cd tmp

> sudo tar xzvf VMWareTools.tar.gz

@mcotton
mcotton / gist:3492905
Created August 27, 2012 22:25
Build Node.js versions for MBA
git checkout v0.8.8
export CC=/Applications/Developer/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
export CXX=/Applications/Developer/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
sudo xcode-select -switch /Applications/Developer/Xcode.app
./configure
make
sudo make install
node -v
@mcotton
mcotton / gist:3805146
Created September 29, 2012 20:43
GAE outputting JSON
from usermodels import *
from django.utils import simplejson
class JSONByIDHandler(webapp.RequestHandler):
def get(self, resource=''):
if resource == '':
self.error(404)
try:
p = Picture.get_by_id(int(resource))
@mcotton
mcotton / gist:4128368
Created November 21, 2012 22:51
YUI Notes
itemAppView creates itemViews for each itemModel in itemModelList
itemView has events for elements inside of view
@mcotton
mcotton / gist:4149150
Created November 26, 2012 16:26
EEN time functions
// Usage: this._epoch_DateToStr(new Date()/1000)
_padTo2Digits: function (num) {
return (((num < 10) ? '0' : '') + num);
},
_epoch_DateToStr: function (epoch_time) {
var yy, mm, dd, hr, mn, sc, ms, timecode, jstime;
jstime = new Date(epoch_time*1000);
$ git status -s|awk '{ print $2 }'|xargs git add
To reset
$ git status -s|awk '{ print $2 }'|xargs git reset HEAD
@mcotton
mcotton / gist:4734816
Last active December 12, 2015 07:09
Backbone.js overload Model.get
Camera = Backbone.Model.extend({
// helper method to map functions to attributes
get: function (attr) {
if (typeof this[attr] == 'function') {
return this[attr]();
}
return Backbone.Model.prototype.get.call(this, attr);
},
@mcotton
mcotton / gist:4741793
Last active December 12, 2015 08:08
Example of using status codes with jQuery ajax
$.ajax('/g/aaa/create_account', {
type: 'POST',
contentType: 'application/json',
data: obj,
dataType: 'json',
success: win,
failure: fail,
statusCode: {
400: function() {
fail('<p>Something went wrong with your request. Please try again</p>')
@mcotton
mcotton / backbone.views.js
Last active December 14, 2015 00:38
render a modal form as a view, track changes throughout tabs, save changes
EditUserProfileView = Backbone.View.extend({
events: {
"click #userSettingsModal_save": "save_changes",
"change .settings": "changed_settings"
},
tmp_settings: {},
template: _.template($('#editUserProfile-template').html()),
@mcotton
mcotton / gist:5059936
Last active December 14, 2015 08:48
Queue
var Task = function(fn) {
this.fn = fn
}
var QueueManager = function() {
var queue = [];
this.add = function(task) {
queue.push(task);
}