Skip to content

Instantly share code, notes, and snippets.

`timescale 1ns / 1ps
module reservation_station
#(parameter int RS_ID, int DATA_WIDTH)
(
input logic clk,
input logic rst,
register_file register_file,
issue_bus issue,
@chop0
chop0 / FileUploadServer
Created November 28, 2023 23:26
simple java file upload server
#!/usr/bin/java --source 21
import java.io.*;
import java.net.*;
import java.nio.file.*;
import com.sun.net.httpserver.*;
public class FileUploadServer implements HttpHandler {
public static void main(String[] args) throws IOException {
@chop0
chop0 / boot.S
Created November 17, 2023 08:55
ASM bootloader that sets up long mode paging with a self-referential PML4E
[bits 16]
load:
mov ah, 0x02 ; read disk sectors
mov al, 0x01 ; 1 sector (probably should statically calculate this somehow, or use linker script)
mov ch, 0x00 ; track
mov cl, 0x02 ; sector
mov dh, 0x00; head
; mov dl, 0x00
mov bx, 0
@chop0
chop0 / Socks5Server.java
Last active November 17, 2023 08:20
A Java socks5 server
package ax.xz.census.proxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
@chop0
chop0 / Socks5Server.java
Created June 28, 2023 21:57
A simple Java SOCKS5 server
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;
import numpy as np
import scipy as sp
def tcp_siggen(samp_rate, freq, amp, noise_var, N):
t = np.arange(start=0, stop=N / samp_rate, step=1 / samp_rate, dtype=np.complex64)
# Create the phase of the sin wave at each samples
phase = 2 * np.pi * freq * t
# create a complex sin wave
carrier = amp * np.exp(phase * 1j)
# generate complex white(ish) gaussian noise with the right variance
import numpy as np
import scipy as sp
def finite_difference_coefficients(k, xbar, x):
"""
based on the maths in Finite Difference Methods for Ordinary and Partial Differential Equations
:param k: the order of the derivative
:param xbar: the point at which the derivative is to be evaluated
:param x: the set of points at which the function is known
:return: the coefficients of the finite difference approximation
@nb.njit
def z(theta): # funny bromwich contour
return (
.1446 + 3.0232 * theta ** 2 / (theta ** 2 - 3.0767 * np.pi ** 2)
+ 0.2339 * 1j * theta
)
@nb.njit
def z_dash(theta, h=.001):
@chop0
chop0 / parse.c
Last active January 10, 2022 18:07
Kernel symbol parser
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "parse.h"
#define BUFSIZE 256
FILE* open_map() {
FILE* ver = fopen("/proc/version", "r");
@chop0
chop0 / gist:934c8799d22d8b3d06711c27f183cbbd
Created December 17, 2021 02:02
grepping through v8 for comments that have "anyway" in them
zone/zone-list.h: // zone-allocated objects for which destructors are not called anyway, so
ast/scopes.cc: // scope and we terminate the iteration there anyway.
ast/scopes.cc: // in the outer scope anyway, because if a binding exists in an outer
ast/scopes.h: // Sloppy eval in script scopes can only introduce global variables anyway,
ast/scopes.h: // isn't extendable anyway, or
heap/memory-chunk.cc: // Not actually used but initialize anyway for predictability.
heap/cppgc/heap-page.cc: // for the first header which will anyways serve as header again.
heap/heap.cc: // This is an optimization. The sweeper will release black fillers anyway.
codegen/x64/assembler-x64.cc: // (larger) kCodeAlignment anyways.
codegen/ia32/assembler-ia32.cc: // (larger) kCodeAlignment anyways.