Code Monkey home page Code Monkey logo

encoded_id's Introduction

Hi there ๐Ÿ‘‹

While I started off coding in various other languages for the past 9 years I have been working with Ruby and am loving it โค๏ธ

Recently, since Hacktoberfest '22 and reading How To Open source by Richard Schneeman, I have been inspired to contribute back so have been focusing more on open source.

I maintain a number of gems (all extracted from projects I have worked on) which I use in production apps today.

Have a look on Rubygems.

gems include:

  • vident - Vident is the base of your design system implementation, which provides helpers for working with Stimulus. For component libraries with ViewComponent or Phlex.
  • typed_operation - Command pattern, which is callable, and can be partially applied, curried and has typed parameters
  • claret - Experiment in adding type information to Ruby via transpilation
  • encoded_id & encoded_id-rails - encode numerical & hex IDs (eg record primary keys) into obfuscated strings. The obfuscated strings are reversible, so you can decode them back. Supports encoding multiple IDs at once, and generating IDs with custom alphabets and separators to make the IDs easier to read or share.
  • ai_refactor - AI Refactor is an experimental tool to see how AI can be applied to bulk refactor code.
  • quo - query objects for ActiveRecord that are composable.
  • yaml_csp_config - provides you with a way to manage your Rails 5.2+ CSP configuration via a YAML file. The CSP configuration can also be extended by environment variables.
  • fixtures_from_factories - tool to help build a set of Fixtures for your Rails app, using your test suite's FactoryBot factories.

Other recent contributions:

Some only very small contributions but I hope to do more soon!

Things I support and hope you might too:

Happy to connect:

stevegeek's GitHub | Stats stevegeek's GitHub | Stats

encoded_id's People

Contributors

avcwisesa avatar jugglebird avatar stevegeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

encoded_id's Issues

Add new option to limit maximum length of encoded IDs

Add a new option to ReversibleId#initialize which specifies the maximum length an encoded ID can be (max_length)

The option should have a default value (say 128).

The option should be used in #encode, #decode, #encode_hex and #decode_hex.

On encoding, this limit value is used to check the generated encoded_id size before returning it.
If the generated encoded_id length is greater than max_length, raise a EncodedId::EncodedIdLengthError error

On decoding this limit should be used to check the input string before performing any operations.
If the input length is greater than max_length, raise a EncodedId::InvalidInputError error

The errors subclasses are all defined in lib/encoded_id.rb.

Note that a max_length of nil should result in no checks being made against the encoded_id and input lengths.

Please also add to the README.md to describe the option.

Add new option to limit the number of IDs that can be encoded together

Add a new option to ReversibleId#initialize which specifies the maximum number of IDs that be encoded into any one encoded_id (max_inputs_per_id)

The option should have a default value (say 32).

The option should be used in #encode, & #encode_hex

If the input size is greater than max_inputs_per_id then raise InvalidInputError with an appropriate message

V2, use Sqids instead of hashids? `https://github.com/sqids/sqids-ruby`

Sqids replace hashids , see https://sqids.org/ruby but are not backwards compatible

Upgrading to a v2 will require using a prefix on any new IDs to allow you to differentiate and if you have hash ID type ids in the wild, you will need to run both side by side and pick the right decoder... maybe the library can do this for you, ie be configured to support decoding older hashids (eg by identifying them someway, eg by format)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.