Skip to content

Instantly share code, notes, and snippets.

justjake / server-preload.js
Last active Dec 22, 2021
Customizing NextJS for error reporting and Datadog APM (dd-trace) integration. See
View server-preload.js
// @ts-check
"use strict"
* Set up datadog tracing. This should be called first, so Datadog can hook
* all the other dependencies like `http`.
function setUpDatadogTracing() {
const { tracer: Tracer } = require('dd-trace')
const tracer = Tracer.init({
ccnokes / axios-instance-config.js
Created Jul 6, 2017
Good default configuration for axios in node.js
View axios-instance-config.js
const axios = require('axios');
const http = require('http');
const https = require('https');
module.exports = axios.create({
//60 sec timeout
timeout: 60000,
//keepAlive pools and reuses TCP connections, so it's faster
httpAgent: new http.Agent({ keepAlive: true }),


function example(obj: { prop: string | number }): string {
  if (typeof obj.prop === 'string') {
    return obj.prop;
  } else {
    return "default";
nzakas /
Created Sep 14, 2012
Replace Apache with nginx on Elastic Beanstalk AMI (Tomcat7/32-bit)
# IMPORTANT: Run this script as sudo or else it won't work
# Original script:
echo 'Installing nginx...sit tight'
yum -y install nginx
echo 'Fixing nginx configuration'
sed -i 's/ 1;/ 4;/g' /etc/nginx/nginx.conf
rm /etc/nginx/conf.d/default.conf