{"id":19170299,"url":"https://github.com/sashadev-sky/url-shortner","last_synced_at":"2026-04-14T03:32:38.716Z","repository":{"id":122653330,"uuid":"147053877","full_name":"sashadev-sky/Url-Shortner","owner":"sashadev-sky","description":"CLI tool","archived":false,"fork":false,"pushed_at":"2018-09-03T22:15:24.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-13T03:33:18.398Z","etag":null,"topics":["cli","deprecated","launchy","postgresql","rails","rake","tasks","terminal"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sashadev-sky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-02T04:21:07.000Z","updated_at":"2019-09-16T17:57:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee1f727e-0548-4105-900b-fe1c033e057f","html_url":"https://github.com/sashadev-sky/Url-Shortner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sashadev-sky/Url-Shortner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashadev-sky%2FUrl-Shortner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashadev-sky%2FUrl-Shortner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashadev-sky%2FUrl-Shortner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashadev-sky%2FUrl-Shortner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sashadev-sky","download_url":"https://codeload.github.com/sashadev-sky/Url-Shortner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashadev-sky%2FUrl-Shortner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31781292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","deprecated","launchy","postgresql","rails","rake","tasks","terminal"],"created_at":"2024-11-09T09:53:35.689Z","updated_at":"2026-04-14T03:32:38.700Z","avatar_url":"https://github.com/sashadev-sky.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL Shortener\n\nA simple CLI tool that takes in an arbitrarily-long URL and will shorten it for the user. Subsequent users can then give the short URL back to the tool and be redirected to the original URL.\n\n## Overview\n- Written in Ruby.\n- Uses the `launchy gem` to allow us to pop open the URL in the browser without actually building in the browser.\n- To see how it works:\n  - make sure PostgreSQL is running.\n  - run `bundle install` from within the project directory.\n  - run `./setup`.\n    - if you get a permission error, run `chmod +x setup` and then `./setup` again.\n  - run `rails runner bin/cli`.\n  - when prompted for an email: enter one of the emails already in the database, which you can find in `db/seeds.rb`.\n\n## Features\n- Tracks clickthroughs for business analytics.\n- Allows users to choose from a set of predefined `TagTopic`s for links (e.g., news, music, etc.).\n  - Allows users to search for the most visited links by topic.\n- Spam protection: users cannot submit more than 5 URLs in a single minute.\n- A `premium` option is available for users: the number of total URLs non-premium users can submit is limited to 5.\n- Stale URLs can be purged from the database with the `ShortenedUrl::prune` method or by running the Rake Task `prune.rake` in `lib/tasks`.\n\n#### Concepts (personal use)\n- building a CLI tool\n- `launchy` gem\n- Base64 encoding (`SecureRandom`)\n- Associations\n  - join table\n  - `dependent: :destroy`\n- ActiveRecord methods\n  - `exists?`\n  - `::create!` vs `::new` \u0026 `#save!`\n**-\u003e use create instead of new/save syntax in factory methods because the other class calling the factory method will get returned to it a \"true\" instead of the object**\n  - `#attributes`\n- lazy evaluation of `ActiveRecord::Relation` objects\n- ActiveRecord Query Interface\n  - `select`\n    - `distinct` chained onto `select`\n  - `where`\n    - `find`, `find_by`, `find_by_#{attribute}`, etc. all return the first matching instance from the DB, `where` returns a collection of instances, regardless of the number.\n  - `joins`\n  - `group`\n  - `limit`\n  - `order`\n    - Rails 6 will need us to wrap our raw SQL in `Arel.sql`\n- ActiveRecord time methods\n  - Using the `created_at` column to interact with Time objects\n- `ActiveModel::EachValidator`\n  - custom url validation\n- client-side email validation\n- `rails runner`: loads the Rails environment for us, so we'll be able to use classes without requiring them explicitly. It also connects to the DB so we can query tables\n- creating a `Rake task`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashadev-sky%2Furl-shortner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsashadev-sky%2Furl-shortner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashadev-sky%2Furl-shortner/lists"}