Skip to content

Instantly share code, notes, and snippets.

View acatl's full-sized avatar

Acatl Pacheco acatl

  • ViacomCBS
  • New York, NY
View GitHub Profile
@acatl
acatl / user.json
Last active August 29, 2015 14:11
sublime 3
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/moiz-theme/Moiz Black.tmTheme",
"fade_fold_buttons": false,
"flatland_sidebar_tree_xsmall": true,
"flatland_square_tabs": true,
"folder_exclude_patterns":
[
".svn",
@acatl
acatl / gist:d7dd716ea674cbf6b93d
Created October 31, 2014 03:16
call try catch callback
function call(method) {
var args = Array.prototype.slice.call(arguments);
var callback = args.pop();
args = args.slice(1);
var error;
var result;
try {
result = method.apply(null, args);
} catch (e) {
error = e;
@acatl
acatl / gist:bdb6e4e867f08bd18bd8
Last active August 29, 2015 14:07
callback slice args
function callbackSliceArgs(callback, howMany) {
return function() {
var args = _.toArray(arguments);
args.splice(howMany, args.length);
return callback.apply(null, args);
};
}
@acatl
acatl / backbone mixins
Created December 18, 2013 17:34
backbone mixins
var ViewA = Backbone.View.extend({
events: {
'click .my-button': 'onMyButtonClick'
}
});
var ViewB = Backbone.View.extend({
ui: {
myButton: '.my-button'
}
@acatl
acatl / gist:7123843
Created October 23, 2013 18:21
loop break
var la = new Array(500);
for (var i = 0; i < la.length; i++) {
la[i] = i;
}
var target = [];
var loop = function () {
var temp = la;
var slices = 50;
@acatl
acatl / gist:4196153
Created December 3, 2012 16:38
Parse JS object path that uses dot and bracket notation
parse = (obj, path) ->
path = path.split(/[\[\]\.]+/)
path.pop() if path[path.length - 1] is ""
while path.length and (obj = obj[path.shift()])
;
obj
@acatl
acatl / gist:1099971
Created July 22, 2011 17:52
requiredfield example
var requeiredFieldOptions = {
watermarkText: "Enter age here...",
functionValidate: function(value) {
if (parseInt(value) < 18) {
return false;
}
return true;
},
dataType: "number",
liveCheck: true
@acatl
acatl / gist:1098931
Created July 22, 2011 05:13
itemrenderer example 6: using the itemRenderer option
// create a custom widget to be attached to each of the items created.
$.widget("ui.customwidget", {
options: {
listData:null
},
_create: function (){
this.element.addClass("ui-customwidget");
$("<span></span>")
.text(this.options.listData.data.name + " is $" + this.options.listData.data.price)
@acatl
acatl / gist:1098903
Created July 22, 2011 04:38
itemrenderer example 5: using rendererFunction option
var itemrendererOptions = {
labelField: "name",
rendererFunction: function (container, listData) {
if(listData.data.price > 100) {
container.css("color","red");
}
container.html(listData.label);
},
dataProvider: [
{
@acatl
acatl / gist:1098891
Created July 22, 2011 04:31
itemrenderer example 4.2: using labelFunction option using the options argument
var itemrendererOptions = {
labelField: "name",
labelFunction: function (data, options) {
return data[options.labelField] + " is $ " + data.price;
},
dataProvider: [
{
name: "lorem",
price: 123.34
},