Skip to content

Instantly share code, notes, and snippets.

View rictorres's full-sized avatar

Ricardo Torres rictorres

View GitHub Profile

JavaScript to Rust Cheat Sheet

The goal of this is to have an easily-scannable reference for the most common syntax idioms in JavaScript and Rust so that programmers most comfortable with JavaScript can quickly get through the syntax differences and feel like they could read and write basic Rust programs.

What do you think? Does this meet its goal? If not, why not?



rictorres /
Created June 18, 2018 20:45 — forked from cecilemuller/
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

Virtual hosts

Let's say you want to host domains and

Create folders for their files:

rictorres / jobs.js
Created October 6, 2015 16:29 — forked from maximilianschmitt/jobs.js
Automated MySQL backups to S3 with node.js
'use strict';
var mysqlBackup = require('./mysql-backup');
var schedule = require('node-schedule');
schedule.scheduleJob({ hour: 22, minute: 0 }, mysqlBackup);
rictorres / gist:ca9168b5b52dc6db002f
Last active September 18, 2015 20:52 — forked from wetzler/gist:4478332
Kickfolio's (minified) code to embed Keen IO charts in their user dashboards. They have 3 line charts (last 7 days, last 24 hours, and last 4 weeks) which show the number of user "connect" sessions for a given app (identified by the filter app.PublicKey). For more context, see this blog post:…
var e=new Keen.Series("connect",{
t=new Keen.Series("connect",{
rictorres / nginx.conf
Last active August 29, 2015 14:18 — forked from plentz/nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048

Setting up a SSL Cert from Comodo

I use as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

Nginx FastCGI response buffer sizes

By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is also explained at the Nginx ngx_http_fastcgi_module page document page.

Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (it's not shared).

The related Nginx options are:

http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
rictorres / gist:500704cec75756afaedc
Last active August 29, 2015 14:06 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
// This is from my comment here:
* How to delete items from an Array in JavaScript, an exhaustive guide
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]