Skip to content

Instantly share code, notes, and snippets.

View junosuarez's full-sized avatar
💭
hi hello

juno suárez junosuarez

💭
hi hello
View GitHub Profile
@junosuarez
junosuarez / boisehackers.js
Created March 13, 2012 22:20
boisehackers.js
(function boiseHackers(you){
var meetup = {
when: new Date("Mar 14 2012 5:00 PM"),
where: "Java Downtown"
};
if(you.doing > you.talking)
{
alert("@BoiseHackers is meeting at " + meetup.where + " at " + meetup.when.toLocaleTimeString() + " on " + meetup.when.toLocaleDateString());
}
@junosuarez
junosuarez / gist:2886716
Created June 7, 2012 05:11
Example using RequireJS 2.x.x shim configuration option to load a non-AMD library as a module
/*global require, window */
require.config({
shim: {
'underscore': {
deps: ['underscore.js'],
exports: function () {
return this._.noConflict();
}
}
}
@junosuarez
junosuarez / gist:2927040
Created June 13, 2012 22:57
Lazy-evaluated getters
private string myString;
public string MyString{
get{
return myString ?? (myString = doSomething());
}
}
@junosuarez
junosuarez / gist:3095747
Created July 12, 2012 04:32
Craigslist annualized rent hack (run in console)
[].slice.call(document.querySelectorAll('p.row')).forEach(
function(L) {
var y = '$'+ +/\$(\d+)/.exec(L.innerText)[1]*12+' - ',
yL = document.createElement('span');
yL.innerText = y;
L.insertBefore(yL, L.firstChild);
});
@junosuarez
junosuarez / gist:3405873
Created August 20, 2012 17:07
New AMD Module: Sublime Text snippet
<snippet>
<content><![CDATA[/*global define: false */
define(
[${1:'app', 'backbone', 'lodash'}],
function (${2:App, B, _}) {
'use strict';
${3}
});]]></content>
@junosuarez
junosuarez / tap.js
Created September 11, 2012 23:19
Easily support tap events without modifying your click event handlers
/*global define: false, window: false */
define(['jquery'], function ($) {
'use strict';
return function () {
/* Begin monkey-patch Tap event support into $ */
var x = 0,
y = 0,
threshold = 40,
// Sometimes there is lag between the last update and touchend.
@junosuarez
junosuarez / gist:3768642
Created September 23, 2012 02:46
Async Collection
/*global define:false */
define(['backbone','underscore','deferred'], function (B, _, flow) {
/**
* @constructor
*/
var AsyncCollection = B.Collection.extend({
initialize: function () {
// if the initialize function is overriden in an
// extended class of AsyncCollection, ensure
@junosuarez
junosuarez / gist:3831191
Created October 4, 2012 02:49
V8 reflection
var reflection = {
getCallStack: function getCallStack() {
var old = Error.prepareStackTrace, e = {};
Error.prepareStackTrace = function (e, cs) { return cs; };
if (Error.captureStackTrace) {
Error.captureStackTrace(e, getCallStack);
e = e.stack;
e.shift();
Error.prepareStackTrace = old;
}
@junosuarez
junosuarez / ts.sublime-build
Created October 12, 2012 07:40
Simple TypeScript build type for SublimeText
{
"cmd": ["tsc", "$file"],
"file_regex": "^(.*)\\(([0-9]*),([0-9]*)",
"selector": "source.ts"
}