Skip to content

Instantly share code, notes, and snippets.

@chop0
chop0 / dft_demo.c
Last active December 31, 2024 09:04
#include <complex.h>
#include <stdint.h>
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <limits.h>
#include <tgmath.h>
#include <stdio.h>
#include <stdbool.h>
//
// Created by alec on 11/25/24.
//
#include <stddef.h>
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
`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):