// Embedded in this article https://medium.com/p/c98e491015b6 | |
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"net/http" | |
"time" |
express = require("express") | |
request = require("request") | |
BufferList = require("bufferlist").BufferList | |
app = express.createServer(express.logger(), express.bodyParser()) | |
app.get "/", (req, res) -> | |
if req.param("url") | |
url = unescape(req.param("url")) | |
request | |
uri: url | |
encoding: 'binary' |
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var assert = require('assert') | |
console.log('\n==========='); | |
console.log(' mongoose version: %s', mongoose.version); | |
console.log('========\n\n'); | |
mongoose.connect('localhost', 'testing_1088'); | |
mongoose.connection.on('error', function () { |
There's been a strange explosion in misinformation about browserify recently, particularly in comparisons to webpack.
Generally speaking, most of this confusion stems from how webpack is more willing to pull features into its core to ease discoverability while browserify is more likely to push features out to userland instead.
I think that longer-term, separability has more benefits from a maintenance and
If you must nest functions in a way that requires access to multiple this', alias outer this to something meaningful - describe the value it's holding. Treat this as the invisible first argument.
In general though, avoiding the situation (nested functions and frivolous use of this
) will frequently produce clearer results.
I was accidentally included in a discussion on how to best name this
in nested functions in JavaScript. +1's were given to this suggestion of using _this
.
Giving style advice on naming nested this
without a meaningful context isn't too helpful in my opinion. Examples below have been altered to have at least some context, although a completely contrived and stupid one.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.
});
/* | |
Some simple Github-like styles, with syntax highlighting CSS via Pygments. | |
*/ | |
body{ | |
font-family: helvetica, arial, freesans, clean, sans-serif; | |
color: #333; | |
background-color: #fff; | |
border: none; | |
line-height: 1.5; | |
margin: 2em 3em; |
This is all based on the [alpha release][1].
From the built-in help system:
For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).
These are simple setting = value listings where the value is a format string in which other variables can be referenced.
// 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); |