Skip to content

Instantly share code, notes, and snippets.

View ddjerqq's full-sized avatar
👀
Delirious

10x developer ddjerqq

👀
Delirious
View GitHub Profile
@ddjerqq
ddjerqq / discord_id_generator.rs
Last active November 2, 2023 12:43
snowflake.rs
use std::time::{SystemTime, UNIX_EPOCH};
const EPOCH: u64 = 1420070400000;
pub struct Id {
internal_worker: u128,
internal_process: u128,
increment: u128,
}
from __future__ import annotations
import random
import string
import time
from base64 import b64encode as b64e
from base64 import b64decode as b64d
from datetime import datetime
__all__ = (
@ddjerqq
ddjerqq / primer.rs
Created September 11, 2022 22:44
generate infinite prime numbers using the power of rust
//! # sieve to generate prime numbers without an upper limit
//!
//! this is very fast, especially when built with --release
//!
//! # example:
//! ```
//! for i in s {
//! println!("{} ", i);
//! }
//! ```
@ddjerqq
ddjerqq / auth.js
Created October 13, 2022 11:54
Password hasher. used to prepare the passwords for super secure storage.
const crypto = require("crypto")
/**
* Password hasher
* used to prepare the passwords for super secure storage.
*
* this system is so secure (unless the SALTS and PEPPERS are *stolen*) that its safe to have weak passwords like password123 iloveu and so on.
* as 2 same passwords will (most *likely*) have a different hash
*
* # Notes:
@ddjerqq
ddjerqq / result_option.py
Created October 22, 2022 23:37
rust option and result but in python
from __future__ import annotations
from typing import Any
from typing import Callable
from typing import Generic
from typing import Tuple
from typing import TypeVar
from typing import Union
from typing import overload
@ddjerqq
ddjerqq / url_extract_and_save.py
Created December 13, 2022 22:18
extract and save urls
"""
1. Create a web crawler/scraper that uses socket connections (No Selenium) to gather links from webpages and add
them to a process queue.
2. The queue will be processed by P number of processes (However many cores on the machine).
3. Each process will use aiohttp (Async) with max T number of threads/tasks (Variable default: 100) to scrape from
the queue and add to the queue.
4. Store the title of all scraped HTML pages along with their URLs in an SQLITE database file.
@ddjerqq
ddjerqq / recursive url and title extractor.py
Created December 13, 2022 22:23
a better version to url_extract_and_save.py. recursively extract urls from a url and go 1 level deeper.
"""recursively extract links and their titles from a web address
"""
from __future__ import annotations
import re
import asyncio as aio
import aiohttp
from aiohttp import ClientTimeout
@ddjerqq
ddjerqq / bloom_filter.py
Created December 15, 2022 22:27
A Bloom filter is a space-efficient probabilistic data structure, conceived by Burton Howard Bloom in 1970, that is used to test whether an element is a member of a set.
"""Bloom Filter
A Bloom filter is a space-efficient probabilistic data structure,
conceived by Burton Howard Bloom in 1970, that is used to test whether
an element is a member of a set. False positive matches are possible,
but false negatives are not – in other words, a query returns either
"possibly in set" or "definitely not in set". Elements can be added to
the set, but not removed (though this can be addressed with the counting
Bloom filter variant); the more items added, the larger the probability
of false positives.
@ddjerqq
ddjerqq / hello.cu
Created January 8, 2023 15:39
hello CUDA application my first CUDA app
#include <iostream>
using namespace std;
// create a 'kernel'. a kernel is a function that runs on the 'device' - GPU
__global__
void saxpy(int n, float a, float* x, float* y)
{
// get the current index in the arrays;
int i = blockIdx.x * blockDim.x + threadIdx.x;
@ddjerqq
ddjerqq / julia.cu
Last active March 28, 2023 06:30
julia fractal set using CUDA and complex numbers
// check comments for where to find these headers
#include "../common/book.h"
#include "../common/cpu_bitmap.h"
#define DIM 1000
#define SCALE 0.1f
#define STEPS 300
#define JULIA_REAL (-0.8f)
#define JULIA_IMAG (0.155f)