Skip to content

Instantly share code, notes, and snippets.

View pirj's full-sized avatar
🚜
Relentless

Phil Pirozhkov pirj

🚜
Relentless
View GitHub Profile
@jmason
jmason / Ridding my home network of IP addresses.md
Last active February 28, 2025 16:18
Ridding my home network of IP addresses

Recent changes in the tech scene have made it clear that relying on commercial companies to provide services I rely on isn't a good strategy in the long term, and given that Tailscale is so effective these days as a remote-access system, I've gradually been expanding a small collection of self-hosted web apps and services running on my home network.

Until now they've mainly been addressed using their IP addresses and random high ports on the internal LAN, for example:

Ruby: The future of frozen string literals

What is a literal?

In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.

Some examples:

7 # integer literal
@paultheman
paultheman / mac_keyremapping.md
Last active April 23, 2025 09:03
Guide on how to remap Keyboard keys on macOS

Guide on how to remap Keyboard keys on macOS

Update 17.10.2024: macOS 15 no longer requires root privileges for hidutil, you need to add hidutil and Terminal to 'Input Monitoring' in Settings/Privacy & Security tab.

Update 13.04.2024: On macOS 14.2 hidutil requires root privileges.

If you have a mac with an INT (ISO) keyboard you might want to change the ± key to ~. During my research I found that the information on this topic is not at all centralized. I prefer this option because it does not involve installing new software.

With macOS 10.12 Sierra Apple introduced hidutil as a tool to remap keyboard keys. See TN2450.

top10Salaries :: FilePath -> IO ()
top10Salaries path = do
Just (h, t) <- uncons . T.lines <$> T.readFile path
let
split = T.splitOn ","
Just ind = elemIndex "Salary" $ split h
top10 :: [Int] = t
& map (\s -> read $ T.unpack $ split s !! ind)
& sortBy (flip compare)
& take 10
@kepano
kepano / obsidian-web-clipper.js
Last active April 25, 2025 11:45
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/[email protected]?module'), import('https://unpkg.com/@tehshrike/[email protected]'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@luisabarca
luisabarca / gist:760bd0d53623ec99ffec2c74d1e86921
Created April 2, 2018 20:15
Regexp for valid instagram username
# Regex by Jonathan Stassen. http://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags
/(?:@)([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)/g
@mdPlusPlus
mdPlusPlus / compile_newest_stable_kernel_with_acso_patch.sh
Last active April 10, 2025 20:00
Download, patch, compile and install the newest stable Linux kernel with the ACS override patch (Ubuntu / Debian)
#!/bin/bash
function install_dependencies() {
echo "Installing dependencies..."
sudo apt -qq update
sudo apt -qq install -y curl git wget
# sudo apt -qq install -y bison flex kernel-package libelf-dev libssl-dev
sudo apt -qq install -y bison flex libelf-dev libssl-dev
}
@mturquette
mturquette / .offlineimaprc
Created January 18, 2016 06:29
OfflineIMAP nametrans and folderfilter example
[Repository local-baylibre]
...
nametrans = lambda folder: {
'drafts': '[Gmail]/Drafts',
'flagged': '[Gmail]/Starred',
'important': '[Gmail]/Important',
'inbox': 'INBOX',
'spam': '[Gmail]/Spam',
'trash': '[Gmail]/Trash',
}.get(folder, folder)
@hubertgrzeskowiak
hubertgrzeskowiak / NodeJS D3 with JSDOM
Last active November 12, 2023 17:37
Using d3.js (aka Data-Driven Documents) without browser with help of jsdom. This allows for server-side rendering or programmatic use in any other contexts than browser.
d3 = require("d3");
jsdom = require("jsdom");
document = jsdom.jsdom();
window = document.parentWindow;
var sampleSVG = d3.select(document.body)
.append("svg")
.attr("width", 100)
.attr("height", 100)
@estum
estum / switch_on.rb
Last active August 8, 2023 05:52
Ruby alternative switch-case syntax.
# = Kernel#switch
# Provides alternative switch-case syntax.
#
# # support methods:
# value = []
# switch value do
# on empty?: -> { "none" }
# on one?: -> { "one" }
# on many?: -> { "many" }
# end