Skip to content

Instantly share code, notes, and snippets.

@danthegoodman1
danthegoodman1 / firecracker.sh
Created June 7, 2024 23:38
Updated getting started that enables an interface configured with internet access (works with theirs, and a default `ubuntu` docker image dump).
TAP_DEV="tap0"
TAP_IP="172.16.0.1"
MASK_SHORT="/30"
# Setup network interface
sudo ip link del "$TAP_DEV" 2> /dev/null || true
sudo ip tuntap add dev "$TAP_DEV" mode tap
sudo ip addr add "${TAP_IP}${MASK_SHORT}" dev "$TAP_DEV"
sudo ip link set dev "$TAP_DEV" up
@dclark
dclark / aws-cloud-shell-get-aws-credentials.sh
Created August 25, 2023 11:37
AWS CloudShell get credentials
#!/usr/bin/env bash
# Retrieve AWS credentials from AWS CloudShell
# shellcheck disable=SC2001
HOST=$(echo "$AWS_CONTAINER_CREDENTIALS_FULL_URI" | sed 's|/latest.*||')
TOKEN=$(curl -s -X PUT "$HOST"/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 60")
OUTPUT=$(curl -s "$HOST/latest/meta-data/container/security-credentials" -H "X-aws-ec2-metadata-token: $TOKEN")
echo "export AWS_ACCESS_KEY_ID=$(echo "$OUTPUT" | jq -r '.AccessKeyId')"
echo "export AWS_SECRET_ACCESS_KEY=$(echo "$OUTPUT" | jq -r '.SecretAccessKey')"
@benkehoe
benkehoe / kms_random.md
Created April 28, 2023 14:45
Python random numbers from KMS.GenerateRandom

Python random numbers from KMS.GenerateRandom

Spurred by this twitter conversation. random.SystemRandom uses os.urandom as a source of bytes, but doesn't provide a way to use a different source of bytes. So stream_random.py is exactly that. Then kms_random.py has raw and buffered bytestreams pulling from KMS.GenerateRandom.

The main interface is kms_random.get_kms_random(boto3_session, buffer_size=None). The default buffer size is 16, chosen arbitrarily.

I do not vouch for the randomness properties of the results.

import network
import socket
import time
import struct
from machine import Pin
NTP_DELTA = 2208988800
host = "pool.ntp.org"
@lukeplausin
lukeplausin / transfer_ssm_file.sh
Last active March 18, 2025 21:19
Transfer a file to EC2 SSM instance without using S3 (SSM only)
# This script will explain how to transfer a file to EC2 using SSM ONLY!
# You will need to have permission to run SSM commands on the target machine and have sudo access as well
# Infos
INSTANCE_ID=i-1234567890
FILE_NAME=the_file.tar.gz
# Step 1: Run command on machine to install netcat and dump from port to filename
# < Start session
@kevinGodell
kevinGodell / mpeg-dash-ffmpeg-dashjs.md
Created September 20, 2017 22:53
Use ffmpeg to connect to an ip cctv camera and create video files on the fly that can be viewed in an mpeg-dash compatible browser using dash.js and an html5 video element.

Live streaming mpeg-dash video using ffmpeg and dash.js

Use ffmpeg to connect to an ip cctv camera and create video files on the fly that can be viewed in an mpeg-dash compatible browser using dash.js and an html5 video element.

Prerequisites

A linux server, such as Ubuntu

Apache web server installed, running, and reachable via its ip address
@urwx
urwx / sys-btrfs.txt
Last active May 28, 2024 18:07
Arch Linux Encrypted LVM Luks Btrfs Guide (EFI)
Arch Linux Encrypted LVM Luks Btrfs Guide (EFI)
# Wipe disk with random data (optional)
badblocks -c 10240 -s -w -t random -v /dev/sda
# Partition
parted -a minimal /dev/sda
- mklabel gpt
- unit Mib
- mkpart ESP fat32 0% 512
- set 1 boot on
- mkpart primary ext4 512 100%
@curzona
curzona / conftest.py
Last active February 16, 2024 16:26
pytest with monkeypatch __buildin__.open
import __builtin__
from StringIO import StringIO
import os
import ConfigParser
import pytest
class MockFileManager():
def __init__(self):
self.files = {}
/******************************************************************************
* MSP-EXP430G2-LaunchPad Software UART Transmission
*
* Original Code: From MSP-EXP430G2-LaunchPad User Experience Application
* Original Author: Texas Instruments
*
* Description: This code shows the minimum neeed to send data over a software
* UART pin (P1.1). This is a highly condenced and modified version
* of the User Experience Application which comes programmed with
* the LaunchPad.