Skip to content

Instantly share code, notes, and snippets.

View ramnes's full-sized avatar

Guillaume Gelin ramnes

View GitHub Profile
@ramnes
ramnes / meteor_id.py
Last active January 6, 2023 14:11
Create an id such as the ones Meteor creates... in Python!
import random
UNMISTAKABLE_CHARS = '23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz'
def meteor_id(chars_count=17, prefix=""):
"""Create an id such as the ones Meteor creates
Reference implementation: https://github.com/meteor/meteor/blob/3a2867fc15/packages/random/AbstractRandomGenerator.js
"""
@ramnes
ramnes / chrome-flags.conf
Created July 13, 2022 15:30
My ~/.local/chrome-flags.conf (enables hardware acceleration for Chrome on Linux)
--ignore-gpu-blocklist
--enable-gpu-rasterization
--enable-zero-copy
--enable-features=VaapiVideoDecoder
--disable-features=UseChromeOSDirectVideoDecoder
--use-gl=desktop
@ramnes
ramnes / qovery_restrict_deployments.py
Created March 29, 2022 14:01
Restrict the deployment of Qovery applications to changes in their root path
import json
import os.path
import httpx
context_path = os.path.expanduser("~/.qovery/context.json")
with open(context_path) as context_file:
context = json.load(context_file)
client = httpx.Client(
@ramnes
ramnes / center_window.py
Created February 5, 2021 22:16
Qtile hook to center all floating windows, until more sensible defaults or a better solution are available
@hook.subscribe.float_change
def center_window():
client = qtile.current_window
if not client.floating:
return
screen_rect = qtile.current_screen.get_rect()
center_x = screen_rect.x + screen_rect.width / 2
center_y = screen_rect.y + screen_rect.height / 2
@ramnes
ramnes / fallback.py
Last active January 4, 2021 12:09
Qtile hook to fallback to the first group with windows available when the last window of a group is killed
from libqtile import qtile
@hook.subscribe.client_killed
def fallback(window):
if window.group.windows != {window}:
return
for group in qtile.groups:
if group.windows:
qtile.current_screen.toggle_group(group)
@ramnes
ramnes / dump.sh
Created December 8, 2020 08:59
Dump any device media content with gphoto2
#!/bin/bash
date=$(date --rfc-3339=date)
mkdir "dump-$date"
cd "dump-$date"
gphoto2 --auto-detect
gphoto2 --get-all-files --skip-existing
cd -
@ramnes
ramnes / route53_trailing_dot.py
Last active June 26, 2020 06:58
Add a trailing dot to all CNAME, MX, NS and PTR records, in all zones, on Route 53
from copy import deepcopy
from pprint import pprint
import boto3
client = boto3.client('route53')
def get_values(record):
values = record.get("ResourceRecords")
import inspect
import json
import os.path
from pytest import fixture
def load_fixture(filepath):
with open(filepath) as file:
return json.load(file)
import json
def flatten(o):
"""Flatten dicts and lists, recursively, JSON-style
It's a generator that yields key-value pairs.
Example:
>>> dict(flatten({"a": [{"b": 1}, [2, 3], 4, {"c.d": 5, True: 6}]}))
@ramnes
ramnes / confused.gif
Last active March 20, 2024 18:40
How did this gif end up here?
confused.gif