Skip to content

Instantly share code, notes, and snippets.

View itsthejb's full-sized avatar

Jonathan Crooke itsthejb

View GitHub Profile
#!/usr/bin/env python3
#
# Dumb script to dump (some) of bcache status
# Copyright 2013 Darrick J. Wong. All rights reserved.
#
# This file is part of Bcache. Bcache is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@plivox
plivox / auto_switch_theme.py
Last active March 25, 2024 04:03
Automatic iTerm2 preset switching on MacOS
#!/usr/bin/env python3
import asyncio
import iterm2
THEME_LIGHT = "Tango Light"
THEME_DARK = "Tango Dark"
class AutoSwitchTheme:
@ollieatkinson
ollieatkinson / FileSystemEventStream.swift
Created October 22, 2020 10:27
sane `fsevents` in Swift
import Foundation
import Combine
public struct Event: Identifiable {
public let id: FSEventStreamEventId
public let path: String
public let flags: Flags
}
public class FileSystemEventStream {
@liusheng
liusheng / make-protoc-2.5.0-statically-linked.sh
Last active June 6, 2024 15:22
protobuf 2.5.0 ARM64 support
apt-get update && apt-get install -y make cmake gcc g++ patch
curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz | tar zx -C /opt/
cd /opt/protobuf-2.5.0
curl -L -O https://gist.githubusercontent.com/liusheng/64aee1b27de037f8b9ccf1873b82c413/raw/118c2fce733a9a62a03281753572a45b6efb8639/protobuf-2.5.0-arm64.patch
patch -p1 < protobuf-2.5.0-arm64.patch
./configure --disable-shared
make
ls -l src/protoc
@jerrymarino
jerrymarino / SwiftBinaryDemangler.sh
Created January 30, 2019 19:49
Demangle the entire symbol table of a swift binary
nm __BINARY__ | awk '{ print $3 }' | xargs xcrun swift-demangle {} \; | less
# Thanks to here https://stackoverflow.com/questions/13861658/is-it-possible-to-search-though-all-xcodes-logs
EXT=".xcactivitylog"
for LOG in *.xcactivitylog; do
NAME=`basename $LOG $EXT`
gunzip -c -S $EXT "${NAME}${EXT}" > "${NAME}.log"
done
@mjuric
mjuric / DockerUserNamespacesOnCentOS74.md
Last active September 6, 2023 18:31
Setting up Docker with user namespaces on CentOS 7.4

Setting up Docker with user namespaces on CentOS 7.4

The procedure below has been tested on a Digital Ocean VM with CentOS 7.4

# Install docker from RHEL’s standard repos
yum install -y docker

#
# We’ll activate the ‘user namespaces’ feature that defends against
@paramsen
paramsen / build.groovy
Last active January 17, 2024 08:17
Generate Android version code from git count in Gradle (build.gradle)
// Generate a minor version code from git commit count (for prod builds)
static def generateVersionCode() {
def result = "git rev-list HEAD --count".execute().text.trim() //unix
if(result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim() //windows
if(result.empty) throw new RuntimeException("Could not generate versioncode on this platform? Cmd output: ${result.text}")
return result.toInteger()
}
def majorVersion = 1
@Luzifer
Luzifer / README.md
Last active May 29, 2024 08:02
Running docker-compose as a systemd service

Running docker-compose as a systemd service

Files

File Purpose
/etc/compose/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/docker-compose-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/docker-compose-reload.timer Timer unit to plan the reloads
/etc/systemd/system/docker-compose.service Service unit to start and manage docker compose
@mosquito
mosquito / README.md
Last active July 24, 2024 14:40
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service