Skip to content

Instantly share code, notes, and snippets.

View xmariopereira's full-sized avatar

Mário Pereira xmariopereira

  • Rotterdam, Netherlands
View GitHub Profile
@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active May 2, 2024 19:03
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@tobywf
tobywf / clean_old_lambda_versions.py
Last active April 11, 2024 06:52
A quick script to remove old AWS Lambda function versions
from __future__ import absolute_import, print_function, unicode_literals
import boto3
def clean_old_lambda_versions():
client = boto3.client('lambda')
functions = client.list_functions()['Functions']
for function in functions:
versions = client.list_versions_by_function(FunctionName=function['FunctionArn'])['Versions']
for version in versions:
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@danielscholl
danielscholl / ieESC_disable
Created March 20, 2017 14:19
Disable IE Enhance Security PowerShell
function Disable-ieESC {
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
Stop-Process -Name Explorer
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green
}
Disable-ieESC
image: debian
before_script:
- apt-get update && apt-get clean
- apt-get install --fix-missing -y python-dev python-pip python-setuptools
- apt-get install --fix-missing -y build-essential
- apt-get install --fix-missing -y libyaml-dev
- apt-get install --fix-missing -y libssl-dev openssl
- apt-get install --fix-missing -y libffi-dev
- apt-get install --fix-missing -y curl tree netcat
@bloodearnest
bloodearnest / selfsigned.py
Last active April 23, 2024 15:23
Create a self-signed x509 certificate with python cryptography library
# Copyright 2018 Simon Davy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@danwagnerco
danwagnerco / vim_vundle_and_conemu.md
Created June 22, 2015 20:43
This is a Windows-specific walkthrough for installing Vim, Vundle and ConEmu

Vim, Vundle and ConEmu on Windows

Let's start by getting it out on the table: Sublime Text is great, and version 3 should no longer be considered "abandonware" as of build 3065. Sublime Text served me very, very well over the years. That said, trying out new things is a major part of leveling-up, and in that vein Vim deserves a go. (And have you seen some of those thoughtbot guys flying around in Vim? It's awesome!)

Getting Vim up-and-running on your Windows machine doesn't have to be an all-day project. In this post, we'll walk through:

  • Installing gVim, which gives us both the "classic" command line version as well as the graphical version
  • Installing Vundle, the best way to handle Vim-enhancing packages
  • Installing ConEmu, a supercharged command line emulator for Windows
@chrisckchang
chrisckchang / rs-connect.js
Created April 23, 2015 05:21
replica set connection with nodejs native
/**
* MongoDB NodeJS Driver Production Connection Example
*
* Copyright (c) 2015 ObjectLabs Corporation
* Distributed under the MIT license - http://opensource.org/licenses/MIT
*/
var MongoClient = require('mongodb').MongoClient;
/**
@edm00se
edm00se / ReadMe.md
Last active April 3, 2022 00:53
Sample nginx.conf settings to perform reverse proxy functionality to.

Read Me

In order to access a server hosted within a vm (guest), for development purposes from the host OS, which is restricted to same origin / localhost only requests, I set up a siple nginx reverse proxy to forward my requests.

Steps

  1. To install in a Windows VM, download and install nginx from the current, stable release; I installed to C:\nginx\
  2. Edit the <install path>/conf/nginx.conf file with the marked changes in the file of the same name in this gist.
  3. Start the nginx executable, located in your install path. There are service wrappers for Windows, or you can just kill the process to stop the nginx instance.

Commands for Windows