Skip to content

Instantly share code, notes, and snippets.

View hisaac's full-sized avatar
👨‍💻
Just Typin'

Isaac Halvorson hisaac

👨‍💻
Just Typin'
View GitHub Profile
@hisaac
hisaac / get-public-ip.swift
Created August 27, 2020 02:33
A quick and dirty playground/script to get the current device's public IP address, validate it, and print it
import Foundation
import Network
/// A quick and dirty playground/script to get the current device's public IP address, validate it, and print it
let url = URL(string: "https://checkip.amazonaws.com")!
var publicIPAddress: IPAddress?
URLSession.shared.dataTask(with: url) { (data, response, error) in
guard let data = data,
// The bookmarklet does a couple things:
// If the current page in the browser is a YouTube page, it will open that video in `invidious.xyz`
// If the current page in the browser is _not_ a YouTube page, it will open the `invidious.xyz` homepage
//
// To use: Copy/Paste the code below into the bookmark's address:
javascript:location.hostname.includes("youtube.com")?location.assign("https://invidious.xyz"+location.pathname+location.search+location.hash):location.assign("https://invidious.xyz");
@hisaac
hisaac / git-orphan.fish
Last active September 2, 2021 20:46
This is a little script I wrote for creating a new, empty default branch for personal forks of a repo. This is to reduce confusion, so that `main`/`master` always points to the upstream version, never your fork's.
function git-orphan --description "Creates an orphan branch and a README.md file"
# Create an orphan branch named "default"
git checkout --orphan default
# Delete everything in the directory that is tracked by git
git rm -rf .
# Delete everything in the directory that is NOT tracked by git
git clean -dfx