Skip to content

Instantly share code, notes, and snippets.

View alertedsnake's full-sized avatar

Michael Stella alertedsnake

View GitHub Profile
@alertedsnake
alertedsnake / ldappasswd
Last active August 29, 2015 14:19
Generate OpenLDAP SSHA password
import getpass
import hashlib
import os
from base64 import urlsafe_b64encode as encode
def make_secret(password):
salt=os.urandom(4)
sha = hashlib.sha1(password)
sha.update(salt)
digest_salt_b64 = '{}{}'.format(sha.digest(), salt).encode('base64').strip()
set_prompt() {
Last_Command=$? # Must come first!
Gray='\[\e[01;30m\]'
Blue='\[\e[01;34m\]'
White='\[\e[01;37m\]'
Purple='\[\e[0;35m\]'
Red='\[\e[01;31m\]'
Green='\[\e[01;32m\]'
Reset='\[\e[00m\]'
FancyX='\342\234\227'
@alertedsnake
alertedsnake / gist:7dd9b87e47b1246fab93
Last active August 17, 2020 08:08
Use custom node + npm for Jenkins job
# setup python virtualenv and install nodeenv
virtualenv .python
. .python/bin/activate
pip install nodeenv
# setup nodeenv with the node of your choice, and upgrade npm to latest
nodeenv --node=0.10.37 --prebuilt .node
. .node/bin/activate
npm install -g npm
@alertedsnake
alertedsnake / stupidboto3.py
Last active September 2, 2019 17:31
Get a list of instances in an AWS autoscaling group, with boto3. I set MaxRecords=2 to experiment with the pagination, it does seem to return the whole list when not set, but.....
import boto3
def as_get_instances(client, asgroup, NextToken = None):
# this is downright ridiculous because boto3 sucks
irsp = None
if NextToken:
irsp = client.describe_auto_scaling_instances(MaxRecords=2, NextToken=NextToken)
else:
@alertedsnake
alertedsnake / .tmux.conf
Created November 25, 2015 14:46
Some useful tmux options, like making it use ^a like screen does
start-server
set -g prefix C-a
unbind C-b
bind C-a send-prefix
set -g status-keys vi
setw -g mode-keys vi
set -g status off
unbind ^L
bind ^L refresh-client
@alertedsnake
alertedsnake / gist:b7dc834510cf9883c84b3cfb286397b5
Created May 27, 2016 15:30
Kill all servers in an AWS Autoscaling Group
#!/bin/bash
#
# Note that this requires the really cool command-line tool 'jq'
#
if [ -z "$1" ]; then
echo "as_kill_instances [group]"
exit -1
fi

Keybase proof

I hereby claim:

  • I am alertedsnake on github.
  • I am alertedsnake (https://keybase.io/alertedsnake) on keybase.
  • I have a public key ASCfxV4qRyhhdxbeDgbNB5_C-vSKI1qSFx2kKHXLcpDhPwo

To claim this, I am signing this object:

Given this config file:
```YAML
credentials:
ftp://ftp.someserver.com:
user: foo
pass: bar
path: /path/to/logs
ftp://ftp.otherserver.com:
@alertedsnake
alertedsnake / gist:4bb4e421ab60aaac5de5006d6123d9f7
Created October 3, 2017 21:21
Useful EC2 shell functions
ec2ip() {
aws ec2 describe-instances --instance-ids $* | jq '.Reservations[0].Instances[0].PrivateIpAddress' | sed 's/"//g'
}
ec2ssh() {
ssh $(ec2ip $1)
}
@alertedsnake
alertedsnake / randompw.py
Last active January 4, 2018 17:54
xkcd #936 password generator
#!/usr/bin/env python3
"""
Random password generator, ala https://xkcd.com/936/
The wordlist is assumed to be a list of words in the language of your choice,
of the sizes of your choice. I got mine out of aspell::
aspell dump master | \
sed -e "s/'s$//" -e '/^[A-Z]/d' -e '/^.\{4,6\}$/!d' | \
sort -u > wordlist.txt