Skip to content

Instantly share code, notes, and snippets.

View aduzsardi's full-sized avatar
🛠️
d(0_0)b

Alexandru Duzsardi aduzsardi

🛠️
d(0_0)b
View GitHub Profile
@aduzsardi
aduzsardi / modrewrite-htaccess
Created September 17, 2019 20:11 — forked from tsertkov/modrewrite-htaccess
Print mod_rewrite server variables using special mod_rewrite rules exporting internal variables via environment variables and PHP script printing there vars.
RewriteEngine On
# special mod_rewrite variables
RewriteRule .* - [E=MR_SPECIALS_API_VERSION:%{API_VERSION},NE]
RewriteRule .* - [E=MR_SPECIALS_THE_REQUEST:%{THE_REQUEST},NE]
RewriteRule .* - [E=MR_SPECIALS_REQUEST_URI:%{REQUEST_URI},NE]
RewriteRule .* - [E=MR_SPECIALS_REQUEST_FILENAME:%{REQUEST_FILENAME},NE]
RewriteRule .* - [E=MR_SPECIALS_IS_SUBREQ:%{IS_SUBREQ},NE]
RewriteRule .* - [E=MR_SPECIALS_HTTPS:%{HTTPS},NE]
@aduzsardi
aduzsardi / pem-split
Created July 26, 2019 08:22 — forked from jinnko/pem-split
Take a PEM format file as input and split out certs and keys into separate files.
#!/usr/bin/awk -f
#
# Take a PEM format file as input and split out certs and keys into separate files
#
BEGIN { n=0; cert=0; key=0; if ( ARGC < 2 ) { print "Usage: pem-split FILENAME"; exit 1 } }
/-----BEGIN PRIVATE KEY-----/ { key=1; cert=0 }
/-----BEGIN CERTIFICATE-----/ { cert=1; key=0 }
split_after == 1 { n++; split_after=0 }
/-----END CERTIFICATE-----/ { split_after=1 }
@aduzsardi
aduzsardi / README.md
Created April 11, 2019 08:35 — forked from dnozay/README.md
Enable memberOf attribute on an openldap server.
@aduzsardi
aduzsardi / shell-prompt.sh
Created March 14, 2019 08:41
bash prompt
export PS1='\[\e[1;33m\]\u\[\e[1;37m\]@\[\e[1;32m\]\h\[\e[1;37m\]: \[\e[1;31m\]\w\[\e[0;36m\]$(__git_ps1 "\e[37m (\e[36m%s ⎇ \e[37m)\e[0m")\n\[\e[1;36m\]└─\$ ▶ \[\e[0m\]'
# if you don't have __git_ps1 (git-prompt.sh) , you can download it from here https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh , and source it in your bash init files (ie. .bashrc)
@aduzsardi
aduzsardi / parse_aws_s3_billing.py
Created February 4, 2019 17:09 — forked from oddskool/parse_aws_s3_billing.py
Simplistic script to parse the detailed AWS billing CSV file. Script displays cost of S3 operations broken down per region, bucket and usage type (either storage or network). It also sums up the amount of storage used per bucket. Output is filtered wrt to costs < 1$. See http://docs.aws.amazon.com/awsaccountbilling/latest/about/programaccess.html
# -*- coding:utf-8 -*-
'''
Simplistic script to parse the detailed AWS billing CSV file.
Script displays cost of S3 operations broken down per region, bucket and usage
type (either storage or network). It also sums up the amount of storage used per bucket.
Output is filtered wrt to costs < 1$.
See http://docs.aws.amazon.com/awsaccountbilling/latest/about/programaccess.html for
how to set up programmatic access to your billing.
@aduzsardi
aduzsardi / get-latest-ami.py
Last active February 1, 2019 07:39
get ami image python script
#!/usr/bin/env python3
import boto3
from dateutil import parser
import argparse
import json
vendor_ami_filters = {
'amazon' : [{ 'Name': 'owner-id', 'Values': ['137112412989']}, {'Name': 'name', 'Values': ['amzn-ami-hvm-*'] }],
'ubuntu' : [{ 'Name': 'owner-id', 'Values': ['099720109477']}, {'Name': 'name', 'Values': ['ubuntu/images/hvm-*'] }]
@aduzsardi
aduzsardi / gist:a4903e2f54aeef044a613abe1960499c
Created January 4, 2019 09:02 — forked from scottious/gist:0d99ea77daa041b28929
__git_ps1 command not found issue.

I've been having an issue with the following error appear in the prompt after upgrading to Yosemite. The solution was to source the git bash completion and prompt files from a local copy.

    curl -o ~/.git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
    curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh

Then in:

    vi ~/bash_profile

Add:

@aduzsardi
aduzsardi / rancher_create_kubernetes_token.sh
Created November 14, 2018 14:21 — forked from superseb/rancher_create_kubernetes_token.sh
rancher_create_kubernetes_token.sh
curl 'http://<rancher_server_ip>/v2-beta/apikey' -H 'content-type: application/json' --data-binary '{"type":"apiKey","accountId":"1a1","name":"kubectl","description":"Provides workstation access to kubectl"}' --compressed | jq -r '.publicValue + ":" + .secretValue' | base64 | tr /+ _- | tr -d =
@aduzsardi
aduzsardi / sed-test
Created November 7, 2018 10:23
select text block
sed -i -ne '/<!-- BEGIN realm -->/ {p; r realm.xml' -e ':a; n; /<!-- END realm -->/ {p; b}; ba}; p' server.xml
@aduzsardi
aduzsardi / README.md
Created November 4, 2018 19:00 — forked from magnetikonline/README.md
Enable LDAP over SSL (LDAPS) for Microsoft Active Directory servers.

Enable LDAP over SSL (LDAPS) for Microsoft Active Directory servers

By default Microsoft active directory servers will offer LDAP connections over unencrypted connections (boo!).

The steps below will create a new self signed certificate appropriate for use with and thus enabling LDAPS for an AD server. Of course the "self-signed" portion of this guide can be swapped out with a real vendor purchased certificate if required.

Steps have been tested successfully with Windows Server 2012R2, but should work with Windows Server 2008 without modification. Will require both a system with OpenSSL (ideally Linux/OSX) and (obviously) a Windows Active Directory server.