Skip to content

Instantly share code, notes, and snippets.

@soarez
soarez / ca.md
Last active April 22, 2024 03:01
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@soarez
soarez / intro.md
Created June 2, 2015 11:38
Symmetrical vs asymmetrical crypto

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

@soarez
soarez / ip-to-country-code.js
Created September 29, 2014 08:32
Query maxmind geolite2 country ( ISO_3166 ) downloadable db
var mmdbreader = require('maxmind-db-reader');
module.exports = Open;
function Open(dbPath) {
var db;
var queued = [];
mmdbreader.open(dbPath, dbReady);
return query;
@soarez
soarez / .tmux.conf
Last active May 5, 2022 08:58
My messy tmux conf
# use b as prefix
set-option -g prefix C-b
unbind-key C-a
bind-key C-b send-prefix
# Start numbering at 1
set-option -g base-index 1
# Allows for faster key repetition
set-option -g escape-time 0
use std::ops::Deref;
pub struct Foo;
impl Foo {
pub fn f(&self) -> &str { "Foo" }
}
pub struct BoxA<T>(T);
impl<T> Deref for BoxA<T> {
type Target = T;
@soarez
soarez / Dockerfile
Created January 8, 2015 17:17
phantomjs 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 / deploy.bash
Last active September 23, 2019 16:15
#!/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
@soarez
soarez / gist:3481961
Created August 26, 2012 17:46
EC2 Amazon Linux AMI port prerouting with NAT iptables
# List rules
sudo iptables -t nat -L
# Add rule to forward 80 to 3080
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3080
# Will delete all rules from nat table
sudo iptables -F -t nat
@soarez
soarez / fg.sh
Created November 22, 2015 11:49
#!/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"
@soarez
soarez / client.js
Created January 31, 2016 17:52
Finding how many requests Node tries to handle at the same time for a single connection
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)