Skip to content

Instantly share code, notes, and snippets.

View carlopires's full-sized avatar

Carlo Pires carlopires

  • Aldeia Global
  • Goiânia/Brazil
View GitHub Profile
@carlopires
carlopires / install-google-fonts.sh
Created May 4, 2020 14:27 — forked from keeferrourke/install-google-fonts.sh
A bash script to install all Google Fonts, system wide, on debian based systems (ex. Ubuntu)
#!/bin/sh
# Written by: Keefer Rourke <https://krourke.org>
# Based on AUR package <https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ttf-google-fonts-git>
# dependancies: fonts-cantarell, ttf-ubuntu-font-family, git
sudo apt-get install fonts-cantarell, ttf-ubuntu-font-family, git
srcdir="/tmp/google-fonts"
pkgdir="/usr/share/fonts/truetype/google-fonts"
giturl="git://github.com/google/fonts.git"
@carlopires
carlopires / openssl.MD
Created October 14, 2019 16:30 — forked from jchandra74/openssl.MD
HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

Overview

My main development workstation is a Windows 10 machine, so we'll approach this from that viewpoint.

Recently, Google Chrome started giving me a warning when I open a site that uses https and self-signed certificate on my local development machine due to some SSL certificate issues like the one below:

Self-Signed SSL Issue in Chrome

@carlopires
carlopires / rate_limit2.py
Created September 26, 2019 18:04 — forked from josiahcarlson/rate_limit2.py
Regular and sliding window rate limiting to accompany two blog posts.
'''
rate_limit2.py
Copyright 2014, Josiah Carlson - [email protected]
Released under the MIT license
This module intends to show how to perform standard and sliding-window rate
limits as a companion to the two articles posted on Binpress entitled
"Introduction to rate limiting with Redis", parts 1 and 2:
@carlopires
carlopires / trio_test.py
Created February 4, 2019 20:39
Trio echo client and server example
import trio
async def test_client(value):
stream = await trio.open_tcp_stream('127.0.0.1', 8000)
async with stream:
await stream.send_all(value)
return await stream.receive_some(4096)
async def start_server(**kwargs):
async def _echo_handler(stream):
@carlopires
carlopires / Testing_local_HTTPS_project.md
Created February 1, 2019 14:42 — forked from powerman/Testing_local_HTTPS_project.md
Cheat sheet: How to securely test local/staging HTTPS project

How to securely test local/staging HTTPS project

Modern projects often support HTTPS and HTTP/2, moreover they can use Strict-Transport-Security: and Content-Security-Policy: headers which result in different behaviour for HTTP and HTTPS versions, or even completely forbid HTTP version. To develop and test such project locally, on CI, and at staging server we either have to provide a way to access it using HTTP in non-production environments (bad idea) or somehow make it work with HTTPS everywhere.

HTTP in non-production environments is a bad idea because we'll test not the same thing which will runs on production, and because there is a chance to occasionally keep HTTP enabled on production too.

@carlopires
carlopires / dijkstra.py
Created January 28, 2019 13:50 — forked from mdsrosa/dijkstra.py
Modified Python implementation of Dijkstra's Algorithm (https://gist.github.com/econchick/4666413)
from collections import defaultdict, deque
class Graph(object):
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
@carlopires
carlopires / gist:86cf32ab5a252dbbf4edbd82b9380f3b
Created January 28, 2019 13:46 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
@carlopires
carlopires / extensions.lua
Created January 17, 2019 20:14 — forked from igmar/extensions.lua
Asterisk LUA dialplan
require("lsqlite3")
-- Igmar: Wanneer closen we dat DB object eigenlijk ?
db = sqlite3.open('/etc/asterisk/users.sqlite')
--CONSOLE = "Console/dsp" -- Console interface for demo
--CONSOLE = "DAHDI/1"
--CONSOLE = "Phone/phone0"
TRUNK = "DAHDI/G1"
@carlopires
carlopires / curio_tls.py
Created June 5, 2017 19:19 — forked from vsajip/curio_tls.py
Demonstrates wrapping of sockets for TLS using contexts which are not Curio's own.
from wsgiref.handlers import format_date_time
import curio
from curio import network
from curio import socket
from curio.io import Socket
import h11
import tls
@carlopires
carlopires / service-checklist.md
Created February 16, 2017 00:17 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?