This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <fcntl.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <termios.h> | |
#include <unistd.h> | |
#include <sys/ioctl.h> | |
#include <sys/timerfd.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00: 902 !..! .... ..!. mov r0, 2 | |
01: cf0 !!.. !!!! .... mov [0xf0], r0 | |
02: 901 !..! .... ...! mov r0, 1 | |
03: cf1 !!.. !!!! ...! mov [0xf1], r0 | |
04: 912 !..! ...! ..!. mov r1, 2 | |
05: 923 !..! ..!. ..!! mov r2, 3 | |
06: dff !!.! !!!! !!!! mov r0, [0xff] | |
07: a19 !.!. ...! !..! mov [r1:r9], r0 | |
08: dff !!.! !!!! !!!! mov r0, [0xff] | |
09: a29 !.!. ..!. !..! mov [r2:r9], r0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html | |
from bs4 import BeautifulSoup | |
soup = BeautifulSoup(open('jvms-6.html', encoding='ISO8859').read(), 'html.parser') | |
ops = { | |
div['title']: { | |
'words': len(div.find('div', {'class': 'literallayout'}).find_all('br')) - 1, | |
'opcodes': [ | |
int(p.text.split(' ')[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this builds on https://gist.github.com/acdimalev/ff75aa864e49a41231d19c921132faf1 | |
# double-word division takes three input parameters and outputs two | |
# for ALU-type usage, it makes sense to re-use two of the input registers as output registers | |
# A : dividend high-word -> remainder | |
# B : dividend low-word -> quotient | |
# C : divisor | |
# long-division is accomplished by zeroing out the dividend high-word, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modprobe snd_pcm_oss | |
#include <fcntl.h> | |
#include <linux/soundcard.h> | |
#include <math.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/ioctl.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import log | |
from random import random, randrange | |
sample = lambda: (randrange(1, 101), random()) | |
q = [ | |
(1 - y) * log(x) + y * x | |
for (x, y) | |
in (sample() for _ in range(1000)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# interactive log-log profiling visualizer with scales I personally find useful for microprocessor-scale optimizations | |
# usage: ./profile <depth> <filename> | |
# | |
# "depth" is basically the height of the graph | |
# it controlls how many samples are stored at any given time | |
# legend for reading the output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import field | |
@dataclass | |
class InMessage: | |
line: str | |
prefix: str | |
command: str | |
params: list[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import crypt, random, sys | |
(_, nick) = sys.argv | |
password = '{:016x}'.format(random.randrange(256 ** 8)) | |
crypted = crypt.crypt(password) | |
passwd_entry = ':'.join([nick, crypted]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File Format | |
|-- 32 bits --| | |
+---------------+ | |
| file magic | 0xa42d19a9 | |
|---------------| | |
| record magic | see Record Magic | |
|---------------| | |
| total records | actual number of stored records |
NewerOlder