# Tips and Tricks (Today I learned)

**URL:** <https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125>\
**Category:** General Dev Chat\
**Tags:** community, today-i-learned, til\
**Created:** [20 January 2021 02:55 UTC](https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125 "2021-01-20T02:55:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DevotionGeo](https://forum.devtalk.com/user_avatar/forum.devtalk.com/devotiongeo/32/1140_2.png) [@DevotionGeo](https://forum.devtalk.com/u/DevotionGeo)\
**Post date:** [20 January 2021 02:55 UTC](https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125/1 "2021-01-20T02:55:03Z")

</div>

In this thread you can add any type of tips and tricks. Any feature of some language, framework, terminal, code-editor, the operating system you use, social media platform you use, or even the devtalk. Thing which you just learned, but you wish that you knew it earlier.  
  
_(You’re welcome to edit the intro)._

---

<div class="post-metadata">

**Author:** ![DevotionGeo](https://forum.devtalk.com/user_avatar/forum.devtalk.com/devotiongeo/32/1140_2.png) [@DevotionGeo](https://forum.devtalk.com/u/DevotionGeo)\
**Post date:** [20 January 2021 03:09 UTC](https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125/3 "2021-01-20T03:09:34Z")

</div>

While you cannot run `ri` commands from inside an `irb` session, you can run `ri` commands from inside a `pry` session.

> **What are ri, irb and pry?**
>
> **ri:**  
> I have seen different (very talented) people saying that it’s abbreviated from different terms, like Ruby Information, Ruby Interactive and Ruby Index. No matter which term it stands for, it’s the Ruby tool for navigating documentation.  
>   
> **irb:**  
> Interactive Ruby Shell is a REPL for Ruby.  
>   
> **pry:**  
> A runtime developer console and IRB alternative with powerful introspection capabilities (as stated on its Github page). Installable as a Gem.

 ![Screenshot from 2021-01-20 08-09-00](https://forum.devtalk.com/uploads/default/original/2X/f/fadcaaa3654ac575e9748769f3058da8cb81b0d3.jpeg)

---

<div class="post-metadata">

**Author:** ![ohm](https://forum.devtalk.com/user_avatar/forum.devtalk.com/ohm/32/559_2.png) [@ohm](https://forum.devtalk.com/u/ohm)\
**Post date:** [20 January 2021 07:30 UTC](https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125/4 "2021-01-20T07:30:59Z")

</div>

You can run `ri` from inside IRB if you do this:

```auto
def ri(*args)
  RDoc::RI::Driver.run(args)
end

```

Now you can do

```ruby
> ri 'String.length'

```

 ![Screenshot 2021-01-20 at 08.30.14](https://forum.devtalk.com/uploads/default/original/2X/d/d4093f2728d8a984bde5dd79f4f9d7fa04ab8420.jpeg)

---

<div class="post-metadata">

**Author:** ![DevotionGeo](https://forum.devtalk.com/user_avatar/forum.devtalk.com/devotiongeo/32/1140_2.png) [@DevotionGeo](https://forum.devtalk.com/u/DevotionGeo)\
**Post date:** [21 January 2021 18:55 UTC](https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125/5 "2021-01-21T18:55:25Z")

</div>

That’s nice!  
Do we need to run that function every time we open IRB or we can save it somewhere?

---

<div class="post-metadata">

**Author:** ![ohm](https://forum.devtalk.com/user_avatar/forum.devtalk.com/ohm/32/559_2.png) [@ohm](https://forum.devtalk.com/u/ohm)\
**Post date:** [22 January 2021 09:59 UTC](https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125/6 "2021-01-22T09:59:22Z")

</div>

You can put it in your `~/.irbrc` file.

I also have

```ruby
if defined? Rails
  banner = if Rails.env.production?
    "\e[41;97;1m #{Rails.env} \e[0m "
  else
    "\e[42;97;1m #{Rails.env} \e[0m "
  end

  IRB.conf[:PROMPT][:CUSTOM] = IRB.conf[:PROMPT][:DEFAULT].merge(
    PROMPT_I: banner + IRB.conf[:PROMPT][:DEFAULT][:PROMPT_I]
  )
  IRB.conf[:PROMPT_MODE] = :CUSTOM
end

```

so that it prints my Rails.env in a different color depending on developer or production.

---

<div class="post-metadata">

**Author:** ![AntonRich](https://forum.devtalk.com/user_avatar/forum.devtalk.com/antonrich/32/3165_2.png) [@AntonRich](https://forum.devtalk.com/u/AntonRich)\
**Post date:** [29 November 2022 16:32 UTC](https://forum.devtalk.com/t/tips-and-tricks-today-i-learned/6125/7 "2022-11-29T16:32:05Z")

</div>

So today I learned, sort of by accident, how to wrap any number of strokes into their separate **li** html elements.

 ![image](https://forum.devtalk.com/uploads/default/original/2X/0/00c9e4c0c7915114267413996dbb0b70da520a62.png)

I use Sublime editor. In there I pressed Ctrl+Shift+p (command pallete) and typed ‘wrap’ and found Emmet’s ‘Wrap with Abbreviation’ function.

At first I just tried **ul\>li\*5**. That wasn’t what I wanted. I just thought how could I get to the result I wanted when I started backspacing and when 5 was removed I was left with \*\*ul\>li \* \*\* it worked. Good think I noticed. Saved some precious time on googling that stuff.

Gosh, I got so excited.

 ![image](https://forum.devtalk.com/uploads/default/original/2X/c/c066cdf66b1aeab6fb4a938f2550ece77d302890.png)
