Thursday, 28 January 2016

Cannot allocate memory - fork ( 2 )

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

Thursday, 21 January 2016

Set uploaded image  resizeness only for images except for files, docs or others.

  version :thumb, :if => :image? do
    process :resize_to_fit => [197, 229]
  end

  version :banner, :if => :image? do
    process :resize_to_fit => [1024, 328]
  end

  version :post, :if => :image? do
    process :resize_to_fit => [700, 400]
  end

  protected

  def image?(file)
    file.content_type.include? 'image'
  end


Thanks,
Hemant Gupta

Wednesday, 20 January 2016

Revert any of the last take pull or commit or anything.

1. git reflog

HEAD@{0}: pull heroku2 master: Merge made by the 'recursive' strategy.
a08fd72 HEAD@{1}: commit: add new banner img
11866dc HEAD@{2}: commit: add new banner img
5fd0584 HEAD@{3}: commit: changes in dislike func.
857d9ba HEAD@{4}: pull origin master: Merge made by the 'recursive' strategy.
e08788d HEAD@{5}: commit: push upload
8d9b90a HEAD@{6}: commit: visible fav icon in chrome
06b307f HEAD@{7}: pull origin master: Merge made by the 'recursive' strategy.
074fde8 HEAD@{8}: commit: notify for request


2. Revert pull or commit by setting HEAD
 git reset HEAD@{1}
 
Thanks,
Hemant Gupta 

Monday, 18 January 2016

Google map with amazing features for Rails

https://github.com/apneadiving/Google-Maps-for-Rails

http://apneadiving.github.io/

Tuesday, 12 January 2016

Add S3 Bucket for Carrierwave

First in order for carrierwave to be able to communicate with Amazon S3, it needs to have the fog gem in the project. So open up your Gemfile and add the following line:
gem "fog", "~> 1.3.1"

run bundle install.
Add carrierwave.rb to config/initializers folder, and Put the following content in this file -

# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV["AWS_ACCESS_KEY"], # required
:aws_secret_access_key => ENV["AWS_SECRET_KEY"] # required
}
config.fog_directory = ENV["AWS_BUCKET"] # required
end
restart your rails server
in your uploaders/image_uploader.rb

#storage :file ##=> Comment in
storage :fog  ##=> Comment out

 restart your rails server
 
Finally we need to push our values stored on figaro up to heroku. We can do that by running this command:

figaro heroku:set -e production

Enjoy...
Get and alter postgres user role and login as pgadmin or pg
  1. find the file pg_hba.conf - it may be located, for example in /etc/postgresql-9.1/pg_hba.conf.
    cd /etc/postgresql-9.1/
  2. Back it up
    cp pg_hba.conf pg_hba.conf-backup
  3. place the following line (as either the first uncommented line, or as the only one):
    local all all trust
  4. restart your PostgreSQL server (e.g., on Linux:)
    sudo /etc/init.d/postgresql restart
  5. you can now connect as any user. Connect as the superuser postgres (note, the superuser name may be different in your installation. In some systems it is called pgsql, for example.)
    psql -U postgres
  6. Reset password
    ALTER USER my_user_name with password 'my_secure_password';
  7. Restore the old pg_hba.conf as it is very dangerous to keep around
    cp pg_hba.conf-backup pg_hba.conf
  8. restart the server, in order to run with the safe pg_hba.conf
    sudo /etc/init.d/postgresql restart