Skip to content

Instantly share code, notes, and snippets.

View renatoargh's full-sized avatar
🚀

Renato Gama renatoargh

🚀
View GitHub Profile
@renatoargh
renatoargh / config.yml
Created February 12, 2021 21:52 — forked from sjparkinson/config.yml
Deploy a Fastly service using Terraform and CircleCI 2.0.
version: 2
jobs:
validate_terraform:
docker:
- image: hashicorp/terraform
steps:
- checkout
- run:
name: Validate Terraform Formatting
@renatoargh
renatoargh / pglogical
Created July 8, 2019 15:23 — forked from ratnakri/pglogical
short tutorial to setup replication using pglogical
Edit /var/lib/postgres/data/postgresql.conf:
# change IP on subscriber
listen_addresses = '*'
wal_level = logical
shared_preload_libraries = 'pglogical'
max_worker_processes = 16
max_wal_senders = 16
max_replication_slots = 16
track_commit_timestamp = on
@renatoargh
renatoargh / RunAProxyOnAmazonEC2VPC.md
Created January 28, 2018 23:38 — 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.
@renatoargh
renatoargh / gist:93702bdafbd19d17b7bad5bfe755d9c5
Created January 28, 2018 17:25 — forked from aws-scripting-guy/gist:884ffa9d44bd14f7493a670543284552
AWS EC2 metadata. Check attached IAM role from EC2 instance. Get temporary credentials.
# Get IAM Role name from Instance Profile Id
curl http://169.254.169.254/latest/meta-data/iam/info
# Get credentials
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name>
# More info
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
@renatoargh
renatoargh / gist:913374310b846ec670e011c44108115e
Created January 28, 2018 13:42 — forked from aioutecism/gist:2638bb9eaf9ffc13348c
Set up a VPN Server (PPTP) on AWS and use it anywhere

Set up a VPN Server (PPTP) on AWS

  1. Create a EC2 instance using Ubuntu 14.04.
  2. In Secure Group Inbound Rules, add a SSH Rule(TCP, Port 22, 0.0.0.0/0) and a Custom TCP Rule(TCP, Port 1723, 0.0.0.0/0).
  3. Optional: Associate a Elastic IP with the instance.
  4. SSH into the instance.
  5. sudo apt-get install pptpd.
  6. sudo vim /etc/pptpd.conf. Uncomment localip 192.168.0.1 and remoteip 192.168.0.234-238,192.168.0.245.
  7. sudo vim /etc/ppp/pptpd-options. Uncomment ms-dns and ms-wins. Change the IP to Google's DNS like this:
@renatoargh
renatoargh / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

function GetEmailParts( strEmail ){
// Set up a default structure with null values
// incase our email matching fails.
var objParts = {
user: null,
domain: null,
ext: null
};
// Get the parts of the email address by leveraging
express = require("express")
request = require("request")
BufferList = require("bufferlist").BufferList
app = express.createServer(express.logger(), express.bodyParser())
app.get "/", (req, res) ->
if req.param("url")
url = unescape(req.param("url"))
request
uri: url
encoding: 'binary'