Skip to content

Instantly share code, notes, and snippets.

Jad Altahan xv

Block or report user

Report or block xv

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
xv /
Created Sep 8, 2019
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 / del_file_content.bat
Created May 18, 2019
Iterates through files of a matching extension and deletes their content while keeping the files themselves.
View del_file_content.bat
@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 /
Created Apr 10, 2019
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 / Commit.fs
Last active Apr 10, 2019
F# snippet to fetch and return the hash identifier of last commit in the specified repository using regex pattern matching.
View Commit.fs
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>
xv /
Created Mar 27, 2018
The good ol' guess the secret number game done in Python.
import random
rand = random.randint(1000, 9999)
attempts = 0
# print rand
def check_proximity(num, guess):
:param str num: The generated random integer casted as a string.
You can’t perform that action at this time.