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
fs = require 'fs' | |
routing = require './utils' | |
postDir = 'posts' | |
shortlinksFile = 'shortlinks.conf' | |
stream = fs.createWriteStream shortlinksFile, {flags: 'a'} | |
shortlinks = (fs.readFileSync shortlinksFile, 'utf8').replace(/\s+$/).split '\n' | |
tail = shortlinks.slice(-1)[0] | |
counter = parseInt (tail.match /(\d+)\s/)?[1] or 0 |
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
stylus = require 'stylus' | |
module.exports = (app) -> | |
app.get /^(.*\.styl)$/, (req, res) -> | |
stylus(req.file.content).render (err, css) -> | |
if err | |
res.send err | |
else | |
res.contentType 'text/css' | |
res.send css |
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
from sandbox import models | |
from tastypie import fields | |
from apibase.resources import CamayakModelResource | |
from django.conf.urls.defaults import url | |
class ModelResource(CamayakModelResource): | |
def override_urls(self): | |
urls = [] | |
for name, field in self.fields.items(): |
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
# run this in a test directory using a regular bash prompt to get an idea of how virtual environments would work, roughly | |
alias npm-env-init="mkdir ./env; mkdir ./env/packages; echo 'root = ./env/packages' > ./env/.npmrc; echo 'Created a new virtual environment for node packages in ./env'" | |
alias npm-env-workon="export npm_config_userconfig=./env/.npmrc; export NODE_PATH=./env/packages;" | |
alias npm-env-ls="nvp workon; nvm ls active;" | |
# we make a virtual environment | |
npm-env-init | |
# we switch to that virtual environment | |
npm-env-workon | |
# we install a package | |
npm install underscore |
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
<ul> | |
{% for comment in latest_comments %} | |
<li><a href="{{ comment.get_absolute_url }}">{{ comment.title }}</a></li> | |
{% endfor %} | |
</ul> |
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
latest_comments = Comments.objects.order_by('date')[:10] |
NewerOlder