Skip to content

Instantly share code, notes, and snippets.

Avatar

Colin Ihrig cjihrig

View GitHub Profile
@cjihrig
cjihrig / why-assert.md
Created Dec 31, 2019
On Using `assert` as Your Assertion Library
View why-assert.md

This gist is a more detailed followup to this tweet in which I advocate for using Node's assert module as your goto assertion library.

Not Hatin', Just Sayin' Disclaimer: There are plenty of perfectly good JavaScript assertion libraries out there. If you're happy with your current choice in assertion libraries, please continue using them. This gist is just my personal opinion. It does not represent the opinion of my employer, your employer, or anyone else.

Background

@cjihrig
cjihrig / wasi.c
Last active Mar 21, 2020
WASI C Header
View wasi.c
#include "uvwasi.h"
__wasi_errno_t __wasi_args_get(char** argv, char* argv_buf) {
return __WASI_ENOTSUP;
}
__wasi_errno_t __wasi_args_sizes_get(size_t* argc, size_t* argv_buf_size) {
return __WASI_ENOTSUP;
@cjihrig
cjihrig / README libvirt cloud-init with static networking.md
Created Feb 14, 2019 — forked from itzg/README libvirt cloud-init with static networking.md
Configuring a libvirt domain with a static IP address via cloud-init local datasource
View README libvirt cloud-init with static networking.md

Here is how to create a cloud-init disk image and OS disk image suitable for configuring into a libvirt domain file.

In my case I am naming my domain (a.k.a. virtual machine or VM) xenial with a static IP address of 192.168.0.101. The filenames "network-config" and "user-data" files are arbitrary, so they can be named with a prefix for the domain, etc.

First, get the cloud image and convert into QCOW2 format:

qemu-img convert -O qcow2 xenial-server-cloudimg-amd64-disk1.img xenial-server-cloudimg-amd64-disk1.qcow2
View post-mortem-debugging-with-async-await.md

Challenges in using post-mortem debugging with async/await

Introduction

async/await is a new feature of the EcmaScript programming language that combines generators and promises to improve the language-level model for writing asynchronous code.

It is [currently in "stage 3"](https://github.com/tc39/ecma262#current- proposals) of the TC39 process,

@cjihrig
cjihrig / README.md
Created Nov 11, 2016 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx
View README.md

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
View keybase.md

Keybase proof

I hereby claim:

  • I am cjihrig on github.
  • I am cjihrig (https://keybase.io/cjihrig) on keybase.
  • I have a public key whose fingerprint is 94AE 3667 5C46 4D64 BAFA 68DD 7434 390B DBE9 B9C5

To claim this, I am signing this object:

View perf-crib-sheet.md

build

Clone and build Node for analysis:

$ git clone https://github.com/joyent/node.git
$ cd node
$ export GYP_DEFINES="v8_enable_disassembler=1"
$ ./configure
$ make -j4
View v8.md

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)

Build V8

  • git clone git@github.com:v8/v8.git
View mdb.md

MDB is unlike most debuggers you've experienced.

It is not a source level debugger like gdb or lldb or even Node's builtin debugger

Generally used for postmortem analysis.

Postmortem is for Production and Development

We operate mostly on core files, though you can attach to running processes as well.

View install.md