Skip to content

Instantly share code, notes, and snippets.

View angrychimp's full-sized avatar

Randall Kahler angrychimp

View GitHub Profile
@angrychimp
angrychimp / awsc-mezz-data.json
Created February 16, 2023 23:43
AWS Console Service Manifest
{
"regions": [
{
"id": "us-east-1",
"name": "US East",
"location": "N. Virginia",
"optIn": false
},
{
"id": "us-east-2",
@angrychimp
angrychimp / sftp-setup-ssh-keys.sh
Created January 24, 2017 18:37
Setting up SSH keys for key-auth with ProFTPd (w/ SFTP module)
#!/bin/bash
USERNAME="your username here"
SFTPHOST="your sftp host"
SFTPPORT=22 # or other port, if non-standard
# Create SSH key-pair for SFTP access
# (creates pair with no passphrase)
ssh-keygen -b 2048 -t rsa -C "$SFTPHOST" -N "" -f ~/.ssh/id_rsa.sftp
@angrychimp
angrychimp / useful.md
Last active May 7, 2022 21:14
A collection of tools, scripts, browser extensions, etc. that I've found make my life easier.

Browser Extentions

@angrychimp
angrychimp / parse-json.php
Created December 28, 2021 17:08
Fine JSON errors in JSONL file
<?php
$fin = fopen($argv[1], 'r');
$lno = 0;
while ($line = fgets($fin)) {
$lno++;
try {
$decoded = json_decode($line, true, 512);
if ($decoded === null && json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception("Invalid JSON format");
@angrychimp
angrychimp / logo.html
Created November 11, 2019 17:18
random isometric logo
<svg color={value.color} viewBox='0 0 32 32' width='100%' height='100%'>
<path stroke="currentColor" strokeWidth='1px' fill="transparent" d='M13,11L8,21M8,21L22,18M22,18L13,11M0,32L8,21M8,21L0,0M8,21L32,32M32,32L22,18M0,0L13,11M13,11L32,0M32,0L22,18M32,32L32,0L0,0L0,32Z' strokeDasharray='0 0 0 0' />
<path stroke="currentColor" strokeWidth='3' fill="transparent" d='M32,32L32,0L0,0L0,32Z' />
<path stroke="currentColor" strokeWidth='1' fill="transparent" d='M2,0A2,2,0,1,1,-2,0A2,2,0,1,1,2,0M34,32A2,2,0,1,1,30,32A2,2,0,1,1,34,32M2,32A2,2,0,1,1,-2,32A2,2,0,1,1,2,32M34,0A2,2,0,1,1,30,0A2,2,0,1,1,34,0M24,18A2,2,0,1,1,20,18A2,2,0,1,1,24,18M10,21A2,2,0,1,1,6,21A2,2,0,1,1,10,21M15,11A2,2,0,1,1,11,11A2,2,0,1,1,15,11' />
</svg>
def duration(sec):
is_float = isinstance(sec, float)
parts = [
('days', int(sec / 86400)),
('hours', int((sec % 86400) / 3600)),
('minutes', int((sec % 3600) / 60)),
('seconds', float(sec % 60) if is_float else int(sec % 60))
]
for i in range(len(parts)):
if float(parts[i][1]) > 0:
@angrychimp
angrychimp / gen-coupons.py
Created December 2, 2021 20:23
Generates random coupon codes
import random
import string
from sys import argv
from time import time
from datetime import datetime, timedelta
# print("\n".join([",".join([x, "".join(random.choices(string.ascii_lowercase + string.digits, k=10))]) for x in range(10)]))
start = int(time())
print(",".join(["id","code","expdate"]))
print("\n".join([",".join([
@angrychimp
angrychimp / slack_members.php
Created September 2, 2021 20:26
Fetch number of members in a Slack channel
<?php
// Your ID and token
$botToken = 'xoxb-xxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx';
$channelID = 'C12345678';
// Setup cURL
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://slack.com/api/conversations.info?channel=$channelID&include_num_members=true",
@angrychimp
angrychimp / seclists-athena.sh
Last active August 10, 2020 22:11
Create an Athena table from danielmiessler/SecLists
#!/bin/bash
# Assumes that your AWS CLI default profile is set. If not, set the AWS_PROFILE environment variable
SECLISTS_BUCKET=my-seclists-bucket
ATHENA_OUTPUT_BUCKET=my-athena-output-bucket
# Create the bucket (if necessary)
if [[ -n $(aws s3 ls s3://$SECLISTS_BUCKET 2>&1 | grep 'does not exist') ]]; then
aws s3 mb s3://$SECLISTS_BUCKET --region $(aws configure get region)
fi
@angrychimp
angrychimp / fix-csv-array.py
Created June 17, 2020 17:37
Fix CSV files with array data
import csv
import os
import sys
sourcefile = os.path.expanduser(sys.argv[1])
targetfile = sourcefile.replace('.', '-fixed.', 1)
with open(sourcefile) as csvfile, open(targetfile, 'w') as fixfile:
reader = csv.DictReader(csvfile)
writer = csv.DictWriter(fixfile, reader.fieldnames)
writer.writeheader()
for row in reader: