Skip to content

Instantly share code, notes, and snippets.

@xv
xv / cpp-cli-form-set-up.md
Created September 8, 2019 03:17
A really short guide on how to set up a UI form in C++/CLI.

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 >> Linker >> System in the tree-view control on the left side.
@xv
xv / del_file_content.bat
Created May 18, 2019 18:56
Iterates through files of a matching extension and deletes their content while keeping the files themselves.
@echo off
rem change .txt to whatever extension you want
type nul > content
for %%f in (*.txt) do copy /y content %%f
del content
@xv
xv / GetRelativeTime.py
Created April 10, 2019 14:30
Returns the relative time (also known as 'time ago') based on the given datetime object input.
from datetime import datetime
from math import floor
def get_relative_time(dateTime):
current_time = datetime.utcnow()
time_diff = current_time - dateTime
intervals = (
(time_diff.days / 36500, "century", "centuries"),
(time_diff.days / 3650, "decade", "decades"),
@xv
xv / Commit.fs
Last active June 29, 2021 02:09
F# snippet to fetch and return the hash identifier of last commit in the specified repository using regex pattern matching.
open System.IO
open System.Net
open System.Text.RegularExpressions
open System
/// <summary>
/// Fetches the Id (SHA1 hash) of the most recent GitHub Git commit in the
/// specified repository.
/// </summary>
///