Skip to content

Instantly share code, notes, and snippets.

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',
var person = function() {
var name = null,
age = null,
hair = null;
return {
birth: function() {
name = 'Chris';
age = 27;
hair = 'blonde';
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) {
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
# Retrieves the root pages and their children (level 0 and level 1)
exports.getPages = (req, res) ->
getChildren = (page, callback) ->
models.Page.find({ parent_id: page._id }).sort({ name: 'asc' }).exec (err, children) ->
page.children = children || []
callback(null, page)
models.Page.find({ parent_id: null }).sort({ name: 'asc' }).exec (err, pages) ->
async.map pages, getChildren, (err, results) ->
@otang
otang / gist:7253368
Created October 31, 2013 17:10
Change your terminal colour when SSH'ing, and change it back when done.
#!/bin/sh
tabc() {
NAME=$1; if [ -z "$NAME" ]; then NAME="Basic"; fi
osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"$NAME\""
}
tabc SSH # switch to theme with name
/usr/bin/ssh "$@" # run ssh
# Show
show: (req, res) ->
query = db.Auction.find
where:
id: req.params.auction
include: [
db.User
db.Region
db.Section
{model: db.Image, as: 'thumbnail'}
config = require 'config'
_ = require 'underscore'
module.exports = (sequelize, types) ->
Membership = sequelize.define 'Membership',
user_id: types.INTEGER
group_id: types.INTEGER
feedback_ups: types.INTEGER
feedback_downs: types.INTEGER
feedback_neutrals: types.INTEGER
query = db.Auction.find
where:
id: req.params.auction
include: [
db.User
db.Region
db.Section
{ model: db.Image, as: 'thumbnail' }
{ model: db.Image, as: 'image' }
# Seller and seller's membership info
config = require 'config'
_ = require 'underscore'
module.exports = (sequelize, types) ->
Membership = sequelize.define 'Membership',
user_id: types.INTEGER
group_id: types.INTEGER
feedback_ups: types.INTEGER
feedback_downs: types.INTEGER
feedback_neutrals: types.INTEGER