Skip to content

Instantly share code, notes, and snippets.

View nobodhi's full-sized avatar

nobody nobodhi

View GitHub Profile
@jpoehls
jpoehls / node-cluster-messaging.js
Created March 29, 2012 01:48
Simple message passing between cluster master and workers in Node.js
var cluster = require('cluster');
if (cluster.isWorker) {
console.log('Worker ' + process.pid + ' has started.');
// Send message to master process.
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'})
// Receive messages from the master process.
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@domenic
domenic / interop.md
Last active July 7, 2022 19:47
`module.exports =` and ES6 Module Interop in Node.js

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.

@andrewpthorp
andrewpthorp / coderay.css
Created March 11, 2013 13:02
A CodeRay theme to get GitHub style code coloring.
.CodeRay {
background-color: #efefef;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
color: #000;
margin-bottom: 14px;
}
.CodeRay pre {
margin: 0px;
padding: 1em;
@ats
ats / Runkeeper_API_startup.md
Created May 8, 2013 04:00
Runkeeper API startup guide: I ran into some hitches with the Runkeeper API while building a plugin to hook it to Slogger, so I wrote a quick guide to accompany the plugin itself.

Runkeeper API startup

Begin with the Runkeeper Registration/Authorization page for general instructions to get started. This page points to the Application Portal you can use to establish your application. You'll obtain client_id and client_secret by registering a personal application in that portal.

Then obtain code by submitting a request to https://runkeeper.com/apps/authorize with the following parameters directly from the Runkeeper instructions:

  • client_id: The unique identifier that your application received upon registration
  • code: code
  • redirect_uri: The page on your site where the Health Graph API should redirect the user after accepting or denying the access request
@blackfalcon
blackfalcon / git-feature-workflow.md
Last active April 13, 2024 07:33
Git basics - a general workflow

Git-workflow vs feature branching

When working with Git, there are two prevailing workflows are Git workflow and feature branches. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited, and the focus of this article.

If you are new to Git and Git-workflows, I suggest reading the atlassian.com Git Workflow article in addition to this as there is more detail there than presented here.

I admit, using Bash in the command line with the standard configuration leaves a bit to be desired when it comes to awareness of state. A tool that I suggest using follows these instructions on setting up GIT Bash autocompletion. This tool will assist you to better visualize the state of a branc

@jbtule
jbtule / justice-will-only-be-acheived.md
Last active April 5, 2023 13:33
Tracing the origin of an internet quote

Tracing the origin of an internet quote

So I saw this quote on twitter

"Justice will only be achieved when those who are not injured by crime feel as indignant as those who are."
–Solomon (635-577 B.C.)

Which I though was a real effective quote relating the

@bradfrost
bradfrost / gist:59096a855281c433adc1
Last active September 4, 2023 15:01
Why I'm Not A JavaScript Developer

Answering the Front-end developer JavaScript interview questions to the best of my ability.

  • Explain event delegation

Sometimes you need to delegate events to things.

  • Explain how this works in JavaScript

This references the object or "thing" defined elsewhere. It's like "hey, thing I defined elsewhere, I'm talkin' to you."

  • Explain how prototypal inheritance works.
@brcooley
brcooley / api-lolesports-com_docs.md
Last active August 5, 2022 16:35
lolesports.com unofficial api docs

Unofficial documentation

This is an unofficial documentation for the internal lolesports.com api.

This documentation is uncomplete and currently only show all information I got so far. Please help me complete and correct this documentation.

Top level domain

The domain for the intern lolesports.com api is http://api.lolesports.com/api/.

@bradoyler
bradoyler / node-standards-v4.md
Last active April 27, 2017 14:17
Node.js Standards (for the enterprise) we should all try to agree on.

Some NodeJs (v4.x) choices we can all agree on?