Skip to content

Instantly share code, notes, and snippets.

View danuw's full-sized avatar

Dan Benitah danuw

View GitHub Profile
@danuw
danuw / gitclonesinglebranch.txt
Created January 14, 2025 16:08
clone single branch from remote url
git clone --single-branch --branch feature/update-for-v1 https://github.com/danuw/aio-quickstart-bash-scripts.git aio
@danuw
danuw / partial-clone.md
Created September 8, 2024 18:36
Cloning a subfolder from git to the local machine

Partial cloning of a repository with Git

To efficiently clone only a specific subset of a large Git repository, you can use sparse checkout. This approach is useful when you don't need the entire repository content, saving both time and storage. Below is a step-by-step guide to achieving this.

I have been trying to make sparse checkout work for a while and the following solution has finally worked. https://askubuntu.com/a/1464994/1928663

@danuw
danuw / export-prime-video-history-from-browser.js
Created August 30, 2024 18:36
Export prime video history to CSV (TSV actually) - mostly gpt generated
// Function to extract data from the list of nodes
function extractData() {
// Select all top-level <li> elements containing each date section
const dateNodes = document.querySelectorAll('li > div[data-automation-id^="wh-date-"]');
const data = [];
Array.from(dateNodes).forEach((dateNode) => {
// Extract the date from the 'data-automation-id' attribute and the inner text
const date = dateNode.getAttribute('data-automation-id').replace('wh-date-', '');
du -h * | awk '$1 ~ /[0-9]+M/ && $1+0 > 20 {print $0}' | sort -h | uniq

This command does the following:

  • du -h *: Lists the sizes of all files and directories in human-readable format.
  • awk '$1 ~ /[0-9]+M/ && $1+0 > 20 {print $0}': Filters the output to only include lines where the size is in megabytes and greater than 20MB.
  • sort -h: Sorts the filtered results in human-readable format.
@danuw
danuw / 0-aio-env.sh
Last active June 3, 2024 00:14
AIO setup script for IoT Operations (in progress)
# Edit before running
echo "Setting up environment variables"
export SUBSCRIPTION_ID=...
export LOCATION="westeurope"
export RESOURCE_GROUP=we-aio-rg
export CLUSTER_NAME=we-aio-arck # https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-abbreviations#compute-and-web
export KEYVAULT_NAME=we-aio-kv
#export KEYVAULT_NAME_RG=we-uciotop-rg
@danuw
danuw / loveyou_choco.scad
Created May 15, 2024 13:26
Chocolate 3D Template
/// Save this file as `choco.scad` and generate the stl using `openscad -o choco.stl -D 'quality="production"' choco.scad`
// text_on_cube.scad - Example for text() usage in OpenSCAD
echo(version=version());
font = "Liberation Sans"; //["Liberation Sans", "Liberation Sans:style=Bold", "Liberation Sans:style=Italic", "Liberation Mono", "Liberation Serif"]
shape_height = 2;
# stop and delete containers from a given image
docker rm $(docker stop $(docker ps -a -q --filter ancestor=my-python-app))
# delete dangling images
docker rmi $(docker images -f "dangling=true" -q)
@danuw
danuw / azure-regions.sh
Last active June 29, 2024 23:34
az cli commands to extract azure regions and their locations
# copy paste in terminal - this excludes locations that have no coordinates - usually called Logical regions (like USA, Europe, Asia etc...)
#az account list-locations --query '[?metadata.latitude != null].{RegionName:name,Longitude:metadata.longitude,Latitude:metadata.latitude}' > azure-regions2.json
#For the Carbon Aware SDK, use to match current format
az account list-locations --query '[?metadata.latitude != null].{Name:name,Longitude:metadata.longitude,Latitude:metadata.latitude}' | jq 'reduce .[] as $item ({}; .[$item.Name] = $item)' > azure-regions2.json
@danuw
danuw / Program.cs
Created October 13, 2022 18:38
List project dependencies (not recursive yet)
using System.Xml;
// Set up a set of projects using https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference
var projectPath = "../Project1/Project1.csproj";
Console.WriteLine($"List of Project dependencies for {projectPath}");
var listOfProjectsChecked = new List<string>();
var listOfDependencies = new List<string>();
@danuw
danuw / start-ngrok-tcp.sh
Last active January 19, 2021 19:12
use ngrok to connect via ssh to remote machine et get notified of new address via IFTTT
#!/bin/sh
## based on post by bobmarksie at https://stackoverflow.com/questions/27162552/ngrok-running-in-background
# Set local port defaulted to 22
LOCAL_PORT=22
IFTTT_KEY="<key goes here>" # make sure to update with key from your webhook in IFTTT
echo "Start ngrok in background on port $LOCAL_PORT"
nohup ./ngrok tcp ${LOCAL_PORT} &>/dev/null &