Skip to content

Instantly share code, notes, and snippets.

View xv's full-sized avatar
🇷🇺

Jad xv

🇷🇺
View GitHub Profile
@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>
///
@xv
xv / GuessTheNumber.py
Created March 27, 2018 18:34
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.