Skip to content

Instantly share code, notes, and snippets.

View craSH's full-sized avatar

Ian Gallagher craSH

View GitHub Profile
@craSH
craSH / pet-snippet.toml
Last active July 3, 2023 03:09
description
[[snippets]]
description = "pacman - show files owned by installed package"
command = "pacman -Ql <package>"
tag = ["arch", "package", "sysadmin"]
output = ""
[[snippets]]
description = "pacman - remove orphan packages"
command = "pacman -Qtdq | sudo pacman -Rns -"
tag = ["arch", "package", "sysadmin"]
@craSH
craSH / bulletproof_arch.md
Last active July 30, 2022 23:00 — forked from altercation/bulletproof_arch.txt
Bulletproof Arch - Minimal Clean Install

Bulletproof Arch

These are working notes on the installation of Arch Linux. I've just completed this install on a notebook (@altercation: Lenovo P50. @craSH: Dell XPS 13" 9380) but the setup should work for most laptop/desktop configurations.

Some assumptions/notes:

  1. This isn't a dual boot configuration. I can see some of the appeal and still work in Adobe from time to time, but given the increasing complexity of EFI and the way Windows/MS manhandles the EFI partition during upgrades, I really would recommend steering clear of dual boot. Just my two cents here.
#!/bin/sh
# Test for presennce of default IPv6 route after applying interface settings
# with OPNsense API. Meant to be used with git bisect run across commits to
# find the bug discussed here:
# https://forum.opnsense.org/index.php?topic=20260.0
#
# Author: cdine / Ian Gallagher <crash@neg9.org> 2020-11
# Dev API keys for root user on this machine. Not really secret.
export key='cY1pLqJ2yhOvRlTJCdHFlzejshbebTgJ9iqNSA8ogKOGDeTUNO+MXQEyaDPw8AH415Byj4czYUJA1c2n'
@craSH
craSH / sekey-keygen
Created June 27, 2020 23:17
sekey-keygen - A helper script for generating SSH keys in the Macbook Pro's secure enclave with SeKey [https://github.com/sekey/sekey]
#!/usr/bin/env bash
# vim: ft=bash
# A helper script for generating SSH keys in the Macbook Pro's secure enclave with SeKey [https://github.com/sekey/sekey]
# This file created by craSH [https://github.com/craSH]
# This work is licensed under a Creative Commons Attribution 4.0 International License [https://creativecommons.org/licenses/by/4.0/]
# Secure umask - dirs 700, files 600
umask 077
# Exit if sekey is not installed
@craSH
craSH / tc_to_kml.py
Created March 14, 2017 09:58
tripcreator-manipulator
#!/usr/bin/env python
"""
Parse a TripCreator JSON file and emit a KML file.
Example: https://widgets.tripcreator.com/gas-stations-prices-iceland-map/tripcreator-gas-prices-iceland.json
Taken from the widget on this page: http://luxeadventuretraveler.com/tips-for-driving-icelands-ring-road-winter/
Copyleft 2017 Ian Gallagher <crash@neg9.org>
"""
import json
import os
@craSH
craSH / init-tunnels.sh
Last active June 3, 2016 08:17
Script to setup multiple SSH tunnels in a reliable way for use with FoxyProxy or other SOCKS-aware clients
#!/usr/bin/env bash
#
# Use to setup numerous various tunnels to SSH servers, useful with ssh config blocks like those below
# for each host, with incrementing port numbers for each - then configure FoxyProxy etc to use the unique
# port for each host you want to tunnel out of.
#
# Thanks to tecknicaltom <tecknicaltom@neg9.org> for the initial idea behind tying this all together.
#
# Host host_alpha
# IdentityFile ~/.ssh/id_ecdsa-$USER-host_alpha-<remote_hostname>-<key_gen_year>-<key_gen_month>
@craSH
craSH / extract_offsets.py
Created September 3, 2015 21:17
Extract chunks between chunk sizes at a given list of offsets. Handy when combined with the output of hachoir-subfile for ELF images in a filesystem, for example.
#!/usr/bin/env python
"""
Extract chunks between chunk sizes at a given list of offsets.
Handy when combined with the output of hachoir-subfile for ELF images in a filesystem, for example.
Copyleft 2015 Ian Gallagher <crash@neg9.org>
"""
import sys
import os
import logging
@craSH
craSH / indexcode
Last active August 29, 2015 14:22
Index code with glimpse, ctags, and cscope. Store the indexes and such in a defined cache directory, which may live on a fast SSD
#!/usr/bin/env bash
# Original credit to tecknicaltom@neg9.org for creating this script and concept - thanks!
# Store indexes and such in a cache located on an SSD, and symlink to them
# Ensure the cache location is at the same or better security level (encrypted drive) as the data you are indexing.
cache_root="${HOME}/.indexcodecache"
cur_proj="$(basename -a ${PWD} | tr -d '\n')-$(echo ${PWD} | shasum -a 512 | cut -c 1-16)"
cache_dir="${cache_root}/${cur_proj}"
# Set umask to create files as mode 0600 (user r/w, go none)
#!/usr/bin/env bash
function ssh-keygen-remove-all() {
if [ -n $1 ]; then
ssh-keygen -R "$1" >/dev/null 2>&1 && \
echo "Removed complete hostname: $1"
simple_host=$(echo $1 | cut -d '.' -f1)
if [ -n "$simple_host" ]; then
ssh-keygen -R "$simple_host" >/dev/null 2>&1 && \
@craSH
craSH / natstrings.py
Last active August 29, 2015 14:19
Like strings(1) but only return stuff that is probably english (or whatever locale you set)
#!/usr/bin/env python
"""
Like strings(1) but only return stuff that is probably English (or whatever locale you set)
TODO:
* Add a parameter to ignore punctuation as token counts towards the threshold.
e.g. "Foo." vs "Foo........" would both return true.
* Add conditional for not counting digit only results if alphanumeric=True in is_natlang()
* Unicode support - currently it doesn't work with unicode, quite bad for non-english input