Skip to content

Instantly share code, notes, and snippets.

View afro-coder's full-sized avatar

Leon afro-coder

View GitHub Profile
@GeorgySk
GeorgySk / table_alignment.py
Created October 27, 2018 22:08
Example of how to print aligned a table from a list of dicts
from operator import itemgetter
from typing import (Any,
Dict,
Iterable,
Iterator,
List,
Sequence)
def max_length(objects: Iterable[Any]) -> int:
@mattupstate
mattupstate / uuid_url64.py
Last active July 2, 2020 13:46
Generate unique, URL friendly ID's based on UUID with Python
import re
import uuid
import base64
def uuid_url64():
"""Returns a unique, 16 byte, URL safe ID by combining UUID and Base64
"""
rv = base64.b64encode(uuid.uuid4().bytes).decode('utf-8')
return re.sub(r'[\=\+\/]', lambda m: {'+': '-', '/': '_', '=': ''}[m.group(0)], rv)
@bwhaley
bwhaley / example_usage.py
Last active July 6, 2021 11:18
Python log handler for Sumo Logic HTTP source
import logging
import logging.config
import sumologger
from sumologger import SumoHTTPHandler
logging.config.dictConfig(sumologger.LOGGING)
logger = logging.getLogger("sumologger")
logger.debug("Nifty log message")
@Phaeilo
Phaeilo / archvm.sh
Last active May 24, 2022 19:55
Archlinux VM automated installation script.
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2015 Philip Huppert
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
@SalahAdDin
SalahAdDin / Steps.md
Last active May 29, 2022 06:11
Instlling React-Native Android Environment in ArchLinux

First step: Install Android SDK

  1. yaourt -S android-sdk android-sdk-platform-tools android-sdk-build-tools
    Note: Maybe you'll have problems with the lasta package: ncurses5-compat-libs. In order to avoid this problem you have to use this command: gpg --recv-keys F7E48EDB. You can find clarification here.
  2. yaourt -S genymotion
    Note: You'll need install virtual-box and his modules, yaourt will make for you but you need choos between ArchLinux host modules or DKMS host modules.
  3. Enter in super user mode with su - and then do echo -e "vboxdrv\nvboxnetflt\nvboxnetadp\nvboxpci" > /etc/modules-load.d/virtualbox.conf
    Note: You need do this with super user because need super user permissions and with sudo, for us at least, doesn't work.
  4. sudo modprobe vboxdrv vboxnetadp vboxnetflt
    Activate for current session.
  5. sudo chmod -R 777 /opt/android-sdk
@anthumchris
anthumchris / validate-permissions.js
Created June 9, 2022 20:55
Validate AWS Policy Action Permissions for IAM User or Role
/* This NodeJS script tests IAM Policy Actions for yourself or a specific PolicySourceArn user/role.
*
* https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/configuring-the-jssdk.html
*/
import AWS from 'aws-sdk' // $ npm i -D aws-sdk@2
const iam = new AWS.IAM()
const sts = new AWS.STS()
@mrimp
mrimp / !proxmox_k3s_cluster.sh
Created September 16, 2021 00:25 — forked from ilude/!proxmox_k3s_cluster.sh
Proxmox k3s cluster creation scripts
#!/bin/bash
# curl -s https://gist.githubusercontent.com/ilude/457f2ef2e59d2bff8bb88b976464bb91/raw/cluster_create_setup.sh?$(date +%s) > ~/bin/setup_cluster.sh; chmod +x ~/bin/setup_cluster.sh; setup_cluster.sh
echo "begin cluster_create_setup.sh"
export CREATE_TEMPLATE=1 #false
while test $# -gt 0; do
case "$1" in
--template)
export CREATE_TEMPLATE=0 #true
@rordi
rordi / root-password-MariaDB-docker-compose.md
Last active January 23, 2024 15:36
Change root password in MariaDB Docker container running with docker-compose

Change root password in MariaDB Docker container running with docker-compose

Override the entrypoint in docker-compose.yml for the MariaDB Docker container by adding:

entrypoint: mysqld_safe --skip-grant-tables --user=mysql

The start up the Docker Compose stack:

$> docker-compose up -d
@dnozay
dnozay / LICENSE
Created December 19, 2017 20:07
Datetime utilities extracted from Django code as a single module.
Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
@perfecto25
perfecto25 / resticheat.md
Last active March 3, 2024 12:34
Restic cheatsheet

Restic backup application - commands cheatsheet

Installation & config

  1. add Retic repo
  2. yum install restic

add a Restic credential file to root

vim /root/.restic