Skip to content

Instantly share code, notes, and snippets.

View umgefahren's full-sized avatar

Hannes umgefahren

View GitHub Profile
@umgefahren
umgefahren / main.rs
Created July 10, 2021 16:03
Use hyper with Tor (Rust)
use tor_stream::TorStream;
use hyper::client::conn::Builder;
use hyper::Body;
use http::Request;
use tokio::net::TcpStream;
#[tokio::main]
async fn main() {
let url = "httpbin.org:80";
@umgefahren
umgefahren / main.rs
Created July 29, 2021 15:41
libp2p Kademlia with async interface
use libp2p::swarm::SwarmEvent;
use libp2p::NetworkBehaviour;
use libp2p::PeerId;
use libp2p::kad::{Kademlia, KademliaEvent, Quorum, Record, QueryResult};
use libp2p::kad::store::MemoryStore;
use libp2p::mdns::{Mdns, MdnsEvent, MdnsConfig};
use libp2p::kad::record::Key;
use libp2p::{identity, noise, Transport, mplex, Swarm};
use libp2p::tcp::TcpConfig;
use libp2p::core::upgrade;
@umgefahren
umgefahren / graph-viz.ipynb
Created December 19, 2021 14:05
Graph Viz
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@umgefahren
umgefahren / main.c
Last active March 6, 2022 15:24
Bitfields in C
#include <stdio.h>
int main() {
unsigned int number = 1203;
short found_one = 0;
for (int i = (sizeof(unsigned int) * 8) - 1; i >= 0; i--) {
if (number & (1u << i)) {
putchar('1');
found_one = 1;
} else if (found_one) {
@umgefahren
umgefahren / Fast-Enum-C.c
Created April 28, 2022 17:55
Implementation of fast enum in C
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#define ONE 1
// #define PRINT_OUPUT
const uint8_t uint8_one = ONE;
const uint16_t uint16_one = ONE;
#include <stdio.h>
#include <stdint.h>
int main() {
FILE * inp_file = fopen("input.txt", "r");
uint64_t a = 0;
uint64_t b = 0;
uint64_t c = 0;
uint64_t slider = 0;
uint64_t incremented = 0;
@umgefahren
umgefahren / init.el
Created January 20, 2023 18:09
Current Emacs Config
;; Define the init file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
;; Define and initialize package repositories
(require 'package)
(setq package-archives '(("melpa" . "http://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)