Skip to content

Instantly share code, notes, and snippets.

@sahal
sahal / gist:308ad4a90936d5a92134c4334427aa01
Created November 29, 2017 00:37
teraform aws_lambda_function failure in 0.11.0 not 0.9.4
. . .
variable "vpc_security_groups" { type = "list", default = [] }
variable "vpc_subnets" { type = "list", default = [] }
. . .
resource "aws_lambda_function" "function" {
...
@sahal
sahal / hook.rb
Created June 29, 2016 13:07 — forked from tache/hook.rb
Hook for letsencrypt.sh to do DNS challenges
#!/usr/bin/env ruby
require 'aws-sdk'
require 'pry'
require 'awesome_print'
require 'domainatrix'
# ------------------------------------------------------------------------------
# Credentials
# ------------------------------------------------------------------------------
@sahal
sahal / python-version-check.sh
Created April 10, 2016 22:47
figure out python version
#!/bin/bash
# basic launcher
set -e
set -u
python_path="$(which python)"
#python_path="/usr/bin/python"
# figure out python version (might be useful in the future)
@sahal
sahal / cache-break.sh
Last active November 30, 2015 05:58
cache breaking for the poor man's soul.
#!/bin/bash
# by sahal ansari github@sahal.info
# todo: specify a list of extensions
# specify a list of files
# the for loop should be near the xargs line instead of above find
# - written like this insetad b/c this can become a oneliner in a jiffy
# - would have to rewrite the logic b/c i don't think its possible to put a for loop in xargs
for ext in css js png
do
@sahal
sahal / tempprof.sh
Last active November 28, 2015 01:54
Create and remove temporary Firefox Profiles on the fly
#!/bin/sh
set -e
set -u
profname="Danger"
profloc="$(firefox --new-instance --CreateProfile "$profname" 2>&1 | sed -e s/.*$profname\'\ at\ \'// -e s/\'$//)"
profdir=$(dirname "$profloc")
profini=""$(dirname $profdir)"/profiles.ini"
tempout="$(mktemp)"
@sahal
sahal / make-smaller.sh
Created August 19, 2015 03:28
Not A SCRIPT to create smaller photos to share with friends online.
#!/bin/sh
echo do not actually run this script
exit 1
mkdir avi
find ./ -type f -name *.AVI -print0 | xargs -0 -I {} mv {} ./avi/
mkdir jpg
find ./ -type f -name *.JPG -print0 | xargs -0 -I {} mv {} ./jpg/
cd ./jpg/
@sahal
sahal / whois-test.sh
Last active August 29, 2015 14:26
add this as an alias for whois to account for whois servers that your machine doesn't know about yet. see: http://blog.sahal.info/post/125728360746/whois-servers-for-gtlds
#!/bin/bash
# ./whois-test.sh domain.test.gtld
# desc: add this as an alias for whois to account for whois servers that your machine doesn't know about yet
# see: http://blog.sahal.info/post/125728360746/whois-servers-for-gtlds
# by: sahal ansari github@sahal.info
PATH_TO_WHOIS="/usr/bin/whois"
# test parameters and set the first potential domain as the DOMAIN_IN_QUESTION
#for parameter in "$@"; do
@sahal
sahal / trimbackups.sh
Last active August 29, 2015 14:15
Trim or prune your backup directories in $prefix_yyyymmdd[hhmm] format. See http://blog.sahal.info/post/110947605246/trimming-backups for more information.
#!/bin/bash
# ./trimbackups.sh [prompt]
# desc: Use this for trimming backup directories stored as $prefix_yyyymmdd[hhmm] in $backup dir
# todo: implement getopts :x
#
# Copyright (c) 2015 Sahal Ansari github@sahal.info
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@sahal
sahal / gpgidchk.sh
Last active August 29, 2015 14:10
Bash function to check for duplicate 32bit KeyIDs
#!/bin/bash
# desc: Looks for 32bit KeyID duplicates in your gpg keyring (More Info: https://evil32.com/)
# see: https://github.com/sahal/wget-tor-mirror for an example implementation
# by: Sahal Ansari (github@sahal.info)
# license: Any of the following: GPLv2 or GPLv3 or MIT
function do_gpgidchk {
gpg --list-keys --fingerprint | grep "Key\ fingerprint"| sed 's/.*\=\ //' | tr -d "\ " | sed 's/.\{32\}//' | sort | uniq -c | sed 's/^\ *//' | grep -v "^1\ "
if [ "$?" -eq "0" ]; then
echo "WARNING: At least two keys in your keyring share 32bit KeyIDs."
@sahal
sahal / gen-passwords.sh
Created November 23, 2014 19:48
Generate a list of passwords using /dev/urandom or /dev/random and bash
#!/bin/sh -e
# by Sahal Ansari - github@sahal.info
# based on this blog post by Kevin Goodman
# http://blog.colovirt.com/2009/01/07/linux-generating-strong-passwords-using-randomurandom/
# NOTE: install haveged for faster/'better' results!
length=24
count=10
random_source="/dev/urandom"