Skip to content

Instantly share code, notes, and snippets.

Avatar

Jad A. xv

View GitHub Profile
@xv
xv / clock.ps1
Last active Jun 15, 2022
PowerShell script utilizing .NET WinForms to create a GUI with a live clock label.
View clock.ps1
Add-Type -AssemblyName System.Windows.Forms
$Win32_ShowWindow = @'
[DllImport("user32.dll")]
public static extern bool ShowWindow(int handle, int nCmdShow);
'@
$User32 = Add-Type -MemberDefinition $Win32_ShowWindow `
-Name 'User32' -Namespace 'Win32' -PassThru
View talia-server-side-includes.md

Server Side Includes (SSI)

Apache allows users to create documents which provide simple information to clients on the fly. Such information can include the current date, the file's last modification date, and the size or last modification of other files. In its more advanced usage, it can provide a powerful interface to CGI and /bin/sh programs.

SSI Issues
SSI Setup
The SSI Format
SSI Environment Variables

SSI Issues

Having the server parse documents is a double edged sword. It can be costly for heavily loaded servers to perform parsing of files while sending them. Further, it can be considered a security risk to have average users executing commands as the server's User. If you disable the exec option, this danger is mitigated, but the performance issue remains. You consider these items carefully before activating server side includes on your server.

View talia-shell-scripting-basics.md

Shell Programming - Scripting Basics

A series of shell commands in a regular text file. Like a command batch (*.bat) file in DOS.

% cat today
#
echo -n the date today is
date
@xv
xv / ShellFileIcon.cs
Created Nov 6, 2020
Simple method to retrieve the 16x16 shell file icon using SHFILEINFO structure.
View ShellFileIcon.cs
internal const uint FILE_ATTRIBUTE_NORMAL = 0x80;
[Flags]
internal enum SHGetFileInfoFlags
{
SHGFI_LARGEICON = 0x0,
SHGFI_SMALLICON = 0x1,
SHGFI_OPENICON = 0x2,
SHGFI_SHELLICONSIZE = 0x4,
SHGFI_PIDL = 0x8,
@xv
xv / UndocumentedAcrylic.cs
Created Nov 5, 2020
Undocumented API for Windows 10 Acrylic style.
View UndocumentedAcrylic.cs
internal enum WindowCompositionAttribute
{
WCA_UNDEFINED = 0,
WCA_NCRENDERING_ENABLED = 1,
WCA_NCRENDERING_POLICY = 2,
WCA_TRANSITIONS_FORCEDISABLED = 3,
WCA_ALLOW_NCPAINT = 4,
WCA_CAPTION_BUTTON_BOUNDS = 5,
WCA_NONCLIENT_RTL_LAYOUT = 6,
WCA_FORCE_ICONIC_REPRESENTATION = 7,
@xv
xv / toggle_disk_space_warning.bat
Last active Oct 17, 2020
Tiny script to enbale/disable the "Low Disk Space" warning.
View toggle_disk_space_warning.bat
@echo off
rem Run this script as administrator
rem You may need to restart your computer to take effect
set hKey=HKLM
for /f "tokens=2 delims==." %%a in ('wmic os get version /value') do (
if %%a neq 10 set hKey=HKCU
)
@xv
xv / ColorFromHTML.cs
Created May 13, 2020
A much faster alternative to Microsoft's ColorTranslator.FromHtml() function.
View ColorFromHTML.cs
/// <summary>
/// Translates an HTML-format color value to a GDI+
/// <see cref="System.Drawing.Color"/> structure.
/// </summary>
///
/// <param name="htmlVal">
/// A 3 or 6 digit hexadecimal value to translate. Do not include the
/// leading "#" sign.
/// </param>
///
@xv
xv / mgsvtpp_gmp_address.txt
Created May 9, 2020
Static memory addresses for offline and online GMP/money values in Metal Gear Solid V: The Phantom Pain.
View mgsvtpp_gmp_address.txt
GMP Offline: mgsvtpp.exe+2BECE68
GMP Online : mgsvtpp.exe+2BECE6C
@xv
xv / InvertWindowBorder.cs
Created Mar 4, 2020
Flashes a screen-inverted rectangle around a window like in Microsoft Spy++.
View InvertWindowBorder.cs
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
[DllImport("user32.dll")]
static extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("gdi32.dll")]
static extern int SaveDC(IntPtr hWnd);
@xv
xv / cpp-cli-form-set-up.md
Created Sep 8, 2019
A really short guide on how to set up a UI form in C++/CLI.
View cpp-cli-form-set-up.md

If you are playing with C++/CLI you are probably already familiar with the C# or VB.NET way of doing WinForms, so there's nothing to be afraid of in CLI -- it is just a bit of pain in the ass at first.

Setting up the project

Assuming that you have C++/CLI installed, fire up Visual Studio and create an empty CLR project. Once the project is created, we need to let Visual Studio know what type of project (WinForms in this case) this is, as well as set an entry point for the application.

Open the project's Properties dialog (Alt+Enter) and select All Platforms from the Platform combo box. After that, you need to:

Define the project type

  1. Navigate to Configuration Properties &gt;&gt; Linker &gt;&gt; System in the tree-view control on the left side.