Posts

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

Display title, description and image by sharing URL on facebook

Put below meta tags into your web application:   <meta property="fb:app_id" content="768103839966918" />   <meta property="og:title" content="Nice title" />   <meta property="og:type" content="article" />   <meta property="og:author" content="Arvind" />   <meta property="og:description" content="This is nice description here" />   <meta content="https://dreamermade-staging.s3.amazonaws.com/uploads/project/image/17/project_bittern-square-logo.png" itemprop="image">   <meta content='https://dreamermade-staging.s3.amazonaws.com/uploads/project/image/17/project_bittern-square-logo.png' property="og:image" >   <meta content="690" property="og:image:width">   <meta content="225" property="og:image:height">   <meta content="origin" id="

Get Gmail contacts in Ruby on rails

>> If you are looking for the functionailty for fetching the  google contacts  than you can follow the below mentioned instructions. >> Firstly You need to define the  google contact and contact groups url  in the scope for fetching the google contacts. It will allow our retrieve access token to use google contact api. >> We can define multiple scopes with the google keys :    config.omniauth :google_oauth2, client_id, client_secret, {       name: 'google',       scope: 'email https://www.google.com/m8/feeds/'   } >> In the scope I have defined  email  for   ( user's email access access )  and  https://www.google.com/m8/feeds/  for  ( read/write access to Contacts and Contact Groups ) >> I am assuming you have added the omniauth-google-oauth2 gem and added the functionality of auth login. >> After successful auth login when you will return back to the website using callback method with some josn. You can see that us

Adaptive paypal to pay multiple paypal accounts at once

Add gem:  gem 'paypal-sdk-adaptivepayments' In views: <div class="modal-body">               <%= form_for cart.build_payment, class: "form-horizontal", role: "form" do |f| %>                 <%=  f.hidden_field :cart_id, :value => cart.id %>                 <% url = "#{baseUrl}/subscriptions/subscription_create?cart_id=#{cart.id}&subscriptions=true" %>                 <%=  f.hidden_field :url, :value => url %>                 <div class="form-group">                   <label class="control-label col-sm-2" for="email">First Name:</label>                   <div class="col-sm-10">                     <%= f.text_field :first_name, class: "form-control", placeholder: "Enter the First Name", required:true %>                   </div>                 </div>                 <div class=&qu

Enable gzip compression on Elastic Beanstalk with nginx

Create nginx_gzip_configuration.config file into .ebextensions directory and then put the following script. files:   "/etc/nginx/conf.d/gzip.conf":       mode: "644"       owner: "root"       group: "root"       content: |         # enable gzip compression         gzip on;         gzip_min_length  1100;         gzip_buffers  4 32k;         gzip_types    text/plain text/html text/xml text/css application/javascript application/json;         gzip_vary on;         # end gzip configuration container_commands:   02_restart_nginx:     command: service nginx restart

Enable gzip configuration in nginx web server on VPS

To change the Nginx  gzip  configuration, open the main Nginx configuration file in  nano  or your favorite text editor. sudo nano /etc/nginx/nginx.conf Find the  gzip  settings section, which looks like this: ## # `gzip` Settings # # gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_min_length 256; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; .. Save and close the file to exit. To enable the new configuration, restart Nginx. sudo service nginx restart

Install SQL sever on Ubuntu

Install SQL Server To install the mssql-server Package on Ubuntu, follow these steps: Enter superuser mode. Copy bash sudo su Import the public repository GPG keys: Copy bash curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - Register the Microsoft SQL Server Ubuntu repository: Copy bash curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list > /etc/apt/sources.list.d/mssql-server.list Exit superuser mode. Copy bash exit Run the following commands to install SQL Server: Copy bash sudo apt-get update sudo apt-get install -y mssql-server After the package installation finishes, run the configuration script and follow the prompts. Copy bash sudo /opt/mssql/bin/sqlservr-setup Once the configuration is done, verify that the service is running: Copy bash systemctl status mssql-server Next steps Install tools If you already have SQL Server tools,  connect to the SQL Se

Upwork Desktop app not working on Ubuntu

Download (64 bit) wget http : //launchpadlibrarian.net/233346181/libnss3_3.19.2.1-0ubuntu0.14.04.2_amd64.deb (32 bit) wget http : //launchpadlibrarian.net/233346229/libnss3_3.19.2.1-0ubuntu0.14.04.2_i386.deb Install sudo dpkg - i libnss3_3 . 19.2 . 1 - 0ubuntu0.14 . 04.2 _amd64 . deb Upwork app should work by now (Tested).

Angular filter with select tag and input value

javascript: var app = angular . module ( 'appX' , []); app . controller ( 'ctrlX' , function ( $scope ) { $scope . dataSet = [{ firstname : 'first 1' , lastname : 'last 1' , age : '24' , sex : 'F' }, { firstname : 'first 2' , lastname : 'last 2' , age : '21' , sex : 'M' }, { firstname : 'first 3' , lastname : 'last 3' , age : '24' , sex : 'M' }, { firstname : 'first 4' , lastname : 'last 4' , age : '26' , sex : 'F' }]; $scope . keyList = []; angular . forEach ( $scope . dataSet , function ( val , key ) { angular . forEach ( val , function ( v , k ) { if ( $scope . keyList . indexOf ( k ) < 0 ) { $scope . keyList . push ( k ); } }) }) }) app . filter ( 'mycust