Skip to content

Instantly share code, notes, and snippets.

💵
Available for work

Damon Harris TheDcoder

💵
Available for work
Block or report user

Report or block TheDcoder

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@TheDcoder
TheDcoder / absMin.js
Created Sep 16, 2019
Math.min in absolute terms
View absMin.js
function absMin(...values) {
return values.find(value => {
value = Math.abs(value);
return values.every(x => Math.abs(x) >= value);
});
}
@TheDcoder
TheDcoder / UNLICENSE
Last active Jul 6, 2019
strseg - Get delimiter-separated segments from a string in a non-destructive method
View UNLICENSE
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 / InteractiveCoordinateSelect.au3
Last active Feb 5, 2019
AutoIt UDF for interactively selecting a coordinate/point on the screen
View InteractiveCoordinateSelect.au3
#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 / monitor_focus.user.js
Created Oct 6, 2018
DOM Focus Tracker Userscript
View monitor_focus.user.js
// ==UserScript==
// @name DOM Focus Tracker (Console)
// @version 0.1
// @description A quick and dirty focus tracker, logs the currently focused element to console
// @include *
// ==/UserScript==
document.documentElement.addEventListener("focusout", event => console.log(event.relatedTarget === null ? "The webpage has lost focus" : event.relatedTarget), true);
@TheDcoder
TheDcoder / Example.au3
Last active Dec 11, 2017
Generate custom/fake/pseudo events in OnEvent mode in AutoIt
View Example.au3
; This snippet will show you a "hack" that you can use in GUI OnEvent mode in AutoIt
; With this hack you can create fake/pseudo events for a control in a OnEvent "handler"
; function which is registered with multiple controls.
; Usually you can get around this by using a unique function for every control
; but I like to use a single function that I use as a handler for a group of related
; controls. Looks neat and organized :)
; Let's get started!
View IsWindowNotResponding.au3
#include <WinAPISys.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: IsWindowNotResponding
; Description ...: Checks if a Window is not responding
; Syntax ........: IsWindowNotResponding($hWindow[, $iTimeout = 5000])
; Parameters ....: $hWindow - A window handle.
; $iTimeout - [optional] Shouldn't matter, Timeout in milliseconds. Default is 5000.
; Return values .: @error set by _WinAPI_SendMessageTimeout
; Author ........: Damon Harris (TheDcoder)
@TheDcoder
TheDcoder / LocalDateTime.bat
Created Oct 19, 2017
Locale-indepent way to get time and date in batch
View LocalDateTime.bat
@echo off
rem I do not claim authorship of this snippet, original source: https://serverfault.com/a/227375/414453
rem Get the time from WMI - at least that's a format we can work with
set X=
for /f "skip=1 delims=" %%x in ('wmic os get localdatetime') do if not defined X set X=%%x
echo.%X%
rem dissect into parts
set DATE.YEAR=%X:~0,4%
@TheDcoder
TheDcoder / ConvertTime12To24.au3
Last active Oct 3, 2017
12 hour to 24 hour format in AutoIt
View ConvertTime12To24.au3
; #FUNCTION# ====================================================================================================================
; Name ..........: ConvertTime12To24
; Description ...: Converts 12 hour time to 24 hour time, made while keeping _DateDiff's format in mind :)
; Syntax ........: ConvertTime12To24($sTime, $sPeriod[, $sDelimiter = ':'])
; Parameters ....: $sTime - Timestamp. (Can be a single digit or a pattern like H:M:S)
; $sPeriod - AM or PM.
; $sDelimiter - [optional] Separator between units of time. Default is ':'.
; Return values .: $sTime in 24 hour format with 0 padding
; Author ........: Damon Harris (TheDcoder)
; Remarks .......: Ensures that the first 3 parts have 0 padding if the time unit is single digit (Example 09 instead of 9)
@TheDcoder
TheDcoder / Simple SQLite Example.au3
Created Aug 6, 2017
Simple SQLite Example in AutoIt
View Simple SQLite Example.au3
#include <Array.au3>
#include <SQLite.au3>
_SQLite_Startup() ; Load the DLL
If @error Then Exit MsgBox(0, "Error", "Unable to start SQLite, Please verify your DLL")
Local $sDatabase = @ScriptDir & '\SQLiteTestDatabase.db'
Local $hDatabase = _SQLite_Open($sDatabase) ; Create the database file and get the handle for the database
_SQLite_Exec($hDatabase, 'CREATE TABLE People (first_name, last_name);') ; CREATE a TABLE with the name "People"
@TheDcoder
TheDcoder / _IEWaitForTagText.au3
Last active Oct 9, 2017
AutoIt Snippet - _IEWaitForTagText
View _IEWaitForTagText.au3
; #FUNCTION# ====================================================================================================================
; Name ..........: _IEWaitForTagText
; Description ...: Waits for a HTML tag to appear with the specified text
; Syntax ........: _IEWaitForTagText($oObject, $sTagName, $sTagText[, $iTimeout = 0[, $bNoError = True]])
; Parameters ....: $oObject - Object related to IE (Any Window, Frame, IFrame or any DOM object).
; $sTagName - Name of the HTML tag (p, img, tr, etc).
; $sTagText - The (inner) text of the tag to wait for.
; $iTimeout - [optional] Timeout for the wait in milliseconds. Default is 0 (No timeout).
; $bNoError - [optional] Temporarily disable IE errors messages in the console. Default is True.
; Return values .: Success: The DOM element's object
You can’t perform that action at this time.