Skip to content

Instantly share code, notes, and snippets.

View HubTou's full-sized avatar
💭
Coding for fun

Hubert Tournier HubTou

💭
Coding for fun
View GitHub Profile
@HubTou
HubTou / print_till_empty_line.awk
Created March 3, 2023 16:59
AWK 1-liner script to print a file till the first empty line
#!/usr/bin/awk -f
# Usage 0: awk '!NF{exit}{print}' file
# Usage 1: print_till_empty_line.awk file
# Usage 2: cat file | print_till_empty_line.awk
NF {exit}
{print}
@HubTou
HubTou / get_string_type_and_value.py
Last active January 21, 2023 13:49
A little Python function to deal with values of other types contained in strings, for example, for sorting purposes
import dateutil.parser
def get_string_type_and_value(string):
""" Return the type and value of the string parameter's content """
# int?
try:
value = int(string)
return "int", value
except ValueError:
pass