Skip to content

Instantly share code, notes, and snippets.

View flaf's full-sized avatar

François Lafont flaf

View GitHub Profile
@flaf
flaf / crack.py
Last active May 18, 2020 08:28
python-and-multiprocessing
#!/usr/bin/env python3
import string
import itertools
import hashlib
import json
from multiprocessing import Pool, Manager
U = string.ascii_uppercase # ['A', 'B', ..., 'Z']
L = string.ascii_lowercase # ['a', 'b', ..., 'z']
@flaf
flaf / powershell-sort-array-of-objects.md
Created June 16, 2019 21:11
powershell-sort-array-of-objects
# pwsh
PowerShell 6.2.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /root/mnt> class A {                                        
>> 
@flaf
flaf / endpoints-of-a-zonegroup.md
Created April 1, 2019 07:12
endpoints of a zonegroup
[root@ceph01 /]# radosgw-admin --cluster ceph-a zonegroup get
{
    "id": "47e7433a-bfe2-4c6a-b761-4cdf32cbf25c",
    "name": "zg-1",
    "api_name": "zg-1",
    "is_master": "true",
    "endpoints": [
        "http://s3.virt.priv:8080"
    ],
@flaf
flaf / rebase-old-branch.md
Last active April 4, 2019 09:48
Rebase an old branch

I have this:

A - B - C - F - G (master)
         \
          D - E (BranchB, origin/BranchB)

I want to have this:

@flaf
flaf / bonding-mac-address.md
Last active February 8, 2019 11:26
MAC address of bonding in Ubuntu 18.04

I'm on Ubuntu 18.04. According to the pastes below:

  • mac address of eno1 0c:c4:7a:c6:ae:26
  • mac address of eno2 0c:c4:7a:c6:ae:27
  • mac address of bond1 (bondig of eno1 and eno2) 92:da:30:66:27:50

Why 92:da:30:66:27:50 for bond1? No relation with the mac address of eno1 and eno2.

Here is the content of /etc/netplan/01-netcfg.yaml
@flaf
flaf / email-from-my-freenas.md
Last active January 31, 2019 05:48
Strange email from my FreeNAS
zstore-2.dc2.backbone.education changes in mounted filesystems:
1d0
< 192.168.19.20:/zstore/nunkis /root/mnt-zstore1-nunkis nfs	rw		0 0

zstore-2.dc2.backbone.education kernel log messages:
> CPU: AMD Opteron(tm) Processor 6128 (2000.06-MHz K8-class CPU)
> SMP: AP CPU #7 Launched!
> SMP: AP CPU #4 Launched!
@flaf
flaf / fubar-spip-cache.txt
Created January 14, 2019 14:13
fubar-spip-cache
# lsof -u www-data | grep -v '/usr/lib/' | grep -v '/lib/x86' | grep svt
php-fpm7. 4525 www-data 5r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4526 www-data 6r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4528 www-data 6r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4529 www-data 5r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4535 www-data 5r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versaille
@flaf
flaf / filter-tags.md
Last active January 10, 2019 15:58
Help me to find the pythonic way to do that...

J'ai une liste de dictionnaires l1 et chaque élément possède la clé tags dont la valeur est une liste de strings. Je cherche à filtrer ma liste via une fonction pour ne garder que les éléments qui possèdent tels ou tels tags.

Voici mon code naïf mais qui marche :

#!/usr/bin/python

def my_filter(array, tags):
@flaf
flaf / ansible-manage-or-remove-file.md
Created December 20, 2018 16:41
Ansible: good syntax to manage or remove file in function of a variable

Is there a ad hoc idiomatic syntax to do that in Ansible, ie manage the content of a file if a variable is defined or remove the file if the same variable is not defined?

Or maybe this is the good way to do that?

- name: manage the content of /tmp/foo.txt
  template:
 src: foo.txt.j2
@flaf
flaf / rundeck-get-all-jobs.sh
Created December 7, 2018 13:02
Get all jobs in Rundeck
#!/bin/sh
URL='http://localhost:4440'
login='admin'
password='password...'
curl --cookie-jar ~/mycookie --data "j_username=$login" --data "j_password=$password" "$URL/j_security_check"
projects=$(curl --silent --cookie ~/mycookie "$URL/api/1/projects" | sed -nr 's|<name>(.*)</name>|\1|p')