Skip to content

Instantly share code, notes, and snippets.

@dannvix
dannvix / mydft.py
Last active January 14, 2025 11:32
Intuitive impementation of discrete Fourier transform (and inverse DFT) in Python (without numpy)
#!/usr/bin/env python3
import math
# >> Discrete Fourier transform for sampled signals
# x [in]: sampled signals, a list of magnitudes (real numbers)
# yr [out]: real parts of the sinusoids
# yi [out]: imaginary parts of the sinusoids
def dft(x):
N, yr, yi = len(x), [], []
@jacky860226
jacky860226 / dominatorTree.cpp
Last active November 16, 2024 21:04
dominator tree
class dominatorTree{
int n, dfnCnt;
vector<vector<int>> G, rG, semiTree;
vector<int> dfn, id, pa, semi, idom;
vector<int> unionFind, best;
int find(int x){
if( x==unionFind[x] ) return x;
int tmp = find(unionFind[x]);
if( dfn[semi[best[x]]] > dfn[semi[best[unionFind[x]]]] )
best[x] = best[unionFind[x]];
@eevee
eevee / perlin.py
Last active February 25, 2025 13:47
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.
@btroncone
btroncone / ngrxintro.md
Last active March 5, 2025 20:40
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@Geal
Geal / future.c
Last active June 5, 2024 06:49
small future and promise library in C with pthreads
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <stdbool.h>
#include <time.h>
#include <stdarg.h>
#include <string.h>
#include "future.h"
//pairing heap
//{elem:object, subheaps:[array of heaps]}
//subheaps might should be a linked list
function PairingHeap(obj) {
this.elem = obj;
this.subheaps = [];
}
function min(heap) {
return heap.elem;
@lpereira
lpereira / coro.c
Created March 22, 2012 01:12
Simple coroutine implementation in C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
typedef struct coro_t_ coro_t;
typedef struct thread_t_ thread_t;
typedef int (*coro_function_t)(coro_t *coro);
typedef enum {
CORO_NEW,