Skip to content

Instantly share code, notes, and snippets.

View mfukar's full-sized avatar

Michael Foukarakis mfukar

View GitHub Profile
mfukar / fuckyou.cpp
Created October 4, 2022 15:06
fuck this interview question and fuck the people that ask stupid questions that require this answer
#include <iostream>
template<int N>
struct stupid {
static void out(std::ostream& os) {
os << N << std::endl;
mfukar / download_owned_cards.ps1
Last active February 2, 2022 03:29
[Tyrant Unleashed] Download your cards into a ownedcards.txt file, and your decks into a currentdecks.txt, for use with the optimiser. From your browser, get the response from the api.php?message=init request into a file named json.txt in the /data/ directory of the optimiser, along with this script. Reqs Powershell 7. Will create two files in t…
$stopwatch = [Diagnostics.Stopwatch]::StartNew()
if (-not (Test-Path "json.txt")) {
Write-Host "[-] To update owned cards, supply the response to api.php?message=init in json.txt"
exit 1
$account_details = Get-Content "json.txt" | ConvertFrom-JSON -AsHashtable
if (-not (Test-Path "cards_section*.xml")) {
Write-Host "[-] Run this script inside the optimiser's /data/ directory"
mfukar / countdown.cpp
Last active November 8, 2021 17:26
* Solver for the Countdown numbers game. Branch-and-bound search.
* Compile with:
* clang++ -std=c++17 -O3 -o countdown countdown.cpp
* Should find answers in much less than a second.
#include <limits>
#include <vector>
#include <string>
mfukar / com.local.jekyll.server.agent.plist
Created August 14, 2017 09:03
macos LaunchAgent to debug, test, and serve a Github page locally
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
mfukar / luhn.cpp
Last active November 8, 2021 17:27
The Luhn test in C++11
#include <algorithm>
#include <numeric>
#include <iostream>
#include <vector>
* Assuming an input of a string of digits, perform the Luhn test on the indicated sequence.
* Returns true if the given string passes the test, false otherwise.
bool luhn(const std::string& seq) {
mfukar /
Last active September 3, 2020 08:07
Recover the key used by Petya to encrypt the MFT
# Recover the key used by the Petya ransomware to encrypt the MFT (master file table)
import z3
import sys, struct
# XOR key for salsa10-src.bin :
# Counter position, as two words
mfukar / terminate-worker-threads.c
Last active May 10, 2024 08:19
C11 code to have a POSIX multithreaded application which signal work completion via a condition variable, and then terminate.
* Demonstration of a way to break out of a multi-threaded program with one "manager" thread and
* many "worker" threads.
* There is the assumption that the work being done is long-standing enough to guarantee that
* all threads have been created and are running prior to one of them completing its assigned work.
* If this is not the case, adjustments to this code have to be made. Better yet, implement and use
* a monitor / barrier.
* The primary use of this is to demonstrate usage of condition variable(s) and cancellation.
mfukar /
Created May 26, 2016 18:21
Some interview question from VMware. Figure out the problem statement, it's obvious.
import sys
def main():
N = raw_input()
elements = [int(element) for element in' ')]
L, R = 0, len(elements)
# We got ourselves a maximum subarray problem, with inverted semantics.
# The subarray we want to find is the one to flip all the bits in.
mfukar / nuke-noscript.user.js
Last active March 24, 2016 07:09
Nuke <noscript> tags
// ==UserScript==
// @name nuke noscript
// @namespace
// @version 0.2
// @description Remove all <noscript> tags in every document
// @author mfukar
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
mfukar /
Created December 3, 2015 10:52
A buffer of bits
import struct
class bitbuffer:
# TODO: need reader?
def __init__(self):
self.buffer = b''
self.byte = 0
self.bit_pos = 7
def append(self, value, nbits):