Skip to content

Instantly share code, notes, and snippets.

@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>
///