Posts

Showing posts from April, 2017

Install redis server on Elastic beanstalk

In .ebextensions/ruby.config packages:   yum:     gcc-c++: []     make: [] sources:   /home/ec2-user: http://download.redis.io/releases/redis-2.8.4.tar.gz commands:   redis_build:     command: make     cwd: /home/ec2-user/redis-2.8.4   redis_config_001:     command: sed -i -e "s/daemonize no/daemonize yes/" redis.conf     cwd: /home/ec2-user/redis-2.8.4   redis_config_002:     command: sed -i -e "s/# maxmemory <bytes>/maxmemory 500MB/" redis.conf     cwd: /home/ec2-user/redis-2.8.4   redis_config_003:     command: sed -i -e "s/# maxmemory-policy volatile-lru/maxmemory-policy allkeys-lru/" redis.conf     cwd: /home/ec2-user/redis-2.8.4   redis_server:     command: src/redis-server redis.conf     cwd: /home/ec2-user/redis-2.8.4

Set database.yml in rails

Database.yml is one of the most important files in rails project, database.yml rails is actualy a configuration file. What is Contains? Database.yml is configuration file which tells rails about database, database information such as Paramter Description host  URL of the Host Machine where database is installed. If over a network then IP/Web address and if local then 127.0.0.1 database  The name of database to be selected. Rails way is mydb_development username  The username of the database chosen password  password for the user account with given username to the database adaptor  Type of database being used for the Rails application (can be any MySQL/Oracle/Sqlite... etc) pooling  Related to maximum number of connections to be made with database There are such multiple configurations here in this file. You need to write appropriate values in this configuration based on the Database you are using, and host/machine of the DB. If you want to use  MySQL Database.y

Get video duration by URL in Ruby on Rails

First install ffmpeg on your system  http://ffmpeg.org/download.html OR sudo add-apt-repository ppa:mc3man/trusty-media And confirm the following message by pressing <enter>: Also note that with apt-get a sudo apt-get dist-upgrade is needed for initial setup & with some package upgrades More info: https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media Press [ENTER] to continue or ctrl-c to cancel adding it Update the package list. sudo apt-get update sudo apt-get dist-upgrade Now FFmpeg is available to be installed with apt: sudo apt-get install ffmpeg In Controller: your_video_path =  https://s3-us-west-2.amazonaws.com/its-get-brighter-staging/uploads/video/video/2/Planking.mp4 result = `ffmpeg -i #{your_video_path} 2>&1` videotime = result.match("Duration: ([0-9]+):([0-9]+):([0-9]+).([0-9]+)")[0].split("Duration: ").last.split(".").first