ERROR — omniauth: Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
add callback_url method in your oauth provider strategy.
module OmniAuth module Strategies class YourApplicationName < OmniAuth::Strategies::OAuth2 option :name, :application_name option :client_options, { :authorize_path => "/oauth/authorize" } uid do raw_info["id"] end info do { :email => raw_info["email"], :first_name => raw_info["first_name"], :last_name => raw_info["last_name"] } end def raw_info @raw_info ||= access_token.get('/api/v1/me.json').parsed end def callback_url full_host + script_name + callback_path end end end end
https://github.com/doorkeeper-gem/doorkeeper/wiki/Create-a-OmniAuth-strategy-for-your-provider
Reason of this error in doorkeeper 4.2.6
Solutions: Roll back to 1.3.1 or override the callback_url method in your strategy.
While upgrading from rails 3.2.22.5 to rails 4.2.6
has_many :subitems, through: :child_associations, source: :child, source_type: 'ContentItem', conditions: 'content_items.deleted 1', order: 'content_associations.position ASC'
has_many :subitems, ->{where('content_items.deleted 1')}, through: :child_associations, source: :child, source_type: 'ContentItem', order: 'content_associations.position ASC'
2. Place order in proc
has_many :subitems, ->{where('content_items.deleted 1').order('content_associations.position ASC') }, through: :child_associations, source: :child, source_type: 'ContentItem'
Short way:
Making script run at boot time at Debian
Manual Way:
cd /etc/init.d && sudo nano delayed_job_script
Paste following code to delayed_job_script:
Note: change RAILS_ROOT and ENV variables according to your setup.
#!/bin/sh
RAILS_ROOT="/home/deploy/apps/ProjectFolder/current"
ENV="production"
case "$1" in
start)
echo -n "Starting Delayed Jobs: "
su - deploy -c "cd $RAILS_ROOT && RAILS_ENV=$ENV ruby script/delayed_job start -n 3"
echo "done."
;;
stop)
echo -n "Stopping Delayed Jobs: "
su - deploy -c "cd $RAILS_ROOT && RAILS_ENV=$ENV ruby script/delayed_job stop -n 3"
echo "done."
;;
*)
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
exit 0
Make file executable:
sudo chmod +x /etc/init.d/delayed_job_script
Create links in Linux Runlevels for delayed_job_script:
sudo ln -s /etc/init.d/delayed_job_script /etc/rc0.d/K80delayed_job_script
sudo ln -s /etc/init.d/delayed_job_script /etc/rc1.d/K80delayed_job_script
sudo ln -s /etc/init.d/delayed_job_script /etc/rc1.d/etc/rc2.d/S80delayed_job_script
sudo ln -s /etc/init.d/delayed_job_script /etc/rc1.d/etc/rc3.d/S80delayed_job_script
sudo ln -s /etc/init.d/delayed_job_script /etc/rc1.d/etc/rc4.d/S80delayed_job_script
sudo ln -s /etc/init.d/delayed_job_script /etc/rc1.d/etc/rc5.d/S80delayed_job_script
sudo ln -s /etc/init.d/delayed_job_script /etc/rc6.d/K80delayed_job_script
Naming convention for link file names
In rc0.d, rc1.d and rc6.d link name starts from K which means kill command will execute. In other run levels link file name starts with S which means start process. After S/K there is number 80 which is just process priority number. After that you can write any name of your choice.
var twice = 0;
var previous_key=null;
$(document).on('keyup', function( e ){
if(twice===1){
if(e.which==previous_key)
console.log(previous_key+'(you pressed twice!)'+e.which);
else{
console.log(previous_key+'-----'+e.which);
twice = 0;
}
}else{
previous_key=e.which;
}
twice = 1;
setTimeout(function(){ // ...reset to 0 after 1s
twice = 0;
}, 1000);
});
Check java version:
java -version
Check path of installed java:
readlink -f $(which java
Note: remove /bin/java from end of path
In ~/.bashrc file add following command at the end:
export JAVA_HOME='/usr/lib/jvm/java-7-openjdk-amd64/jre/'
Now run:
source ~/.bashrc
Cause: While trying to run elasticsearch in background my elasticsearch user and group was recreated and had a new user and group id
Solution:
sudo chown -R elasticsearch:elasticsearch /var/lib/elasticsearch/
Now
sudo service elasticsearch start
sudo service elasticsearch status
This error occurred because index was corrupted or missing
Solution either re-index your documents or copy index from your backup.
In Ubuntu elastic-search data directory path is mentioned below:
/var/lib/elasticsearch/
inside this directory project wise data directories exists. Copy your data directory from here to take backup once in a day or week.
And to fix your index either copy your backup from one system to another.
OR
Use this link StackOverFlow: how to move elasticsearch data from one server to another
FATAL: permission denied for database “postgres” DETAIL: User does not have CONNECT privilege.
Run this command to solve this error:
heroku addons | grep POSTGRES
If you use the algorithm package in your LaTeX document, as mentioned below:
\usepackage{algorithm}
you might get this error on compiling it
LaTeX Error: File `algorithm.sty’ not found.
For Ubuntu, this LaTeX package is bundled in the texlive-science package. To install this package.
Run this command in terminal:
sudo apt-get install texlive-science