Skip to content

Instantly share code, notes, and snippets.

models.Page.find({ parent_id: null }).sort({ name: 'asc' }).exec (err, pages) ->
for page, i in pages
models.Page.find({ parent_id: page._id }).sort({ name: 'asc' }).exec (err, children) ->
pages[i].children = children
# return pages when all the queries are done
function get_user($where, $ignore = array('email', 'password', 'ip_address', 'fb_id')) {
if($where) $this->db->where($where);
$this->db->limit(1);
$query = $this->db->get('users');
if($query->num_rows() > 0) {
$user = $query->row();
// Unset some private data that should not leave our database
if(is_array($ignore) && count($ignore)) {
foreach($ignore as $i) {
var person = function() {
var name = null,
age = null,
hair = null;
return {
birth: function() {
name = 'Chris';
age = 27;
hair = 'blonde';
var myClojure = function() {
// What types of variables should I keep here?
// Beyond them being private, what's the advantage?
// Sometimes I lose track of the names and clobber these with variables in the object
var privateValue = 'this is a secret';
return {
// And, which should I place here?
publicValue: 'Everyone knows this',