Skip to content

Instantly share code, notes, and snippets.

View ptman's full-sized avatar
💭
.

Paul Tötterman ptman

💭
.
View GitHub Profile
@ptman
ptman / error.log
Last active February 5, 2024 11:55
robotframework playwright
> ERROR: Could not find a version that satisfies the requirement wrapt>=1.15.0 (from versions: none)
> ERROR: No matching distribution found for wrapt>=1.15.0
> error: Command '['/nix/store/rac8pxbi1vapwrlqzbrkycbyg521djzw-python3-3.11.6/bin/python3.11', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/build/tmph3z78e84', '--quiet', 'wrapt>=1.15.0']' returned non-zero exit status 1.
@ptman
ptman / redis_session.go
Created December 3, 2023 20:26
Redis Session Module for Revel.
// Copyright © Paul Tötterman <paul.totterman@iki.fi>. All rights reserved.
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License version 3 as published by
// the Free Software Foundation.
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
@ptman
ptman / sessioncookie.go
Created May 2, 2022 11:59
session cookies in go
func errPanic(err error) {
if err != nil {
panic(err)
}
}
func secureRandom(size int) ([]byte, error) {
nonce := make([]byte, size)
_, err := cryptorand.Read(nonce)
errPanic(err)
@ptman
ptman / tailscale.py
Created November 25, 2021 15:51
Ansible Tailscale inventory script
#!/usr/bin/env python3
# Copyright (c) 2021 Paul Tötterman <paul.totterman@iki.fi>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
@ptman
ptman / revel_sentry.go
Created April 1, 2020 08:15
revel sentry filter
// Copyright (c) 2020 Paul Tötterman <paul.totterman@iki.fi>.
import sentry "github.com/getsentry/sentry-go"
// look at github.com/getsentry/sentry-go/http
var SentryFilter = func(c *revel.Controller, fc []revel.Filter) {
if dsn := revel.Config.StringDefault("sentry.dsn", ""); dsn != "" {
defer func() {
if err := recover(); err != nil {
hub := sentry.CurrentHub().Clone()
@ptman
ptman / reversestringer.go
Created November 12, 2015 12:25
Complement for go stringer
import "strings"
func ParseType(s string) Type {
return parseType(0, s)
}
func parseType(i int, s string) Type {
j := strings.Index(_Type_name[i:], s)
if j == -1 {
abraham
absent
absorb
absurd
academy
accent
acid
acrobat
action
active
@ptman
ptman / lookup_plugins:ldap_sshkeys.py
Last active January 23, 2019 11:26
Trying to get and use complex data from LDAP for Ansible.replace : in filename with /
# vim: set si ai et sw=4 sts=4 ts=4 ft=python:
# coding: utf-8
# Copyright (c) 2013, ZenRobotics Ltd.
# Author: Paul Tötterman <paul.totterman@zenrobotics.com>
"""Ansible lookup plugin for looking up user data in an LDAP directory."""
from ansible import utils, errors
import ldap
@ptman
ptman / watchdog.ps1
Created September 19, 2013 12:59
SuperMicro IPMI Watchdog for Windows
# coding: utf-8
# vim: set ts=4 sw=4 sts=4 si ai et ft=powershell:
# Copyright (c) 2013, ZenRobotics Ltd.
# author: Paul Tötterman <paul.totterman@zenrobotics.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@ptman
ptman / ipm.py
Created September 13, 2013 13:53
#!/usr/bin/env python
# coding: utf-8
# vim: set ts=4 sts=4 sw=4 si ai et ft=python:
# author: Paul Tötterman <paul.totterman@zenrobotics.com>
#
# Copyright (c) 2013, ZenRobotics Ltd.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.