Skip to content

Instantly share code, notes, and snippets.

View pbertera's full-sized avatar
🕳️

Pietro Bertera pbertera

🕳️
View GitHub Profile
@pbertera
pbertera / oidc-discovery.yaml
Created August 19, 2022 13:07
OpenShift OIDC Federation
apiVersion: v1
kind: ServiceAccount
metadata:
name: oidc-discovery
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: oidc-discovery
namespace: oidc-discovery
@pbertera
pbertera / replaceCA.sh
Last active September 13, 2024 07:06
OpenShift API Client CA replace script
#!/bin/bash
set -e -o pipefail
cleanup(){
rm -f ${USER}.key ${USER}.csr ${USER}.crt ${NAME}-ca.key ${NAME}-ca.crt
}
msg(){
echo "$(date) $@"
}
@pbertera
pbertera / create.sh
Last active May 28, 2020 16:58
AMQ broker with TLS+SNI and custom credentials
#!/bin/sh
# create the project
oc new-project amq-broker
# import the templates (this is done project-wise here)
oc replace --force -f \
https://raw.githubusercontent.com/jboss-container-images/jboss-amq-7-broker-openshift-image/76-7.6.0.GA/amq-broker-7-image-streams.yaml
for template in amq-broker-76-basic.yaml \
@pbertera
pbertera / bottlequeue.py
Last active October 11, 2018 09:24 — forked from fspot/bottlequeue.py
Example app using bottle and multiprocessing for queuing long jobs and using several workers.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Example app using bottle and multiprocessing for queuing long jobs
and using several workers.
"""
from multiprocessing import Process, Queue, cpu_count
from bottle import Bottle, run
@pbertera
pbertera / syslog.py
Created June 27, 2017 12:38
Minimal syslog server in Python (working with 2.7 and 3.x)
#!/usr/bin/env python
try:
import socketserver
except ImportError: # Python 2:
import SocketServer as socketserver
import socket
import sys
class LoggedUDPServer(socketserver.ThreadingMixIn, socketserver.UDPServer):
def __init__(self, server_address, RequestHandlerClass):
@pbertera
pbertera / freshdesk-sso.py
Last active March 14, 2019 13:05
Freshdesk Single sign-on in Python
import time
import hashlib
import hmac
import urllib
def get_sso_url(email, name, base_url, key, redirect_url=None, phone=None, company=None):
"""This function returns the Freshdesk SSO URL.
For more info look at https://goo.gl/NISgpr
"""
utctime = int(time.time())
# coding=utf-8
import datetime
import sys
import time
import threading
import traceback
import SocketServer
from dnslib import *
@pbertera
pbertera / tsafe.py
Last active October 27, 2023 02:09
A server launcher with log console in Python Tkinter
# Copyright 2015 Pietro Bertera <pietro@bertera.it>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
@pbertera
pbertera / __init__.py
Created January 20, 2015 20:58
Flask-codemirror over HTTPS: flask_codemirror/__init__.py
#! /usr/bin/env python
#-*- coding : utf-8 -*-
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
"""
Flask-Codemirror
~~~~~~~~~~~~~~~~
Manage a source code field using CodeMirror and WTForms
for Flask
@pbertera
pbertera / pyxmlvalidator.py
Created January 20, 2015 13:28
Usage: pyxmlvalidator.py file1.xml file2.xml ...
#!/usr/bin/python
from xml.sax.handler import ContentHandler
from xml.sax import make_parser
from glob import glob
import sys
def parsefile(file):
parser = make_parser()
parser.setContentHandler(ContentHandler())