This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import create_connection, timeout | |
from requests import get | |
from subprocess import Popen | |
from contextlib import suppress | |
from os import environ | |
from sys import stdout as sys_stdout, stderr as sys_stderr | |
ssh_sock5_proxy = Popen( | |
["ssh", "-o", "StrictHostKeyChecking=no", "-D", "8888", "-C", "-N", f"ubuntu@{environ['SSH_IP']}"], | |
stdout=sys_stdout, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
# Copyright (c) 2024 Will Bender | |
# Copyright (c) 2011 Dominic Tarr https://github.com/dominictarr/JSON.sh | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def real_uptime_ns(): | |
from time import CLOCK_BOOTTIME | |
from time import clock_gettime_ns | |
from os import sysconf, sysconf_names | |
with open("/proc/self/stat") as f: | |
stat_fields = f.readline().split() | |
proc_start_since_boot_tick = float(stat_fields[21]) | |
start_since_boot_sec = proc_start_since_boot_tick / sysconf( | |
sysconf_names["SC_CLK_TCK"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = "Stop" | |
$global:ProgressPreference = "SilentlyContinue" | |
# Import the necessary .NET classes | |
Add-Type -TypeDefinition @' | |
using System.IO; | |
public class DirectoryHelper { | |
public static void CreateDirectoryIfNeeded(string path) { | |
if (!Directory.Exists(path)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
MIT License | |
Copyright (c) 2023 Will Bender | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Diffs changelist to correct prettier format | |
# | |
# You can apply the prettier patch from this output | |
# xclip -out | git apply - | |
# pbpaste | git apply - | |
# cat /dev/clipboard | git apply - | |
git_root=$(git rev-parse --show-toplevel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require("https") | |
const http = require("http") | |
(async () => { | |
await httpsGetToFile("https://example.com/", "/tmp/example.com.txt", { headers: {"Range": "bytes=0-4"}}) | |
})() | |
/** | |
* @param {string} uri | |
* @param {ClientRequestArgs} options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Copyright (c) 2023 Will Bender. All rights reserved. | |
# | |
# This work is licensed under the terms of the MIT license. | |
# For a copy, see <https://opensource.org/licenses/MIT>. | |
# See most recently checked out branches and easily switch to one | |
NUMBER=5 # Max branches to echo in list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2019 Will Bender. All rights reserved. | |
# This work is licensed under the terms of the MIT license. | |
# For a copy, see <https://opensource.org/licenses/MIT>. | |
# Very fast __git_ps1 implementation | |
# Inspired by https://gist.github.com/wolever/6525437 | |
# Mainly this is useful for Windows users stuck on msys, cygwin, or slower wsl 1.0 because git/fs operations are just slower | |
# Caching can be added by using export but PROMPT_COMMAND is necessary since $() is a subshell and cannot modify parent state. | |
# Linux: time __ps1_ps1 (~7ms) |