|
| 1 | +# usefulib - All usefulibs |
| 2 | + |
| 3 | +## reverse_string() by @hamdivazim |
| 4 | +Reverses a string. |
| 5 | + |
| 6 | +## loop_dict() by @hamdivazim |
| 7 | +Allows you to loop through a dictionary while having access to its value, key and current loop index. |
| 8 | +Example: |
| 9 | +``` |
| 10 | +my_dict = {'a':1, 'b':2, 'c':3} |
| 11 | +
|
| 12 | +for key, val, i in loop_dict(my_dict): |
| 13 | + # Stuff here |
| 14 | +``` |
| 15 | + |
| 16 | +## find_nth_root() by @hamdivazim |
| 17 | +Returns the nth root of the number you provide. |
| 18 | + |
| 19 | +## filter_by_string() by @hamdivazim |
| 20 | +Filters a list based on whether elements contain a specific string. |
| 21 | + |
| 22 | +## filter_by_condition() by @hamdivazim |
| 23 | +Filters a list based on a specific condition.<br> |
| 24 | +How to use: |
| 25 | +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: |
| 26 | + |
| 27 | +``` |
| 28 | +lst = [0,1,2,3,4,5,6,7,8,9,10] |
| 29 | +
|
| 30 | +new_lst = usefulib.filter_by_condition(lst, "i % 2 == 0") |
| 31 | +``` |
| 32 | +The variable `i` is the element. |
| 33 | + |
| 34 | +## generate_random_string() by @hamdivazim |
| 35 | +Generates a random string using ASCII chars, digits and special chars. |
| 36 | + |
| 37 | +## generateUUID() by @hamdivazim |
| 38 | +Generates a UUID using version 4 by default but you can choose. |
| 39 | + |
| 40 | +## external_verbose_output() by @hamdivazim |
| 41 | +If you are printing a lot of data, you can use this method to write the output to log file. |
0 commit comments