Skip to content

Instantly share code, notes, and snippets.

@ri0day
ri0day / curl-saml-to-aws-role.sh
Last active July 25, 2023 03:06 — forked from lantrix/aws.sh
Bash functions to autenticate and assume roles in aws federated accounts - for ADFS3
#!/bin/bash
# bash functions to autenticate and assume roles in aws federated accounts
# required tools on $PATH - aws, date, curl, jq, libxml2-utils
# requried environment variables:
export AWS_CLI=`which aws`
# optional environment variable, to automatically assume a specific role when calling assume()
# AWS_ASSUME_ROLE=arn:aws:iam::369407384105:role/cross-account-federated-role
@ri0day
ri0day / aliyuncms.go
Created March 26, 2022 07:13
aliyuncms.go
package aliyuncms
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"sync"
"time"
@ri0day
ri0day / discovery.go
Last active March 26, 2022 07:12
discovery.go
package aliyuncms
import (
"encoding/json"
"reflect"
"strconv"
"strings"
"sync"
"time"
__author__ = "Mark Allan B. Meriales"
# based from http://www.pythoncentral.io/watermark-images-python-2x/
# mine uses a picture as a watermark
from PIL import Image, ImageEnhance
def add_watermark(image_file, logo_file, opacity=1):
img = Image.open(image_file).convert('RGB')
logo = Image.open(logo_file)
@ri0day
ri0day / simple_gridfs_server.py
Created December 23, 2015 08:46 — forked from artisonian/simple_gridfs_server.py
A simple GridFS server built with Flask
from flask import Flask, request, redirect, url_for, make_response, abort
from werkzeug import secure_filename
from pymongo import Connection
from pymongo.objectid import ObjectId
from gridfs import GridFS
from gridfs.errors import NoFile
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
DB = Connection().gridfs_server_test
FS = GridFS(DB)
from threading import Thread
import Queue
import time
class TaskQueue(Queue.Queue):
def __init__(self, num_workers=1):
Queue.Queue.__init__(self)
self.num_workers = num_workers
self.start_workers()
@ri0day
ri0day / .profile
Last active August 29, 2015 14:18 — forked from riemers/.profile
PBLOC=~/projects/somewhere/addserver.yml
addserver() {
if [[ -z "$1" ]]; then
echo "[e] You need to give an IP for this to work. Dont use ssh-agent, since it will have precedence"
else
echo "[i] Running setup for new server, be ready to type in your root password"
echo "[i] Removing and re-adding the known_hosts file"
ssh-keygen -f "${HOME}/.ssh/known_hosts" -R $1
ssh-keyscan -t rsa -H $1 >> ~/.ssh/known_hosts
ansible-playbook ${PBLOC} -u root -i "newserver," --extra-vars="hosts=newserver ansible_ssh_host=$1" -k
loglevel.default = "DEBUG"
rdeck.base = "/var/lib/rundeck"
rss.enabled = true
dataSource {
dbCreate = "update"
url = "jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true"
}
#!/bin/bash -e
#set to correct path to xmlstarlet
XMLSTARLET=/usr/local/bin/xml
# xmlstarlet select xpath
# usage: xmlsel XPATH file
xmlsel(){
xpath=$1
shift
$XMLSTARLET sel -T -t -v "$xpath" $*
[
{
id: "locahost",
description: "Rundeck server node",
hostname: "localhost",
osArch: "x86_64",
osFamily: "unix",
osName: "Mac OS X",
osVersion: "10.6.6",
tags: ''