Skip to content

Instantly share code, notes, and snippets.

View posilva's full-sized avatar
💭
I may be slow to respond.

Pedro Marques da Silva posilva

💭
I may be slow to respond.
View GitHub Profile
@posilva
posilva / DynamoDbGrammar.g4
Created September 4, 2019 09:48
DAX antlr grammar and tokens
/*
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
* use this file except in compliance with the License. A copy of the License
* is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on
@posilva
posilva / ami-fetch
Last active February 13, 2020 09:15
AMI Fetch
AMI_FILTER=amzn-ami-hvm-2018.03*-x86_64-ebs
for REGION in us-east-1 us-west-2 us-west-1 eu-west-1 eu-central-1 ap-northeast-1 ap-southeast-1 ap-southeast-2 us-east-2
do
aws --region $REGION ec2 describe-images --owners amazon \
--filters "Name=name,Values=$AMI_FILTER" \
--query 'sort_by(Images, &CreationDate)[] ' | jq -c 'max_by(.CreationDate) | {region: "'$REGION'", name: .Name, image: .ImageId, date: .CreationDate} '
done
@posilva
posilva / install.sh
Created November 13, 2019 11:45
Try Dax
#!/bin/bash
pip install amazon-dax-client
@posilva
posilva / dbg.erl
Created December 26, 2019 16:11
DBG Erlang DNS Resolution
%% Check the default lookup resolution option
inet_db:res_option(lookup).
%% Set the lookup resolution option giving priority to the ERVM dns client
inet_db:set_lookup([dns, native]).
%% Setup DBG (DO NOT USE IT IN PRODUCTION) good to run in the local erl console
dbg:stop_clear(). % Stop in any case
dbg:start(). % start application
dbg:tracer(). % create tracer
dbg:p(all, c). % allow for all process
@posilva
posilva / httpc.py
Created January 6, 2020 12:09
Python3 http request
from urllib import request, parse
# some json data
data = parse.urlencode({'secret':'a', 'response':'b'}).encode()
req = request.Request("https://www.google.com/", data=data) # this will make the method "POST"
resp = request.urlopen(req)
print(resp.read())
@posilva
posilva / ListenSocketState.sh
Created January 14, 2020 15:35
Some cmd snippets
netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c
@posilva
posilva / top_metrics.py
Created June 8, 2020 15:50
Get Datadog Top Metrics
import time
import urllib.parse
import urllib.request
import json
import os
import csv, sys
from urllib.error import HTTPError
def http_get(path):
@posilva
posilva / Unreal_Buildgraph.sh
Last active August 30, 2024 06:44
Unreal Notes using BuildGraph
# List the existing targets in the installed engine build
./Engine/Build/BatchFiles/RunUAT.command BuildGraph -Script=Engine/Build/InstalledEngineBuild.xml -ListOnly
# Build Editor
./Engine/Build/BatchFiles/RunUAT.command BuildGraph -Script=Engine/Build/InstalledEngineBuild.xml -Target="Editor Mac"
# Build the editor but remove the Android and other options
./Engine/Build/BatchFiles/RunUAT.command BuildGraph \
-Script=Engine/Build/InstalledEngineBuild.xml \
-Target="Make Installed Build Mac" \
-set:WithMac=true \
@posilva
posilva / cli.py
Last active June 1, 2021 12:12
Python Cli Template
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This console application description
EXAMPLE:
python3 {}
""".format(__file__)
@posilva
posilva / add_to_authorized_keys.sh
Created March 2, 2021 11:17
Add pub key to remote host from Pem
ssh-keygen -f my_key.pem -y | ssh user@host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"