Skip to content

Instantly share code, notes, and snippets.

@novoru
novoru / fdf.py
Created July 18, 2022 00:46
Fractional Delay Filter using the Farrow Structure
# Fractional Delay Filter using the Farrow Structure
# https://wirelesspi.com/fractional-delay-filters-using-the-farrow-structure/
import numpy as np
import matplotlib.pyplot as plt
if __name__ == "__main__":
# Fixed Coefficients of the Farrow structure for a cubic interpolator
b3 = np.array([-1/6, 1/2,-1/2, 1/6])
b2 = np.array([ 1/2,-1, 1/2, 0])
@novoru
novoru / gps.py
Created May 1, 2022 09:18
Receive GPS signals with ADALM-PLUTO
import adi
import numpy as np
from datetime import datetime
# ADALM-PLUTO parameter
sample_rate = 12e6 # 12MHz
bandwidth = 4.2e6 # 4.2MHz
center_freq = 1572.42e6 # 1572.42MHz (GPS L1/CA)
duration = 100e-3 # 100ms
num_samps = duration*sample_rate
@novoru
novoru / game_of_life.py
Last active February 13, 2022 01:25
Conway's Game of Life
# Conway's Game of Life
import curses
import time
import signal
import sys
from typing import List
Vector = List[str]
// Reverse polish calculator
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
if(argc == 1)
exit(0);
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <readline/readline.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/wait.h>
#include <signal.h>
typedef struct Vector {
@novoru
novoru / dup_test.c
Last active February 28, 2021 01:43
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#define BUF_SIZE 256
int main(int argc, char **argv) {
pid_t pid;
@novoru
novoru / rot.hs
Last active January 30, 2021 01:39
rotChar :: Int -> Char -> Char
rotChar n c
| c `elem` ['A'..'Z'] = chr(mod ((ord(c) - ord('A')) + n) 26 + ord('A'))
| c `elem` ['a'..'z'] = chr(mod ((ord(c) - ord('a')) + n) 26 + ord('a'))
| otherwise = c
rot :: Int -> String -> String
rot n s = map (rotChar n) s
main = do
@novoru
novoru / sign_extend.c
Last active July 6, 2021 15:52
extend sign
// extend n bit of x to the left.
// Reference: ハッカーのたのしみ(ISBM978-4-434-04668-1) p.18-19
int32_t sign_extend(uint8_t x, uint8_t n)
{
return (int32_t) ((x + (1 << n)) & ((1 << n) | ((1 << n) - 1))) - (1 << n);
}
// リンカ・ローダ実践開発テクニック p.88: pointer.c
#include <stdio.h>
#include <stdlib.h>
char s1[] = "This is array.";
char *s2 = "This is pointer.";
int main() {
printf(" s1 = 0x%08lx\n", (unsigned long) s1);
// リンカ・ローダ実践開発テクニック p.78-80: ardump.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <elf.h>
#include <ar.h>
#include <sys/stat.h>