Skip to content

Instantly share code, notes, and snippets.

@chapel
chapel / publish.js
Created January 12, 2012 04:39
Mongoose publish
function shim(obj) {
if (toString.call(obj) == '[object Function]') {
return obj()
}
return obj
}
module.exports = function(schema, options) {
options || (options = {})
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
/ Fatalities
var fatalities = {
triggers: {
konamiCode: function(scriptPath, scriptFn) {
console.log("Added function");
var konamiKeys = [], konamiCombo = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
konamiKeys.push(e.keyCode);
if(konamiKeys.toString().indexOf(konamiCombo) >= 0) {
$(document).unbind('keydown', arguments.callee);
/*===========================================================================
SETTINGS
============================================================================= */
var port = 3000,
cacheAge = 60000 * 60 * 24 * 365,
logs = {
set: false,
string: '\\n ' + ':date'.bold.underline + '\\n\\n' + ' IP: '.cyan.bold
+ ' ' + ':remote-addr'.white + '\\n' + ' Method: '.red.bold
exports.exec = (options, callback) ->
# Load image
fs.readFile './image.jpg', (err, img) ->
if err
return callback(err, null);
# POST image to imgur
request {
method: 'POST',
body: "image=" + img.toString() + "&key=42e1c4982b52fabcae9033ff428d5175",
uri: 'http://imgur.com/api/upload.json',
var http = require('http');
var querystring = require('querystring');
var data = {
message: 'Hello'
};
var form_data = querystring.stringify(data);
var options = {
var req = http.request({
host: '127.0.0.1',
port: '5984',
path: '/ms/',
method: 'POST',
headers: {
'Content-Type': 'application/json' // Need to add headers object
}}, function(res){
var sigma = '';
res.on('data',function(chunk){sigma+=chunk})
var sys = require("sys"),
http = require("http"),
url = require("url"),
querystring = require("querystring");
var apiPort = process.ARGV[2] || 8080;
var apiKey = 'YOUR KEY HERE';
http.createServer(function(req, res) {
var jsonp = 'jsonp';
this.post('#/reply', function (context) {
var fields = this.params, doc = {};
doc.content = fields['post'];
doc.datetime = new Date.now();
doc.thread_id = fields['thread_id'];
doc.type = 'post';
doc.user_id = 'chapel';
console.log(doc);
db.saveDoc(doc, {
success: function() {
-- -------------------------------------- -- Gist Script for Linkinus -- by Jacob Chapel -- Version 0.5 -- -------------------------------------- on linkinuscmd(paste_type) set useGrowl to do shell script "defaults read com.conceitedsoftware.Linkinus alertGrowl" set theURL to "" set file_type to ".txt" set file_types to {{"ActionScript", ".as"}, {"C", ".c"}, {"Csharp", ".cs"}, {"Common_Lisp", ".cl"}, {"emacs_lisp", ".sls"}, {"erlang", ".hrl"}, {"haskell", ".hs"}, {"html", ".html"}, {"java", ".java"}, {"lua", ".lua"}, {"objective_c", ".m"}, {"perl", ".pl"}, {"Scala", ".scala"}, {"scheme", ".sls"}, {"TeX", ".tex"}, {"XML", ".xml"}, {"Ada", ".adb"}, {"AppleScript", ".scpt"}, {"Arc", ".arc"}, {"ASP", ".ascx"}, {"Assembly", ".asm"}, {"Batchfile", ".bat"}, {"Befunge", ".befunge"}, {"Boo", ".boo"}, {"Brainfuck", ".b"}, {"C_ObjDump", ".c-objdump"}, {"ChucK", ".java"}, {"Clojure", ".clj"}, {"CoffeeScript", ".coffee"}, {"ColdFusion", ".cfm"}, {"Cpp_ObjDump", ".cppobjdump"}, {"Cucumber", ".feature"}, {"D", ".d"},