Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 2.13 KB

ALLFUNCTIONS.md

File metadata and controls

58 lines (44 loc) · 2.13 KB

usefulib - All usefulibs

reverse_string() by @hamdivazim

Reverses a string.

loop_dict() by @hamdivazim

Allows you to loop through a dictionary while having access to its value, key and current loop index. Example:

my_dict = {'a':1, 'b':2, 'c':3}

for key, val, i in loop_dict(my_dict):
    # Stuff here

find_nth_root() by @hamdivazim

Returns the nth root of the number you provide.

filter_by_string() by @hamdivazim

Filters a list based on whether elements contain a specific string.

filter_by_condition() by @hamdivazim

Filters a list based on a specific condition.
How to use: condition property is a string. If you wanted to filter a list based on whether the element (suppose is going to be an integer) was even or not, you would:

lst = [0,1,2,3,4,5,6,7,8,9,10]

new_lst = usefulib.filter_by_condition(lst, "i % 2 == 0")

The variable i is the element.

generate_random_string() by @hamdivazim

Generates a random string using ASCII chars, digits and special chars.

generateUUID() by @hamdivazim

Generates a UUID using version 4 by default but you can choose.

external_verbose_output() by @hamdivazim

If you are printing a lot of data, you can use this method to write the output to log file.

get_hash() by @MKM12345

This takes a string as input, hashes it using the SHA-256 algorithm, and returns the hexadecimal representation of the hash value.

denary_to_ternary() by @AtomicCodeLegend

Converts from denary to ternary

calculate_fibonacci() by @TheCodingLedendoftheNether

This calculates and returns the nth Fibonacci number using recursion.

is_palindrome() by @TheCodingLedendoftheNether

This checks whether a given string is a palindrome, meaning it reads the same backward as forward.

convert_base by @ShadowStrike-Atomiser

Converts from one base to another (base 2-16).

Extract Bytes from File: extract_bytes(filename, arg1, arg2) by @Cracko298

Convert Bytes to Integer: convert_bytes(bytestring,order="") by @Cracko298

Sort List of Numbers: qsort(numlist, start, end) by @silas-wr

Sorts the numbers from numlist[start] to numlist[end] using the quicksort algorithm.