This file contains hidden or 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
//// | |
// Math Support | |
// | |
// This is an an awesome addition to mustache.js to | |
// add support for basic math operations. No evals! | |
// | |
// Examples: | |
// | |
// 2 == {{#math}} {{four}} / {{two}} {{/math}} | |
// 20 == {{#math}} 100 / 5 {{/math}} |
This file contains hidden or 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
<?php | |
// requires php5 | |
define('UPLOAD_DIR', 'images/'); | |
$img = $_POST['img']; | |
$img = str_replace('data:image/png;base64,', '', $img); | |
$img = str_replace(' ', '+', $img); | |
$data = base64_decode($img); | |
$file = UPLOAD_DIR . uniqid() . '.png'; | |
$success = file_put_contents($file, $data); |
This file contains hidden or 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() { | |
var clicked, canvas, ctx, coords, offsetX, offsetY, oldX, oldY; | |
app.views.Signature = Ext.extend(Ext.Panel, { | |
layout: { | |
type: 'vbox', | |
pack: "center", | |
align: "center" | |
}, |
This file contains hidden or 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
~ $ mongo -u USERNAME -p PASSWORD Flame.mongohq.com:27094/wereviewutah | |
MongoDB shell version: 1.6.5 | |
connecting to: Flame.mongohq.com:27094/wereviewutah | |
> db.logs.find() | |
{ "_id" : ObjectId("4da0d8a5a130714ae1000023"), "count" : 1 } | |
> db.logs.findOne() | |
{ "_id" : ObjectId("4da0d8a5a130714ae1000023"), "count" : 1 } | |
> db.logs.update({}, {$inc:{count:1}}) | |
> db.logs.findOne() | |
{ "_id" : ObjectId("4da0d8a5a130714ae1000023"), "count" : 2 } |
This file contains hidden or 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
// using the res.local syntax | |
app.all('*', function(req, res, next) { | |
db.logs.findOne(function(err, logs) { | |
if (err) return console.log("Error: ", err); | |
res.local('count', logs.count); | |
res.local('edit', false); | |
next(); | |
}); | |
}); |
This file contains hidden or 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
//////////////////////////////////////// | |
// Simple MongoDB Wrapper // | |
// Written to use with MongoHQ.com // | |
// By Jamund Ferguson // | |
// April 9, 2011 | |
//////////////////////////////////////// | |
var mongodb = require('mongodb'), | |
db; |
This file contains hidden or 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
// initialize it with your db name and credentials | |
var db = require("./db").init({ | |
user: "username", | |
pass: "password", | |
name: "database", | |
host: "yourmongohqhost.mongohq.com", | |
port: 27094 | |
}); | |
// define your collections |
This file contains hidden or 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
//////////// | |
// jQuery // | |
//////////// | |
// 1. Name jQuery objects so that we know what they are | |
var $container = $("div"); | |
/////////////// | |
// Normal JS // | |
/////////////// |
This file contains hidden or 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
// articles per page | |
var limit = 10; | |
// pagination middleware function sets some | |
// local view variables that any view can use | |
function pagination(req, res, next) { | |
var page = parseInt(req.params.page) || 1, | |
num = page * limit; | |
db.articles.count(function(err, total) { | |
res.local("total", total); |
OlderNewer