Skip to content

Instantly share code, notes, and snippets.

View Sasszem's full-sized avatar
💥
Burning the dynamite at both ends

László Baráth Sasszem

💥
Burning the dynamite at both ends
  • Szolnok, Hungary
View GitHub Profile
@Sasszem
Sasszem / otp.c
Last active December 18, 2020 18:02
OTP passwords! You can't hack it!
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
/*
##########
# SOLVES #
##########
- sparrow
@Sasszem
Sasszem / pwnme.c
Last active January 28, 2021 01:15
Pwn me - do not modify the source, but make it print the "you won" text! Use Linux/WSL!
#include <stdio.h>
int main() {
long admin = 0;
long s;
char name[100];
fprintf(stdout, "\e[41mDEBUG:\e[49m %p\n", &s);
fprintf(stdout, "\e[41mDEBUG:\e[49m %ld %ld\n", sizeof s, sizeof &s);
printf("Whats ur name? ");
scanf("%100s", name);
@Sasszem
Sasszem / interpret.c
Last active December 18, 2020 17:52
Easy one this time. Give an input that makes it print "you won"!
#include <stdio.h>
/*
##########
# Solves #
##########
- (Derisis13) nope, OBOE, fixed it just after K0B4MB1
- K0B4MB1
- sparrow
@Sasszem
Sasszem / guess.hs
Last active December 16, 2020 17:12
Super-simple number guessing game in Haskell. Took me a day or so to make... Needs 'random' package!
import Text.Read (readMaybe)
import System.Random
import System.IO
readGuess :: Integer -> IO Integer
readGuess no = do
let str = "Please enter your " ++ show no ++ "th guess:"
putStr str
hFlush stdout -- need that coz we don't print a \n
name <- getLine
@Sasszem
Sasszem / message.c
Created December 8, 2020 16:42
Last programming assignment in the semester: write a program that prints what we liked to STDOUT and what we did not to STDERR. (in Hungarian)
#include <stdint.h>
#include <stdio.h>
uint64_t csoeoe(uint64_t thatFirstParam, uint64_t paramNumberOne, uint64_t dQw4w9WgXcQ) {
return (int64_t)(((__int128_t)thatFirstParam*paramNumberOne)%dQw4w9WgXcQ);
}
uint64_t fueuetoeoecsoeoe(uint64_t ZWxzb1BhcmFtZXRlcg, uint64_t bWFzb2Rpa1BhcmFtZXRlcg, uint64_t dXRvbHNvUGFyYW1ldGVy)
{
uint64_t dmFsYW1pUmFuZG9tVmFsdG96bw = 1;
@Sasszem
Sasszem / paulunger.py
Created November 27, 2020 17:59
Simple Paul-Unger state table optimalization helper for single input sequential networks
from collections import deque
"""
Input your (not) fully specified state table here
"""
T = [
["a", ["h", "1"], ["f", "-"]],
["b", ["c", "1"], ["h", "1"]],
["c", ["b", "0"], ["a", "0"]],
["d", ["d", "1"], ["-", "0"]],
@Sasszem
Sasszem / jsonIter.py
Created May 29, 2020 18:14
Extract JSON from text - a quick-and-dirty iterator. Handles braces in strings and escapes (possibly).
def extractJSON(string):
extracted = ""
seen = 0
in_string = False
escape = False
for char in string:
if char=="{" and not in_string:
seen += 1
@Sasszem
Sasszem / polc.py
Created April 17, 2020 09:11
Brute-forcing a simple combinatorical problem to verify the correctness of out solution
def num_to_str(n):
return "{:012b}".format(n)
def has_four(s):
return sum(int(ch) for ch in s)==4
def no_next_to(s):
return s.find("11")==-1
all_possible = list(filter(no_next_to, filter(has_four, map(num_to_str, range(2**12)))))
@Sasszem
Sasszem / Menu.hpp
Created April 16, 2020 08:38
Simple rotary-encoder driven LCD menu for Arduino
// WARNING: Only include this file ONCE in your project
// Made by Sasszem, 2020
// If you ever make any money using this you own me a beer
#include <LiquidCrystal.h>
#include <Arduino.h>
namespace Menu
{
struct Entry {
@Sasszem
Sasszem / fibo.py
Created April 14, 2020 19:20
The simplest possible way of printing the first 100 fibonacci numbers in python
from collections import namedtuple, deque
from sys import stdin, stdout
class SVM:
def __init__(self, progmem = "H", stack = [], status = [0, False]):
self.progmem = progmem
self.stack = deque(stack)
self.PC, self.HALT = status
def step(self):