Skip to content

Instantly share code, notes, and snippets.

View elsamuko's full-sized avatar

Samuel elsamuko

  • Kiel
View GitHub Profile
@elsamuko
elsamuko / bernd_AI.py
Created April 4, 2023 08:00
bernd_AI.py
#!/usr/bin/env python3
import random
from signal import signal, SIGINT
def handler(signal_received, frame):
exit(0)
signal(SIGINT, handler)
answer = "Moin"
@elsamuko
elsamuko / double_interrupt.cpp
Last active March 16, 2022 13:12
Boost::Thread interrupt crash
#include <iostream>
#include <thread>
#include <boost/thread.hpp>
#include <boost/thread/thread_guard.hpp>
#define LOG( A ) std::cout << A << std::endl;
void work() {
size_t sum = 0;
@elsamuko
elsamuko / record.sh
Last active September 12, 2023 04:18
Screen recording with ffmpeg under Windows
#!/usr/bin/env bash
# capture screen with ffmpeg and stop it with CTRL-C
# https://trac.ffmpeg.org/ticket/6336
# https://bugs.python.org/issue42962
SIZE="1920x1080"
VIDEO="video.mp4"
if [ -f "$VIDEO" ]; then rm "$VIDEO"; fi
@elsamuko
elsamuko / qprocess_windows.cpp
Created February 10, 2021 21:53
Starting a process with Qt
#include <QCoreApplication>
#include <QProcess>
#include <QTimer>
int main( int argc, char* argv[] ) {
QCoreApplication a( argc, argv );
// does work
QProcess p;
p.start( "cmd", { "/c", "ECHO", "Hi", ">", "accentué_list.txt"} );
@elsamuko
elsamuko / main.qml
Created January 28, 2021 11:12
QML demo
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
@elsamuko
elsamuko / lazy.cpp
Last active February 26, 2021 15:03
Lazy evaluation with std::call_once
#!/usr/bin/env cppsh
// lazy class based on
// https ://www.codeproject.com/Articles/682455/Generic-Lazy-Evaluation-in-Cplusplus
// but using std::call_once instead
// https://old.reddit.com/r/cpp/comments/hsbs4v/lazy_evaluation_with_stdshared_future_and/fycwsvy/
#include <iostream>
#include <thread>
#include <vector>
@elsamuko
elsamuko / pseudo_rng.cpp
Created April 18, 2020 11:12
Pseudo PRNG for testing
#!/usr/bin/env cppsh
#include <iostream>
#include <vector>
#define LOG( A ) std::cout << A << std::endl;
struct TestPRNG {
size_t pos = 0;
std::vector<int> buffer = { 1458660379,
@elsamuko
elsamuko / d3d_info.cpp
Created March 4, 2020 12:17
Print Direct3D information
#!/usr/bin/env cppsh
#include <cstdio>
#include <windows.h>
#include <d3d9.h>
//! \sa https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/windows/qwindowsopengltester.cpp#L124
void detect() {
typedef IDirect3D9 * ( WINAPI * PtrDirect3DCreate9 )( UINT );
@elsamuko
elsamuko / piggi.py
Created March 3, 2020 18:51
script to generate a first name from a three digit integer, useful, if you have to name 850 pigs
#!/usr/bin/env python3
# generate a first name from a three digit integer
# useful, if you have to name 850 pigs
import sys
import random
A = ["An", "Fen", "Wil", "Ni", "Ha", "Fre", "Sa", "Li", "Ma", "Ta"]
B = ["thil", "riss", "rin", "xim", "lin", "ra", "li", "ko", "thi", "de"]
C = ["hardt", "linde", "muth", "ja", "as", "helm", "tin", "ka", "than", "da"]
@elsamuko
elsamuko / vm_protect_bug.sh
Created February 6, 2020 07:32
Demonstrate (mach_)vm_protect error with Xcode 11
#!/usr/bin/env bash
# VERSION="10.3"
VERSION="11.3.1"
XCODE="/Applications/Xcode${VERSION}.app/Contents/Developer"
INCLUDE="${XCODE}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
SOURCE_FILE="${TMPDIR}/vm_protect.cpp"
BIN_FILE="${TMPDIR}/vm_protect"