Skip to content

Instantly share code, notes, and snippets.

View PeterWaIIace's full-sized avatar
💘
In love with computational evolution

W4ltz PeterWaIIace

💘
In love with computational evolution
View GitHub Profile
@PeterWaIIace
PeterWaIIace / SimpleExcFileowners2Filegroups.py
Created June 11, 2020 13:08
Fileowners to filegroups - simple python excercise for list comprehension (I dont know the source)
# Excercise sent by friend - I dont know the source
# fo is dict with fileowners - objective is to transfer it to fg (file group) where user (ie Randy) is unique key
# and hold list of files
# fo = {"input.txt":"Randy","code.py":"Stan","Output.txt":"Randy"} -> fg = {"Randy":["input.txt","Output.txt"],"Stan":["code.py"]}
fo = {"input.txt":"Randy","code.py":"Stan","Output.txt":"Randy"}
fg = dict()
kelse = lambda fo,fg,k : fg.update({fo[k]:[k]})
kif = lambda fo,fg,k : fg[fo[k]].append(k)
@PeterWaIIace
PeterWaIIace / GR_load_mf.py
Last active July 6, 2020 00:05
GNURadio meta files load to python - scirpt for loading GNURadio meta files into numpy array. Additionaly you can access small chunks of data.
# gnu radia meta file load
from gnuradio.blocks import parse_file_metadata as pfm
from gnuradio.gr import pmt
import numpy as np
import scipy
# segment, index and length is only required if you want to access specific chunk of data. You will always get info for that chuck
# Setting segment specify which segment you want get, index specify from which index from that segment function should start reading,
# and length specify how long the function should od reading
@PeterWaIIace
PeterWaIIace / tcpclientsocket.c
Created July 4, 2020 18:42
Simple template for tcp client socket in C for Linux. Based on https://www.youtube.com/watch?v=bdIiTxtMaKA
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@PeterWaIIace
PeterWaIIace / tcpserver.c
Created July 9, 2020 21:43
TCP listening non-blocking socket server template.
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@PeterWaIIace
PeterWaIIace / IEEE_802_11_OFDM_Preamble.py
Last active July 21, 2020 17:35
Short code with prepared long and short sequence for OFMD IEE802.11n
#prepare OFDM
import numpy as np
from matplotlib import pyplot as plt
import scipy
import scipy.signal
fs = 20e6
class OFDM:
@PeterWaIIace
PeterWaIIace / gist:f7ae9542a6eb163201f0100c8d0781e3
Last active September 17, 2022 18:38
Python-like rust json/dictionary
use serde_json::{Map, Value};
fn main()
{
let mut map = Map::new();
let mut map2 = Map::new();
// assuming keys_vals is a Vec<(String, String)>
map.insert("key1".to_string(), Value::String("val".to_string()));
map.insert("key2".to_string(), Value::String("val2".to_string()));
@PeterWaIIace
PeterWaIIace / RingBuff.h
Last active October 28, 2022 20:52
Experiment with generic ring buffer using preprocessor
#ifndef _RING_BUFFER_H_
#define _RING_BUFFER_H_
#include <stdint.h>
#define RING_BUFFER_MAX_SIZE 255
#define INIT_RING_BUFFER(_NAME,_SIZE,_DATATYPE,NULLTYPE)\
typedef struct _NAME ## _s_ring_buffer _NAME ## _s_ring_buffer;\
typedef struct _NAME ## _s_ring_buffer\
@PeterWaIIace
PeterWaIIace / BezierCurves.js
Created February 4, 2023 18:05
BezierCurves.js
class BezierCurve
{
constructor(x1, y1, x2, y2, id) {
this.p1 = {x: x1, y: y1};
this.p2 = {x: x2, y: y2};
}
updatePoint1(x1, y1) {
this.p1 = {x: x1, y: y1};
@PeterWaIIace
PeterWaIIace / timeit.cpp
Last active July 24, 2023 23:42
timeit.cpp
#include <functional>
#include <chrono>
#include <iostream>
using namespace std::chrono;
void timeit(std::function<void(void)> fn)
{
auto start = high_resolution_clock::now();
fn();
auto stop = high_resolution_clock::now();
@PeterWaIIace
PeterWaIIace / readme.md
Created September 25, 2023 23:14
add directory to Conda's environment's path

conda env config vars set PATH=$PATH;<yourpath>

in windows use $PATH instead of %PATH%