Skip to content

Instantly share code, notes, and snippets.

View noelyahan's full-sized avatar
🍂
listening to the listener

Noel Yahan noelyahan

🍂
listening to the listener
View GitHub Profile
@noelyahan
noelyahan / RedisPythonPubSub1.py
Created February 7, 2016 19:13 — forked from jobliz/RedisPythonPubSub1.py
A short script exploring Redis pubsub functions in Python
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@noelyahan
noelyahan / cluster.md
Created February 10, 2016 10:37 — forked from learncodeacademy/cluster.md
Node Cluster - Enhance your node app by using all the cores of your processor.

Here's all you have to do to add clustering to your node.js application.

  • save this code as cluster.js, and run cluster.js instead of server.js (or /bin/www, or whatever it's called for your project)
  • the only line you'll need to change is the last line - it needs to point to the location of your server.js file
var cluster = require('cluster');

if (cluster.isMaster) {
  // Count the machine's CPUs
 var cpuCount = require('os').cpus().length;

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@noelyahan
noelyahan / generators.md
Created January 12, 2017 16:19 — forked from learncodeacademy/generators.md
What are Javascript Generators?

##what are generators##

  • They're pausable functions, pausable iterable functions, to be more precise
  • They're defined with the *
  • every time you yield a value, the function pauses until .next(modifiedYieldValue) is called
var myGen = function*() {
  var one = yield 1;
  var two = yield 2;
  var three = yield 3;
 console.log(one, two, three);