JavaScript String substr() Method

var str = “Hello world!”;

var res = str.substr(1, 4)

via JavaScript String substr() Method.


Moment.js | Parse, validate, manipulate, and display dates in javascript.

A javascript date library for parsing, validating, manipulating, and formatting dates.

here is the link:

via Moment.js | Parse, validate, manipulate, and display dates in javascript..

internet explorer – Detect IE version in Javascript – Stack Overflow

I did the following:

function isIE (){var myNav = navigator.userAgent.toLowerCase();return(myNav.indexOf('msie')!=-1)? parseInt(myNav.split('msie')[1]):false;}
if(isIE()){// is IE}else{// Other browser}

internet explorer – Detect IE version in Javascript – Stack Overflow.

Return the last day of the month, the bad and ugly way (but great way!)

Taken from

function daysInMonth(month,year) {
var m = [31,28,31,30,31,30,31,31,30,31,30,31];
if (month != 2) return m[month - 1];
if (year%4 != 0) return m[1];
if (year%100 == 0 && year%400 != 0) return m[1];
return m[1] + 1;

The Asset Pipeline

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB.

The first feature of the pipeline is to concatenate assets. This is important in a production environment, because it can reduce the number of requests that a browser makes to render a web page. Web browsers are limited in the number of requests that they can make in parallel, so fewer requests can mean faster loading for your application.

The second feature of the asset pipeline is asset minification or compression. For CSS files, this is done by removing whitespace and comments. For JavaScript, more complex processes can be applied. You can choose from a set of built in options or specify your own.

The third feature of the asset pipeline is that it allows coding assets via a higher-level language, with precompilation down to the actual assets. Supported languages include Sass for CSS, CoffeeScript for JavaScript, and ERB for both by default.

read more( and how it works on rails):

Example: PHP array to Javascript Array

in php

$colorCodes = array("Restaurants"=> "#FFD014", "Bars"=> "#FBA10C", "Beauty Shops"=> "#12CBE1", "Automotive"=> "#0C93A5", "Health Services"=> "#C17FB5", "Clothing & Accessories"=> "#C22A9A", "Home Furnishings"=> "#97B63F", "Pets"=> "#CDDE61", "Other"=> "#8DD9CC");
$color = array();
//$spendByCategory is a array that hold the category name with spend amount and total count of transection
foreach ($spendByCategory as $spend) {
// json encoding the array $color.
$color = json_encode($color);

at Javascript i do the follow:

var colors = <?php echo $color ?>;

another alternative:
var js_array = [<?php echo '"'.implode('","', $php_array).'"' ?>];
taken from:

jQuery onScrollBeyond and scrollExtend plugins

The scrollExtend plugin is designed to automatically load new content at the bottom of the screen (by appending to a DOM element) when the user scrolls beyond the element, much like Facebook does with their status updates. The existing infinite scroll plugin was primarily designed to integrate with WordPress, which didn’t really suit my purposes.

There are two plugins encapsulated here – onScrollBeyond, which allows the developer to specify a callback to be run when an element is scrolled beyond (or the end of the document is reached), and scrollExtend, which is simply an implementation of onScrollBeyond that automatically loads new content via ajax when a user scrolls past an element.

Works with jQuery 1.3.2 and jQuery 1.4.2

Tested in IE6, IE7, Firefox, Chrome, Safari

Update v1.0.1 – fixed scrollExtend would get stuck in a disabled state if beforeStart returned false, even if it returned true on subsequent calls

– See more at:

here how i used this,

limit = 10;
 page = 0;

 $.post("tsz_analytics_controller.php?c=fetchCustomerInfo&venueId=<?php echo $_GET['venueId'] ?>&limit=" + limit + "&page=" + (page) + "", function(data) {


Getting Started with MongoDB

This tutorial provides an introduction to basic database operations using the mongo shell. mongo is a part of the standard MongoDB distribution and provides a full JavaScript environment with a complete access to the JavaScript language and all standard functions as well as a full database interface for MongoDB. See the mongo JavaScript API documentation and the mongo shell JavaScript Method Reference.

The tutorial assumes that you’re running MongoDB on a Linux or OS X operating system and that you have a running database server; MongoDB does support Windows and provides a Windows distribution with identical operation. For instructions on installing MongoDB and starting the database server, see the appropriate installation document.


read from:


 Load a JavaScript file from the server using a GET HTTP request, then execute it.


$.getScript('ajax/test.js', function() {
    alert('Load was performed.');


Nodize is an open source Content Management System for Node.js, written in CoffeeScript.

Nodize is an adaption of Ionize, a PHP CMS, to the Node.js platform.

Nodize is developed on top of Express and Zappa and is using Sequelize to manage the connection to the MySQL database.


– Multilingual content management
– Live update of articles (using & JQuery)
– Easy backoffice interface that your customers will love
– WYSIWYG editor (TinyMCE)
– Eco and CoffeeKup templates
– Node.js stability & low memory footprint
– Page caching (when Redis is installed)
– Easy integration of articles in your HTML design with helpers
– Cloud hosting with AppFog
– Pages & articles sorting with drag & drop
– A good looking media manager, with drag & drop uploads
– SEO friendly URLs

Application stack

nodejs >0.6.x





redis (optional)


My note: Although i did not get much success on this CMS, but you can try out, let me know if you do something good (i am not considering best yet) using this CMS.

From : download and installation instruction: