Skip to content

Instantly share code, notes, and snippets.

View colkito's full-sized avatar

colkito

View GitHub Profile
@colkito
colkito / smtp_tester.py
Last active June 25, 2024 18:44
SMTP Tester
# Code generated by Claude 3.5 Sonnet, an AI assistant created by Anthropic.
import smtplib
import ssl
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from typing import Optional
def test_smtp_connection(
sendgrid_username: str,
@colkito
colkito / generate-ssh-key.sh
Created January 14, 2021 03:10 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@colkito
colkito / docker-npm.js
Last active July 7, 2018 05:40 — forked from jokeyrhyme/docker-npm.js
execute `npm` within a Docker container, within the host's working directory
// ideal for use with AWS Lambda and native Node.js modules
// requires Docker: https://docs.docker.com/engine/installation/
/*
Usage:
node docker-npm.js install
node docker-npm.js rebuild
*/
@colkito
colkito / RunAProxyOnAmazonEC2VPC.md
Created December 3, 2017 19:48 — forked from webinista/RunAProxyOnAmazonEC2VPC.md
Create a proxy server on an Amazon EC2 (VPC) instance

This will create a proxy server in whatever your availability zone your VPC is in. For me, that's us-east-1b. For you, that may be something different. Steps 10+ should more or less work regardless of your provider since those steps cover the setup and configuration of TinyProxy.

  1. Click the Launch Instance button.
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type. This isn't strictly necessary. If you choose another OS, check its documentation for how to install new packages.
  3. On the Choose an Instance Type screen, select t2.micro. It's Free Tier eligible.
  4. Click the Next: ... buttons until you reach the Configure Security Group screen.
    • You may wish to reduce the amount of storage on the Add Storage screen. This is optional.
    • You may wish to add a tag on the Tag Instance screen. This is also optional.
  5. On the Configure Security Group screen:
  • Select Create a new security group.
@colkito
colkito / mongoose-connection-options.js
Created April 6, 2017 17:32
mLab recommended mongoose connection options. More supported connections for the underlying Node Native driver can be found here: http://mongodb.github.io/node-mongodb-native/
// mongoose 4.3.x
var mongoose = require('mongoose');
/*
* Mongoose by default sets the auto_reconnect option to true.
* We recommend setting socket options at both the server and replica set level.
* We recommend a 30 second connection timeout because it allows for
* plenty of time in most operating environments.
*/
var options = { server: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } },
@colkito
colkito / README.md
Created November 25, 2016 14:19 — forked from dominikwilkowski/README.md
Ubuntu 16.04 setup with NGINX http/2 and letsencrypt

Intro

This is a basic collection of things I do when setting up a new headless ubuntu machine as a webserver. Following the steps below should give you a reasonable secure server with HTTP/2 support (including ALPN in chrome) and the fast NGINX server. I am happy to add things so leave a comment.

Basics

After creating the server (droplet on DigitalOcean) log in with

@colkito
colkito / after_res_hooks.js
Created October 7, 2016 20:00 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@colkito
colkito / gist:8f4b738679f670ac41dece8b40d37429
Created October 7, 2016 14:14 — forked from ivan-loh/gist:ee0d96c3795e59244063
Node.JS ( & pm2 ) Process Memory Limit
# Plain Ol' Node
node --max-old-space-size=1024 app.js # increase to 1gb
node --max-old-space-size=2048 app.js # increase to 2gb
node --max-old-space-size=3072 app.js # increase to 3gb
node --max-old-space-size=4096 app.js # increase to 4gb
node --max-old-space-size=5120 app.js # increase to 5gb
node --max-old-space-size=6144 app.js # increase to 6gb
# For pm2
pm2 start app.js --node-args="--max-old-space-size=1024" # increase to 1gb

Keybase proof

I hereby claim:

  • I am colkito on github.
  • I am colkito (https://keybase.io/colkito) on keybase.
  • I have a public key whose fingerprint is 99B5 5A51 A065 9A3C 53B9 3DEA F394 55B3 EF35 3424

To claim this, I am signing this object:

@colkito
colkito / serverup.sh
Last active March 30, 2016 15:32
PM2 start with log date
NODE_ENV=<environment> pm2 start <server file> --name <app name> --log-date-format 'DD-MM-YYYY HH:mm:ss.SSS';