Skip to content

Instantly share code, notes, and snippets.

View cmsj's full-sized avatar
🏠
Working from home

Chris Jones cmsj

🏠
Working from home
View GitHub Profile
@cmsj
cmsj / cmsj_docker_tool.sh
Created August 24, 2023 10:13
cmsj_docker_tool.sh
#!/bin/bash
# A simple tool for managing docker containers
# Drop this in your path somewhere and chmod +x it, then create symlinks to it with the names:
# clog - show the logs for a container
# cblip - restart a container and then show its logs
# cgo - run a command inside a container (defaults to /bin/sh)
# Usage for each is: <command> CONTAINER_NAME
CMD="$(basename $0)"
@cmsj
cmsj / slm.py
Created April 19, 2023 17:04
Quick hack to run SLM locally
# pip install the following, and make sure you have a pytorch that supports CUDA.
# accelerate
# bitsandbytes
# transformers
# IPython
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from IPython.display import Markdown, display
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from IPython.display import Markdown, display
def hr(): display(Markdown('---'))
def cprint(msg: str, color: str = "blue", **kwargs) -> str:
if color == "blue": print("\033[34m" + msg + "\033[0m", **kwargs)
elif color == "red": print("\033[31m" + msg + "\033[0m", **kwargs)
elif color == "green": print("\033[32m" + msg + "\033[0m", **kwargs)
elif color == "yellow": print("\033[33m" + msg + "\033[0m", **kwargs)
@cmsj
cmsj / kyber.lua
Last active February 13, 2023 09:47
Proxmark3 (iceman) Lua script to easily write Galaxy's Edge kyber crystal data to EM4305 rfid tags
local cmds = require('commands')
local getopt = require('getopt')
local bin = require('bin')
local utils = require('utils')
local cmds = require('commands')
local ansicolors = require('ansicolors')
copyright = 'Various copyrights - Based on hf_mfu_amiibo_sim.lua'
author = 'Chris Jones <cmsj@tenshu.net>'
version = 'v2.0'
#include <Adafruit_NeoPixel.h>
#include <Adafruit_DotStar.h>
// led_effects
// by Chris Jones <cmsj@tenshu.net>
// Released under the MIT License.
// RGB LED built in to the Trinket M0
Adafruit_DotStar dot = Adafruit_DotStar(1, INTERNAL_DS_DATA, INTERNAL_DS_CLK, DOTSTAR_BGR);
#!/usr/bin/env python3
"""syslogreceiver.py - receive remote syslog events and pass them into
systemd's journal"""
import re
import socketserver
from systemd import journal
HOST, PORT = "0.0.0.0", 514
@cmsj
cmsj / muteEnforcer.js
Created March 28, 2022 09:16
gmail mute that actually mutes
// Enforce thread muting
// When you mute a thread in Gmail, it adds a "Muted" label
// Unfortunately, it doesn't really completely mute the thread - e.g. emails added to the thread will still be marked as unread and show up against folder counts
//
// This script will ensure that all emails appearing on muted threads, will be marked read, and archived.
//
// By default it will only look for emails that are less than 3 days old, to limit the size of the query results. You can adjust that if you want to
var age_max="3d"
function enforceMutes() {
> Found 188 debug information files
> Prepared debug information files for upload
> Uploaded 188 missing debug information files
> File upload complete:
PENDING 023f433a-8828-3373-8720-e6dec1fd6af2 (libosascript.dylib.dSYM/Contents/Resources/DWARF/libosascript.dylib; x86_64 debug companion)
PENDING 8391d288-aa61-3a71-bbc1-6b7835adf8e1 (libdockicon.dylib.dSYM/Contents/Resources/DWARF/libdockicon.dylib; arm64 debug companion)
PENDING 9a926012-63a8-3c6a-a0d6-d6411ff4bcb3 (libnetworkping.dylib.dSYM/Contents/Resources/DWARF/libnetworkping.dylib; arm64 debug companion)
PENDING 8e680fea-cc8b-3be1-8663-41de2e387242 (libdialog.dylib.dSYM/Contents/Resources/DWARF/libdialog.dylib; arm64 debug companion)
PENDING 4623d0a4-dcc2-355f-b794-b6b98e63a563 (libscreen.dylib.dSYM/Contents/Resources/DWARF/libscreen.dylib; arm64 debug companion)
static int camera_isinuse(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L];
[skin checkArgs:LS_TUSERDATA, USERDATA_TAG, LS_TBREAK];
HSCamera *camera = [skin toNSObjectAtIndex:1];
// This was the original code here, crashed every time
// lua_pushboolean(skin.L, camera.isInUse);
// return 1;
local events = hs.uielement.watcher
watchers = {}
function init()
appsWatcher = hs.application.watcher.new(handleGlobalAppEvent)
appsWatcher:start()
-- Watch any apps that already exist
local apps = hs.application.runningApplications()