Skip to content

Instantly share code, notes, and snippets.

@gkbrk
gkbrk / todograph.py
Last active December 30, 2023 18:11
Todo.txt to graph
#!/usr/bin/python3
import matplotlib.pyplot as plt
import datetime
def get_stats(filename):
data = {}
with open(filename) as todofile:
for line in todofile:
date = line.split()[1]
if date in data:
@gkbrk
gkbrk / Program.cs
Created December 26, 2023 08:35
RBU time signal demodulator
// Leo's RBU time signal demodulator (2023-12-25)
// Copyright (C) 2023 Gokberk Yaltirakli (gkbrk.com)
// - https://en.wikipedia.org/wiki/RBU_(radio_station)
// - https://www.sigidwiki.com/wiki/RBU
// Tune to 66.0 kHz
// http://websdr.ewi.utwente.nl:8901/?tune=66.0
// To compile, just `dotnet build -c Release`. To run, `dotnet run -c Release`.
@gkbrk
gkbrk / lobsters-mastodon.lisp
Last active January 20, 2023 06:20
Common lisp Mastodon bot
(ql:quickload :drakma)
(ql:quickload :cl-json)
(ql:quickload :plump)
(ql:quickload :babel)
(ql:quickload :tooter)
(ql:quickload :split-sequence)
(defvar *feed-path* "https://lobste.rs/rss")
(setf drakma:*drakma-default-external-format* :UTF-8)
@gkbrk
gkbrk / rust_md5.md
Created December 10, 2015 20:57
Rust MD5 [AdventOfCode]

Is Rust's MD5 Slow? Heck no!

Today I came across this post on the Rust subreddit. Basically it is comparing two MD5 Miners written in Python and Rust. The miner is written for a code challenge called Advent of Code.

To be honest, speed is one of the things I love about Rust, so seeing Rust being blown away by Python (which I also like and use a lot) made me sad. I decided to make this a bit more fair for Rust so I made a very short piece of Rust code to complete this challenge FAST.

The challenge

The challenge, as written on the Advent of Code page is as follows:

  • You are given a key, for example abcdef.
  • You are looking for a string that is made by taking the MD5 of this key plus a number. This hash has to start with 5 leading zeros. (Like abcdef609043)
@gkbrk
gkbrk / lolcat.asm
Created July 27, 2016 13:26
Lolcat clone in x64 assembly
section .data
char_buffer db 0
section .text
global _start
_start:
mov r12, 0
.loop:
call read_char
@gkbrk
gkbrk / main.c
Last active January 15, 2022 00:02
Thanos-snap half of your files out of existence
#define _XOPEN_SOURCE 500
#include <assert.h>
#include <dirent.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
@gkbrk
gkbrk / slowloris.py
Last active January 13, 2022 09:28
Slowloris implementation in Python. https://github.com/gkbrk/slowloris
import socket
import random
import time
import sys
log_level = 2
def log(text, level=1):
if log_level >= level:
print(text)
@gkbrk
gkbrk / server.c
Created June 25, 2021 22:31
Chat server using the poll() API
#include <arpa/inet.h>
#include <poll.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
@gkbrk
gkbrk / whois.rs
Created December 5, 2015 17:43
Rust whois client
use std::io::prelude::*;
use std::net::TcpStream;
use std::io::BufReader;
use std::env;
fn get_tld_server(tld: &str) -> Option<String> {
let mut stream = TcpStream::connect("whois.iana.org:43").unwrap();
stream.write_all(format!("{}\n", tld).as_bytes()).unwrap(); //Send the tld
let reader = BufReader::new(stream);
@gkbrk
gkbrk / titan-conquest-bot.py
Created August 1, 2019 00:17
Game bot for Titan Conquest
#!/usr/bin/env python3
import requests
import re
from bs4 import BeautifulSoup
UA = "Mozilla/5.0 (X11; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
USERNAME = "usernameHere"
PASSWORD = "passwordHere"
ROOT = "https://titanconquest.com/"
WORKER = f"{ROOT}worker.php"