Skip to content

Instantly share code, notes, and snippets.

View lighth7015's full-sized avatar
Perpetually exhausted.

Robert Butler lighth7015

Perpetually exhausted.
View GitHub Profile
@lighth7015
lighth7015 / main.asm
Created April 17, 2019 17:57
Protected Mode
;---
; Giza system bootstrap
; - check for a supported CPU, exit with error message if unsupported
; - Enter Protected Mode
; - Call system bootstrap
; - Leave Protected Mode
; - exit (status = byte obtatained)
;
Unsupported db "CPU: Not an 80386-class CPU; unable to start",0Dh,0Ah,'$'
@lighth7015
lighth7015 / stub.asm
Last active April 18, 2019 17:19
Enter/Leave Protected Mode
org 0x100
start: use16
cli ; disable interrupts
in al, 0x92 ; IO port method to enable A20
or al, 2
and al,0xFE
out 0x92, al
lgdt [descriptor] ; load GDT header into GDT register, so the CPU can find the GDT entries
@lighth7015
lighth7015 / stub.asm
Last active April 19, 2019 02:08
Enter/Leave Protected Mode
org 100h
bits 16
section .text
global __start
jmp __start
Unsupported db 'This application requires at least an 80386 processor.', 0x0d, 0x0a, '$' ; $-terminated message
AlreadyInit db 'Already in Protected Mode!', 0x0d, 0x0a, '$' ; $-terminated message
A20LineFail db 'A20 Line is Disabled or Not Present.', 0x0d, 0x0a, '$' ; $-terminated message
[Unit]
Description=Minecraft Server: %i
After=network.target
[Service]
Type=simple
WorkingDirectory=/srv/minecraft/instances/%i
Environment="ServerArgs="
Environment="ServerName=minecraft_server.jar"
@lighth7015
lighth7015 / loader.c
Last active May 18, 2019 00:08
loader.c
#include <stdio.h>
#include <dlfcn.h>
#include <string.h>
#include <stdlib.h>
#include <libelf.h>
#include <sys/stat.h>
#include <sys/mman.h>
char* buffer;
static struct stat fileinfo;
@lighth7015
lighth7015 / endian.c
Created May 30, 2019 00:16
ELF loader
#include <stdint.h>
//! Byte swap unsigned short
uint16_t swap_uint16( uint16_t val )
{
return (val << 8) | (val >> 8 );
}
//! Byte swap short
int16_t swap_int16( int16_t val )
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct {
union {
uint8_t zero: 1;
uint8_t fault: 1;
uint8_t present: 1;
uint8_t virtual: 1;
/* Copyright (c) 2014 Christopher Swenson. */
#include <stdlib.h>
#include <string.h>
#ifndef VECTOR_NAME
#error "Must declare VECTOR_NAME"
#endif
#ifndef VECTOR_TYPE
@lighth7015
lighth7015 / App\Models\Plan
Created September 3, 2019 02:13
So I'm trying to get eager loading to work correctly with a model I have; but it only ever wants to either return `null` or throw an exception because it's using the wrong column value to look up the related record;
<?php
namespace App\Models;
class Plan extends Model
{
protected $connection = 'sqlite3_db';
public $timestamps = false;
protected $hidden = [ 'plan_id' ];
protected $primaryKey = 'plan_type';
[http@saturn app]$ transform input.txt
Arr::unique => array_unique
Arr::unshift => array_unshift
Arr::values => array_values
Arr::walk_recursive => array_walk_recursive