Skip to content

Instantly share code, notes, and snippets.

Igor Soarez soarez

View GitHub Profile
@soarez
soarez / client.js
Created Jan 31, 2016
Finding how many requests Node tries to handle at the same time for a single connection
View client.js
const net = require('net');
const fs = require('fs');
var req = fs.readFileSync('./req.txt', { encoding: 'utf8' });
var socket = new net.Socket();
socket.connect(7001, '127.0.0.1', function() {
console.log('Connected');
var c = 50000;
while (c --> 0)
View fg.sh
#!/bin/bash
set -e
#node="/home/vagrant/nodes/iojs-v1.6.2-linux-x64/bin/iojs"
node="/home/vagrant/nodes/node-v0.12.1-linux-x64/bin/node"
node_flags='--perf_basic_prof'
script='/home/vagrant/porf/single.js'
script_log=/dev/null
# load_generator="node test.js"
View spy.js
var util = require('util');
var EventEmitter = require('events').EventEmitter;
function Spy(f, ctx) {
var ee = new EventEmitter();
spy.called = false;
Object.keys(EventEmitter.prototype).forEach(function(p) {
spy[p] = transfer;
View event-loop-play.js
console.log('experiment')
var intervalTime = 1000;
setInterval(runSomething, intervalTime);
var lastTime = Date.now();;
function runSomething() {
var now = Date.now();
var elapsed = now - lastTime;
lastTime = now;
@soarez
soarez / gist:b2a092c309ed846be4f6
Created Jul 10, 2015
Upstart service error email alert
View gist:b2a092c309ed846be4f6
#!/bin/bash
srv=$1
to=$2
machine=$3
loglinesinbody=50
logfile="/var/log/upstart/$srv.log"
from="Upstart"
@soarez
soarez / intro.md
Created Jun 2, 2015
Symmetrical vs asymmetrical crypto
View intro.md

Symmetrical vs asymmetrical crypto


Disclaimer: This content is merely educational. [Don't roll your own crypto][dontDoYourOwnCrypto]. Use TLS and GPG.

These aren't new topics, but if you're reading this maybe you could use a quick

View deploy.bash
#!/bin/bash
function deploy {
# Update the rsync target on the server
rsync \
-av \
--delete \
--delete-excluded \
$rsync_ignore_list_param \
$rsync_source/ $target:$rsync_target
View challenge.erl
-module(challenge).
-export([ swap/3 ]).
% no effect on an empty list
swap([ ], _, _) -> [ ];
% no effect on a list with a single item
swap([ H | [] ], _, _) -> [ H ];
% no effect when both indexes are the same
@soarez
soarez / Dockerfile
Created Jan 8, 2015
phantomjs dockerfile
View Dockerfile
FROM ubuntu:14.04
MAINTAINER blueoffice
ENV PHANTOMJS_BINARY https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
RUN apt-get update && \
apt-get install -y wget libfontconfig && \
wget $PHANTOMJS_BINARY -O phantomjs.tar.bz2 && \
tar xf phantomjs.tar.bz2 && \
@soarez
soarez / server.js
Created Oct 20, 2014
REST my Cookies
View server.js
/*
* npm i express cors cookie-parser && node server
*/
var url = require('url');
var util = require('util');
var assert = require('assert');
var express = require('express');
var cors = require('cors');
var cookieParser = require('cookie-parser');
You can’t perform that action at this time.