Skip to content

Instantly share code, notes, and snippets.

View 4383's full-sized avatar
🏠
Working from home

Hervé Beraud 4383

🏠
Working from home
View GitHub Profile
@zzzeek
zzzeek / async_to_greenlet_to_async.py
Last active January 22, 2024 15:35
Write a program in asyncio, that calls into a library that knows nothing about asyncio, which then calls out to a database adapter that is only asyncio
"""Proof of concept of an adapter that will wrap a blocking IO library in
greenlets, so that it can be invoked by asyncio code and itself make calls out
to an asyncio database library.
hint: any Python ORM or database abstraction tool written against the DBAPI
could in theory allow asyncio round trips to a pure async DB driver like
asyncpg.
The approach here seems too simple to be true and I did not expect it to
collapse down to something this minimal, so it is very possible I am totally
@mbaldessari
mbaldessari / disable-haproxy-backends.sh
Created September 18, 2019 08:57
Disables other controller haproxy backends on osp ctlplane
#!/bin/bash
set -e
# Before running this script it would be best to disable haproxy on the other nodes
# via: for i in controller-1 controller-2; do pcs resource ban haproxy-bundle $i; done
# To clear the bans: for i in controller-1 controller-2; do pcs resource clear haproxy-bundle $i; done
# Run this script as root on the single controller you want to stay active
CONF="/var/lib/config-data/puppet-generated/haproxy/etc/haproxy/haproxy.cfg"
HOST=$(hostname)
# Enable admin access to the haproxy stat socket
@zaneb
zaneb / fast8.sh
Created June 20, 2019 17:12
Run flake8 against only files that have changed
#!/bin/bash
set -e
enable_env() {
local env_name="$1"
local env_dir=".tox/${env_name}"
if [ ! -d "${env_dir}" ]; then
if [ ! -f tox.ini ]; then
echo 'No tox.ini found' >&2
@Gsantomaggio
Gsantomaggio / mandatory.md
Last active May 28, 2019 09:48
mandatory

Basic Idea

The idea is to add another parameter to the function RPCCLient as:

client = oslo_messaging.RPCClient(transport, target, options={'mandatory': True})
client.call({}, 'foo', id_value=str(i), test_value="hello oslo")

Inside the function, _publish decode the option value, as:

export OS_PROJECT_DOMAIN_NAME='Default'
export OS_USER_DOMAIN_NAME='Default'
export OS_PROJECT_NAME='admin'
export OS_USERNAME='admin'
export OS_AUTH_URL=http://192.168.24.2:5000/
export OS_AUTH_TYPE='password'
export OS_IDENTITY_API_VERSION='3'
export OS_PASSWORD=$(sudo hiera -c /etc/puppet/hiera.yaml keystone::admin_password)
@bogdando
bogdando / docker_vs_podman_run.sh
Last active February 1, 2019 10:54
Comparing the time it takes to launch containers concurrently for docker and podman runtimes
#!/bin/bash
set -e
containers_total=${1:-100}
containers_concur=${2:-10}
container_image=${3:-docker.io/library/busybox}
podman pull $container_image
docker pull $container_image
rm -f bench-jobs.txt
@parsa
parsa / hexchat_external_sasl_auth.md
Last active January 17, 2024 22:44
Nickserv Commands

Generate a certificate

Note: Git Bash comes with OpenSSL

$ openssl req -x509 -new -newkey rsa:4096 -sha256 -days 730 -nodes -out freenode.pem -keyout freenode.pem
Generating a 4096 bit RSA private key
.....................................................++
............................................................................++
writing new private key to 'freenode.pem'
@kenanpelit
kenanpelit / myweechat.md
Created November 9, 2016 21:45 — forked from pascalpoitras/config.md
My always up-to-date WeeChat configuration (weechat-dev)

WeeChat Screenshot

Enable mouse support

/mouse enable

Encrypted password in sec.conf

@subfuzion
subfuzion / curl.md
Last active November 17, 2024 03:54
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.