Skip to content

Instantly share code, notes, and snippets.

View zydeco's full-sized avatar

Jesús A. Álvarez zydeco

View GitHub Profile
@zydeco
zydeco / mcadiff.py
Created January 19, 2024 10:41
mca diff
import mcworldlib as mc
import deepdiff
import re
from sys import argv
#argv = [None, 'world/region/r.0.0.original.mca', 'world/region/r.0.0.mca']
name1 = argv[1]
name2 = argv[2]
file1 = mc.anvil.load_region(name1)
@zydeco
zydeco / cheers.html
Created February 12, 2023 12:18
Cheers!
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta http-equiv='x-ua-compatible' content='ie=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
<title>Cheers!</title>
<style type='text/css'>
.ingredient {
@zydeco
zydeco / annotate-trace.py
Created September 22, 2020 21:59
annotate mini vmac trace
import sys
import re
A_LINE_PATTERN = re.compile(r"^([0-9A-F]+) \$(A[0-9A-F]{3})$")
HEX_PATTERN = re.compile(r"^[0-9A-F]+$")
BRANCH_PATTERN = re.compile(r'^(?P<address>[0-9A-F]+) (?P<instruction>B(?:RA|CC|CS|EQ|GE|GT|HI|LE|LS|LT|MI|NE|PL|VC|VS)) (?P<dest>[0-9A-F]+)$')
def read_rom_procs(rom_disasm_path):
# read procedure names from FDisasm rom disassembly
procs = {}
@zydeco
zydeco / sqlite_options_ios_10_11.diff
Created September 14, 2017 09:14
SQLite iOS compile-time options
--- iOS 10.3
+++ iOS 11
+BUG_COMPATIBLE_20160819
-COMPILER=clang-8.1.0
+COMPILER=clang-9.0.0
+DEFAULT_CACHE_SIZE=128
+DEFAULT_CKPTFULLFSYNC
+DEFAULT_JOURNAL_SIZE_LIMIT=32768
+DEFAULT_PAGE_SIZE=4096
+DEFAULT_SYNCHRONOUS=2
@zydeco
zydeco / reenumerate.c
Created March 7, 2017 12:30
Simulate unplugging and plugging in of usb device
// cc reenumerate.c -framework IOKit -framework CoreFoundation -o reenumerate
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/usb/IOUSBLib.h>
#include <mach/mach.h>
#define kExcAccMaxWait 5
@zydeco
zydeco / EUMShowTouch.m
Created May 17, 2016 20:28
single file drop-in version of eumlab/EUMTouchPointView
/*
EUMShowTouchDropIn
single-file drop-in version
Copyright (c) 2014 Shawn Xiao <[email protected]>
Copyright (c) 2016 Jesús A. Álvarez <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@zydeco
zydeco / liconv.rb
Created October 6, 2015 14:01
line-based iconv with fallback encoding
#!/usr/bin/env ruby
# iconv line by line with fallback encoding
require 'optparse'
options = {
from: Encoding::UTF_8,
to: Encoding::UTF_8,
fallback: Encoding::ISO_8859_1
}
@zydeco
zydeco / iCloud.swift
Created July 6, 2015 12:18
iCloud UIBezierPath
let points = [
((-1, 0), (0,0), (13,25)),
((13, 22), (13, 24), (13, 23)),
((23, 12), (13, 17), (17, 12)),
((31, 16), (26, 12), (29, 14)),
((54, 0), (34, 7), (43, 0)),
((78, 24), (67, 0), (78, 11)),
((78, 27), (78, 25), (78, 26)),
((79, 27), (78, 27), (78, 27)),
((94, 42), (87, 27), (94, 33)),
@zydeco
zydeco / DisableKnockToAdmin
Created April 20, 2015 11:16
Disable Knock for admin password dialogs
#!/bin/bash
# wait until knock launches
while [ -z "`ps cax | grep Knock`" ]; do
sleep 3
done
# wait a bit more
sleep 3
# disable security agent support
lldb <<EOF
attach Knock
@zydeco
zydeco / goestoward.swift
Last active April 27, 2016 08:36
goes toward operator
infix operator --> { associativity left precedence 80 }
func --><T:IntegerType>(inout left:T, right:T) -> Bool {
if left != right {
left = left.advancedBy(left > right ? -1 : 1)
return true
} else {
return false
}
}