Skip to content

Instantly share code, notes, and snippets.

View doowb's full-sized avatar
:octocat:
Creating something awesome!

Brian Woodward doowb

:octocat:
Creating something awesome!
View GitHub Profile

Easiest Table of Contents possible

In .verb.md where you want to inject the TOC:

<!-- toc -->

Done!

@kpdecker
kpdecker / nodebf.md
Last active June 2, 2016 18:02
mobile.walmart.com #nodebf 2014

Mobile Server Side Rendering

This year marks the first year that we are doing full scale rendering of our SPA application on our mobile.walmart.com Node.js tier, which has provided a number of challenges that are very different from the mostly IO-bound load of our prior #nodebf.

The infrastructure outlined for last year is the same but our Home, Item and a few other pages are prerendered on the server using fruit-loops and hula-hoop to execute an optimized version of our client-side JavaScript and provide a SEO and first-load friendly version of the site.

To support the additional CPU load concerns as peak, which we hope will be unfounded or mitigated by our work, we have also taken a variety of steps to increase cache lifetimes of the pages that are being served in this manner. In order of their impact:

Event Loop Management

Unary operators

(and the oddities of number evaluation in JavaScript)

Type conversion, typecasting, and coercion are different ways of, implicitly or explicitly, changing an entity of one data type into another. [--wikipedia][wikipedia]


Unary operators, or "typeof +'foo' === huh?"

Project organization

Here is how I prefer to organize projects:

┌─ _dist/
├─ assets/
├─ content/
├─ data/
@jonschlinkert
jonschlinkert / task-vs-target.md
Created May 23, 2014 12:49
What is a "task" and a "target" in Grunt configuration?

What's a target?

Demystifying tasks and targets

Here, we have the basics of any Gruntfile.

module.exports = function(grunt) {
  grunt.initConfig({
 // tasks will go here. A "task" is run by a grunt "plugin"

In the assemble options, define the path to your assets directory:

options: {
  assets: 'dist/assets'
}

Now, in your templates you can use the variable like this:

// Define a config object to load data (for templates etc)
var config = [
// load data to the root object
['components/*.json'],
// load data to the `pkg` object
{name: 'pkg', src: 'package.json'},
// load data to the `site` object
{name: 'site', src: '.assemblerc.yml'},
// load data to an object named after the basename of each file
// e.g. foo.json is loaded to `{foo: {// data}}`
@arobson
arobson / abstractions.md
Last active October 14, 2021 06:46
Rabbit.MQ + Node.js Notes

Abstraction Suggestions

Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.

Broker

As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:

  • publish
  • request
  • start/stop subscription
@sindresorhus
sindresorhus / np.sh
Last active December 11, 2022 21:26
shell function for publishing node modules with some goodies
# npm publish with goodies
# prerequisite: `npm install -g trash`
# `np` with an optional argument `patch`/`minor`/`major`/`<version>`
# defaults to `patch`
np() {
trash node_modules &>/dev/null;
git pull --rebase &&
npm install &&
npm test &&
npm version ${1:-patch} &&
@creationix
creationix / app.js
Last active November 10, 2017 06:28
This is a science experiment showing how the new process.addAsyncListener API in node 0.12.x could be (ab)used to create a very easy to use web-framework.
module.exports = function () {
// If there is an uncaught exception anywhre in your app, it will result in a proper 500 page.
if (Math.random() < 0.3) throw new Error("Oops, my random is low");
// They don't have to happen in the first tick either
if (Math.random() < 0.2) return setTimeout(function () {
throw new Error("Delayed random bites");
});
// If you throw an object, it will send a JSON document to the client
if (Math.random() > 0.6) throw {Hello: request.url};