Skip to content

Instantly share code, notes, and snippets.

@href
href / yubikey_otp_to_serial.py
Created August 30, 2016 11:27
Calculate the Yubikey serial number from the OTP
# adapted from Java:
# https://github.com/Yubico/yubikey-salesforce-client/blob/
# e38e46ee90296a852374a8b744555e99d16b6ca7/src/classes/Modhex.cls
ALPHABET = 'cbdefghijklnrtuv'
def yubikey_otp_to_serial(otp):
""" Takes a Yubikey OTP and calculates the serial number of the key.
@kvaps
kvaps / rspamd-lists.md
Last active February 21, 2025 03:34
Howto create local whitelists and blacklists for Rspamd

Local whitelists and blacklists for Rspamd

  • cd /etc/rspamd
  • create rspamd.conf.local
  • create lists:
touch local_bl_from.map.inc local_bl_ip.map.inc local_bl_rcpt.map.inc \
local_wl_from.map.inc local_wl_ip.map.inc local_wl_rcpt.map.inc
  • change permissions:
@simonw
simonw / how-to-use-aws-elasticsearch.md
Last active November 28, 2023 20:01
How to use Amazon AWS Elasticsearch

How to use Amazon AWS Elasticsearch

The good news: you can get it running on the free tier (with a tiny instance).

The bad news: it's stuck on Elasticsearch 1.5.2 and dynamic scripting (Groovy) is disabled.

http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html

Authentication: the safest option is to create a brand new IAM user (using the tool at https://console.aws.amazon.com/iam/home?region=us-east-1 ) with its own access key and secret key. Then when you create the Elasticsearch instance you can paste in the following IAM string:

@jbeezley
jbeezley / ls.py
Created April 8, 2015 18:04
Recursively list files in s3
#!/usr/bin/env python
import sys
import json
from boto.s3.connection import S3Connection
from boto.s3.prefix import Prefix
from boto.s3.key import Key
bucketname = sys.argv[1]
delimiter = '/'
@mgwilliams
mgwilliams / lxc-agent-forward.sh
Last active September 30, 2020 13:50
example of how to forward ssh-agent into an lxc
#!/bin/bash
# Example Script to forward ssh-agent socket into an unprivileged lxc
# This allows access to the ssh-agent by commands executed with lxc-attach
set -m
CONTAINER=$1 # e.g., test-container
REMOTE=$2 # e.g, [email protected]
@mgagne
mgagne / nova-flavor-slots.py
Created January 15, 2015 17:20
Nova flavor slots
#!/usr/bin/env python
import argparse
import os
import prettytable
from novaclient.v1_1 import client as novaclient
OS_USERNAME = os.environ['OS_USERNAME']
OS_PASSWORD = os.environ['OS_PASSWORD']
@anarchivist
anarchivist / slack_munin.sh
Last active February 4, 2025 00:54
Slack notification script for Munin
#!/bin/bash
# Slack notification script for Munin
# Mark Matienzo (@anarchivist)
#
# To use:
# 1) Create a new incoming webhook for Slack
# 2) Edit the configuration variables that start with "SLACK_" below
# 3) Add the following to your munin configuration:
#
@pschyska
pschyska / 0_pw_hash.rb
Last active July 6, 2021 12:30
PW hashing with puppet parser function
# lib/puppet/parser/functions/pw_hash.rb
module Puppet::Parser::Functions
newfunction(:pw_hash, type: :rvalue) do |args|
raise Puppet::ParseError, "pw_hash takes exactly two arguments, #{args.length} provided" if args.length != 2
# SHA512 ($6), default number of rounds (5000)
# rounds could be specified by prepending rounds=<n>$ parameter before the salt, i.e.
# args[0].crypt("$6$rounds=50000$#{args[1]}")
args[0].crypt("$6$#{args[1]}")
end
@tschaefer
tschaefer / linux-error.txt
Created April 9, 2014 08:00
glibc linux error list
code[1] define[EPERM] str[Operation not permitted]
code[2] define[ENOENT] str[No such file or directory]
code[3] define[ESRCH] str[No such process]
code[4] define[EINTR] str[Interrupted system call]
code[5] define[EIO] str[Input/output error]
code[6] define[ENXIO] str[No such device or address]
code[7] define[E2BIG] str[Argument list too long]
code[8] define[ENOEXEC] str[Exec format error]
code[9] define[EBADF] str[Bad file descriptor]
code[10] define[ECHILD] str[No child processes]
@tschaefer
tschaefer / linux-error.c
Created April 9, 2014 07:57
glibc linux error list
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main(void) {
struct error {
int code;
char *define;
};