Posts

Showing posts from 2018

Add progress bar to process array requests in Ruby on Rails

index.html.erb: <div class="row" id="wrapper"> <div class="progress-files-count"></div> <div class="progress">   <div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"><span class="progress-files-percentage">0</span></div> </div> <table class="table">   <thead>     <tr>       <th scope="col">URL</th>       <th scope="col">EMAIL</th>       <th scope="col">STATUS</th>     </tr>   </thead>   <tbody>   <% @entries.each do |entry| %>     <tr>       <td><%=link_to entry[:link], entry[:link] %></td>       <td><span id="email-<%= entry[:id]%>"></spa

Update Ruby version on AWS elastic Beanstalk

aws elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2018.03 v2.8.1 running Ruby 2.3 (Puma)" --environment-name "dev-bg-123456" --region "us-east-1" Check available stacks: aws elasticbeanstalk list-available-solution-stacks { "SolutionStacks": [ "64bit Amazon Linux 2018.03 v4.16.0 running Node.js", "64bit Amazon Linux 2018.03 v2.9.11 running PHP 5.4", "64bit Amazon Linux 2018.03 v2.9.11 running PHP 5.5", "64bit Amazon Linux 2018.03 v2.9.11 running PHP 5.6", "64bit Amazon Linux 2018.03 v2.9.11 running PHP 7.0", "64bit Amazon Linux 2018.03 v2.9.11 running PHP 7.1", "64bit Amazon Linux 2018.03 v2.9.11 running PHP 7.2", "64bit Amazon Linux 2018.03 v2.9.11 running PHP 7.3", "64bit Amazon Linux 2018.03 v2.9.15 running Python 3.6", "64bit Amazon Linux 2018.03 v2.9.15 running Python 3.4", "64bit Amazon Linux 2018

React form validation and test cases.

In Component: import React , { Component } from 'react' ; import './InputForm.css' ; class InputForm extends Component { constructor ( props ) { super ( props ); this . onFormSubmit = this . onFormSubmit . bind ( this ); this . validate = this . validate . bind ( this ); this . onInputChange = this . onInputChange . bind ( this ); this . state = { fields : {}, fieldErrors : {}, }; } onInputChange ( e ) { const fields = this . state . fields ; const newFields = {}; newFields [ e . target . name ] = e . target . value ; this . setState ({ fields : {... fields , ... newFields } }); } validate ( formData ) { const errors = {}; if (! formData . name || formData . name === '' || formData . name === null ) { errors . name = 'Please enter your name.' ; } return errors ; } onFormSubmit ( e