Skip to content

Instantly share code, notes, and snippets.

@dfsnow
dfsnow / json-exporter-config.yaml
Last active April 27, 2024 00:39
Export Jellyfin playback statistics to Prometheus and Grafana. See https://sno.ws/jellyfin-stats for more info
modules:
jellyfin:
headers:
# The Token value here needs to be an API key generated from the
# Jellyfin admin panel. It's hard-coded here but I'm sure there's
# a better way
Authorization: MediaBrowser Token=ADD_TOKEN_HERE
Content-Type: application/json
accept: application/json
@glowinthedark
glowinthedark / generate_directory_index_caddystyle.py
Last active February 16, 2024 21:58
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options ❗️superseded by https://github.com/glowinthedark/index-html-generator
#!/usr/bin/env python3
# NOTE: this script is deprecated;
# maintained version with SVG icons: https://github.com/glowinthedark/index-html-generator/
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@mayel
mayel / up
Last active January 2, 2022 01:11
up: script to keep your Mac up-to-date (both OS and Homebrew updates) via the command line
replaced by https://gist.github.com/mayel/c07bc0acb91824501d5bdbdc9eb7b33a

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@kaleksandrov
kaleksandrov / global-protect.sh
Last active April 19, 2024 03:46
Simple script that starts and stops GlobalProtect.app on Mac OSX.
#!/bin/bash
case $# in
0)
echo "Usage: $0 {start|stop}"
exit 1
;;
1)
case $1 in
start)
@terranware
terranware / snsToSlack.js
Last active March 7, 2024 14:47
AWS Lambda function to Slack Channel hookup
var https = require('https');
var util = require('util');
exports.handler = function(event, context) {
console.log(JSON.stringify(event, null, 2));
console.log('From SNS:', event.Records[0].Sns.Message);
var postData = {
"channel": "#aws-sns",
"username": "AWS SNS via Lamda :: DevQa Cloud",
@newmaniese
newmaniese / aws_key_gen.sh
Last active March 23, 2016 18:12
One of our issues with AWS IAM users is that a super user needs to distribute keys and can't guarantee that a user will get to setting up their MFA. We force them to run this before granting the IAM user any more than "Onboarding" Permissions.
#! /bin/bash
WAITTIME=15
printf "This script will secure your profile in AWS, by\n"
printf " * creating keys that only you have\n"
printf " * removing the ones that you don't\n"
printf " * creating an Virtual MFA Device for authentication\n\n\n"
has_aws_installed=$(command -v aws)
@garnaat
garnaat / gist:4123f1aefe7d65df9b48
Created October 15, 2014 19:08
A skew script to audit all security groups for non-whitelisted IP addresses
import skew
# Add whitelisted CIDR blocks here, e.g. 192.168.1.1/32.
# Any addresses not in this list will be flagged.
whitelist = []
for secgrp in skew.scan('arn:aws:ec2:*:*:security-group/*'):
for ipperms in secgrp.data['IpPermissions']:
for ip in ipperms['IpRanges']:
if ip['CidrIp'] not in whitelist:
@sinkers
sinkers / livestreammonitor.py
Created July 14, 2014 04:50
Script for live video streaming monitoring with notifications
#!/usr/bin/python
'''
Script to monitor live streams and send an Amazon SNS if the stream is down (and possibly take restorative action)
Future:
Black detect: ffmpeg -i out.mp4 -vf blackdetect -f null -
Note the following doesn't seem to fully work without looking at the debug logs
On live ffmpeg -y -i rtmp://cp30129.live.edgefcs.net/live/videoops-videoops@50541 -vf blackdetect -t 10 -loglevel debug -f null -
'''
@alghanmi
alghanmi / podcastgen.py
Last active October 18, 2023 21:49
Podcast Feed Generator -- Generate an podcast RSS feed for a set of media in a directory.
"""Podcast Feed Generator
Generate an podcast RSS feed for a set of media in a directory.
Use the list-extensions argument to see the list of supported extensions. You can add custom extensions using
Usage:
podcastgen.py gen <directory> --title=<podcast-title> --link=<podcast-link> --desc=<description> [--output=<rss-feed-file>] [--feed-link=<feed-url>] [--id=<podcast-id>] [--logo=<image_file>] [--category=<itunes-category> [--subcategory=<itunes-category>]] [--language=<language>] [--use-extension=<ext>]
podcastgen.py list-categories
podcastgen.py list-extensions
podcastgen.py -h | --help