- Go to mysql prompt
- Type below command for getting random access password number
- select PASSWORD(‘your password’);
- GRANT ALL PRIVILEGES ON *.* TO ‘user’@’ip’ IDENTIFIED BY PASSWORD ’41 digits random number’ WITH GRANT OPTION;
Ignoring changed files from git commit
If you don’t want to show particular changed files in git commit Do follow steps
git update-index --skip-worktree FILENAME git update-index --skip-worktree FILENAME
FILENAME like your file ex config/database.yml
If you use the second command (assume-unchanged), the files will revert after git reset
command.
if You want to undo any of the above then run below command
git update-index --no-assume-unchanged FILENAME
For Live cricket score API
http://synd.cricbuzz.com/j2me/1.0/livematches.xml
http://synd.cricbuzz.com/j2me/1.0/sch_calender.xml
https://www.cricruns.com/widget/
Refer this urls for getting live score in your website
git commit revert back
- once you commit five files its stored into git object.\
- Then if you dont want revert back two files.
- Then do git reset –soft HEAD~ (it is for revert bak)
- git reset file_one
- git reset file_two
- then you can do checkout like
git checkout file_one or file_two - its same as previous file
Git conflict resolving
- git status (Shows all files that are in conflict as unmerged changed in working directory.)
- Resolve merge conflicts.
- git add <files> (conflict files)
- git commit -m “<Informative commit message>”
Use single attachment for video/image in paperclip
class Background < ActiveRecord::Base has_attached_file :background validates_attachment_presence :background validates_attachment_content_type :background, :content_type => ['video/mp4'], :message => "Sorry, right now we only support MP4 video", :if => :is_type_of_video? validates_attachment_content_type :background, :content_type => ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'], :message => "Different error message", :if => :is_type_of_image? protected def is_type_of_video? background.content_type =~ %r(video) end def is_type_of_image? background.content_type =~ %r(image) end end
what id difference b/w member route and collection route in rails
Let us take one example
resources :users do
member do
get :preview
end
end
resources :users do
collection do
get :search
end
end
A member route required id because it's act on member.
Collection route dont need id because its act as on collection of objects.
preview is an example of member route because it will display single object.
search is an example of collection route because it will display a collection of objects like index.
routes should like
member /users/1/preview preview_user_path(user)
collection /users/search search_users_url
if you want reset your table primary key from first then follow the below steps
first delete all records from table
Model.delete_all
Next reset your data from id one
ActiveRecord::Base.connection.reset_pk_sequence!(“table_name”)
Storing environment variables into my local PC
Storing environment variables into my local PC
- sudo nano ~/.profile
- ADD this nano file
- export ROLLBAR_TOKEN=b5f9c2eaf5ff4ea188e576628eba928
- Ctl + X
- ~/.profile
- echo $ROLLBAR_TOKEN (its showing token)
Clear the cache code in rails
1) addd this link to whenever you want
%li#clear_cache
%a{:href => “#{request.fullpath}#{request.fullpath.include?(‘?’) ? ‘&clear_cache=true’ : ‘?clear_cache=true’}”, :class => params[:clear_cache] == “true” ? “current” : “”}
%i.fa.fa-bars
%span Clear Cache
.clear
2) add before_filter :clear_all_cache in controller which controller you want
3) add below action in application controller
def clear_all_cache
binding.pry
if params[:clear_cache]
Rails.cache.clear
end
end