Skip to content

Instantly share code, notes, and snippets.

@slowpeek
slowpeek / dropbear-netplan-fix
Last active February 12, 2024 04:20
Clean up netplan stuff after dropbear-initramfs
#!/bin/sh
: <<'README'
This is a fix for a well-known problem [1] with dropbear-initramfs+netplan
combo.
When dropbear starts, it enables networking [2]. This results in netplan configs
for available ifaces created under /run/netplan. After unlocking, the configs
are still there preventing networkmanager from picking ifaces up: by default,
@alexrashed
alexrashed / zfs-ext4-docker.sh
Created October 7, 2021 11:48
Creates a new ZFS volume for docker with ext4
#!/bin/bash
# This is just a writeup to build an ext4 FS on top of ZFS to overcome issues with the Docker ZFS storage driver.
# DO NOT EXECUTE THIS SCRIPT IF YOU DO NOT KNOW WHAT YOU'RE DOING!
sudo zfs create -V 100G rpool/docker-overlay
sudo mkfs.ext4 /dev/zvol/rpool/docker-overlay
sudo mount /dev/zvol/rpool/docker-overlay /var/lib/docker-overlay
docker system prune -af
sudo su
cat > /etc/docker/daemon.json << EOF
{
@myell0w
myell0w / CGPath Utilities.swift
Last active July 18, 2023 13:14
Some helpers to make working with CGPaths in Swift easier
/*
Copyright 2021 Matthias Tretter
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?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">
@Ekhoo
Ekhoo / Record.md
Created March 5, 2018 08:26
Record iOS Simulator output

xcrun simctl io booted recordVideo filename.ext

@muendelezaji
muendelezaji / bash-to-zsh-hist.py
Created October 5, 2016 14:18 — forked from op/bash-history-to-zsh-history.py
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
import sys
import time
@SamuelMarks
SamuelMarks / upgrade_all_pip_packages.py
Last active February 8, 2016 06:24
Upgrade all packages using pip
#!/usr/bin/env python
from __future__ import print_function
from sys import stderr
from pip import get_installed_distributions
from pip.commands import install
from pip.exceptions import InstallationError
@gruber
gruber / Liberal Regex Pattern for Web URLs
Last active April 22, 2024 19:02
Liberal, Accurate Regex Pattern for Matching Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@reimund
reimund / dict2xml.py
Last active December 25, 2023 06:09
Simple dictionary to xml serializer.
"""
Simple xml serializer.
@author Reimund Trost 2013
Example:
mydict = {
'name': 'The Andersson\'s',
'size': 4,
@ccstone
ccstone / BBEdit-TextWrangler_RegEx_Cheat_Sheet.txt
Last active May 10, 2024 15:41
BBEdit-TextWrangler Regular Expression Cheat-Sheet
————————————————————————————————————————————————————————————————————————————————————————————————————
BBEdit / BBEdit-Lite / TextWrangler Regular Expression Guide Modified: 2018/08/10 01:19
————————————————————————————————————————————————————————————————————————————————————————————————————
NOTES:
The PCRE engine (Perl Compatible Regular Expressions) is what BBEdit and TextWrangler use.
Items I'm unsure of are marked '# PCRE?'. The list while fairly comprehensive is not complete.