Skip to content

Instantly share code, notes, and snippets.

View dreamorosi's full-sized avatar
👽

Andrea Amorosi dreamorosi

👽
View GitHub Profile
@dreamorosi
dreamorosi / README.md
Last active March 9, 2022 18:02
Convert Markdown to PDF with Asciidoctor

Use the script above by making it executable (chmod +x convert.sh) and running it (./convert.sh).

If you want to add a page break use <<<, if you want to add syntax highlighting add :source-highlighter: rouge at the top of the Markdown file, it won't be rendered in Markdown but will be used by asciidoctor.

@dreamorosi
dreamorosi / instance_id.md
Created June 16, 2020 06:50
Get Instance ID / VM ID on AWS or Azure via bash or powershell command.

Get instance metadata on AWS EC2

curl -H Metadata:true "http://169.254.169.254/latest/meta-data/instance-id"

On Azure Windows VM

curl -H @{'Metadata'='true'} "http://169.254.169.254/metadata/instance/compute/vmId?api-version=2017-08-01&format=text"
@dreamorosi
dreamorosi / windows_steps.md
Last active June 13, 2023 09:04
Steps needed to PowerBI & PowerBI On-premises data gateway to AWS RDS PostgreSQL in VPC

Connect PowerBI / On-premises data gateway to AWS RDS PostgreSQL in VPC

TL;DR

  1. Install Npgsql 4.0.10.0 or earlier (download .msi link here) with GAC enabled.
  2. Add SSL Certificate used by PostgreSQL to Windows Trusted Root Certification; if you are on AWS you can download the bundle here, if not you'll have to bring your own or find the correct one.

Problem

Out of the box PowerBI is not able to connect to a PostgreSQL database; this limitation applies also to the On-premises data gateway that needs to be installed in order to connect to the RDS from outside of a VPC (more info here). Assuming that the host on which the two applications are running have network connectivity with the database there are a few steps needed in order to solve the following issues:

  • PostgreSQL Data Provider is not installed
@dreamorosi
dreamorosi / gist:08bd39c0dc5bff9025b3b490102c955b
Last active September 1, 2020 10:28
Reduce video size with ffmpeg

Reduce video size (H.264)

docker run --rm -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg -stats -i input.mp4 -vcodec libx264 -crf 28 output.mp4

Use libx265 (H.265) for even more reduction (not compatible with Windows 10 without additional codec).

@dreamorosi
dreamorosi / shiny.conf
Created February 5, 2020 13:15
NGINX conf for Shiny App + RStudio + Preview (RunApp) with reverse proxy
# /etc/nginx/conf.d/shiny.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80 ipv6only=on;
@dreamorosi
dreamorosi / AllowAlsoListingOfBucketRoot.json
Last active July 10, 2019 10:26
IAM Policy that gives programmatic access to list and perform actions on specific sub folder inside a S3 Bucket. All events must come from inside a specific VPC. Can also add programmatic listing of root and Console access.
{
"Sid": "AllowListingOfBucketRoot",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::{{BUCKET_NAME}}"
],
"Condition": {
@dreamorosi
dreamorosi / AllowAlsoListingOfBucketRoot.json
Created July 10, 2019 10:05
IAM Policy that gives programmatic access to a list and perform actions on specific sub folder inside a S3 Bucket. Can also add programmatic listing of root and Console access.
{
"Sid": "AllowListingOfBucketRoot",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::{{BUCKET_NAME}}"
],
"Condition": {
@dreamorosi
dreamorosi / LambdaConsole.json
Last active April 7, 2021 16:10
AWS Role that allows to access, create and run and develop lambda functions through the Console, allows to use only a specific execution role for the function, good for training sessions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadOnlyPermissions",
"Effect": "Allow",
"Action": [
"lambda:GetAccountSettings",
"lambda:ListFunctions",
"lambda:ListTags",
@dreamorosi
dreamorosi / Readme.md
Last active October 18, 2023 06:16
Create new Python virtual environment and manage dependencies

Create new Python virtual environment and manage dependencies

Requirements

Create new virtual environment

The following command creates a new virtual environment named venv in the current directory, usually this will be your project's directory.

@dreamorosi
dreamorosi / Readme.md
Last active April 6, 2023 15:22
Install and configure webserver based on nginx with php 7 and fpm over socket configured.

Install and configure webserver based on nginx with php 7 and fpm over socket configured plus a couple of utils.

While launching a new instance open the section Advanced details in step 3. Configure Instance paste this code that will clone this gist and run the install commands.

#!/bin/bash
yum install git -y
git clone https://gist.github.com/828861e850bbb14893ae144c28f39e0e.git /home/ec2-user/install
chmod a+x install/install.sh
bash /home/ec2-user/install/install.sh