Translate

Monday, December 26, 2016

MYSQL How to prepend a string when updating a column




In order to prepend a string when you are updating a columns is kind of easy, you only need to know the right Mysqsl function to achieve that.

Example:

For any reason, someone requested you to update the user user_login for the user ID:999  with this symbol "@" prefix to each name:

   

update users 
set user_login = concat('@', user_login)
where id = 999;


 



As you can see the function "concat" is prepending the @ to each user login.

The expected output would be


ID user_login
999 @john.doe






It is important to note that Concat allows you to add a string either at the end or at the beginning.






Tuesday, November 1, 2016

Ruby on Rails: How to upgrade bundler







To upgrade bundler, just type this command in to  the command line:
gem install bundler

To check if it was upgraded , just display the new version by typing the following command:

bundle --version

Friday, September 2, 2016

Rails - How to enable asset pipeline in development


Sometimes, for debugging purpose, it can be quite helpful to enable the Rails assets pipeline in development model.


to do this, go to config/enviroments/development.rb and add the following configuration:

config.assets.debug = false
config.assets.compile = false
config.assets.digest = true

An important thing to keep in mind is be sure  to have  config.assets.debug = true (the default setting) is disabled.

Finally, you only need to restart your server and then run:

rake assets:precompile

Git: How to rename a branch


To rename a branch created locally, what you need to do is:


  • First, go to the branch you want to rename:
git checkout my_branch_1
  • then, rename your current branch by typing the following command:
git branch -m my_new_name_branch_2



if you display all branches (git branch) you will in green color the new name of your branch

GIT: How to delete last commit?



To undo or delete a commit previously done, just type the following command in your console:


git reset --hard HEAD~1

Wednesday, June 29, 2016

How to downgrade Firefox Version on ubuntu


In  this tutorial I will show you how to downgrade your firefox version in this case from firefox 47.0 to 45.

First run this command:


apt-cache show firefox | grep Version

then you will see a list of available Firefox versions:


  • Version: 47.0+build3-0ubuntu0.16.04.1
  • Version: 45.0.2+build1-0ubuntu1

Now, run the next command to install the desired firefox version

sudo apt-get install firefox=28.0+build2-0ubuntu2


Finally, you have to avoid upgrading to the newer version.


sudo apt-mark hold firefox

And that's all.



If for any reason you do not see the version that you want, that means that version is very old.
To install a very old version of Firefox, you need to do the following:



1. First you must uninstall your current Firefox version.

  
$ sudo apt-get purge firefox

2. Then run the following command to download firefox 47.0 source code, which comes as .tar file.

 
$ wget http://ftp.mozilla.org/pub/firefox/releases/47.0/firefox-47.0.linux-i686.sdk.tar.bz2



3. Extract the package.

 $ tar -xjf firefox-47.0.linux-i686.sdk.tar.bz2


4. Move firefox to /opt directory.

 $ sudo mv firefox /opt/


5. Create symlink in order to set the new Firefox as default.

$ sudo mv /usr/bin/firefox /usr/bin/firefox_old
$ sudo
mv /usr/bin/firefox /usr/bin/firefox_old



6.  Avoid upgrading to the newer version.

$ sudo apt-mark hold firefox



Note: This is the original source [here]