Skip to content

Instantly share code, notes, and snippets.

@segrax
segrax / BashHistoryAutocomplete
Last active August 29, 2015 14:03
search command prompt history with auto complete
# .bashrc
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
@segrax
segrax / CreateFreeBSDVm.sh
Last active September 8, 2020 16:05
Create a FreeBSD 64bit VM with VirtualBox, on FreeBSD, Accepting VNC Connections
# Create a VM named 'MyBSDBox' (64 bit FreeBSD)
VBoxManage createvm --ostype FreeBSD_64 --register --basefolder /vms --name MyBSDBox
# 1gig of memory, 1 CPU.. and set the network to bridged via EM0, emulating the 82540EM chipset
VBoxManage modifyvm MyBSDBox --memory 1024 --ioapic on --cpus 1 --chipset ich9 --nic1 bridged --nictype1 82540EM --bridgeadapter1 em0
# 20 gig Dynamic HDD image, on sata controller
VBoxManage createhd --size 20000 --filename "/vms/MyBSDBox/MyBSDBox.vdi"
VBoxManage storagectl MyBSDBox --name "SATA Controller" --add sata --controller IntelAhci --portcount 4
VBoxManage storageattach MyBSDBox --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/vms/MyBSDBox/MyBSDBox.vdi"
@segrax
segrax / BSD Youtrack rc script
Last active January 22, 2023 00:12 — forked from artuomvproskunin/BSD Youtrack rc script
Youtrack Startup script
#!/bin/sh
# $FreeBSD: head/devel/youtrack/files/youtrack.in 329474 2013-10-05 16:11:37Z lwhsu $
#
# PROVIDE: youtrack
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Configuration settings for youtrack in /etc/rc.conf:
@segrax
segrax / MemorySegments
Last active August 29, 2015 14:12
Memory Segment Calculations
To calculate the segment of a memory address,
Memory Address >> 4 = Segment
-----------------------------
0xFFFF0 >> 4 = 0xFFFF
To calculate the memory address from a segment
Segment << 4 = Memory Address
@segrax
segrax / x64_function_call_register_use
Last active August 29, 2015 14:16
x64 CPU Register function call usage
RAX temporary register; with variable arguments passes information about the number of vector registers used; 1st return register
RDI used to pass 1st argument to functions
RSI used to pass 2nd argument to functions
RDX used to pass 3rd argument to functions; 2nd return register
RCX used to pass 4th argument to functions
R8 used to pass 5th argument to functions
R9 used to pass 6th argument to functions
@segrax
segrax / X64 Memory Paging
Last active August 29, 2015 14:16
Calculating Indexs from a virtual address
PML4 Directory Ptr Page Directory Page Table Page Offset
x-xxxx-xxxx x-xxxx-xxxx x-xxxx-xxxx x-xxxx-xxxx XXXX-XXXX-XXXX
$address = 0xFF8000000000;
$pml4 = ($address & 0xFF8000000000) >> 39;
$pdp = ($address & 0x7FC0000000) >> 30;
$pd = ($address & 0x3FE00000) >> 21;
$pt = ($address & 0x1FF000) >> 12;
@segrax
segrax / BytesToSigned.php
Last active August 29, 2015 14:25
Take an array of bytes, and output a series of signed integers (16bit)
<?php
$data = array(
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
);
$final = array();
@segrax
segrax / ConvertSpriteData.php
Last active September 6, 2015 23:44
Convert structures of sprite data and change address to a relative address, instead of an absolute
<?php
/*
*
const sSpriteSheet* stru_8C358[] = {
{ 0x57F60, 0, 2, 0xE, 0x3480, 0 },
{ 0x57F62, 0, 2, 0xE, 0x3480, 0 },
{ 0x57F64, 0, 2, 0xE, 0x3480, 0 },
};
@segrax
segrax / FreeBSD_ManualInstall
Last active July 6, 2017 21:43
FreeBSD manual install on zfs
mdconfig -a -t vnode -f FreeBSD-11.0-RELEASE-amd64-disc1.iso
mount -t cd9660 /dev/md0 /cdrom
zfs create pool/os
zfs create pool/os/fbsd11
export DESTDIR=/pool/os/fbsd11
cd /cdrom/usr/freebsd-dist
@segrax
segrax / Amiga_Lemmings_Codes
Created December 22, 2015 06:47
Lemmings Codes
Fun:
Level6: DLCIJNLGCT
Level7: LCANLLDHCO
Level8: CINNLDLICJ
Level9: CEKHMDLJCO
Level10: MKHMDLCKCX
Level11: OJMLLBELCN
Level12: HMDLCINMCY
Level13: MDLCAKLNCS