Blog Archives

start delayed job on reboot [sh script]

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)

Tagged with: , ,
Posted in Ubuntu

Check if same key pressed twice in 1second

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); });

Posted in Javascript

Check and export Java path and version Ubuntu

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

Tagged with:
Posted in java

Elasticsearch service not starting Ubuntu

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 referenced from

Posted in Elasticsearch

Elasticsearch 1.2.1 ::Transport::Transport::Errors::BadRequest – [400]

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

Posted in Elasticsearch

Heroku permission denied for database “postgres”

FATAL: permission denied for database “postgres” DETAIL: User does not have CONNECT privilege. Run this command to solve this error: heroku addons | grep POSTGRES

Tagged with: , ,
Posted in Heroku, Uncategorized

LaTeX | error algorithm.sty not found [Ubuntu 14.04]

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

Tagged with: ,
Posted in Latex

Connect with MongoDB on separate EC2 Instance

You need to open mongoDB port to world so that you can listen inbound traffic. To do so: In instance security group -> Inboud Open 27017 port or whatever port on which your mongoDB is currently running. Type Protocol Port

Tagged with: , , ,
Posted in amazon, EC2, mongodb, mongoid

Ubuntu Server Basic Libraries [ with SSL, nokogiri, postgress and nodjs ]

To install basic tools and nokogiri libraries sudo apt-get install git build-essential patch ruby-dev zlib1g-dev liblzma-dev sudo apt-get install -y libssl-dev libreadline-dev Uglifier required library sudo apt-get install nodejs Postgres required library sudo apt-get install libpq-dev Install and Setup Nginx

Tagged with:
Posted in Nokogiri, postgres, Ubuntu

Create and integrate SSL certificate in Rails app Using [ Godaddy + Nginx(1.8) + Puma + Ubuntu Server(14.04 LTS) ]

Login to your server by ssh and then: Create file YOUR_RAILS_APP_DIRECTORY/config/puma.rb Below is puma.rb file content: #!/usr/bin/env puma directory ‘/home/ubuntu/YOUR_RAILS_APP_DIRECTORY/public/’ rackup ‘/home/ubuntu/YOUR_RAILS_APP_DIRECTORY/config.ru’ environment ‘production’ daemonize true pidfile ‘/home/ubuntu/YOUR_RAILS_APP_DIRECTORY/tmp/pids/puma.pid’ state_path ‘/home/ubuntu/YOUR_RAILS_APP_DIRECTORY/tmp/pids/puma.state’ stdout_redirect ‘/home/ubuntu/YOUR_RAILS_APP_DIRECTORY/log/puma.log’ threads 2, 5 bind ‘unix:///home/ubuntu/YOUR_RAILS_APP_DIRECTORY/tmp/sockets/puma.sock’ workers 2 Generate

Tagged with: , , ,
Posted in amazon, DNS, Godaddy, Nginx, production, Puma, Ruby on Rails, Ubuntu
StackOverFlow
Categories
Archives