Skip to content

Instantly share code, notes, and snippets.

View Techno-coder's full-sized avatar

Techno-coder

View GitHub Profile
@Techno-coder
Techno-coder / nztrain.py
Created February 24, 2021 18:27
Training website prototype problem creation script
#!/usr/bin/env python3
# Problem creation auxiliary script.
# Run: chmod +x nztrain.py && ./nztrain.py
# Configure: model/model.py
#
# Do not move this script as it uses
# paths relative to its file location.
import importlib
@Techno-coder
Techno-coder / segment_tree.cpp
Created January 9, 2021 02:57
Minimum Segment Tree
int next_binary_power(int x) {
return 1 << (32 - __builtin_clz(x - 1));
}
struct SegmentTree {
vector<int> nodes;
SegmentTree(int size) : nodes(next_binary_power(size) * 2, INT_MAX) {}
int query(int left, int right) {
@Techno-coder
Techno-coder / iTunesRichPresence.py
Last active December 23, 2020 03:55
Apple Music Discord Rich Presence
#!/usr/local/opt/python@3.8/bin/python3.8
import objc
import time
from Foundation import *
from PyObjCTools import AppHelper
from pypresence import Presence
# References image assets
client_id = "511368737199357972"
@Techno-coder
Techno-coder / bench-execute-main.rs
Created December 22, 2020 08:13
Benchmarks for various interpretation techniques
#![feature(test)]
extern crate test;
mod tree {
type BNode = Box<Node>;
pub enum Node {
If(BNode, BNode, BNode),
Minus(BNode, BNode),
Add(BNode, BNode),
@Techno-coder
Techno-coder / macOS_window_titles.rs
Created April 14, 2020 16:09
Gets all the window titles using AppleScript
use std::process::Command;
const PREFIX: &str = r#"tell application "System Events""#;
const SUFFIX: &str = r#"to get the title of every window of every process"#;
const PERMISSION_ERROR: &str = "osascript is not allowed assistive access";
#[derive(Debug, Copy, Clone)]
pub enum WindowTitleError {
NoAccessibilityPermission,
}
use std::io::{Cursor, Write};
use goblin::elf::{self, Elf};
use goblin::mach::*;
use scroll::{IOwrite, Pwrite, SizeWith};
use crate::PAGE_SIZE;
#[derive(Debug, Default)]
struct Segment {
@Techno-coder
Techno-coder / boot.asm
Last active April 13, 2020 14:49
64-bit higher-half boot script (with notes on changing KERNEL_BASE)
global start
KERNEL_BASE equ 0xFFFFC00000000000
section .inittext
bits 32
start:
mov esp, stack_top - KERNEL_BASE ; set up stack
mov edi, ebx
@Techno-coder
Techno-coder / .travis.yml
Created September 17, 2017 06:15
Travis file that supports a CMakeLists file that uses Conan to build SFML
language: cpp
before_script:
- mkdir cmake
- pushd cmake
- wget https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.sh
- chmod +x cmake-*-Linux-x86_64.sh
- ./cmake-*-Linux-x86_64.sh --exclude-subdir --skip-license
- export PATH="${PWD}/bin:$PATH"
- popd