Translate

Wednesday, June 21, 2017

Jquery DatePicker - How to Reset Date



Sometimes,  when you are working with jquery hiding elements or showing some elements, you might need to reset Datepicker to avoid sending a wrong date.



This code will allow you to reset the date by setting a null value in the date selector



var my_date = $('#my_birthday').datepicker();
$('#btn-clear-date').on('click', function () { my_date.datepicker('setDate', null);
});

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