Skip to content

Instantly share code, notes, and snippets.

We couldn’t find that file to show.
/**
* Recursively counts the number of DOM domNodes inside a given domNode
* @param {DomNode} domNome The DOM node to count children for (defaults to the body DOM node)
* @return {Number} The number of DOM nodes inside this domNode
*/
countNodes = function(domNode) {
var domNode = domNode || document.body;
var runningTotal = 1; //this domNode
if (domNode.childNodes.length > 0) {
#using the attr_accessible declaration to whitelist mass-assignable attributes
#this example will only update title and body when performing a Post.new(params[:post]) or @post.update_attributes(params[:post])
#even if params[:post] contains other keys and values (i.e. thread_id will not be overwritten this way)
class Post
belongs_to :thread
attr_accessible :title, :body
end
class PostsController < ApplicationController
alias ll="ls -alh"
alias rss="ruby script/server"
alias rss4="ruby script/server -p 4000"
alias rssp="ruby script/server -e production"
alias rsc="ruby script/console"
alias rsa="ruby script/about"
alias rsg="ruby script/generate"
alias rsgm="ruby script/generate migration"
alias rsgrm="ruby script/generate rspec_model"
/**
* @class Ext.ux.BreadcrumbTrail
* @extends Ext.Container
* @author Ed Spencer
* Renders a series of breadcrumbs which fire events when clicked.
* Add Ext.ux.Breadcrumb objects as items - each Breadcrumb is mostly just a reference to a Component such as
* an Ext.Panel. When the breadcrumb-clicked event is fired it is called with the component as the only arg.
*
* Example Usage - move to a specific tab:
*
//taken from a recent project - tells ExtMVC.Model to use a ScriptTagProxy and a remote host
Ext.apply(ExtMVC.Model.Adapter.REST.classMethods, {
urlExtension: '.json',
// port: 3000,
// host: 'http://localhost',
host: 'http://widgets.jungle-media.com',
proxyType: Ext.data.ScriptTagProxy,
parseSingleLoadResponse: function(response, options, callbacks) {
var m = this.getReader().readRecords(eval("(" + response.responseText + ")"));
propertiesExist = function(object, properties) {
var allExist = true;
properties = properties || {};
Ext.each(properties, function(property) {
var splits = property.split('.');
var currentObj = object;
Ext.each(splits, function(currentProperty, index, all) {
if (!allExist) return false;
Ext.onReady(function() {
//The panel we'll be adding our nav items to
var navGroup = new Ext.Panel({
region: 'west',
width: 180
});
//assuming this returns some JSON like {response: [{title: 'My Nav Item', html: 'some text'}, {title: 'Another item', html: 'test'}]}
var store = new Ext.data.JsonStore({
url: '<?= RELATIVE_PATH ?>/Nav/View',
/**
* @class CampaignFilter
* @extends Ext.Panel
* Description
*/
CampaignFilter = Ext.extend(Ext.Panel, {
constructor: function(config) {
var config = config || {};
//constructor for the MyClass class
MyClass = function() {
//do whatever constructor logic you need, or just leave it blank
};
//creates a class-level function, which you can call via MyClass.loadThing()
MyClass.loadThing = function() {
//do your loading thing
}