Skip to content

Instantly share code, notes, and snippets.

View freemo's full-sized avatar

Jeffrey Phillips Freeman freemo

View GitHub Profile
class ImmutableMeta(ElementMeta):
def __new__(cls, name, bases, namespace, **kwargs):
def my_setattr(self, name, value):
if hasattr(self, "_immutable") and self._immutable and not name.startswith("__"):
raise AttributeError("this class was set immutable can not set %s, %s" % (name, self))
return object.__setattr__(self, name, value)
namespace["__setattr__"] = my_setattr
def my_freeze(self):
self._immutable = True
@freemo
freemo / tfyzf
Created November 21, 2019 23:18
untitled
git clean -xdf && cp -r ../include/ . && mkdir -p m4 && aclocal --force && libtoolize --force --copy && automake --foreign --add-missing --copy --force && autoconf --force && CC=clang ./configure --target=windows-shared-x64 && CC=clang make && ls .libs
git clean -xdf && cp -r ../include/ . && mkdir -p m4 && aclocal --force && libtoolize --force --copy && automake --foreign --add-missing --copy --force && autoconf --force && docker run --rm aparapi/aparapi-toolchain-win64 > dockcross && chmod +x dockcross && ./dockcross ./configure --host=x86_64 --target=windows-shared-x64 && ./dockcross make && ls .libs
@freemo
freemo / script
Last active October 22, 2023 11:58
Backup script usint btrfs
#!/bin/bash
TIMESTAMP=$(date +%F_%R)
OLD_TIMESTAMP="$1"
echo "new timestamp is $TIMESTAMP"
echo "old time is $OLD_TIMESTAMP"
if [ -z "$OLD_TIMESTAMP" ]
then
@freemo
freemo / Script
Created September 20, 2019 08:53
BTRFS change writability
btrfs property set -ts /path/to/snapshot ro false
btrfs property set -ts /path/to/snapshot ro true
@freemo
freemo / script
Last active September 18, 2019 11:36
Get the boot up dmesg output for a previous boot.
#list all boot-id
journalctl --list-boots
#display dmesg for specific boot-id
journalctl -b <boot-id>
@freemo
freemo / script
Last active February 3, 2023 02:20
Backing up with btrfs
sudo mount /mnt/backup #this should be a btrfs volume
sudo btrfs subvolume snapshot -r / /mnt/backups/root-backup-$(date +%F_%R)
#list all other subvolumes
sudo btrfs subvolume list -p /
#repeat for all subvolumes
sudo btrfs subvolume snapshot -r /home /mnt/backups/home-backup-$(date +%F_%R)
sudo btrfs subvolume snapshot -r /etc /mnt/backups/etc-backup-$(date +%F_%R)
sudo btrfs subvolume snapshot -r /var /mnt/backups/var-backup-$(date +%F_%R)
@freemo
freemo / script
Last active September 20, 2019 08:18
Check listening ports with process on OSX
lsof -Pn -i -sTCP:LISTEN
@freemo
freemo / Bring up container (aws-cli)
Last active November 12, 2019 10:31
QOTO on AWS
aws ecs register-task-definition --family load-balancer --network-mode bridge --container-definitions "$(cat container-def.json)" --volumes "$(cat volumes-def.json)"
# Launch ECS task, when above command ran once X == 1, for every update X increases by one.
# will have too double check docs how to get latest
aws ecs run-task --cluster default --task-definition load-balancer:X --count 1
@freemo
freemo / AstarSearch.java
Last active September 20, 2019 08:49
AStar algorithm in Java
import java.util.*;
public class AstarSearch {
private final Map<Integer, Set<Neighbor>> adjacency;
private final int destination;
private final NavigableSet<Step> pending = new TreeSet<>();
public AstarSearch(Map<Integer, Set<Neighbor>> adjacency, int source, int destination) {
this.adjacency = adjacency;