Skip to content

Instantly share code, notes, and snippets.

@SulimanLab
SulimanLab / tailscale_zsh_completetion.sh
Last active November 5, 2023 20:28
Zsh autocompletion for Tailscale command-line interface
#compdef tailscale
_cli_zsh_autocomplete() {
local -a opts
local cur last_word FLAGS
local wordsLen=${#words}
for (( i=${#words[@]}; i>=1; i-- )); do
if [[ -n "${words[i]}" ]]; then
@chriselsner
chriselsner / nix-on-macos-catalina.md
Last active January 24, 2024 18:35
Nix on macOS Catalina

Nix on macOS Catalina

I'm writing this gist for my own records but it might help someone else too.

Installing Nix

Support for Catalina has improved a lot since the update was first rolled out.

Note: See the NixOS manual for discussion of the --darwin-use-unencrypted-nix-store-volume option.

@mcdamo
mcdamo / ipmi-updater.py
Last active January 25, 2024 11:22 — forked from HQJaTu/ipmi-updater.py
Supermicro IPMI certificate updater
#!/usr/bin/env python3
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=python
# This file is part of Supermicro IPMI certificate updater.
# Supermicro IPMI certificate updater is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@u1735067
u1735067 / snapraid-dup-log2csv.py
Last active April 19, 2018 18:12
snapraid dup -l dups.log > /dev/null && snapraid-dup-log2csv.py dups.log dups.csv ';' && rm dups.log
#!/usr/bin/env python3
import sys, errno, csv
if len(sys.argv) < 3:
print('usage: snapraid', file=sys.stderr)
sys.exit(errno.EINVAL)
def size_to_human(size, formatted_number=True):
prefixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
prefix_index = 0
@juancarlospaco
juancarlospaco / 10-my-media-automount.rules
Last active October 17, 2022 15:16
UDev rule that auto mounts any hot-plugged device under /media/<label> and works seamlessly with vfat, ntfs, etc USB storages on Arch Linux. Paste this file and reboot:
# /etc/udev/rules.d/10-my-media-automount.rules
# start at sdb to ignore the system hard drive
KERNEL!="sd[b-z]*", GOTO="my_media_automount_end"
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end"
# import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"
@ethack
ethack / TypeClipboard.md
Last active May 15, 2024 17:47
Scripts that simulate typing the clipboard contents. Useful when pasting is not allowed.

It "types" the contents of the clipboard.

Why can't you just paste the contents you ask? Sometimes pasting just doesn't work.

  • One example is in system password fields on OSX.
  • Sometimes you're working in a VM and the clipboard isn't shared.
  • Other times you're working via Remote Desktop and again, the clipboard doesn't work in password boxes such as the system login prompts.
  • Connected via RDP and clipboard sharing is disabled and so is mounting of local drives. If the system doesn't have internet access there's no easy way to get things like payloads or Powershell scripts onto it... until now.

Windows

The Windows version is written in AutoHotKey and easily compiles to an executable. It's a single line script that maps Ctrl-Shift-V to type the clipboard.

// Render any jsonnet value (except functions) to TOML format.
local
inlineTable(body) =
"{" +
std.join(", ", ["%s = %s" % [escapeKeyToml(k), renderBody(body[k])] for k in std.objectFields(body)]) +
"}",
renderArray(body) =
local
@dwiel
dwiel / repo_install_prereqs
Last active January 29, 2016 06:01
try installing requirements out of py.prereqs from conda, and if that fails from pypi with pip
#!/bin/bash
SCRIPT_PATH=$(readlink -f ${BASH_SOURCE[0]})
WD=$(dirname ${SCRIPT_PATH})
export PW_HOME=${WD}
if [[ -f ~/anaconda/bin/activate ]];then
source ~/anaconda/bin/activate ~/anaconda
fi
INST_CACHE_ROOT=~/.pw_install_cache
function check_if_updated()
@gbrks
gbrks / snapraid-sync
Last active July 3, 2023 15:37
SnapRAID sync and scrub: script and systemd timers to run nightly
#! /bin/bash
#######################################################################
# this is a helper script that keeps SnapRAID parity info in sync with
# your data. Here's how it works:
# 1) it first calls diff to figure out if the parity info is out of sync
# 2) if there are changed files (i.e. new, changed, moved or removed),
# it then checks how many files were removed.
# 3) if the deleted files exceed X (configurable), it triggers an
# alert email and stops. (in case of accidental deletions)
# 4) otherwise, it will call sync.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.18556660413742065</real>
<key>Green Component</key>
<real>0.21965453028678894</real>