Skip to content

Instantly share code, notes, and snippets.

View Pear0's full-sized avatar
๐Ÿ

Will Gulian Pear0

๐Ÿ
  • Atlanta, GA, USA
View GitHub Profile
import os
import signal
import sys
import threading
_print = print
def print(*args, **kwargs):
pid = os.getpid()
@Pear0
Pear0 / linux-snippets.sh
Created August 21, 2020 02:44
Various Linux snippets to do sometimes obscure things
# Make Firefox the default PDF application for Gnome
xdg-mime default firefox.desktop application/pdf
#![allow(unused_macros)]
#[macro_export]
macro_rules! do_syscall0 {
($sys:expr) => ({
asm!(
"svc $0"
:
: "i"($sys)
: "memory"
#!/bin/sh
foo=$(mktemp)
cat > "$foo" <<EOF
target remote :1234
add-symbol-file build/kernel.elf 0x80000
define fn
si
diff --git a/bin/gen-rpi3-config.py b/bin/gen-rpi3-config.py
index 0ea5f68..c4039eb 100755
--- a/bin/gen-rpi3-config.py
+++ b/bin/gen-rpi3-config.py
@@ -5,7 +5,9 @@ import sys
import subprocess
ROOT = os.path.abspath(os.path.dirname(__file__))
-READELF = os.path.join(ROOT, "aarch64-readelf")
+# READELF = os.path.join(ROOT, "aarch64-readelf")
@Pear0
Pear0 / run.sh
Last active March 29, 2019 21:18
A script to manage running gameboy games for Tech's CS 2110
#!/usr/bin/env bash
#
# Imagine having to run an emulator that composites once for X11 then gets
# sent over VNC to finally by composited again by the user's host machine. Lunacy!
#
# This script has been written for macOS but should run just as well on most Linux distros.
#
# -gwgg
set -e
#include <stdio.h>
#define QUINE(x) const char *the_code = #x; x
QUINE(void main(int argc, char **argv) {
printf("%s\n", "#include<stdio.h>\n#define QUINE(x) const char *the_code = #x; x");
printf("QUINE(%s)\n", the_code);
})
document.querySelectorAll('video').forEach(v => v.playbackRate = 16)
@Pear0
Pear0 / SomeActivity.java
Created June 23, 2018 22:53
Template for a proxy object to work around memory leaks.
/*
* SomeActivity is some heavyweight object that is very costly if leaked.
*/
public class SomeActivity extends Activity implements SomeListenerInterface {
/*
* MyListener is a minimal implementation of the necessary interfaces that forwards all of its
* method calls to the outer class if the parent has not been GC'd.
*
* Crucially, because this listener only holds a weak reference, it won't prevent SomeActivity from being GC'd. And because MyListener is a small object, it may still be leaked but it's a matter of bytes being leaked rather than megabytes if an Activity were leaked.
@Pear0
Pear0 / WindowsTimeFixUTC.reg
Created June 22, 2018 17:58
A Windows Registry tweak that makes Windows treat the Motherboard RTC as UTC rather than local time. This is sometimes needed for compatibility with Linux in a dualboot system.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001