Skip to content

Instantly share code, notes, and snippets.

Avatar

Joseph C. Sible josephcsible

View GitHub Profile
@josephcsible
josephcsible / Main.hs
Last active Jun 2, 2020
"Obvious" refactors can be wrong
View Main.hs
{-# OPTIONS -Werror=type-defaults #-}
import Data.Maybe (isJust)
import Data.Word (Word16, byteSwap16)
default ()
oneNumTup :: Num a => (a, a)
oneNumTup = (2, 300)
View gist:3cf0fd579fc52c1012c6c909b02236cf
Var ::= [a-zA-Z]+
;
PrimaryTerm ::= Var
| '(' Term ')'
;
ApplyTerm ::= PrimaryTerm
| ApplyTerm PrimaryTerm
;
@josephcsible
josephcsible / Counterexample.hs
Last active Dec 29, 2019
Something like STRef but usable in a monad transformer
View Counterexample.hs
{-# LANGUAGE RankNTypes #-}
-- Adapted from https://gist.github.com/Lysxia/18fce5d4ce8ff7eb7117dfb827770187 to work on StatesT
import Control.Monad
import Control.Monad.Trans.Class
import Data.Void
import StatesT
-- Demonstration that StatesT is unsafe
@josephcsible
josephcsible / combinatory.c
Last active Jun 16, 2020
Combinatory logic with C, using raw function pointers as closures
View combinatory.c
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <sys/mman.h>
typedef void *(*f)(void *);
f make_function_with_state(f code, size_t code_len, void *state, size_t state_len) {
f mem = mmap(NULL, code_len + state_len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
View compose.cpp
#include <iostream>
#include <cstring>
#include <sys/mman.h>
extern "C" {
extern const char compose_helper_nomem[];
extern const size_t compose_helper_nomem_size;
extern const char compose_helper_mem[];
extern const size_t compose_helper_mem_size;
View delay_puts.c
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <sys/mman.h>
typedef int (delayed_puts_t)(void);
extern delayed_puts_t puts_helper;
extern size_t puts_helper_size;
__asm__ (
@josephcsible
josephcsible / gist:44c669a4871751007249de851470d2a2
Created Nov 13, 2018
logcat of Google Camera force closing
View gist:44c669a4871751007249de851470d2a2
11-12 19:56:06.638 12583 12583 D AndroidRuntime: Shutting down VM
11-12 19:56:06.638 12583 12583 E AndroidRuntime: FATAL EXCEPTION: main
11-12 19:56:06.638 12583 12583 E AndroidRuntime: Process: com.google.android.GoogleCamera, PID: 12583
11-12 19:56:06.638 12583 12583 E AndroidRuntime: java.lang.RuntimeException: java.lang.IllegalArgumentException: Could not find tag for key 'com.google.nexus.experimental2017.request.disable_hdrplus')
11-12 19:56:06.638 12583 12583 E AndroidRuntime: at fef.run(PG:2)
11-12 19:56:06.638 12583 12583 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:790)
11-12 19:56:06.638 12583 12583 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 19:56:06.638 12583 12583 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
11-12 19:56:06.638 12583 12583 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
11-12 19:56:06.638 12583 12583 E AndroidRuntime: at java.lang.refl
@josephcsible
josephcsible / unmap_all_syscalls.c
Last active Jun 16, 2020
Make it impossible for strace to force a syscall
View unmap_all_syscalls.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/syscall.h>
View gist:54fdab0586e5019a6ddfe3945b4f9c26
java.lang.StackOverflowError: Exception ticking world
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.ClassLoader.checkPackageAccess(Unknown Source)
at net.minecraftforge.fml.common.eventhandler.EventBus.handleException(EventBus.java:199)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:190)
at net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(ForgeEventFactory.java:158)
at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:462)
at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:423)
at net.minecraft.world.World.markAndNotifyBlock(World.java:368)
at net.minecraft.world.World.setBlockState(World.java:349)
View crash-2018-01-13_15.57.49-server.txt
---- Minecraft Crash Report ----
WARNING: coremods are present:
LoadingPlugin (RandomThings-MC1.12.2-4.1.jar)
Contact their authors BEFORE contacting forge
// Surprise! Haha. Well, this is awkward.
Time: 1/13/18 3:57 PM
Description: Ticking block entity
You can’t perform that action at this time.