Skip to content

Instantly share code, notes, and snippets.


Javier Blanco Gutiérrez jbgutierrez

View GitHub Profile
michiel / cors-nginx.conf
Created Jul 5, 2011
Wide-open CORS config for nginx
View cors-nginx.conf
# Wide-open CORS config for nginx
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
kremalicious /
Last active Aug 9, 2022
Install and configure Tor as proxy for all OpenVPN server traffic
# what we want:
# client -> OpenVPN -> Tor -> Internet
# Install & configure OpenVPN
# assumed OpenVPN configuration
# tun0-Interface
Vestride /
Last active Aug 9, 2022
Encoding video for the web

Encoding Video


Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
iros /
Created Aug 22, 2012
Documenting your REST API


<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')
tomkersten / somehost.conf
Created Oct 28, 2011
Nginx config with CORS headers added globally (for application w/ Basic Auth)
View somehost.conf
upstream your-app {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/tmp/your_app.socket fail_timeout=0;
server {
listen 80;
algal / nginx-cors.conf
Created Apr 29, 2013
nginx configuration for CORS (Cross-Origin Resource Sharing), with an origin whitelist, and HTTP Basic Access authentication allowed
View nginx-cors.conf
# A CORS (Cross-Origin Resouce Sharing) config for nginx
# == Purpose
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
jedi4ever /
Last active May 28, 2022
nodejs clustering, zero downtime deployment solutions

Clustering: The basics

The trick? pass the file descriptor from a parent process and have the server.listen reuse that descriptor. So multiprocess in their own memory space (but with ENV shared usually)

It does not balance, it leaves it to the kernel.

In the last nodejs > 0.8 there is a cluster module (functional although marked experimental)

ryanb /
Created Nov 29, 2012
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article &lt; ActiveRecord::Base
henrik / hash_deep_diff.rb
Created Jul 14, 2009
Recursively diff two Ruby hashes.
View hash_deep_diff.rb
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <> 2009-07-14 under the MIT license.
# Example:
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {