Skip to content

Instantly share code, notes, and snippets.

View TheDcoder's full-sized avatar

TheDcoder TheDcoder

View GitHub Profile
@TheDcoder
TheDcoder / monitor_focus.user.js
Last active March 3, 2020 05:38
DOM Focus Tracker Userscript
// ==UserScript==
// @name DOM Focus Tracker (Console)
// @version 0.2
// @description A quick and dirty focus tracker, logs the currently focused element to console
// @include *
// @run-at document-start
// ==/UserScript==
window.addEventListener("focusout", event => console.log(event.relatedTarget === null ? "The webpage has lost focus" : event.relatedTarget), true);
@TheDcoder
TheDcoder / InteractiveCoordinateSelect.au3
Last active February 5, 2019 12:25
AutoIt UDF for interactively selecting a coordinate/point on the screen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: InteractiveCoordinateSelect
; Description ...: Lets the user interactively select a point on the screen
; Syntax ........: InteractiveCoordinateSelect()
; Parameters ....: None
; Return values .: Success: An array with the X and Y positions of the selected point
; Failure: False (This happens when the overlay window is closed)
@TheDcoder
TheDcoder / UNLICENSE
Last active July 6, 2019 14:07
strseg - Get delimiter-separated segments from a string in a non-destructive method
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@TheDcoder
TheDcoder / absMin.js
Created September 16, 2019 08:02
Math.min in absolute terms
function absMin(...values) {
return values.find(value => {
value = Math.abs(value);
return values.every(x => Math.abs(x) >= value);
});
}
@TheDcoder
TheDcoder / sleep.js
Created February 5, 2020 11:14
sleep.js - synchronous sleep in JavaScript!
// Synchronous sleep
function sleep(ms) {
var start = performance.now();
while (performance.now() - start < ms);
}
// Calling the function will block all code in your script until the specified ms have passed
// It will also cause your CPU fans to run at full speed!
@TheDcoder
TheDcoder / background-image-url-copier.user.js
Last active April 12, 2020 15:08
Background Image URL Copier
// ==UserScript==
// @name Background Image URL Copier
// @namespace Violentmonkey Scripts
// @match *://*/*
// @noframes
// @grant GM_setClipboard
// @run-at document-start
// @version 1.3
// @author TheDcoder
// @description Started working on 4/5/2020, 11:54:15 PM
@TheDcoder
TheDcoder / gog-image-hunter.user.js
Last active April 13, 2020 05:44
GOG Image Hunter
// ==UserScript==
// @name GOG Image Hunter
// @namespace Violentmonkey Scripts
// @match https://email2.gog.com/view.html
// @noframes
// @grant GM_setClipboard
// @run-at document-start
// @version 1.1
// @author TheDcoder
// @description Started work on 12/4/2020, 8:04:15 PM
@TheDcoder
TheDcoder / pause.c
Created May 24, 2020 21:38
POSIX pause utility
#include <unistd.h>
#include <signal.h>
/* A simply utility to call the POSIX pause function,
* it will keep running and while ignoring SIGINT.
*
* Useful for simulating a hung process
*/
int main() {
@TheDcoder
TheDcoder / readfile.c
Last active June 14, 2020 14:56
readfile - Read the contents of a text file into a dynamically allocated buffer efficiently
/*
* MIT License
*
* Copyright (c) 2020 Damon Harris <TheDcoder@protonmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@TheDcoder
TheDcoder / syncthing_portable.py
Created August 29, 2020 11:29
Portable syncthing helper tool to create portable and isolated instances
#!/usr/bin/env python3
import os
import xml.etree.ElementTree as ET
HOME_DIR_NAME = '.syncport'
CMD_PARAMS = ['-no-restart']
def main():
print("Setting up portable syncthing...")