Today I Learned

Useful when you need to accept any number of parameters, but you actually don't care about them or you just want to pass them away to the superclass method.

class Bar
  def do_something(*args)
    puts "Passed args: #{args.inspect}"
  end
end

class Foo < Bar
  def do_something(*)
    super
  end
end

Foo.new.do_something("hello", "world")
#=> Passed args: ["hello", "world"]

Sometimes we do not follow all best guidelines, creating new branches because there is a point that makes no sense if you have just typo in translation and you amend your last commit or you squash your commits, there will be no harm but in situations when you must work with a teammate on sam branch there is one safer solution than

git push --force

`--force-with-lease` refuse to update a branch unless it is the state that we expect; i.e. nobody has updated the branch upstream

git push --force-with-lease

 

note: this is not a bulletproof solution but is still better than just using `--force`

here is a good article explaining it with potential pitfalls https://blog.developer.atlassian.com/force-with-lease/

If you develop gem and want to test changes in real-time without pushing code you could use path instead of git repo but this has few disadvantages if you need a test that code is working on multiple projects you need to add that change to every single project and later remember to remove this, but here come local git repos to rescue.

Simply tell bundler to use local version instead.

$ bundle config local.my_gem ~/projects/my_gem

When you are done with testing just remove the binding.

$ bundle config --delete local.my_gem

Pluck all the ID's for the ActiveRecord relation using the table's primary key

User.ids 
# the same as:
User.pluck(:id) 
#=> SELECT users.id FROM users

 

To create a hyperlink in a terminal execute following code:

echo -e '\e]8;;https://effectiva.hr\aEffectiva studio\e]8;;\a'

Result:

* some terminals may not support hyperlinks

Use this comments to "tag" commands in terminal so it's easier to find it later.

df -h #disk #useful
git reset HEAD~ #git #undo #undocommit #useful

Than you can use:

history | grep "# useful"

or reverse search with CTRL+R