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 / conversions.elm
Created November 26, 2023 17:21
Elm multi-form for units conversions
module Main exposing (main)
import Browser
import Html exposing (Html, Attribute, p, span, input, text)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
-- MAIN
@PeterWaIIace
PeterWaIIace / password.elm
Created November 21, 2023 22:16
Elm is bit odd with its if statements (in viewValidation model)
import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
-- MAIN
@PeterWaIIace
PeterWaIIace / progressbar.cpp
Created October 19, 2023 19:25
progress bar for cpp/C
#define PBSTR "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
#define PBWIDTH 60
void printProgress(double percentage) {
int val = (int) (percentage * 100);
int lpad = (int) (percentage * PBWIDTH);
int rpad = PBWIDTH - lpad;
printf("\r%3d%% [%.*s%*s]", val, lpad, PBSTR, rpad, "");
fflush(stdout);
}
@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%

@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 / 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 / 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 / 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 / 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 / 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>