This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var person = function() { | |
var name = null, | |
age = null, | |
hair = null; | |
return { | |
birth: function() { | |
name = 'Chris'; | |
age = 27; | |
hair = 'blonde'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer