Skip to content

Instantly share code, notes, and snippets.

View mrandreastoth's full-sized avatar
:octocat:
Coding...

Andreas Toth mrandreastoth

:octocat:
Coding...
View GitHub Profile
@mrandreastoth
mrandreastoth / UNetworkInterfaceMonitor.pas
Created August 9, 2023 15:24
Modern Delphi code example (Delphi 10.4.2) illustrating nested classes and types, inlined variables, etc. — requires MSI_Network.pas, from the MiTeC'c System Information Component Suite, and UTimeUtils.pas, a proprietary unit (easily replaced)
unit UNetworkInterfaceMonitor;
interface
uses
System.SysUtils,
System.Classes,
System.Generics.Collections,
System.SyncObjs,
MSI_Network,
@mrandreastoth
mrandreastoth / clean_code.md
Last active January 26, 2023 15:11 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@mrandreastoth
mrandreastoth / UMyTreeView.pas
Last active December 9, 2021 13:18
Delphi TTreeView hint fix
unit UMyTreeView;
// TMyTreeView by Andreas Toth
//
// This fixes Delphi's TTreeView hint implementation which uses tooltips instead of the application's THintWindow class.
// Note that tooltips not only look different to hints but their widths are limited to 80 characters.
interface
uses
@mrandreastoth
mrandreastoth / UTestRecord.pas
Created October 14, 2021 11:03
Delphi record usage test (tested under Delphi 2007 and 10.4.2)
unit UTestRecord;
// By Andreas Toth
//
// NOTE: The greatest mistake when using $IF is to use $ENDIF instead of $IFEND
// when writing code meant to be backwards compatible as $ENDIF is not
// supported by older Delphi versions, in particular not Delphi 2007!
// Similary, $IFDEF must be terminated by $ENDIF!
//{$DEFINE INCLUDE_ERROR_E2064_LEFT_SIDE}
@mrandreastoth
mrandreastoth / Borland.Common.Targets
Created September 7, 2021 11:12 — forked from anonymous/Borland.Common.Targets
Delphi 2007 Borland.*.Targets files that should be in C:\Windows\Microsoft.NET\Framework\v2.0.50727 and C:\Windows\Microsoft.NET\Framework64\v2.0.50727
<!--
===============================================================================================
Borland.Common.Targets
WARNING
DO NOT MODIFY unless you have made a backup of these files. Modifying
this file unless you have knowledge about MSBuild you could cause problems
when loading or building projects in the IDE or building from the
@mrandreastoth
mrandreastoth / install-kbd-backlight.sh
Created August 27, 2021 12:21 — forked from stefansundin/install-kbd-backlight.sh
Script to control keyboard backlight brightness on a Chromebook Pixel running Ubuntu. Includes extra bits like restore old session value on boot, dim keyboard on screen lock, restoring value when resuming from suspend, and so on. Relies on kernel module acpi_call (instructions below).
#!/bin/sh
# This script will install the files below.
# Please look through them first so you know what will happen.
# Install by running this command:
# curl -fL https://gist.githubusercontent.com/stefansundin/7003429/raw/install-kbd-backlight.sh | sh
# Uninstall with:
# sudo rm /opt/kbd-{backlight,lock}.sh /etc/pm/sleep.d/70-kbd-backlight
# rm ~/.config/autostart/kbd-{backlight,lock}.sh.desktop
@mrandreastoth
mrandreastoth / clop.c
Created August 27, 2021 12:19 — forked from stefansundin/clop.c
(Windows) clop.exe: like Mac's pbpaste.
// https://gist.github.com/stefansundin/9d95826a712096b24ae2
// https://devblogs.microsoft.com/oldnewthing/?p=3023
// gcc -s -o clop clop.c
// Usage:
// clop | gpg -v
// clop /u = output is printed in Unicode
// clop /a = output is printed in ANSI
// otherwise, output is printed in OEM codepage
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrandreastoth
mrandreastoth / README-Template.md
Created June 8, 2018 12:30 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@mrandreastoth
mrandreastoth / ping_and_growl.rb
Created March 12, 2018 22:21 — forked from priceflex/ping_and_growl.rb
simple network monitor with ping and growl
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'logger'
=begin
WHATIS
* ping monitoring once every 30 secs