Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Rattray rattrayalex

View GitHub Profile
View strictness-comparison.md

Input

function example(obj: { prop: string | number }): string {
  if (typeof obj.prop === 'string') {
    mutatesProp(obj);
    return obj.prop;
  } else {
    return "default";
 }
@nzakas
nzakas / replace-apache.sh
Created Sep 14, 2012
Replace Apache with nginx on Elastic Beanstalk AMI (Tomcat7/32-bit)
View replace-apache.sh
#!/bin/sh
# IMPORTANT: Run this script as sudo or else it won't work
# Original script: http://my.safaribooksonline.com/book/programming/java/9781449309558/hacking-elastic-beanstalk/hackingelectric#X2ludGVybmFsX0ZsYXNoUmVhZGVyP3htbGlkPTk3ODE0NDkzMDk1NTgvSV9zZWN0MTRfZDFlMjAyNQ==
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
@kemitchell
kemitchell / -
Last active Mar 10, 2022
npm license values
View -
74925 NONE
54706 MIT
9268 ISC
3050 BSD
1521 BSD-2-CLAUSE
791 APACHE-2.0
699 APACHE 2.0
392 BSD-3-CLAUSE
364 WTFPL
346 UNKNOWN
@ccnokes
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 }),
@justjake
justjake / server-preload.js
Last active May 24, 2022
Customizing NextJS for error reporting and Datadog APM (dd-trace) integration. See https://jake.tl/notes/2021-04-04-nextjs-preload-hack
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({