All Projects → dwyl → useful

dwyl / useful

Licence: GPL-2.0 license
🇨🇭 A collection of useful functions for working in Elixir

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to useful

go-tools
A utility tool library of Golang.
Stars: ✭ 44 (+109.52%)
Mutual labels:  utility, utils
timestampy
🕒 Bunch of utilities useful when working with UNIX timestamps
Stars: ✭ 21 (+0%)
Mutual labels:  utility, utils
Schematics Utilities
🛠️ Useful exported utilities for working with Schematics
Stars: ✭ 73 (+247.62%)
Mutual labels:  utility, utils
bat
Battery management utility for Linux laptops.
Stars: ✭ 107 (+409.52%)
Mutual labels:  utility, utils
Utils
A collection of useful PHP functions, mini classes and snippets that you need and can use every day.
Stars: ✭ 750 (+3471.43%)
Mutual labels:  utility, utils
Bash Utility
Bash library which provides utility functions and helpers for functional programming in Bash.
Stars: ✭ 92 (+338.1%)
Mutual labels:  utility, utils
Bbo
bbo is a utility library of zero dependencies for javascript. 🍖🌭🍔
Stars: ✭ 227 (+980.95%)
Mutual labels:  utility, utils
Windows10Tools
Tools for Windows 10
Stars: ✭ 45 (+114.29%)
Mutual labels:  utility
Octotab.crx
⚒ (I'm dead) A super tiny chrome extension making your Github news feed more organized.
Stars: ✭ 17 (-19.05%)
Mutual labels:  utility
i2c-exp-driver
Driver to program I2C based Onion Expansions
Stars: ✭ 33 (+57.14%)
Mutual labels:  utility
mik
The Move to Islandora Kit is an extensible PHP command-line tool for converting source content and metadata into packages suitable for importing into Islandora (or other digital repository and preservations systems).
Stars: ✭ 32 (+52.38%)
Mutual labels:  utility
aimscroll
🍹 Painless utility libary to handle scroll positions and methods in react
Stars: ✭ 12 (-42.86%)
Mutual labels:  utility
utils.js
Fast, small and purely functional utility library
Stars: ✭ 132 (+528.57%)
Mutual labels:  utils
sharyn
🌹 Sharyn – A collection of JavaScript / TypeScript packages that make your life easier and reduce your boilerplate code
Stars: ✭ 30 (+42.86%)
Mutual labels:  utility
fsimilar
find/file similar
Stars: ✭ 13 (-38.1%)
Mutual labels:  utility
tracked
Header-only C++17 library enables to track object instances with varied policies and gives you to control exceptions on policy rule break.
Stars: ✭ 12 (-42.86%)
Mutual labels:  utility
drain-js
Makes smooth transitions between two numbers.
Stars: ✭ 45 (+114.29%)
Mutual labels:  utility
csa-misc-utils
Miscellaneous samples, documents, how-tos, utilities, scripts, and other CSA tidbits
Stars: ✭ 79 (+276.19%)
Mutual labels:  utils
JetBrainsRunner
A Krunner Plugin which allows you to open your recent projects
Stars: ✭ 31 (+47.62%)
Mutual labels:  utility
DropPoint
Make drag-and-drop easier using DropPoint. Drag content without having to open side-by-side windows
Stars: ✭ 303 (+1342.86%)
Mutual labels:  utility

useful

A collection of useful functions for building Elixir Apps.

GitHub Workflow Status codecov.io Hex.pm Libraries.io dependency status contributions welcome HitCount

swiss-army-knife

Why? 🤷

We found ourselves copy-pasting a few useful "helper" functions across our Elixir projects ...
it wasn't "DRY", so we created this library.

What? 💭

A library of useful functions that we reach for when building Elixir Apps.

Who? 👤

This library is used in our various Elixir / Phoenix apps.
As with everything we do it's Open Source, Tested and Documented so that anyone can benefit from it.

How? 💻

Install ⬇️

Install by adding useful to your list of dependencies in mix.exs:

def deps do
  [
    {:useful, "~> 1.0.8"}
  ]
end

Function Reference

atomize_map_keys/1

Converts a Map that has strings as keys (or mixed keys) to have only atom keys. e.g:

# map that has different types of keys:
my_map = %{"name" => "Alex", id: 1}
Useful.atomize_map_keys(my_map)
%{name: Alex, id: 1}

Works recursively for deeply nested maps:

person = %{"name" => "Alex", id: 1, details: %{"age" => 17, height: 185}}
Useful.atomize_map_keys(person)
%{name: Alex, id: 1, details: %{age: 17, height: 185}}

flatten_map/1

Flatten a Map of any depth/nesting:

iex> map = %{name: "alex", data: %{age: 17, height: 185}}
iex> Useful.flatten_map(map)
%{data__age: 17, data__height: 185, name: "alex"}

Note: flatten_map/1 converts all Map keys to Atom as it's easier to work with atoms as keys e.g: map.person__name instead of map["person__name"]. We use the __ (double underscore) as the delimiter for the keys of nested maps, because if we attempt to use . (period character) we get an error:

iex(1)> :a.b
** (UndefinedFunctionError) function :a.b/0 is undefined (module :a is not available)
    :a.b()

stringify_tuple/1

Stringify a tuple of any length; useful in debugging.

iex> tuple = {:ok, :example}
iex> Useful.stringify_tuple(tuple)
"ok: example"

typeof/1

Returns the type of a variable, e.g: "function" or "integer" Inspired by typeof from JavaScript land.

iex> myvar = 42
iex> Useful.typeof(myvar)
"integer"

empty_dir_contents/1

Empties the directory (+deletes all files and any nested directories_) recursively, but does not delete the actual directory. This is useful when you want to reset a directory, e.g. when testing.

iex> dir = "tmp" # contains lots of sub directories and files
iex> Useful.empty_dir_contents(dir)
{:ok, dir}

Docs 📜

Detailed docs available at: https://hexdocs.pm/useful/Useful.html


Help Us Help You! 🙏

If you need a specific helper function or utility (e.g: something you found useful in a different programming language), please open an issue so that we can all benefit from useful functions.

Thanks!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].