Skip to content

Instantly share code, notes, and snippets.

@3v1n0
3v1n0 / web-snapshts-saver.py
Last active March 6, 2024 16:07
Simple Browser snapshots saver with webkit and python-gtk3
#!/usr/bin/env python3
import gi
import datetime
import os
os.environ['GDK_BACKEND'] = 'x11'
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
@3v1n0
3v1n0 / sssd-smart-card-pam-auth-configs-tester.sh
Last active September 14, 2023 10:27
A simple interactive tester for sssd PAM configurations
#!/usr/bin/env bash
# Copyright 2023 - Marco Trevisan
# Released under the GPLv3 terms
#
# A simple tool to simulate PAM authentication using SSSD smartcard settings.
#
# To be used with softhsm2 smart cards generators from
# https://gist.github.com/3v1n0/287d02ca8e03936f1c7bba992173d47a
#
# Origin: https://gist.github.com/3v1n0/d7bc0f10cf44a11288648ae9d228430d
@3v1n0
3v1n0 / pam_conv_example.c
Created June 15, 2023 15:45
PAM module conv tests
#include <glib.h>
#include <json-glib/json-glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
/* expected hook */
PAM_EXTERN int
@3v1n0
3v1n0 / sssd-gdm-smartcard-pam-auth-tester.sh
Last active September 7, 2023 17:53
Some crazy automated tests to get Smartcard authentication with SSSD, simiulating various setups via software via softhsm2 and a test tool to verify usage with GDM
#!/usr/bin/env bash
# Copyright 2023 - Marco Trevisan
# Released under the GPLv3 terms
#
# A simple tool to simulate PAM authentication using GDM smartcard settings.
#
# This can also be used in interactive mode to test GDM login from the UI, by
# setting the environment variable `WAIT`, so that the script will restart the
# gdm service and will allow the user to login it using its name and a provided
# `PIN` (123456 by default).
#!/usr/bin/env bash
#
# Use
# eval $(prefix-builder.sh [add|rm|prepend|append] folder)
#
# or Alias such as:
# function eval_cmd() { eval $($*); }
# alias build-prefix="eval_cmd prefix-builder.sh"
# alias add-build-prefix="eval_cmd prefix-builder.sh add"
# alias rm-build-prefix="eval_cmd prefix-builder.sh rm"
@3v1n0
3v1n0 / pynchos.py
Created November 4, 2021 18:05
Pynchos
# Initial commit
@3v1n0
3v1n0 / map-string-any-kotlin-serialization-tests.kt
Last active September 25, 2023 18:15
Kotlin Map<String, Any?> (andy Any type in general) (de)serialization tests with both Binary (CBOR) and JSON support
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.*
import kotlin.reflect.KType
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.starProjectedType
@3v1n0
3v1n0 / fitbit-svg-to-grayscale-magic-png.sh
Last active January 6, 2021 13:05
Simple script to convert SVG icons to fitbit Grayscale Magic compatible PNGs
#!/bin/bash
# Simple script to convert SVG icons to fitbit grayscale magic compatible PNGs
# Usage: convert-svg.sh [icons-path]
#
# Author: Marco Trevisan (Treviño) <mail@3v1n0.net>
# Licensed under GPLv3
PNG_SIZE=${PNG_SIZE:-80}
icons_path=${1:-$(dirname "$0")}
@3v1n0
3v1n0 / .zshrc
Created June 6, 2020 14:35
ZSH zinit configuration with powerlevel10k instant mode
typeset -g MY_ZSH_CONFIG_PATH=${ZDOTDIR:-$HOME/.config/zsh}
typeset -g MY_ZINIT_PATH=${ZDOTDIR:-$HOME/.local/share}/zinit
HISTFILE=$MY_ZSH_CONFIG_PATH/zsh_history
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
if [ ! -f $MY_ZINIT_PATH/bin/zinit.zsh ] && ((${+commands[git]})); then
@3v1n0
3v1n0 / .zshrc
Last active June 6, 2020 14:35
Broken zsh syntax highlighting when using async zinit (turbo mode) + powerlevel10k and zsh-autosuggestions
typeset -g MY_ZSH_CONFIG_PATH=${ZDOTDIR:-$HOME/.config/zsh}
typeset -g MY_ZINIT_PATH=${ZDOTDIR:-$HOME/.local/share}/zinit
HISTFILE=$MY_ZSH_CONFIG_PATH/zsh_history
if [ ! -f $MY_ZINIT_PATH/bin/zinit.zsh ] && ((${+commands[git]})); then
__zinit_just_installed=1
mkdir -p $MY_ZINIT_PATH && chmod g-rwX "$MY_ZINIT_PATH" && \
git clone --depth=1 https://github.com/zdharma/zinit.git $MY_ZINIT_PATH/bin
fi