Skip to content

Instantly share code, notes, and snippets.

View Filirom1's full-sized avatar

Romain Filirom1

View GitHub Profile
@dsmrt
dsmrt / query-aws-logs-insights.bash
Last active December 14, 2023 11:27
Using AWS CLI to query CloudWatch Logs with Insights. Looking -30 mins to now.
# this script queries aws logs with insights filtering on ERROR
# explanation of start and end times
#--start-time = unix timestamp 30 mins in the past
#--end-time = unix timestamp now
QUERY_ID=$(aws logs start-query \
--profile $profile \
--log-group-name /aws/lambda/aap-event-consumer-dev \
--start-time `date -v-30M "+%s"` \
@nbellocam
nbellocam / azFuncInvitation.js
Last active May 22, 2021 04:09
This code shows how to invite users to an Office 365 tenant as guest using Microsoft Graph API from an Azure Function
module.exports = function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (req.query.email && req.query.name) {
const userEmail = req.query.email;
const userDisplayName = req.query.name;
getToken().then(token => {
/* INVITE A USER TO YOUR TENANT */
var options = {
@ruanbekker
ruanbekker / mysql-iam-rds.sh
Last active December 3, 2022 02:09
MySQL Client Wrapper for RDS IAM Based Authentication
#!/usr/bin/env bash
# Wrapper MySQL Client for IAM Based Authentication for MySQL and Amazon Aurora on RDS
# Read: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html
# Usage: [app] [aws_profile] [rds_endpoint] [rds_mysql_username]
command_exists() {
type "$1" &> /dev/null ;
}
@vitalyisaev2
vitalyisaev2 / personal_access_token.py
Last active April 26, 2024 05:02
Script for obtaining Gitlab API Personal Access Token
#!/usr/bin/python3
"""
Script that creates Personal Access Token for Gitlab API;
Tested with:
- Gitlab Community Edition 10.1.4
- Gitlab Enterprise Edition 12.6.2
- Gitlab Enterprise Edition 13.4.4
"""
import sys
import requests
@JoeyG1973
JoeyG1973 / aws_saml.py
Last active September 9, 2023 10:15
aws saml login with session that auto refreshes.
# Took this:
# https://s3.amazonaws.com/awsiammedia/public/sample/SAMLAPICLIADFS/samlapi_formauth_adfs3.py
# converted to boto3 and smooshed it together with this:
# https://gist.github.com/kapilt/ac8e222081f63ba64e93
# which gave birth too this:
import sys
import botocore
import boto3
import requests
@fangdingjun
fangdingjun / get_original_dst.go
Created January 13, 2017 03:42
golang: get the original destination for the socket when redirect by linux iptables
// get the original destination for the socket when redirect by linux iptables
// refer to https://raw.githubusercontent.com/missdeer/avege/master/src/inbound/redir/redir_iptables.go
//
const (
SO_ORIGINAL_DST = 80
IP6T_SO_ORIGINAL_DST = 80
)
func getOriginalDst(clientConn *net.TCPConn) (rawaddr []byte, host string, newTCPConn *net.TCPConn, err error) {
if clientConn == nil {
@dnephin
dnephin / compose-hooks.sh
Last active October 21, 2022 20:44
Execute a hook in './hooks/<service>/<action>' when that event is received
#!/bin/bash
set -e
function handle_event() {
local entry="$1"
local action=$(echo $entry | jq -r '.action')
local service=$(echo $entry | jq -r '.service')
local hook="./hooks/$service/$action"
if [ -x "$hook" ]; then
"$hook" "$entry"
@icetan
icetan / gen-rsa-pubkey.sh
Created October 27, 2015 01:38
Create a public RSA key from modulus and exponent on the command line
#!/bin/bash
set -e
b2hex() { echo -n $1|base64 --decode | xxd -p -u | tr -d \\n; }
modulus=$(b2hex u2/nlDLMbqLY+XBnWlqHv74a/wvmPoefKv+5NkTU0sbQAEMN7Gar9Hgp50uMUQhiOhwO6L4hezrY021etPyh2Q==)
exponent=$(b2hex AQAB)
asn1conf=$(echo -e "asn1=SEQUENCE:pubkeyinfo\n[pubkeyinfo]\nalgorithm=SEQUENCE:rsa_alg\npubkey=BITWRAP,SEQUENCE:rsapubkey\n[rsa_alg]\nalgorithm=OID:rsaEncryption\nparameter=NULL\n[rsapubkey]\nn=INTEGER:0x$modulus\ne=INTEGER:0x$exponent" | openssl asn1parse -genconf /dev/stdin -noout -out /dev/stdout | base64)
package main
import (
"errors"
"net"
"strconv"
"syscall"
"unsafe"
"os"
)
@oscarrenalias
oscarrenalias / README.md
Last active September 27, 2020 18:46
Docker service discovery with HAproxy, consul and registrator on Docker Machine and Docker Swarm