Skip to content

Instantly share code, notes, and snippets.

View leotada's full-sized avatar

Leonardo leotada

View GitHub Profile
@leotada
leotada / keymap.cson
Last active July 21, 2023 17:17
Atom/Pulsar Editor keybinding, for my use with atomic-emacs package (disabled default keybindings)
# Your keymap
#
# Pulsar keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Pulsar keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
@leotada
leotada / document.rb
Created September 6, 2022 14:26
document class
class Document
def initialize(document)
@document = document
end
def raw
@document
end
def is_cnpj?
@leotada
leotada / exemplo.py
Created July 1, 2022 21:57
python async vs sync
import asyncio
from time import time
import httpx
url = 'https://api.coindesk.com/v1/bpi/currentprice.json'
async def busca_bitcoin():
async with httpx.AsyncClient() as client:
print((await client.get(url)).text)
@leotada
leotada / add_permission.py
Created May 19, 2021 14:37
Add permission to own public IP on AWS EC2 SecurityGroup
#!/usr/bin/env python3
from urllib.request import urlopen
import boto3
class SecurityGroup:
def __init__(self, security_group_id: str):
ec2 = boto3.resource('ec2')
self.security_group_id = security_group_id
@leotada
leotada / openvpn3.txt
Created May 17, 2021 19:32
connect to .ovpn using openvpn3
# Connect
openvpn3 session-start --config ~/test.ovpn
# List connections
openvpn3 sessions-list
# Disconnect
openvpn3 session-manage --session-path /net/openvpn/v3/sessions/fbd8d1d7s682cs5555sb18bs4c10c18c28ea --disconnect
# Enable Split tunneling, add this lines to .ovpn file
route-nopull
route 192.168.8.1 255.255.255.255
@leotada
leotada / ip-forwarding.txt
Last active May 17, 2021 19:46
IP forwarding and Port redirect/forwarding on Linux
# Redirect Ports using IPTables
sudo iptables -t nat -A PREROUTING -i ens18 -p tcp --dport 80 -j REDIRECT --to-port 8080
# IP forwarding: Receive packets on one PORT and forward to another IP and PORT.
# Can redirect packages through a VPN client connection. Ex: EC2 linux receive packages and route through VPN.
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -A INPUT -p tcp --dport 1444 -j ACCEPT
sudo iptables -t nat -A PREROUTING -p tcp --dport 1444 -j DNAT --to-destination 192.168.8.6:1433
sudo iptables -t nat -A POSTROUTING -p tcp -d 192.168.8.6 --dport 1433 -j MASQUERADE
@leotada
leotada / init.el
Last active November 23, 2021 18:53
Emacs config file
;; Melpa
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl
(warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
@leotada
leotada / gist:08059bc5fc886deed9ec17c918489ca2
Last active December 18, 2019 19:24
Regex to get domain in a url - link
domain
([\w-]+\.)+(\w+)
link to another page
href="(.+?)"
link to another page excluding extensions
href="(.+(?:(?<!css|js|jpg|jpeg|gif|tiff|png|bmp|svg|ico)))"
@leotada
leotada / app.d
Last active December 4, 2019 02:40
D Programming Language (Dlang) - Example Garbage Collection ProfileStats
import std.stdio;
import core.memory;
import std.algorithm.mutation;
void main()
{
int[] list;
int[] list2;
int[] result;
@leotada
leotada / app.js
Created November 27, 2019 01:12
Templating components with JQuery
class TextComponent {
static template () {
return `<button type="button">
StaticText
</button>`
}
app.components = {
'text-component': TextComponent,
};