Skip to content

Instantly share code, notes, and snippets.

View datapimp's full-sized avatar

Jonathan Soeder datapimp

View GitHub Profile
Site.util.number_to_currency = function num2money(n_value) {
// validate input
if (isNaN(Number(n_value))) return 'ERROR';
// save the sign
var b_negative = Boolean(n_value < 0);
n_value = Math.abs(n_value);
// round to 1/100 precision, add ending zeroes if needed
var s_result = String(Math.round(n_value * 1e2) % 1e2 + '00').substring(0, 2);
We couldn’t find that file to show.
scoped = order("#{ sort_by } #{ direction }")
scoped = scoped.where( :publisher_id => params[:publisher_id] ) if params[:publisher_id].present?
scoped = scoped.where( :category_id => params[:category_id] ) if params[:category_id].present?
scoped = scoped.where( "title like ?", "%#{ params[:title] }%" ) if params[:title].present?
scoped = scoped.where( "description like ?", "%#{ params[:description] }%" ) if params[:description].present?
scoped = scoped.drafts if params[:drafts_only].present?
scoped = scoped.published if params[:published_only].present?
class CategoriesController < ApplicationController
before_filter :require_admin
before_filter :get_category, :only => [:show,:edit,:update,:destroy]
respond_to :html, :xml, :json
responders :flash, :http_cache, :collections
def index
respond_with( @categories = Category.query(params) )
end
Application.handlers = {
registration_submit : function(){
var form = Ext.getCmp('registration_form_panel');
form.submit();
},
poll_submit : function(){
var form = Ext.getCmp('poll_question_2_panel_form');
form.submit();
}
};
Application.handlers = {
registration_submit : function(){
var form = Ext.getCmp('registration_form_panel');
form.submit();
},
poll_submit : function(){
var form = Ext.getCmp('poll_question_2_panel_form');
form.submit();
}
};
We couldn’t find that file to show.
var value = 1,
other_value = 2,
and_another = "what up girl whatchu wearing?",
method = function(){
alert('we do it big');
};
Application = {};
Application.is = {
init : function(navigator) {
var platforms = this.platforms,
ln = platforms.length,
i, platform;
navigator = navigator || window.navigator;
for (i = 0; i < ln; i++) {
# assignment is pretty
# you never have to worry about typing 'var'
# and no need to wrap args in ()
fs = require "fs"
sys = require "sys"
global.client = require "./client"
args = process.argv.slice 2
# i like that in coffeescript
# you automatically return the last statement