Skip to content

Instantly share code, notes, and snippets.

View tbassetto's full-sized avatar

Thomas Bassetto tbassetto

View GitHub Profile
@angus-c
angus-c / variables.js
Created May 21, 2011 16:51
variable decalration
//one statement - all on one line - good for short, similar purpose vars
var foo = [], bar = [], buzz = [];
//multiple var statements - good for large number or disperate purpose vars
var a = 12;
var collate = false;
var foo = [1,2,3,4];
var circle = {radius: 2, color: blue};
//one statement on multiple lines, no indent
/**
NOTE: The template in this example relies on itemView, which is not yet
in SproutCore 2.0 master, but is coming
*/
MyApp.Selection = SC.Object.extend({
name: null,
isSelected: false
});
@pamelafox
pamelafox / touch.js
Created January 6, 2012 18:25
Touch/click events wrapper
ISTOUCHING = false;
function useTouchEvents() {
return isTouchDevice();
}
function triggerClick(dom) {
if (useTouchEvents()) {
dom.trigger('tap');
} else {
@indexzero
indexzero / include.js
Created January 22, 2012 09:03
Find the source of your `sys` deprecation warnings in node@0.6.x
//
// Place this at the beginning of your node.js program before
// **any and all** require statements.
//
var util = require('util');
var _warning = util._deprecationWarning;
util._deprecationWarning = function () {
console.trace();
_warning.apply(util, arguments);
@bga
bga / [fun] various forms of ternary operator in JavaScript.js
Created March 7, 2012 15:10
[fun] various forms of ternary operator in JavaScript
// add your variants of
a ? b : c
// in comments :)
// a is boolean
// b and c - any type
// lazy evaluation isnt important
@paulgreg
paulgreg / future
Created July 16, 2012 15:24
Future
var future = function(expectedCalls, action) {
var counter = 0;
return function() {
counter++;
if (counter === expectedCalls) action();
}
}
var products = [ {id:1}, {id:2}, {id:3}, {id:4}, {id:5} ];
@peutetre
peutetre / gist:3781590
Created September 25, 2012 12:50
Show Safari remote inspector from the command line
try
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
tell menu bar 1
tell menu bar item "Develop"
tell menu "Develop"
tell menu "iPhone Simulator" of menu item "iPhone Simulator"
delay 1
@xcambar
xcambar / LICENSE
Last active November 20, 2015 12:57
Authenticated routing using AngularJS
Copyright (c) 2015 - Xavier Cambar <@ xcambar_gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@sindresorhus
sindresorhus / ios-clear-btn.css
Created January 22, 2013 13:54
Recreation of the native iOS textfield clear button in a data uri. *Should be identical, but is not the original*
.clear-btn {
width: 19px;
height: 19px;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAMAAACf4xmcAAAAMFBMVEWysrKysrKysrKysrKysrKysrKysrKysrKysrKysrL////39/fh4eG9vb23t7eysrKQDTJbAAAACnRSTlMBKlNxqbO70e7739UFWQAAAMFJREFUeNqNlMsOxSAIREs1AbVe/v9v78JMSn0kMytJTzqIwPWRpKxWimlOcp2U1IM07SHzSbaCor6RTta3+VZ2f6jiB5WboSIncNzKkB+yP0gHlRD/cJjCURdYPrX1F+qtPrCNP+u1Dg5UrYhSzKyBA9VCdhJtwOEICTzjx0jBNfvCLZRnpBa5SCE584WLFEpSfMOBggqJkabkFciCkOUlH4t7erKRuLYkm5wbGXIAuXHmlgO3asjFxa9BfqmSK/oPfl489V95hyMAAAAASUVORK5CYII=');
background-size: 100%;
cursor: pointer;
}
@padolsey
padolsey / 1.js
Created February 21, 2013 21:26
A little JS [ES3] task: In each case, implement `x` so that the expression is true. Do not modify the expressions though. Post your solutions as a fork of this gist. ***Remember: ES3 only.
/x/==x