Skip to content

Instantly share code, notes, and snippets.

@felipap
felipap / .vimrc
Created June 12, 2016 22:13
.vimrc as of today
" I can't believe I'm redoing this.
" List of sources this .vimrc was based on:
" - https://amix.dk/vim/vimrc.html
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
vector<double> *genRandomVector(int size) {
static random_device rnd_device;
static mt19937 mersenne_engine(rnd_device());
uniform_real_distribution<double> dist(-1, 1);
auto gen = std::bind(dist, mersenne_engine);
vector<double> *vec = new vector<double>(size);
generate(begin(*vec), end(*vec), gen);
return vec;
}
normal
<div style="font-family: 'notoserif'; font-size: 30; margin-bottom: 20;">notoserif</div>
<div style="font-family: 'sans-serif'; font-size: 30; margin-bottom: 20;">sans-serif</div>
<div style="font-family: 'sans-serif-light'; font-size: 30; margin-bottom: 20;">sans-serif-light</div>
<div style="font-family: 'sans-serif-thin'; font-size: 30; margin-bottom: 20;">sans-serif-thin</div>
@felipap
felipap / gist:d23858fe4245e47a225891722e3441ac
Last active January 9, 2024 02:56
Joyent's Error Handling in Node.js

The links to the original on the internet are all down. Posting this here hoping others can easily find it. Of course, I don't own this content.

Error Handling in Node.js

Error handling is a pain, and it's easy to get by for a long time in Node.js without dealing with errors correctly. However, building robust Node.js applications requires dealing with errors properly, and it's not hard to learn how. If you're really impatient, skip down to the "Summary" section for a tl;dr.

This document will answer several questions that programmers new to Node.js often ask:

  • In functions that I write, when should I throw an error, and when should I emit it with a callback, event emitter, or something else?
  • What should my functions assume about their arguments? Should I check that they're the correct types? Should I check more specific constraints, like that an argument is non-null, is non-negative, looks like an IP address, or the like?