Skip to content

Instantly share code, notes, and snippets.

View gpr's full-sized avatar

Grégory Romé gpr

View GitHub Profile
@gpr
gpr / teleport.sh
Created January 28, 2022 10:46
Setup remote environment shared with Teleport
# /etc/profile.d/teleport.sh
# Set environment in Teleport session
if [ -n "${SSH_TELEPORT_USER}" ]
then
USER_FIRSTNAME=$(echo "${SSH_TELEPORT_USER%%@*}" | cut -d'.' -f1)
USER_LASTNAME=$(echo "${SSH_TELEPORT_USER%%@*}" | cut -d'.' -f2)
export USER_FULLNAME="${USER_FIRSTNAME^} ${USER_LASTNAME^}"
export GIT_AUTHOR_NAME="${USER_FULLNAME}"
export GIT_AUTHOR_EMAIL="${SSH_TELEPORT_USER}"
@gpr
gpr / OutlookMonitoring.py
Last active September 4, 2021 19:43
Outook mail monitoring and processing with Python
# Origin: http://stackoverflow.com/users/1259292/yusumishi
import win32com.client
import pythoncom
import re
class Handler_Class(object):
def OnNewMailEx(self, receivedItemsIDs):
# RecrivedItemIDs is a collection of mail IDs separated by a ",".
# You know, sometimes more than 1 mail is received at the same moment.
@gpr
gpr / kubectl-copy-secret.sh
Last active May 17, 2021 08:29
[Copy secrets among different namespaces] #kubernetes #k8s #secrets
#!/bin/bash
#
# Example: ./kubectl-copy-secret.sh s3access default gitlab-runnner
SECRET_NAME=${1:?}
NS_SRC=${2:?}
NS_SRC=${3:?}
kubectl get secret $SECRET_NAME \
--namespace=$NS_SRC \
@gpr
gpr / snippet.yaml
Last active February 15, 2021 08:23
[Node affinity based on hostname] #kubernetes #pods
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node_hostname
@gpr
gpr / kubeconfig-merge.sh
Created November 12, 2020 13:59
[How to merge kubeconfig files?] Merge several configuration to manage them as context #k8s #kubernetes #kubectl
KUBECONFIG=file1:file2:file3 kubectl config view --merge --flatten > config.yaml
@gpr
gpr / gui.rb
Last active November 4, 2019 19:11
How to use Glade resource with Ruby Gtk3
#!/usr/bin/env ruby
require 'gtk3'
def not_yet_implemented(object)
puts "#{object.class.name} sent a signal!"
end
def on_main_window_destroy(object)
Gtk.main_quit()
@gpr
gpr / CACHEDIR.TAG
Created October 17, 2019 07:48
[Cache Directory Tagging] See https://bford.info/cachedir/spec.html #tools #sysadmin
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/
@gpr
gpr / mattermost-bot.sh
Created October 15, 2019 19:57
[Mattermost Bot Usage]
#!/usr/bin/env bash
curl -i -X POST -H 'Content-Type: application/json' -d '{"channel_id":"<channel-id>", "message":"This is a message from a bot", "props":{"attachments": [{"pretext": "Look some text","text": "This is text"}]}}' -H 'Authorization: Bearer <bot-access-token>' <mattermost-url>/api/v4/posts
@gpr
gpr / Systemd_Cheat_Sheet.md
Created August 7, 2019 08:18
[System Cheat Sheet] A collection of Howto about Systemd #systemd #doc
@gpr
gpr / git-log-show-jira-commit.bash
Last active July 30, 2019 11:31
[Show commits that contain a reference to a Jira issue] #jira #git
#!/usr/bin/env bash
#
# usage: git-log-show-jira-commit.bash <JIRA_KEY>
#
JIRA_KEY=${1:?}
REGEX="^.*(${JIRA_KEY}-\d+).*\$"
git log -P --grep="${REGEX}" --pretty=%H | while read line
do