Skip to content

Instantly share code, notes, and snippets.

@junqueira
junqueira / scala_base64_encode_decode.scala
Created September 29, 2020 17:06 — forked from frgomes/scala_base64_encode_decode.scala
Scala - Base64 encode/decode
// Base64 encode
val text = "This is plaintext."
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes())
// Base64 decode
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded))
println(textDecoded)
@junqueira
junqueira / httpx_aiohttp.py
Created June 1, 2020 12:35 — forked from imbolc/httpx_aiohttp.py
Httpx vs aiohttp benchmark
from starlette.applications import Starlette
from starlette.routing import Route
from starlette.responses import PlainTextResponse
import httpx
import aiohttp
HOST, PORT = "localhost", 8000
URL = f"http://{HOST}:{PORT}/"
@junqueira
junqueira / README.md
Created May 30, 2020 18:43 — forked from florimondmanca/README.md
HTTPX vs aiohttp (over HTTPS)

Usage

  • Generate TLS certificates for localhost:
pip install trustme-cli
trustme-cli
  • Run wrk on each endpoint, eg:
1 hostname elliot-01
2 echo elliot-01 > /etc/hostname
3 bash
4 vim /etc/modules-load.d/k8s.conf
5 curl -fsSL https://get.docker.com | bash
6 docker version
7 docker ps
8 apt-get update && apt-get install -y apt-transport-https
9 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
10 echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
oc project kubernauts
podname=$(oc get pods | grep postgres-$(oc get dc postgres -o jsonpath='{.status.latestVersion}') | grep -v deploy | grep Running | awk '{print $1}')
oc rsh -c postgres $podname
OR
oc get pods | grep postgres
oc exec -it postgres-pod-name bash
oc project kubernauts
podname=$(oc get pods | grep postgres-$(oc get dc postgres -o jsonpath='{.status.latestVersion}') | grep -v deploy | grep Running | awk '{print $1}')
oc rsh -c postgres $podname
OR
oc get pods | grep postgres
oc exec -it postgres-pod-name bash
@junqueira
junqueira / git_fetch_pull_all_subfolders.sh
Created April 25, 2020 02:40 — forked from mnem/git_fetch_pull_all_subfolders.sh
Simple bash script for fetching and pulling all repos in the executed folder to the latest of the branch they are on
#!/bin/bash
################
# Uncomment if you want the script to always use the scripts
# directory as the folder to look through
#REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPOSITORIES=`pwd`
IFS=$'\n'
@junqueira
junqueira / kafka_python_consumer.py
Created April 15, 2020 04:42 — forked from DmitryBe/kafka_python_consumer.py
Kafka stream consumers
# https://pypi.python.org/pypi/kafka-python
from kafka import TopicPartition
from kafka import KafkaConsumer
topic_name = 'test-01'
group_id = 'test-consumer-01'
KAFKA_BROKER_LIST="10.2.65.197:9092,10.2.67.55:9092,10.2.91.23:9092"
# option 1
@junqueira
junqueira / global-protect.sh
Created April 2, 2020 22:59 — forked from kaleksandrov/global-protect.sh
Simple script that starts and stops GlobalProtect.app on Mac OSX.
#!/bin/bash
case $# in
0)
echo "Usage: $0 {start|stop}"
exit 1
;;
1)
case $1 in
start)

Disable:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Enable:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist