Skip to content

Instantly share code, notes, and snippets.

View ljmccarthy's full-sized avatar

Luke McCarthy ljmccarthy

View GitHub Profile
@ljmccarthy
ljmccarthy / hello.asm
Created August 26, 2022 15:45
Flat Assembler Hello World (Linux x86-64)
format ELF64 executable 3
segment readable executable
entry $
mov eax, 1 ; sys_write
mov edi, 1 ; fd = STDOUT_FILENO
mov rsi, message ; buf
mov rdx, message.end - message ; count
syscall
@ljmccarthy
ljmccarthy / make_battery_report.cmd
Created July 3, 2022 20:47
Make battery report (Windows)
powercfg /batteryreport /output "C:\battery_report.html"
const std = @import("std");
const ExprType = enum {
Val,
Var,
Add,
Mul,
};
const Value = u32;
@ljmccarthy
ljmccarthy / dummy_xserver.sh
Created February 22, 2022 15:14
WSL2 Dummy X server
# Dummy X server
pgrep Xvfb >/dev/null || (Xvfb :99 &)
export DISPLAY=:99
@ljmccarthy
ljmccarthy / wsl_setup.sh
Last active January 19, 2022 11:03
WSL Bash Setup - Remove Windows path, set DISPLAY for local X11 forwarding, add alias for clip
# Remove Windows path
export PATH="$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
# Set DISPLAY for local X11 forwarding
export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"
# Alias for copying to Windows clipboard
alias clip='/mnt/c/Windows/System32/clip.exe'
@ljmccarthy
ljmccarthy / gist:f663a5f6120b0b448e6ed11e10c0c366
Created December 23, 2021 15:39
All single-byte x86 instructions (excluding prefixes)
06 push es
07 pop es
0E push cs
16 push ss
17 pop ss
1E push ds
1F pop ds
27 daa
2F das
37 aaa
This file has been truncated, but you can view the full file.
-- Journal begins at Sat 2021-12-18 01:16:40 GMT, ends at Sat 2021-12-18 14:15:17 GMT. --
Dec 18 02:46:22 pythagoras systemd[1]: Stopping Network Configuration...
Dec 18 02:46:22 pythagoras systemd-networkd[274]: enp0s20f3: DHCPv6 lease lost
Dec 18 02:46:22 pythagoras systemd-networkd[274]: enp0s20f2: DHCPv6 lease lost
Dec 18 02:46:22 pythagoras systemd-networkd[274]: enp0s20f1: DHCPv6 lease lost
Dec 18 02:46:22 pythagoras systemd-networkd[274]: enp0s20f0: DHCPv6 lease lost
Dec 18 02:46:22 pythagoras systemd[1]: systemd-networkd.service: Deactivated successfully.
Dec 18 02:46:22 pythagoras systemd[1]: Stopped Network Configuration.
Dec 18 02:46:22 pythagoras systemd[1]: Starting Network Configuration...
Dec 18 02:46:23 pythagoras systemd-networkd[22214]: veth4c4bd7c: Link UP
@ljmccarthy
ljmccarthy / getlinks.py
Created October 13, 2021 19:45
Simple script to get all links from a web page
@ljmccarthy
ljmccarthy / bitwise_add.c
Last active October 6, 2021 10:11
8-bit bitwise addition (full adder) implemented using only bitwise operations.
/*
* 8-bit bitwise addition (full adder) implemented using only bitwise operations.
* Luke McCarthy 2021-10-06
*/
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
static uint8_t carry(uint8_t A, uint8_t B, uint8_t C)
TARGETNAME := my-program
BUILDDIR := build
SRCDIRS := src
INCDIRS := include
LIBDIRS :=
LIBS :=
DEFINES :=
PKGS :=
STDC := c11
STDCPP := c++20