Skip to content

Instantly share code, notes, and snippets.

View MCJack123's full-sized avatar
💚
Go Green!

JackMacWindows MCJack123

💚
Go Green!
View GitHub Profile
@MCJack123
MCJack123 / buffer.c
Created October 22, 2018 15:52
FILE-like buffer system for memory
//
// buffer.c
//
// Created by Homework User on 10/20/18.
// Copyright © 2018 JackMacWindows. All rights reserved.
//
#include "buffer.h"
#include <stdlib.h>
#include <string.h>
@MCJack123
MCJack123 / DisplaySong.py
Last active March 6, 2021 16:53
iPod-style Spotify track info display (or clock when no track is playing) using 16x2 I2C LCD (Python 2 only)
# Requires smbus: sudo apt install python-smbus
import I2C_LCD_driver
import time
import json
import httplib
import io
import os
from sys import exit
# Add the refresh key here (https://bit.ly/2DM1oRZ)
@MCJack123
MCJack123 / gitinafile
Last active February 5, 2019 04:43
Quick-and-dirty git repository packer/unpacker
#!/bin/bash
if [ "$1" == "pack" ]; then
BNAME=`basename $2`
mkdir "._$BNAME"
git format-patch --root -o "._$BNAME"
git log > "._$BNAME/history.txt"
tar -cJf "$2" -C "._$BNAME" .
rm -r "._$BNAME"
elif [ "$1" == "unpack" ]; then
BNAME=`basename $2`
@MCJack123
MCJack123 / BeatSaberLevelFormat.md
Last active September 11, 2021 22:47
Beat Saber 1.0 level format conversion
info.json Info.dat
+ _version = "2.0.0"
songName _songName
songSubName _songSubName
authorName _songAuthorName
+ _levelAuthorName = ""
beatsPerMinute _beatsPerMinute
difficultyLevels[].offset _songTimeOffset
Difficulty.json => _shuffle _shuffle
@MCJack123
MCJack123 / evilwin.scpt
Created June 3, 2019 00:15
Evil window manipulation AppleScript
tell application "Finder" to set theBounds to bounds of window of desktop
repeat
set theNumber to random number from 1 to 1000000
try
tell application (path to frontmost application as text)
if theNumber is 51 then set bounds of front window to theBounds
if theNumber is 87 then set miniaturized of front window to true
end tell
on error
@MCJack123
MCJack123 / imagescripter.py
Created June 27, 2019 03:06
PNG manipulation module in Python 2/3
import png # pip install pypng
class pixel:
def __init__(self, x=0, y=0, r=0, g=0, b=0, a=0):
self.x = x
self.y = y
self.r = r
self.g = g
self.b = b
self.a = a
@MCJack123
MCJack123 / runapi.lua
Last active July 1, 2019 05:09
ComputerCraft script to call a function in an API
-- Syntax: runapi <file> <func> [<format> <args...>]
-- format argument is in the format [bnstx]+
-- Example: runapi CCWinX/CCWinX.lua QueueEvent snbt CustomEvent 0 false {test=true,text="Hello\sWorld!"}
local args = {...}
if args[2] == nil then error("Usage: runapi <file> [<format> <args...>]") end
local file = table.remove(args, 1)
if not os.loadAPI(file) then error("Could not load API at " .. file) end
local apiname = string.gsub(fs.getName(file), ".lua", "")
local api = _G[apiname]
if api == nil then error("Could not determine name of API (tried " .. apiname .. ")") end
@MCJack123
MCJack123 / CCtar.lua
Last active March 20, 2020 02:59
[Outdated: see https://github.com/MCJack123/CC-Archive] TAR library/program for ComputerCraft (gzip from https://github.com/safeteeWow/LibDeflate)
-- Tape Archive (tar) archiver/unarchiver library (using UStar)
-- Use in the shell or with os.loadAPI
local function trim(s) return string.match(s, '^()[%s%\0]*$') and '' or string.match(s, '^[%s%\0]*(.*[^%s%\0])') end
local function u2cc(p) return bit.band(p, 0x1) * 8 + bit.band(p, 0x2) + bit.band(p, 0x4) / 4 + 4 end
local function cc2u(p) return bit.band(p, 0x8) / 8 + bit.band(p, 0x2) + bit.band(p, 0x1) * 4 end
local function pad(str, len, c) return string.len(str) < len and string.sub(str, 1, len) .. string.rep(c or " ", len - string.len(str)) or str end
local function lpad(str, len, c) return string.len(str) < len and string.rep(c or " ", len - string.len(str)) .. string.sub(str, 1, len) or str end
local function tidx(t, i, ...)
if i and t[i] == nil then t[i] = {} end
@MCJack123
MCJack123 / ipsw_keys.py
Last active December 1, 2023 22:46
Extract iOS firmware keys using on-device AES engine
#!/usr/bin/env python
from sys import argv, stdout
from os import system, remove, path
from urlparse import urlparse
import re
import dfu
import ssl
import math
import json
import getopt
@MCJack123
MCJack123 / muxzcat.lua
Last active August 15, 2020 12:51
XZ/LZMA decompression library in pure Lua (see https://github.com/MCJack123/CC-Archive for more CC archive scripts)
--[[
XZ/LZMA decompressor ported from https://github.com/pts/muxzcat
Licensed under GNU GPL 2.0 or later
This should work under all Lua 5.1+
To use:
muxzcat.DecompressXzOrLzmaFile(input, output) will read an XZ/LZMA file from input (FILE* or path) and write the result to output (FILE* or path)
muxzcat.DecompressXzOrLzmaString(input) will decompress a loaded XZ/LZMA file and returns the result
muxzcat.GetError(num) will return a string representation for an error code
muxzcat.ErrorCodes is a table that reverses GetError()
Written by pts@fazekas.hu at Sat Feb 2 13:28:42 CET 2019