text:
Q: For Each Loop in Thymeleaf not retunring results I've used this method to filter through a list of objects before, so I have no clue why this one isn't working. There are three results that should be showing up in this table, instead I get No results found. In the controller function, if I debug it, I see it is registering the contactList... so not sure why it's not populating in the table. I keep getting this not binded error: Neither BindingResult nor plain target object for bean name 'contactList[0]' available as request attribute. I'm not sure how to go about binding it.
Here is the table that isn't populating. The whole HTML page runs through CarrierAppointment as the object.

    Contact Type
    Contact Name
    Contact's Email
    Contact's Phone
    <button type="submit" name="addCommercialContact" class="btn btn-default" ></button>

         <select class="form-control" th:field="*{contactList[__${stat.index}__].contactType}">
            <option value="Account Manager">Account Manager</option>
            <option value="Marketing Manager">Marketing Manager</option>
            <option value="Underwriter">Underwriter</option>
        </select>
         <input type="text" class="form-control" th:field="*{contactList[__${stat.index}__].contactName}"/>
         <input type="text" class="form-control" th:field="*{contactList[__${stat.index}__].contactEmail}"/>
        <input type="text" class="form-control" th:field="*{contactList[__${stat.index}__].contactPhone}"/>
         <input type="hidden" class="form-control" th:field="*{contactList[__${stat.index}__].contactTable}" th:value="Commercial Lines"/>
         <button type="submit" name="removeContact" th:value="${stat.index}" class="btn btn-danger"></button>

Here is the controller function:
       @RequestMapping(value="/carrierAppointment/details/{id}")
public String viewDetails(Model model,@PathVariable("id")CarrierAppointment carrierAppointment){
    String username= SecurityContextHolder.getContext().getAuthentication().getName();
    Role role=roleRepository.findByUsernameContainingIgnoreCaseAndActive(username,true);
    Document newDoc=new Document();

    List<CarrierContact> contactList = new ArrayList<>();
    CarrierContact contact = new CarrierContact();
    contactList.add(contact);

    model.addAttribute("contact",contact);
    model.addAttribute("role",role);
    model.addAttribute("newDocument",newDoc);
    model.addAttribute("docs",documentRepository.findByCarrierAppointment(carrierAppointment));
    model.addAttribute("carrier",carrierAppointment);
    model.addAttribute("contactList",contactList);
    return "carrierAppointments/carrierDetails";
}

Contact Model
@Entity
@Table(name="CarrierContact")
public class Contact {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="contactId")
    private Long id;
    private String contactType;
    private String contactName;
    private String contactEmail;
    private String contactPhone;
    private Long carrier;
    private String contactTable;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getContactType() {
        return contactType;
    }

    public void setContactType(String contactType) {
        this.contactType = contactType;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public String getContactEmail() {
        return contactEmail;
    }

    public void setContactEmail(String contactEmail) {
        this.contactEmail = contactEmail;
    }

    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

//    public CarrierAppointment getCarrier() {
//        return carrier;
//    }
//
//    public void setCarrier(CarrierAppointment carrier) {
//        this.carrier = carrier;
//    }
//
    public Long getCarrier() {
        return carrier;
    }

    public void setCarrier(Long carrier) {
        this.carrier = carrier;
    }

    public String getContactTable() {
        return contactTable;
    }

Carrier Appointment Model:
@Entity
@Table(name="CarrierAppointment")
@EntityListeners(AuditingEntityListener.class)
public class CarrierAppointment {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CarrierAppointmentId")
    private Long id;
    private String parentCompanyCarrier;
    private String writingCompany;
    private String masterAgencyCode;
    private String serviceCenterCode;
    private String affiliateSubcode;
    private String clMarketingContact;
    private String plMarketingContact;
    private String clUnderwriterContact;
    private String plUnderwriterContact;
    private String plAccountManager;
    private String clAccountManager;
    private String supportDesk;
    private String licensingDept;
    private String custServiceDept;
    private String loginPasswordRequirements;
    private String quotingWebsite;
    private String states;
    private String appetite;
    private String affiliateUseOfLogo;
    private String premiumVolumeRequirementForAffiliateSubcode;
    private String notes;
    private String knownForPersonal;
    private String knownForCommercial;
    private String linesOfBusiness;
    @CreatedDate
    private LocalDateTime createdDate;
    @LastModifiedDate
    private LocalDateTime lastModifiedDate;
    private Boolean carrierDownloads;

    @OneToMany(
            cascade = CascadeType.ALL
    )
    @JoinColumn(name = "carrier")
    private List<Contact> contactList= new ArrayList<>();

    public List<Contact> getContactList() {
        return contactList;
    }

    public void setContactList(List<Contact> contactList) {
        this.contactList = contactList;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getParentCompanyCarrier() {
        return parentCompanyCarrier;
    }

    public void setParentCompanyCarrier(String parentCompanyCarrier) {
        this.parentCompanyCarrier = parentCompanyCarrier;
    }


text:
Q: $U = \{v\in V|\phi(v) = 0\ \text{for every }\phi\in U^0\}$ Is the following Proof Correct?
Theorem.  Given that $V$ is finite-dimensional and $U$ is a subspace of $V$
$$U = \{v\in V|\phi(v) = 0\ \text{for every }\phi\in U^0\}$$
Proof. Let $H =  \{v\in V|\phi(v) = 0\ \text{for every }\phi\in U^0\}$. The proof of the proposition $U\subseteq H$ is trivial we therefore prove the converse $H\subseteq U$.
Let $u_1,u_2,...,u_n$ be a basis for $U$ which we may extend to yield a basis for $V$ namely $u_1,u_2,...,u_n,u_{n+1},u_{n+2},...,u_m$, furthermore let $\phi_1,\phi_2,...,\phi_n,...,\phi_{n+1},\phi_{n+2},...,\phi_m$ be the corresponding dual basis for $V'$.
Now let $v = c_1u_1+cu_2+\cdot\cdot\cdot+c_nu_n+c_{n+1}u_{n+1}+c_{n+2}+\cdot\cdot\cdot+c_{m}v_m$ be an arbitrary vector in $H$. It is not difficult to see that $U^0 = \operatorname{span}(\phi_{n+1},\phi_{n+1},...,\phi_{m})$.
Since $\phi(v) = 0$ for all $\phi\in H$ then in particular for $\phi_{n+1},\phi_{n+1},...,\phi_{m}$ we have $\phi_{n+1}(v) = c_{n+1} = \phi_{n+2}(v) = c_{n+2} = \cdot\cdot\cdot = \phi_{m}(v)  = c_{m} = 0$ consequently $v\in\operatorname{span}(u_1,u_2,...,u_n) = U$.
$\blacksquare$

A: It looks correct, but:

*

*There's a typo. You wrote $\operatorname{span}(\phi_{n+1},\phi_{n+1},\ldots,\phi_{m})$ where you meant $\operatorname{span}(\phi_{n+1},\phi_{n+2},\ldots,\phi_{m})$.

*You ought to justify the assertion that $U^0=\operatorname{span}(\phi_{n+1},\phi_{n+2},\ldots,\phi_{m})$.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Convert Raw SQL Query to Laravel Eloquent using eager loading I'm having great difficulty in trying to convert the following query into an Eloquent one.
SELECT Sum(t.amount) AS amount,
       m.name
FROM   transactionsv2 t
       JOIN channels c
         ON t.entityid = c.uuid
       JOIN merchants m
         ON c.sender = m.uuid
WHERE  t.paymenttype = 'DB'
       AND t.status = 1
       AND t.processing_time >= '2019-01-01'
       AND t.processing_time < '2019-01-21'
GROUP  BY m.name;

This is what I have but the result set is not right...
public function getTransactionsVolumeReport()
{
    $report = Transaction::select(DB::raw('sum(amount) as amount, entityId'))
        ->where('paymentType', '=', 'DB')
        ->where('status', 1)
        ->where('processing_time', '>=', '2019-01-01 00:00:00')
        ->where('processing_time', '<=', '2019-01-21 23:59:59')
        ->with(['channel' => function ($q) {
            $q->select('uuid', 'name', 'sender');
        }])
        ->with(['channel.merchant' => function ($q) {
            $q->select('uuid', 'name')
                ->groupBy('name');
        }])
        ->get();

    echo $report;
}

These are the queries that Laravel debugbar is showing...

Below are my Eloquent relationships...

Transaction Model

protected $with = ['channel', 'statusPayment'];

public function channel() {

    return $this->hasOne(Channel::class, 'uuid', 'entityId');
}

-----

Channel Model

protected $with = ['merchant', 'attachedMerchantAccount'];

public function merchant() {

    return $this->hasOne('App\Merchant', 'uuid', 'sender');
}


text:
Q: Why this program runs in infinite loop? Mutual exclusion Below is the java program with which i started learning about mutual exclusion.
class MutexVar{
    public static int Turn = 1;
}

class CriticalSection{
    private static int modelNumber =0;
    public static void setModelNumber(int number){
        modelNumber = number;
    }

    public static int getModelNumber(){
        return modelNumber;
    }
}

public class MutualExclusion{
    public static void main(String[] args){
        Thread threadObjRef = new Thread(new Runnable(){
            public void run(){
                int autoVar = 1;
                int newModelNumber = -1;
                while(true){
                    /*                               Non - critical section - start   */
                    System.out.println("\n" + "In  run() thread");
                    /*                               Non - critical section - end     */
                    while(MutexVar.Turn == 2){
                        //System.out.println("loop-run"); //infinite loop problem is here
                    }
                    /*                               Critical Section -start          */
                    CriticalSection.setModelNumber(autoVar);
                    newModelNumber = CriticalSection.getModelNumber();
                    MutexVar.Turn = 2;
                    /*                               Critical Section -end            */

                    /*                               Non - critical section - start   */
                    System.out.println("run() thread: " + newModelNumber + "\n");
                    autoVar = autoVar + 2;
                    /*                               Non - critical section - end     */
                }
            }
        });
        threadObjRef.start();
        int autoVar = 0;
        int newModelNumber = -1;
        while(true){

            /*                                       Non - critical section - start    */
            System.out.println("\n" + "In  main thread");
            /*                                       Non - critical section - end      */
            while(MutexVar.Turn == 1){
                //System.out.println("loop-main"); //infinite loop problem is here
            }
            /*                                       Critical Section -start           */
            CriticalSection.setModelNumber(autoVar);
            newModelNumber = CriticalSection.getModelNumber();
            MutexVar.Turn = 1;
            /*                                       Critical Section -end             */

            /*                                       Non - critical section - start    */
            System.out.println("main- thread: " + newModelNumber + "\n");
            autoVar = autoVar + 2;
            /*                                       Non - critical section - end      */
        }
    }
}

My question:
1) Is there a data race between two threads to set MutexVar.Turn?
2) If no, then this program looks good to me, But my program loops infinitely with below output. why infinite loop loop-run or loop-main?
In  main thread

In  run() thread
run() thread: 1

In  run() thread

My observation:
This looks like a Thread scheduling issue. I learnt that java threads are visible to windows OS because they are created internally using CreateThread() api of kernel32.dll and scheduled by OS as 1-1 threading model in windows. java program runs using java jdk 1.6 on windows 7 multi core OS.

A: Read your code wrong at first. Looks like you have a stale value.
MutexVar.Turns value is never flushed for other threads to see the latest change. If you changed Turn to be declared as volatile or synchronized on some common lock when you read and write to the common variable shared between threads then you'll probably find MutexVar.Turns value to change.

A: Always synchronize access to shared mutable data.  It's not exactly obvious what the JIT/CPU is doing but you are almost certainly running into thread-caching issues by using a non-volatile Turn.  Declare MutrexVar as
static class MutexVar {
    public static volatile int Turn = 1;
}

Volatile on a keyword says, Each thread that reads this value will have the most up-to-date value and prohibits compiler reorderings.

A bit more detail of compiler re-orderings.  The JIT compiler is able to take your code and hoist the read of Turn.  For example it can transform
while(MutexVar.Turn == 1){
    //System.out.println("loop-main"); //infinite loop problem is here
}

into
if(MutexVar.Turn == 1) {
    while(true) {
        //System.out.println("loop-main"); //infinite loop problem is here
    }
 }

This in no way violates Java's compiler contract and can improve performance dramatically.  Declaring the field volatile prevents this type or re-ordering.


text:
Q: Import Google or iCal calendar data into a google spreadsheet I am trying to keep a record of google calendar entries in a google spreadsheet to further process the data. I have the following code, which I borrowed from other sources:
function importEvents(){
var startOfDay = new Date();
  startOfDay.setUTCHours(0);
  startOfDay.setMinutes(0);
  startOfDay.setSeconds(0);
  startOfDay.setMilliseconds(0);
var endOfDay = new Date(startOfDay.getTime() + 24 * 60 * 60 * 1000);
var Calendar = CalendarApp.getCalendarById("[calendarIDhere]");
var events = Calendar.getEvents(startOfDay, endOfDay)
var events_sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ImportedEvents");
var lr = events_sheet.getLastRow();
var eventarray = new Array();
var i = 0; // edited
 for (i = 0; i < events.length; i++) {
  line = new Array();
  line.push(events[i].getTitle());
  line.push(events[i].getDescription());
  line.push(events[i].getStartTime());
  line.push(events[i].getEndTime());
  eventarray.push(line);
 }

events_sheet.getRange('A1:D' + (lr)).setValues(eventarray);

var l = events_sheet.getLastRow();
var m = events_sheet.getMaxRows();
events_sheet.deleteRows(l+1,m-l);
}

Getting errors with the .getRange() function regarding incorrect height of data

A: If you're setting values on a range, your range has to match the size of the values array in both columns and rows.
Instead of the following line:
events_sheet.getRange('A1:D' + (lr)).setValues(eventarray);

Try this:
events_sheet.getRange('A1:D' + eventarray.length).setValues(eventarray);


text:
Q: Error CS1674 trying to open second form I'm sure, this is a total newbie question, but I'm hanging for hours now...
My main form should have a method that opens a second form with a textbox. Just to have a kind of messagebox with scrollbar. I know there are lots of examples out there, but they are all too extensive for my needs. So here is my code so far:
private void ShowBox (string info)
{
    if (info != "")
    {
        using (var form = new Message())
        {
             // work to do
        }
    }
}

public partial class Message : Form
{
    public Message()
    {
        InitializeComponent();
        say.Text = "OK";
    }
}

Message is my 2nd form. I receive CS1674 (type used in a using statement must be implicitly convertible to 'System.IDisposable') error on the using line.
I already took this as reference Opening and closing form2 from form1 C# but I don't see the difference to my code.
What am I doing wrong?

A: Message probably resolves as System.Windows.Forms.Message which is a structure.
Ctrl+Click on your usage of new Message() will jump to the declaration.

A: In namespace System.Windows.Forms there is already a struct named Message. Seems like the compiler confounds your class with that. You should rename your form to something like MessageForm.


text:
Q: traefik logrotate access log docker volume I'm trying to logrotate access logs with traefik docker on the host. When logrotate run it create a new log file, great, but it always to zero like if the docker volume was not remount. On traefik docker the access log still continue to grow. What is the trick to logrotate my access log ? thx
my /etc/logrotate.d/traefik
/var/www/traefik_access.log {
  size 10K
  rotate 30
  missingok
  notifempty
  compress
  dateext
  dateformat .%Y-%m-%d
  create 0644 www-data www-data
  postrotate
    docker kill --signal="USR1" traefik
  endscript
}

my docker-compose.yml :
version: '3'

services:
  traefik:
    image: traefik:latest
    container_name: traefik
    restart: always
    ports:
    - 80:80
    - 443:443
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - ./traefik.toml:/traefik.toml
    - ./acme.json:/acme.json
    - ./traefik_access.log:/access.log
    networks:
    - web

my files
-rw-r--r--  1 www-data www-data  1818 août   7 11:30 traefik_access.log.2019-08-07.gz
-rw-r--r--  1 www-data www-data     0 août   7 11:30 traefik_access.log

A: I faced the same issue with 'traefik:chevrotin'.
I found a solution at this How to enable logrotation for traefik? thread thanks to @anastymous comment.
For the USR1 signal to be correctly applied, in the docker-compose.yml you need to bind a log directory where logs are located instead of binding each log files.
Successful logrotation at signal USR1 received:
OK docker-compose.yml
services:

  traefik:
    image: "traefik:chevrotin"
    container_name: "traefik"
    restart: "unless-stopped"
    command:
      - "--log.level=DEBUG"
      - "--log.filePath=/logs/traefik.log"
      - "--accessLog.filePath=/logs/access.log"
    volumes:
      - "/var/log/traefik:/logs" #make sure to touch log files before starting container

Failed logrotation at signal USR1 received:
NOK docker-compose.yml
services:

  traefik:
    image: "traefik:chevrotin"
    container_name: "traefik"
    restart: "unless-stopped"
    command:
      - "--log.level=DEBUG"
      - "--log.filePath=/logs/traefik.log"
      - "--accessLog.filePath=/logs/access.log"
    volumes:
      - "/var/log/traefik.log:/logs/traefik.log"
      - "/var/log/traefik-access.log:/logs/acccess.log"

Hope it can helps !


text:
Q: Scala - java.lang.VerifyError with simple function Actually I use my code in a html parser. But here I rewrite it for test.
def parse: Int = {
  var texts = Array("a.b.c.d.1321,123.f")
  for (text <- texts) {
    var lines = text.split("\\.")
    return try { lines(4).replaceAll("[^0-9]", "").toInt } catch { case _ => 0 }
  }
  0
}

Call parse, I got this exception:
java.lang.VerifyError: (class: $anonfun$parse$1, method: apply signature: (Ljava/lang/String;)Lscala/runtime/Nothing$;) Inconsistent stack height 0 != 3
        at .parse(<console>:10)
        at .<init>(<console>:10)
        at .<clinit>(<console>)
        at .<init>(<console>:11)
        at .<clinit>(<console>)
        at $print(<console>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
        at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
        at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
        at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
        at java.lang.Thread.run(Thread.java:722)

My question is why does the code raise that exception?
Edited
Please don't mention about the coding style, just focus on the exception. Because the code can be compiled successfully.
Edited
Change a little of result:
def parse: Int = {
  var texts = Array("a.b.c.d.1321,123.f")
  for (text <- texts) {
    var lines = text.split("\\.")
    return try { lines(4).replaceAll("[^0-9]", "").toInt } catch { case _ => -1 }
  }
  0
}

If I don't use for loop, it is ok:
def parse: Int = {
  var text = "a.b.c.d.1321,123.f"
  var lines = text.split("\\.")
  return try { lines(4).replaceAll("[^0-9]", "").toInt } catch { case _ => -1 }
}

But I'm still confused about the first case.

A: It seems to be because you're returning the result of the entire try block.  If you move your return inside the block, it's fine:
try { return lines(4).replaceAll("[^0-9]", "").toInt } catch { case _ => return 0 }

It looks like a compiler bug related to returning the try block inside a for loop.  Notice that this works fine:
def parse: Int = {
  return try { 1 } catch { case _ => 0 }
  0
}

while this fails:
def parse: Int = {
  for (x <- List(1))
    return try { 1 } catch { case _ => 0 }
  0
}


text:
Q: certain characters behaving unusually within htmlentities function So first I noticed when an ampersand (&) is in the htmlentities function it will count the ampersand as 5 characters. So this code:
$a = htmlentities("&12345");
$b = substr($a,0,6);
  echo $b;

would echo '&1' as, I believe it is counting & as 5 characters.
more interestingly is with the GBP symbol (£) which is ignored all together so this:
$a = htmlentities("£");
  echo $a;

echos nothing. I get the same results on Chrome and FF. I don't know if this is a bug or I should use a different syntax. Does anyone know why this might be happening? Thanks
UPDATE
I have solved the £ issue with this: $a = htmlentities("£", ENT_COMPAT, 'ISO-8859-15');
but the ampersand issue remains.

A: The problem is that you are viewing the output in the browser window where output from htmlentities (and equivalent functions) is rendered for display to an end user.
For example:
echo htmlentities("&");

Will output & because it has converted the & character to it's html entity equivalent. See that it is five characters long. However, you don't see the full text & because you're viewing from your browser which has pre-rendered it as the & symbol. In firfox if you right click the viewport and click on "View Page Source" you will see the full text &...
Your code:
$a = htmlentities("&12345"); //Outputs: &12345
$b = substr($a, 0, 6); //Selects first six charachters: &, a, m, p, ; and 1
echo $b; // Echo's: &1 which is displayed by the browser as &1

To get around this you can change the order of your functions:
$a = substr("&12345", 0, 6);
echo htmlentities($a);


text:
Q: AjaxStart issue I am trying to build a shopping website with ajax. When a user clicks the "add to cart" image. The little loading image will show next to the Add To Cart Image. The first click works fine and the image showed as I expected. However, the second and the following clicks appends more images on the first loading image(2nd:add two loading images, 3rd: add three images..6 total images after 3 clicks). I did use ajaxStop and remove the first image...Not sure what's going on...Could use a help. Thanks a lot.
My javascript code
// add to cart
$(".addToCart").click(function(e){
 $this=$(this);
 $tableId=$this.closest('table').attr('id');

$($this).prev().ajaxStart(function(){
   $("").insertBefore($this);
});

$($this).prev().ajaxStop(function(){
   $($this).prev().remove();
});

HTML

<?php echo $productPriceWas; ?>

<?php echo "$".$productPrice;?>
**//I want my image here**

A: .ajaxStart() is a global event.  Each click you are binding another set of event handlers which causes 2 or more loading images to show up.   You could try using the .one(types, function() { ... }) event binding to only fire that block of code once per click.
However, I would suggest looking at the $.ajax() callbacks beforeSend and complete as places to bind code for a specific ajax request (as opposed to every ajax request).
I usually use a pattern something like this:
$(".addToCart").click(function(e){

   // you need to use "var" to make sure $this is only available inside this function
   var $this=$(this);

   // avoid using $ on variables that aren't jQuery objects (this is just a string)
   var tableId=$this.closest('table').attr('id');

   // insert the element before starting the ajax call
   var $loadingElem = $("");
   $loadingElem.insertBefore($this);

   // call ajax with some data
   $.ajax({
     url: '...', data: {id: tableId}, // ....
     complete: function(xhr, textStatus) {
       // remove the element when the ajax completes
       $loadingElem.remove();
     }
   });
 });

Also, $($this) is a wasted call, it will just return $this


text:
Q: cant insert multiple data need rescue As you can see I'm making a scoreboard program I have a multiple entries that I need to save to the database...but my problem is the 'frm1' only saves in the database the other 9 entries that I inputted doesn't save? btw I'm just a newbie programmer my codes is ugly sorry.
html code:
<form action="interview.php" method="post">

          <form name="frm1" id="frm1" >
            <input name="name1" type="text"  value="" required size="41" id="query1" onblur="getvalues1()" />

            <input type="radio" name="optA1" value="1" onClick="optTotal1()" />1
            <input type="radio" name="optA1" value="2" onClick="optTotal1()" />2
            <input type="radio" name="optA1" value="3" onClick="optTotal1()" />3

            <input type="radio" name="optB1" value="1" onClick="optTotal1()" />1
            <input type="radio" name="optB1" value="2" onClick="optTotal1()" />2
            <input type="radio" name="optB1" value="3" onClick="optTotal1()" />3

            <input type="radio" name="optC1" value="1" onClick="optTotal1()" />1
            <input type="radio" name="optC1" value="2" onClick="optTotal1()" />2

            <input type="radio" name="optD1" value="1" onClick="optTotal1()" />1
            <input type="radio" name="optD1" value="2" onClick="optTotal1()" />2

            <input type="text" name="total1" onKeyUp="optTotal1()" readonly size="3" />
            <input name="remarks1" type="text"  value="" required size="8" readonly />
            </form>

         <form name="frm2" id="frm2" >
            <input name="name2" type="text"  value="" required size="41" id="query2" onblur="getvalues2()" />

            <input type="radio" name="optA2" value="1" onClick="optTotal2()" />1
            <input type="radio" name="optA2" value="2" onClick="optTotal2()" />2
            <input type="radio" name="optA2" value="3" onClick="optTotal2()" />3

            <input type="radio" name="optB2" value="1" onClick="optTotal2()" />1
            <input type="radio" name="optB2" value="2" onClick="optTotal2()" />2
            <input type="radio" name="optB2" value="3" onClick="optTotal2()" />3

            <input type="radio" name="optC2" value="1" onClick="optTotal2()" />1
            <input type="radio" name="optC2" value="2" onClick="optTotal2()" />2

            <input type="radio" name="optD2" value="1" onClick="optTotal2()" />1
            <input type="radio" name="optD2" value="2" onClick="optTotal2()" />2

            <input type="text" name="total2" id="total2" onKeyUp="optTotal2()" readonly size="3" />
            <input name="remarks2" type="text"  value="" required size="8" readonly />
            </form>

          <form name="frm3" id="frm3" >
            <input name="name3" type="text"  value="" required size="41" id="query3" onblur="getvalues3()" />

            <input type="radio" name="optA3" value="1" onClick="optTotal3()" />1
            <input type="radio" name="optA3" value="2" onClick="optTotal3()" />2
            <input type="radio" name="optA3" value="3" onClick="optTotal3()" />3

            <input type="radio" name="optB3" value="1" onClick="optTotal3()" />1
            <input type="radio" name="optB3" value="2" onClick="optTotal3()" />2
            <input type="radio" name="optB3" value="3" onClick="optTotal3()" />3

            <input type="radio" name="optC3" value="1" onClick="optTotal3()" />1
            <input type="radio" name="optC3" value="2" onClick="optTotal3()" />2

            <input type="radio" name="optD3" value="1" onClick="optTotal3()" />1
            <input type="radio" name="optD3" value="2" onClick="optTotal3()" />2

            <input type="text" name="total3" onKeyUp="optTotal3()" readonly size="3" />
            <input name="remarks3" type="text"  value="" required size="8" readonly />
            </form>

           <form name="frm4" id="frm4" >
            <input name="name4" type="text"  value="" required size="41" id="query4" onblur="getvalues4()" />

            <input type="radio" name="optA4" value="1" onClick="optTotal4()" />1
            <input type="radio" name="optA4" value="2" onClick="optTotal4()" />2
            <input type="radio" name="optA4" value="3" onClick="optTotal4()" />3

            <input type="radio" name="optB4" value="1" onClick="optTotal4()" />1
            <input type="radio" name="optB4" value="2" onClick="optTotal4()" />2
            <input type="radio" name="optB4" value="3" onClick="optTotal4()" />3

            <input type="radio" name="optC4" value="1" onClick="optTotal4()" />1
            <input type="radio" name="optC4" value="2" onClick="optTotal4()" />2

            <input type="radio" name="optD4" value="1" onClick="optTotal4()" />1
            <input type="radio" name="optD4" value="2" onClick="optTotal4()" />2

            <input type="text" name="total4" onKeyUp="optTotal4()" readonly size="3" />
            <input name="remarks4" type="text"  value="" required size="8" readonly />
            </form>

          <form name="frm5" id="frm5" >
            <input name="name5" type="text"  value="" required size="41" id="query5" onblur="getvalues5()" />

            <input type="radio" name="optA5" value="1" onClick="optTotal5()" />1
            <input type="radio" name="optA5" value="2" onClick="optTotal5()" />2
            <input type="radio" name="optA5" value="3" onClick="optTotal5()" />3

            <input type="radio" name="optB5" value="1" onClick="optTotal5()" />1
            <input type="radio" name="optB5" value="2" onClick="optTotal5()" />2
            <input type="radio" name="optB5" value="3" onClick="optTotal5()" />3

            <input type="radio" name="optC5" value="1" onClick="optTotal5()" />1
            <input type="radio" name="optC5" value="2" onClick="optTotal5()" />2

            <input type="radio" name="optD5" value="1" onClick="optTotal5()" />1
            <input type="radio" name="optD5" value="2" onClick="optTotal5()" />2

            <input type="text" name="total5" onKeyUp="optTotal5()" readonly size="3" />
            <input name="remarks5" type="text"  value="" required size="8" readonly />
            </form>

          <form name="frm6" id="frm6" >
            <input name="name6" type="text"  value="" required size="41" id="query6" onblur="getvalues6()" />

            <input type="radio" name="optA6" value="1" onClick="optTotal6()" />1
            <input type="radio" name="optA6" value="2" onClick="optTotal6()" />2
            <input type="radio" name="optA6" value="3" onClick="optTotal6()" />3

            <input type="radio" name="optB6" value="1" onClick="optTotal6()" />1
            <input type="radio" name="optB6" value="2" onClick="optTotal6()" />2
            <input type="radio" name="optB6" value="3" onClick="optTotal6()" />3

            <input type="radio" name="optC6" value="1" onClick="optTotal6()" />1
            <input type="radio" name="optC6" value="2" onClick="optTotal6()" />2

            <input type="radio" name="optD6" value="1" onClick="optTotal6()" />1
            <input type="radio" name="optD6" value="2" onClick="optTotal6()" />2

            <input type="text" name="total6" onKeyUp="optTotal6()" readonly size="3" />
            <input name="remarks6" type="text"  value="" required size="8" readonly />
            </form>

          <form name="frm7" id="frm7" >
            <input name="name7" type="text"  value="" required size="41" id="query7" onblur="getvalues7()" />

            <input type="radio" name="optA7" value="1" onClick="optTotal7()" />1
            <input type="radio" name="optA7" value="2" onClick="optTotal7()" />2
            <input type="radio" name="optA7" value="3" onClick="optTotal7()" />3

            <input type="radio" name="optB7" value="1" onClick="optTotal7()" />1
            <input type="radio" name="optB7" value="2" onClick="optTotal7()" />2
            <input type="radio" name="optB7" value="3" onClick="optTotal7()" />3

            <input type="radio" name="optC7" value="1" onClick="optTotal7()" />1
            <input type="radio" name="optC7" value="2" onClick="optTotal7()" />2

            <input type="radio" name="optD7" value="1" onClick="optTotal7()" />1
            <input type="radio" name="optD7" value="2" onClick="optTotal7()" />2

            <input type="text" name="total7" onKeyUp="optTotal7()" readonly size="3" />
            <input name="remarks7" type="text"  value="" required size="8" readonly />
            </form>

         <form name="frm8" id="frm8" >
            <input name="name8" type="text"  value="" required size="41" id="query8" onblur="getvalues8()" />

            <input type="radio" name="optA8" value="1" onClick="optTotal8()" />1
            <input type="radio" name="optA8" value="2" onClick="optTotal8()" />2
            <input type="radio" name="optA8" value="3" onClick="optTotal8()" />3

            <input type="radio" name="optB8" value="1" onClick="optTotal8()" />1
            <input type="radio" name="optB8" value="2" onClick="optTotal8()" />2
            <input type="radio" name="optB8" value="3" onClick="optTotal8()" />3

            <input type="radio" name="optC8" value="1" onClick="optTotal8()" />1
            <input type="radio" name="optC8" value="2" onClick="optTotal8()" />2

            <input type="radio" name="optD8" value="1" onClick="optTotal8()" />1
            <input type="radio" name="optD8" value="2" onClick="optTotal8()" />2

            <input type="text" name="total8" onKeyUp="optTotal8()" readonly size="3" />
            <input name="remarks8" type="text"  value="" required size="8" readonly />
            </form>

         <form name="frm9" id="frm9" >
            <input name="name9" type="text"  value="" required size="41" id="query9" onblur="getvalues9()" />

            <input type="radio" name="optA9" value="1" onClick="optTotal9()" />1
            <input type="radio" name="optA9" value="2" onClick="optTotal9()" />2
            <input type="radio" name="optA9" value="3" onClick="optTotal9()" />3

            <input type="radio" name="optB9" value="1" onClick="optTotal9()" />1
            <input type="radio" name="optB9" value="2" onClick="optTotal9()" />2
            <input type="radio" name="optB9" value="3" onClick="optTotal9()" />3

            <input type="radio" name="optC9" value="1" onClick="optTotal9()" />1
            <input type="radio" name="optC9" value="2" onClick="optTotal9()" />2

            <input type="radio" name="optD9" value="1" onClick="optTotal9()" />1
            <input type="radio" name="optD9" value="2" onClick="optTotal9()" />2

            <input type="text" name="total9" onKeyUp="optTotal9()" readonly size="3" />
            <input name="remarks9" type="text"  value="" required size="8" readonly />
            </form>

          <form name="frm10" id="frm10" >
            <input name="name10" type="text"  value="" required size="41" id="query10" onblur="getvalues10()" />

            <input type="radio" name="optA10" value="1" onClick="optTotal10()" />1
            <input type="radio" name="optA10" value="2" onClick="optTotal10()" />2
            <input type="radio" name="optA10" value="3" onClick="optTotal10()" />3

            <input type="radio" name="optB10" value="1" onClick="optTotal10()" />1
            <input type="radio" name="optB10" value="2" onClick="optTotal10()" />2
            <input type="radio" name="optB10" value="3" onClick="optTotal10()" />3

            <input type="radio" name="optC10" value="1" onClick="optTotal10()" />1
            <input type="radio" name="optC10" value="2" onClick="optTotal10()" />2

            <input type="radio" name="optD10" value="1" onClick="optTotal10()" />1
            <input type="radio" name="optD10" value="2" onClick="optTotal10()" />2

            <input type="text" name="total10" onKeyUp="optTotal10()" readonly size="3" />
            <input name="remarks10" type="text"  value="" required size="8" readonly />
            </form>

        _______________________________

              Signature of Rater

<input type="hidden" name="username" id="username" value="<?php echo $_SESSION['username']; ?> " />
<input type="hidden" name="repcode" id="repcode" value="<?php echo $_SESSION['repcode']; ?> " />

<input type="hidden" name="aic1" id="aic1"/>
<input type="hidden" name="batchcode1" id="batchcode1" />

<input type="hidden" name="aic2" id="aic2"/>
<input type="hidden" name="batchcode2" id="batchcode2" />

<input type="hidden" name="aic3" id="aic3"/>
<input type="hidden" name="batchcode3" id="batchcode3" />

<input type="hidden" name="aic4" id="aic4"/>
<input type="hidden" name="batchcode4" id="batchcode4" />

<input type="hidden" name="aic5" id="aic5"/>
<input type="hidden" name="batchcode5" id="batchcode5" />

<input type="hidden" name="aic6" id="aic6"/>
<input type="hidden" name="batchcode6" id="batchcode6" />

<input type="hidden" name="aic7" id="aic7"/>
<input type="hidden" name="batchcode7" id="batchcode7" />

<input type="hidden" name="aic8" id="aic8"/>
<input type="hidden" name="batchcode8" id="batchcode8" />

<input type="hidden" name="aic9" id="aic9"/>
<input type="hidden" name="batchcode9" id="batchcode9" />

<input type="hidden" name="aic10" id="aic10"/>
<input type="hidden" name="batchcode10" id="batchcode10" />

 <input type="submit" style="width:964px;height:30px" value="CLICK ME TO SAVE" name="save" id="press" />

</form>

php code:
<?php

if(isset($_POST['save']))
{
include('connection.php');
//opt1
$opt1aic = array_key_exists('aic1', $_POST) ? $_POST['aic1'] : null;
$opt1batchcode = array_key_exists('batchcode1', $_POST) ? $_POST['batchcode1'] : null;
$opt1name = array_key_exists('name1', $_POST) ? $_POST['name1'] : null;
$opt1score1 = array_key_exists('optA1', $_POST) ? $_POST['optA1'] : null;
$opt1score2 = array_key_exists('optB1', $_POST) ? $_POST['optB1'] : null;
$opt1score3 = array_key_exists('optC1', $_POST) ? $_POST['optC1'] : null;
$opt1score4 = array_key_exists('optD1', $_POST) ? $_POST['optD1'] : null;
$opt1total = ($opt1score1 + $opt1score2 + $opt1score3 + $opt1score4);
//opt2
$opt2aic = array_key_exists('aic2', $_POST) ? $_POST['aic2'] : null;
$opt2batchcode = array_key_exists('batchcode2', $_POST) ? $_POST['batchcode2'] : null;
$opt2name = array_key_exists('name2', $_POST) ? $_POST['name2'] : null;
$opt2score1 = array_key_exists('optA2', $_POST) ? $_POST['optA2'] : null;
$opt2score2 = array_key_exists('optB2', $_POST) ? $_POST['optB2'] : null;
$opt2score3 = array_key_exists('optC2', $_POST) ? $_POST['optC2'] : null;
$opt2score4 = array_key_exists('optD2', $_POST) ? $_POST['optD2'] : null;
$opt2total = ($opt2score1 + $opt2score2 + $opt2score3 + $opt2score4);
//opt3
$opt3aic = array_key_exists('aic3', $_POST) ? $_POST['aic3'] : null;
$opt3batchcode = array_key_exists('batchcode3', $_POST) ? $_POST['batchcode3'] : null;
$opt3name = array_key_exists('name3', $_POST) ? $_POST['name3'] : null;
$opt3score1 = array_key_exists('optA3', $_POST) ? $_POST['optA3'] : null;
$opt3score2 = array_key_exists('optB3', $_POST) ? $_POST['optB3'] : null;
$opt3score3 = array_key_exists('optC3', $_POST) ? $_POST['optC3'] : null;
$opt3score4 = array_key_exists('optD3', $_POST) ? $_POST['optD3'] : null;
$opt3total = ($opt3score1 + $opt3score2 + $opt3score3 + $opt3score4);
//opt4
$opt4aic = array_key_exists('aic4', $_POST) ? $_POST['aic4'] : null;
$opt4batchcode = array_key_exists('batchcode4', $_POST) ? $_POST['batchcode4'] : null;
$opt4name = array_key_exists('name4', $_POST) ? $_POST['name4'] : null;
$opt4score1 = array_key_exists('optA4', $_POST) ? $_POST['optA4'] : null;
$opt4score2 = array_key_exists('optB4', $_POST) ? $_POST['optB4'] : null;
$opt4score3 = array_key_exists('optC4', $_POST) ? $_POST['optC4'] : null;
$opt4score4 = array_key_exists('optD4', $_POST) ? $_POST['optD4'] : null;
$opt4total = ($opt4score1 + $opt4score2 + $opt4score3 + $opt4score4);
//opt5
$opt5aic = array_key_exists('aic5', $_POST) ? $_POST['aic5'] : null;
$opt5batchcode = array_key_exists('batchcode5', $_POST) ? $_POST['batchcode5'] : null;
$opt5name = array_key_exists('name5', $_POST) ? $_POST['name5'] : null;
$opt5score1 = array_key_exists('optA5', $_POST) ? $_POST['optA5'] : null;
$opt5score2 = array_key_exists('optB5', $_POST) ? $_POST['optB5'] : null;
$opt5score3 = array_key_exists('optC5', $_POST) ? $_POST['optC5'] : null;
$opt5score4 = array_key_exists('optD5', $_POST) ? $_POST['optD5'] : null;
$opt5total = ($opt5score1 + $opt5score2 + $opt5score3 + $opt5score4);
//opt6
$opt6aic = array_key_exists('aic6', $_POST) ? $_POST['aic6'] : null;
$opt6batchcode = array_key_exists('batchcode6', $_POST) ? $_POST['batchcode6'] : null;
$opt6name = array_key_exists('name6', $_POST) ? $_POST['name6'] : null;
$opt6score1 = array_key_exists('optA6', $_POST) ? $_POST['optA6'] : null;
$opt6score2 = array_key_exists('optB6', $_POST) ? $_POST['optB6'] : null;
$opt6score3 = array_key_exists('optC6', $_POST) ? $_POST['optC6'] : null;
$opt6score4 = array_key_exists('optD6', $_POST) ? $_POST['optD6'] : null;
$opt6total = ($opt6score1 + $opt6score2 + $opt6score3 + $opt6score4);
//opt7
$opt7aic = array_key_exists('aic7', $_POST) ? $_POST['aic7'] : null;
$opt7batchcode = array_key_exists('batchcode7', $_POST) ? $_POST['batchcode7'] : null;
$opt7name = array_key_exists('name7', $_POST) ? $_POST['name7'] : null;
$opt7score1 = array_key_exists('optA7', $_POST) ? $_POST['optA7'] : null;
$opt7score2 = array_key_exists('optB7', $_POST) ? $_POST['optB7'] : null;
$opt7score3 = array_key_exists('optC7', $_POST) ? $_POST['optC7'] : null;
$opt7score4 = array_key_exists('optD7', $_POST) ? $_POST['optD7'] : null;
$opt7total = ($opt7score1 + $opt7score2 + $opt7score3 + $opt7score4);
//opt8
$opt8aic = array_key_exists('aic8', $_POST) ? $_POST['aic8'] : null;
$opt8batchcode = array_key_exists('batchcode8', $_POST) ? $_POST['batchcode8'] : null;
$opt8name = array_key_exists('name8', $_POST) ? $_POST['name8'] : null;
$opt8score1 = array_key_exists('optA8', $_POST) ? $_POST['optA8'] : null;
$opt8score2 = array_key_exists('optB8', $_POST) ? $_POST['optB8'] : null;
$opt8score3 = array_key_exists('optC8', $_POST) ? $_POST['optC8'] : null;
$opt8score4 = array_key_exists('optD8', $_POST) ? $_POST['optD8'] : null;
$opt8total = ($opt8score1 + $opt8score2 + $opt8score3 + $opt8score4);
//opt9
$opt9aic = array_key_exists('aic9', $_POST) ? $_POST['aic9'] : null;
$opt9batchcode = array_key_exists('batchcode9', $_POST) ? $_POST['batchcode9'] : null;
$opt9name = array_key_exists('name9', $_POST) ? $_POST['name9'] : null;
$opt9score1 = array_key_exists('optA9', $_POST) ? $_POST['optA9'] : null;
$opt9score2 = array_key_exists('optB9', $_POST) ? $_POST['optB9'] : null;
$opt9score3 = array_key_exists('optC9', $_POST) ? $_POST['optC9'] : null;
$opt9score4 = array_key_exists('optD9', $_POST) ? $_POST['optD9'] : null;
$opt9total = ($opt9score1 + $opt9score2 + $opt9score3 + $opt9score4);
//opt10
$opt10aic = array_key_exists('aic10', $_POST) ? $_POST['aic10'] : null;
$opt10batchcode = array_key_exists('batchcode10', $_POST) ? $_POST['batchcode10'] : null;
$opt10name = array_key_exists('name10', $_POST) ? $_POST['name10'] : null;
$opt10score1 = array_key_exists('optA10', $_POST) ? $_POST['optA10'] : null;
$opt10score2 = array_key_exists('optB10', $_POST) ? $_POST['optB10'] : null;
$opt10score3 = array_key_exists('optC10', $_POST) ? $_POST['optC10'] : null;
$opt10score4 = array_key_exists('optD10', $_POST) ? $_POST['optD10'] : null;
$opt10total = ($opt10score1 + $opt10score2 + $opt10score3 + $opt10score4);

$username = mysql_real_escape_string($_SESSION['username']);
$repcode = mysql_real_escape_string($_SESSION['repcode']);
$position = mysql_real_escape_string($_POST['position']);
$division = mysql_real_escape_string($_POST['division']);
$sgrade = mysql_real_escape_string($_POST['sgrade']);
$salary = mysql_real_escape_string($_POST['salary']);

//insert 1
if($opt1aic != "" && $opt1batchcode != "" && $opt1name != "" && $opt1score1 != "" && $opt1score2 != "" && $opt1score3 != "" && $opt1score4 != "" && $opt1total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt1aic','$opt1batchcode','$position','$division','$sgrade','$salary','$opt1name','$opt1score1','$opt1score2','$opt1score3','$opt1score4','$opt1total',CURRENT_TIMESTAMP)");
}
//insert 2
if($opt2aic != "" && $opt2batchcode != "" && $opt2name != "" && $opt2score1 != "" && $opt2score2 != "" && $opt2score3 != "" && $opt2score4 != "" && $opt2total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt2aic','$opt2batchcode','$position','$division','$sgrade','$salary','$opt2name','$opt2score1','$opt2score2','$opt2score3','$opt2score4','$opt2total',CURRENT_TIMESTAMP)");
}
//insert 3
if($opt3aic != "" && $opt3batchcode != "" && $opt3name != "" && $opt3score1 != "" && $opt3score2 != "" && $opt3score3 != "" && $opt3score4 != "" && $opt3total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt3aic','$opt3batchcode','$position','$division','$sgrade','$salary','$opt3name','$opt3score1','$opt3score2','$opt3score3','$opt3score4','$opt3total',CURRENT_TIMESTAMP)");
}
//insert 4
if($opt4aic != "" && $opt4batchcode != "" && $opt4name != "" && $opt4score1 != "" && $opt4score2 != "" && $opt4score3 != "" && $opt4score4 != "" && $opt4total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt4aic','$opt4batchcode','$position','$division','$sgrade','$salary','$opt4name','$opt4score1','$opt4score2','$opt4score3','$opt4score4','$opt4total',CURRENT_TIMESTAMP)");
}
//insert 5
if($opt5aic != "" && $opt5batchcode != "" && $opt5name != "" && $opt5score1 != "" && $opt5score2 != "" && $opt5score3 != "" && $opt5score4 != "" && $opt5total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt5aic','$opt5batchcode','$position','$division','$sgrade','$salary','$opt5name','$opt5score1','$opt5score2','$opt5score3','$opt5score4','$opt5total',CURRENT_TIMESTAMP)");
}
//insert 6
if($opt6aic != "" && $opt6batchcode != "" && $opt6name != "" && $opt6score1 != "" && $opt6score2 != "" && $opt6score3 != "" && $opt6score4 != "" && $opt6total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt6aic','$opt6batchcode','$position','$division','$sgrade','$salary','$opt6name','$opt6score1','$opt6score2','$opt6score3','$opt6score4','$opt6total',CURRENT_TIMESTAMP)");
}
//insert 7
if($opt7aic != "" && $opt7batchcode != "" && $opt7name != "" && $opt7score1 != "" && $opt7score2 != "" && $opt7score3 != "" && $opt7score4 != "" && $opt7total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt7aic','$opt7batchcode','$position','$division','$sgrade','$salary','$opt7name','$opt7score1','$opt7score2','$opt7score3','$opt7score4','$opt7total',CURRENT_TIMESTAMP)");
}
//insert 8
if($opt8aic != "" && $opt8batchcode != "" && $opt8name != "" && $opt8score1 != "" && $opt8score2 != "" && $opt8score3 != "" && $opt8score4 != "" && $opt8total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt8aic','$opt8batchcode','$position','$division','$sgrade','$salary','$opt8name','$opt8score1','$opt8score2','$opt8score3','$opt8score4','$opt8total',CURRENT_TIMESTAMP)");
}
//insert 9
if($opt9aic != "" && $opt9batchcode != "" && $opt9name != "" && $opt9score1 != "" && $opt9score2 != "" && $opt9score3 != "" && $opt9score4 != "" && $opt9total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt9aic','$opt9batchcode','$position','$division','$sgrade','$salary','$opt9name','$opt9score1','$opt9score2','$opt9score3','$opt9score4','$opt9total',CURRENT_TIMESTAMP)");
}
//insert 10
if($opt10aic != "" && $opt10batchcode != "" && $opt10name != "" && $opt10score1 != "" && $opt10score2 != "" && $opt10score3 != "" && $opt10score4 != "" && $opt10total != ""){
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt10aic','$opt10batchcode','$position','$division','$sgrade','$salary','$opt10name','$opt10score1','$opt10score2','$opt10score3','$opt10score4','$opt10total',CURRENT_TIMESTAMP)");
}

    header("Location:interview.php");
}

?>

I want to save from frm1 to frm10..can anyone help me please.

A: That's because they're not part of the form...
Only fields inside the <form> that you submit are submitted!


text:
Q: How to select the previous sibling using selenium css syntax EG How do select the second div in this list if all I have is the id of the third?

I want this

This Suggests that I could use tilde. eg css=#i_know_this ~ div but it is selecting the next sibling rather than the previous one. Also, the ::before selector doesn't work.

A: CSS selector path does not give you the privilege to move backward in the DOM hierarchy in that case you will have to use XPath //*[@id='i_know_this']/preceding-sibling::div[1]

A: You can use the axe library (axe is a CSS post-processor).
In this instance, the immediate previous axe selector is ?.
(It's the opposite of + in conventional CSS).
Working Example:

div {
height: 36px;
padding: 6px 12px;
line-height: 36px;
}

#i_know_this:hover ? div {
color: rgb(255, 255, 255);
background-color: rgb(255, 0, 0);
}

Ignore me

I want this

Hover me


text:
Q: passing text box value to another React page in different page whereas shows in same page I have finding difficault to pass the value form one component to another component in React Js.
I have files like App.js and Home.JS
App.js have one input box and one h1 tag while typing on the input box the value will be displayed inside the h1 tag. I wants the same method whereas instead of displaying on the same page i want to display the same value in Home.js with React Router.
Appp.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class App extends Component {

  constructor(){
    super();
    this.state = {
        name : "sivaprakash",
        age : 25
    }
  }
  update(e){
    this.setState({name: e.target.value})
  }
  render() {

    return (

{this.state.name} - {this.state.age}

          <form>
              <input type="text" name="tx1" onChange={this.update.bind(this)} placeholder="Type Something..."/>
          </form>

    );
  }
}

export default App;

Home.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class Home extends Component {
  constructor(){
    super();
    this.state = {
        name : "",

    }
  }

  render() {

    return (

{this.state.name}

    );
  }
}

export default Home;

Please let me know if my question seems confusing.

A: First, you have to render Home.js in App.js.
import Home from './home_component_path'

ex: import Home from './Home';
Then render Home component bellow form section or wherever to wish to, and pass App.js state as props to Home.js like this in App.js
<Home user={this.state}/>

In Home.js component render passed props like this.
Instead of
{this.state.name}
 do this
{this.props.user.name}

A: In React this is usually solved by lifting state up, meaning you keep the state in a parent component and pass the value (and, if you want to, a change handler) down to the child components showing the data.
Using React Router you could do something like this:
Parent.js:
class Parent extends Component {
    state = {
        name: "sivaprakash",
        age: 25
    };

    changeName = newName => this.setState({ name: newName });

    render() {
        return (
            <Router>
                <Switch>
                    <Route path="/app"
                           render={() =>
                               <App name={this.state.name}
                                    age={this.state.age}
                                    changeName={this.changeName} />
                           } />
                    <Route path="/home"
                           render={() =>
                               <Home name={this.state.name} />
                           } />
                </Switch>
            </Router>
        )
    }
}

App.js:
class App extends Component {
    update(e) {
        this.props.changeName(e.target.value);
    }

    render() {
        return (

{this.props.name} - {this.props.age}

                    <form>
                        <input type="text"
                               name="tx1"
                               onChange={this.update.bind(this)}
                               placeholder="Type Something..." />
                    </form>

        );
    }
}

Home.js:
class Home extends Component {
    render() {
        return (

{this.props.name}

        );
    }
}


text:
Q: Qt doesn't play sound on other devices All I want to do write a programm in Qt that plays a simple .wav file.
This works perfectly on the PC where my Qt runs, but whenever I want to run the program on a different computer there is no sound.
I couldn't find any solution for this problem anywhere yet.
This is what I tried so far:

*

*different libraries: QSound, QSoundEffect, QMediaPlayer

*implement the QT += multimedia in the .pro file (of course)

*make sure that the filepath was correct (even with a absolute path):

QFile dir("C:/Sounds/countdown3.wav");
        if(dir.exists()){
            ui->labelSound->setText("File found!");
            ui->pushButtonPlay->setEnabled(true);
            ui->labelplay->setEnabled(true);
            ui->pushButton->setEnabled(false);
        }
        else ui->labelSound->setText("File not available!");
(When I rename the file I get the "File not available!" message, so this works.)
To deploy the program from my pc to my laptop, I put the following into a folder:

*

*PlaySound.exe

*platforms/qwindows.dll

*icudt53.dll

*icuin53.dll

*icuuc53.dll

*libgcc_s_dw2-1.dll

*libstdc++-6.dll

*libwinpthread-1.dll

*Qt5Core.dll

*Qt5Gui.dll

*Qt5Multimedia.dll

*Qt5Network.dll

*Qt5Widgets.dll

and the "Sounds" folder with countdown3.wav to the C:/ -drive. Still no sound :(
What am I missing?
I hope you can help me!

A: The audio plugins folder: [Qt-Installation]\5.4\msvc2013\plugins\audio

*

*audio\qtaudio_windows.dll what you need

*audio\qtaudio_windowsd.dll is the debug library

*audio\qtaudio_windowsd.pdb symbols

You don't need to deploy the last two.


text:
Q: plot dataframe column on one axis and other columns as separate lines on the same plot (in different color) I have following dataframe.
        precision    recall        F1  cutoff
cutoff
0        0.690148  1.000000  0.814610       0
1        0.727498  1.000000  0.839943       1
2        0.769298  0.916667  0.834051       2
3        0.813232  0.916667  0.859741       3
4        0.838062  0.833333  0.833659       4
5        0.881454  0.833333  0.854946       5
6        0.925455  0.750000  0.827202       6
7        0.961111  0.666667  0.786459       7
8        0.971786  0.500000  0.659684       8
9        0.970000  0.166667  0.284000       9
10       0.955000  0.083333  0.152857      10

I want to plot cutoff column on x-axis and precision,recall and F1 values as separate lines on the same plot (in different color). How can I do it?
When I am trying to plot the dataframe, it is taking the cutoff column also for plotting.
Thanks

A: Remove column before ploting:
df.drop('cutoff', axis=1).plot()

But maybe problem is how is created index, maybe help change:
df = df.set_index(df['cutoff'])
df.drop('cutoff', axis=1).plot()

to:
df = df.set_index('cutoff')
df.plot()


text:
Q: how to trigger function when receive FCM in background without tapping in cordova im developing a cordova app with firebase cloud messaging. So the plugin i used is cordova-plugin-firebase-messaging.
The requirement is i need to have the voice notification (phone to read the text out loud when receiving notification). im doing this by using
cordova-plugin-texttospeech

However, I can only do this when the app is in foreground using onMessage function :
cordova.plugins.firebase.messaging.onMessage(callback); <= i put the TTS function in the callback
However, when the app is in background, this not works:
cordova.plugins.firebase.messaging.onBackgroundMessage(callback); <= put the TTS function not works, because the callback only triggered when user tapped the notification. I want it triggered as soon as they receive it
Anybody has any idea how to do this ?


text:
Q: Cap'n Proto CMake support: CAPNP_LIB_CAPNP-JSON is NOTFOUND Why do I have to set
set(CAPNP_LIB_CAPNP-JSON "")
in my CMakeLists.txt in order to not get an error? Error as follows:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CAPNP_LIB_CAPNP-JSON (ADVANCED)
    linked by target "client" in directory <...>
    linked by target "server" in directory <...>

The way I'm using capnproto CMake support is by copying the cmake file included in the capnproto source into my project and including it manually. (Is there a better / standard way to do this? Feels hackish.) The rest is just taken from the CMake file's instructions.
CMake snippet:
# so capnp cmake plugin is found
set(CapnProto_DIR "${CMAKE_CURRENT_SOURCE_DIR}/etc/cmake")
# for some reason there is some json lib or something that isn't found?
#set(CAPNP_LIB_CAPNP-JSON "")
find_package(CapnProto REQUIRED)
include_directories(${CAPNP_INCLUDE_DIRS})
add_definitions(${CAPNP_DEFINITIONS})
set(CAPNPC_SRC_PREFIX "src/capnp")
# capnp out of source config
set(CAPNPC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CAPNPC_OUTPUT_DIR})
# gen cpp
capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS
        src/capnp/schema.capnp
)

CMake 3.6.2, building using CLion's integrated build commands. capnp is installed via homebrew, latest version.
Why am I getting the error about the JSON bit? What is that about?
Also, is there a better way for including the official Cap'n Proto CMake file? It seemed to not get distributed with the header and library files when installing via homebrew.

A: It turns out json encoding/decoding support is an as yet (Oct 2016) unreleased feature of Cap'n Proto and trying to use the .cmake file from the master branch with the last released version produces this conflict.
Possible solutions:
1) Use workaround posted in the question, i.e.
set(CAPNP_LIB_CAPNP-JSON "") # add this before next line
find_package(CapnProto REQUIRED)

2) Use the released version of the .cmake script here: FindCapnProto.cmake
3) Build and install Cap'n Proto from source, use with latest .cmake script.


text:
Q: A necessary and sufficient condition for a full lattice over an integral domain I'm learning about lattices over integral domains and I would be grateful if someone could clarify the following for me.
Let $R$ be an integral domain with quotient field $K$ where $K\neq R$. Suppose we have an $R$ -lattice $M$, i.e. a finitely generated torsion free $R$-module and a finite dimensional $K$-vector space $V$.
Is it true that $K\otimes_{R}M=V$ if and only if $M$ contains a $K$-basis of $V$?
I know that since $M$ is $R$-torsion free, it embeds into $V$. Does this imply that $M$ contains a $K$-basis of $V$?

A: $K\otimes_R M=S^{-1}M$, where $S=R-\{0\}$. Since $S^{-1}M=V$, then a basis of $V$ has the form $x_1/1,\dots,x_n/1$ with $x_i\in M$.


text:
Q: Prove the series $\sum_{n=2}^\infty \frac{1}{n \ln(n)(\ln(\ln(n)))^2}$ converges I need to prove the series $$\sum\limits_{n=2}^\infty \frac{1}{n \ln(n)(\ln(\ln(n)))^2}$$ converges.
I cant use comparison test, since if I take away any term in denominator I know it will diverge. Any help please?

A: Hint. Since the general term is a positive and decreasing sequence, by the integral test, your series behaves as the following integral:
$$
\int_3^{\infty}\frac{{\rm d} x}{x \ln x \:(\ln(\ln x))^2}. \tag1
$$ By the change of variable $$u=\ln(\ln x), \quad du=\dfrac{dx}{x \ln x },$$ we easily have

$$
\begin{align}
\int_3^{\infty}\frac{{\rm d} x}{x \ln x \:(\ln(\ln x))^2} \mathrm dx=\int_{\ln(\ln 3)}^{\infty}\frac{{\rm d} u}{u^2}
=\left[ -\frac{1}{u}\right]_{\ln(\ln 3)}^{\infty}
=\frac1{\ln(\ln 3)}.
\end{align}
$$

Your initial series is convergent.
Edit. Thanks to user109899's remark, we have singled out the term coming from $n=2$.

A: Hint. You may apply the Cauchy condensation test since the sequence is positive and decreasing:

$\sum_n a_n$ converges if and only if $\sum_n 2^n \:a_{2^n}$ converges.

By setting $\displaystyle a_n=\frac{1}{n \ln(n)(\ln(\ln(n)))^2} $, we easily get
$$\sum_n 2^n \:a_{2^n}=\sum_{n\geq2} \frac{2^n}{2^n \cdot n \ln2\cdot(\ln n +\ln 2)^2}\leq \frac1{\ln 2}\sum_{n\geq2} \frac{1}{n \ln^2 n}.$$
The latter series may be treated in the same way, you may consider
$$
\sum_{n\geq2}\frac{2^n }{2^n \ln^2 (2^n)}= \frac1{\ln^2 2}\sum_{n\geq2}\frac{1}{n^2 }.
$$
Your initial series is convergent.


text:
Q: optional line break for long strings I am writing an excel file using openxlsx. It contains a column (with a specified width) with strings, that sometimes are longer than the width of the column.
Is there a way for the string to make an automatic line break as soon as the string has the length of the column dimension width?
I've so far only found fixed solutions, like
worksheet.cell('A1').value = "Line 1\nLine 2"

A: worksheet.cell('A1').style.alignment.wrap_text = True
If it works as the Wrap Text feature in Excel does, you should be fine with that.


text:
Q: jQuery check if remote page has loaded in while loop We're working on an embeded "visualization" in a page. The embeded object is loaded from another URL on the same server (no CORS issues), however once the user has loaded the main page, the secondary resource takes a while to come up (1-5 seconds).
<object id="main" width="100%" height="100%">
    <embed src="some-url" />
</object>

We'd like to run some sort of spinner during that time, testing if we get a 200 OK from the embeded resource, before appending it to the page, as there's no good way for us to allow refreshing of the embeded object until it becomes available. This is what I've tried so far:
function test_ie_availability(){
    var loaded_page = false;
    var count = 0;
    while (!loaded_page){
        console.log("Test: " + count);
        count = count + 1;
        if(count > 10){
            break;
        }
        $.ajax({
            type: "GET",
            async: true,
            url: access_url,
        }).done(function(data, textStatus, jqXHR){
            if(textStatus === "success"){
                loaded_page = true;
            }else{
                console.log(textStatus);
            }
        });
        if(!loaded_page){
            setTimeout(function(){
                console.log("Sleeping for a second");
            }, 1000);
        }
    }
}

with async:true and async:false both producing the same result:
Test: 0 z.js:34
Test: 1 z.js:34
Test: 2 z.js:34
Test: 3 z.js:34
Test: 4 z.js:34
Test: 5 z.js:34
Test: 6 z.js:34
Test: 7 z.js:34
Test: 8 z.js:34
Test: 9 z.js:34
Test: 10 z.js:34
undefined
(10) Sleeping for a second

I've tried variations upon this with setting the loaded_page variable in a success/error callback, neither of which worked.

A: How about creating a function inside an interval to keep checking to see if it loaded...
var interval = setInterval( function () {

    if (document.all["main"].readyState == 4) {

        clearInterval(interval);

        alert("Initialization is ready.");
    }

}, 100);

A: setTimeout(...) doesn't cause your program to "sleep" – it causes it to do something after a given interval.
So your while loop runs 11 times without pause, each time creating a new 1s timer that outputs "Sleeping for a second" to your console.
You can remove the loop altogether, and simply add the code to hide the spinner in place of this line:
loaded_page = true;


text:
Q: Nhibernate - query results to asp.net datagrid  ISession s = Dal.Session;

        string queryString = @"select t.SellDate as SellDate, t.DocumentNumber as DocNo, t.PriceGross as Gross,
                                t.PaymentDate as PaymentDate, ts.SettlementValue as SettlementValue, ds.{Path} + '\' + ds.Name as FilePath
                               from TransactionSettlement ts, Transaction t, DocScanned ds
                                where ts.TransactionId = t.Id and t.DocID = ds.DocID and ts.PaymentId = :paymentID";

 query.SetInt32("paymentID", paymentID);
 IQuery query = s.CreateQuery(queryString);
 IList resultList = query.List();

How to bind nhibernate query results to asp.net datagrid?

A: So the error you're seeing is because your resultList is a list of object arrays (object[]) instead of actual objects.
What you could do to get the data into the shape that you want is to write a Linq (Linq to objects, not linq to nhibernate), it'll probably look something along these lines:
var newResultList = from r in resultList
                    select new {
                        SellDate = r[0],
                        DocNo = r[1],
                        Gross = r[2],
                        PaymentDate = r[3],
                        SettlementValue = r[4],
                        FilePath = r[5]
                    };

Then you'll have an object you can more easily databind to.  There's probably a way to databind each row to an array, I just haven't found an examples of how to do that.

A: Have you tried using LINQ to nHibernate to return an IEnumerable or IQueryable?
http://ayende.com/Blog/archive/2009/07/26/nhibernate-linq-1.0-released.aspx
http://www.hookedonlinq.com/LINQToNHibernate.ashx


text:
Q: Should we use supervisors to keep processes running in Docker containers? I'm using Docker to run a java REST service in a container. If I were outside of a container then I might use a process manager/supervisor to ensures that the java service restarts if it encounters a strange one-off error. I see some posts about using supervisord inside of containers but it seems like they're focused mostly on running multiple services, rather than just keeping one up.
What is the common way of managing services that run in containers? Should I just be using some built in Docker stuff on the container itself rather than trying to include a process manager?

A: You should not use a process supervisor inside your Docker container for a single-service container. Using a process supervisor effectively hides the health of your service, making it more difficult to detect when you have a problem.
You should rely on your container orchestration layer (which may be Docker itself, or a higher level tool like Docker Swarm or Kubernetes) to restart the container if the service fails.
With Docker (or Docker Swarm), this means setting a restart policy on the container.


text:
Q: input text field padding i have this simple code - one text field and one image (height of image is 30px)
the code is:
<input type="text" style="height:30px;" />
<input type="image" src="images/download_button.png" />

and result is two element with height 30px that are not aligned. The text field is down relative to image - like padding??? Do you know, why the element is not aligned???
screenshot:

A:            Assuming your form id is "myform"

            #myform input{

            vertical-align:middle;

        }

       will do the trick.
if you are not using form:Try

<input type="text" style="height:30px;vertical-align:middle;" />
<input type="image" style="height:30px;vertical-align:middle;" src="images/download_button.png" />

A: Try removing padding and margin:
<input type="text" style="margin:0px;padding:0px;height:30px;" />
<input type="image" style="margin:0px;padding:0px;" src="images/download_button.png" />

Remember that the text input box is likely to add 2 pixels either side of the block for its border. You could remove the border all together with border:0;.
Also, double check any contradicting CSS rules elsewhere in your markup.
EDIT:
It's to do with the behaviour of the inputs in regards to floating. Add float:left; to both style to see what I mean. They don't know how to behave next to each other until you specify that you want them to appear on the same line.

A: Use the CSS "top" properties to increase the buttons distance from the top:
<style>
  [selector for image] {top: 20px;}
</style>`


text:
Q: ffmpeg file integrity check and rename on error with a batch file I've found the code to check a file for errors and it creates a log file with the contents. Is there a way to alter it and rename a file that has errors but not the ones without?
@echo off

set "filtro=%1"
if [%filtro%]==[] (
    set "filtro=*.mp4"
    )

for /R %%a in (%filtro%) do call :doWork "%%a"

    PAUSE
    exit /B

:doWork
    "F:\- error check\ffmpeg.exe" -v error -i %1 -f null - > "%~1.log" 2>&1

A: 1) Try using delayed expansion for your variables:
setlocal enabledelayedexpansion
2) Verify if some extension (%~x1) was provided in argument:
if /i "%~x1"=="" (set "_filtro=.mp4") else set "_filtro=%~x1"
3) Use For /F and Where.exe /R loop command, where you can recursively list/process your files:
for /f "tokens=* delims= " %%i in ('%__APPDIR__%where.exe /r . "*!_filtro!"'
4) Take advantage of the operator ||, for to rename any file that has an error:
"!_ffmpeg!" -i "%%~i" -v error -f null - || ren "%%~i" "%%~ni_ERROR_%%~xi"
5) Use Clip command for copy your log file content to your ClipBoard/Crtl+C:
type .\error.log|"%__APPDIR__%clip.exe"
6) If you prefer, you can also replace Pause to Timeout.exe, and/or, exit /b to goto :EOF:
"%__APPDIR__%timeout.exe" /t -1 & endlocal & goto :EOF

@echo off && setlocal enabledelayedexpansion

echo\ & cd/d "%~dp0" && >nul cd.>.\error.log

set "_ffmpeg=F:\- error check\ffmpeg.exe"
if /i "%~x1"=="" (set "_filtro=.mp4") else set "_filtro=%~x1"

echo\Filtro: ..\*!_filtro! && for /f "tokens=* delims= " %%i in ('%__APPDIR__%where.exe /r . "*!_filtro!"'
)do echo\%%~i && 2>>error.log ("!_ffmpeg!" -i "%%~i" -v error -f null - || ren "%%~i" "%%~ni_ERROR_%%~xi")

type error.log | "%__APPDIR__%clip.exe" & "%__APPDIR__%timeout.exe" /t -1 & endlocal & goto :EOF

*

*Same code in compacted formatting:

@echo off && setlocal enabledelayedexpansion && echo\ & cd/d "%~dp0" & >nul cd.>.\error.log

set "_ffmpeg=F:\- error check\ffmpeg.exe" && if /i "%~x1"=="" (set "_filtro=.mp4") else set "_filtro=%~x1"
echo\Filtro: ..\*!_filtro! && for /f "tokens=* delims= " %%i in ('%__APPDIR__%where.exe /r . "*!_filtro!"'
)do echo\%%~i && 2>>error.log ("!_ffmpeg!" -i "%%~i" -v error -f null - || ren "%%~i" "%%~ni_ERROR_%%~xi")
echo/ && type .\error.log|"%__APPDIR__%clip.exe" & "%__APPDIR__%timeout.exe" /t -1 & endlocal & goto :EOF

For command line help, you can use /?:
Ren /?, For /?,Where /?, Endlocal /?, Goto /?, Timeout /?, SetLocal /?, if /?
On the internet, you can get more help on:

*

*Ren

*For /f

*Where

*Endlocal

*Goto :EOF

*Timeout.exe

*EnableDelayedExpansion

*Conditional Execution || && ...

*If, Else If, Else, If Defined, Errorlevel ...


text:
Q: Handling States.Runtime errors in AWS Step Functions I am using AWS Step functions for an automation solution and the execution is stopping because of a Runtime exception.I added a catch block to catch the States.Runtime exception and when it occurs it should go to the next task defined,but it does not reach there an stops at the block where the exception happened. Here is my Step function definition:
    {
  "Comment": "Terminate a Tagged EC2 Instance",
  "StartAt": "DescribeInstances",
  "States": {
    "DescribeInstances": {
      "ResultPath": "$.DescribeInstances",
      "Resource": "arn:aws:states:::aws-sdk:ec2:describeInstances",
      "Type": "Task",
      "Parameters": {
        "InstanceIds.$": "$.Params.InstanceIds"
      },
      "ResultSelector": {
        "Value.$": "$.Reservations[0].Instances[0].Tags[0].Value"
      },

      "Catch": [
        {
          "ErrorEquals": [
            "States.Runtime"
          ],
          "Next": "RuntimeErrorFallback"
        }
      ],
      "Next": "isInstanceTagged"
    },
    "isInstanceTagged": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.DescribeInstances.Value",
          "StringEquals": "true",
          "Next": "TerminateInstances"
        },
        {
          "Not": {
            "Variable": "$.DescribeInstances.Value",
            "StringEquals": "true"
          },
          "Next": "send_email2"
        }
      ]
    },
    "TerminateInstances": {
      "ResultPath": "$.TerminateInstances",
      "Resource": "arn:aws:states:::aws-sdk:ec2:terminateInstances",
      "Type": "Task",
      "Parameters": {
        "InstanceIds.$": "$.Params.InstanceIds"
      },

      "Next": "send_email"
    },
    "send_email": {
      "Resource": "arn:aws:lambda:us-east-1:1111111:function:send_email",
      "Type": "Task",
      "End": true
    },
    "send_email2": {
      "Resource": "arn:aws:lambda:us-east-1:1111111:function:send_email",
      "Type": "Task",
      "End": true
    },
    "RuntimeErrorFallback": {
      "Type": "Pass",
      "Result": "This is a fallback for Runtime Error",
      "End": true
    }
  }
}

Is there anything I am missing so that I can handle this correctly?

A: Unfortunately, you cannot catch States.Runtime errors.
"An execution failed due to some exception that it couldn't process. Often these are caused by errors at runtime, such as attempting to apply InputPath or OutputPath on a null JSON payload. A States.Runtime error isn't retriable, and will always cause the execution to fail. A retry or catch on States.ALL won't catch States.Runtime errors." -- From Step Functions documentation.
The most common case for this type of scenario is when the JSON Path you specified in your definition conflicts with the input to your state or the results from a Task.
In your particular case, I suspect that the input either doesn't have the required array of InstanceIds or the input contains a string rather than an array of strings (as required by the API). If that's the case, the following ASL demonstrates how to handle this. The first choice condition confirms that the referenced item exists, then sends to a Fail state if not (you could take some other compensating action). If it's present but is a string instead of an array, then it will transform to an array using the States.Array intrinsic function.
{
  "StartAt": "Check for Instance Ids",
  "States": {
    "Check for Instance Ids": {
      "Type": "Choice",
      "Choices": [
        {
          "Not": {
            "Variable": "$.Params.InstanceIds",
            "IsPresent": true
          },
          "Next": "No Instance Ids"
        },
        {
          "Variable": "$.Params.InstanceIds",
          "IsString": true,
          "Next": "Transform To Array"
        }
      ],
      "Default": "DescribeInstances"
    },
    "No Instance Ids": {
      "Type": "Fail",
      "Error": "InvalidInput",
      "Cause": "The required value $.Params.InstanceIds was not provided"
    },
    "Transform To Array": {
      "Type": "Pass",
      "Next": "DescribeInstances",
      "Parameters": {
        "Params": {
          "InstanceIds.$": "States.Array($.Params.InstanceIds)"
        }
      }
    },
    "DescribeInstances": {
      "Type": "Task",
      "End": true,
      "Parameters": {
        "InstanceIds.$": "$.Params.InstanceIds"
      },
      "Resource": "arn:aws:states:::aws-sdk:ec2:describeInstances",
      "ResultSelector": {
        "Value.$": "$.Reservations[0].Instances[0].Tags[0].Value"
      }
    }
  }
}


text:
Q: Read a file of unknown size/length, strip non-alphabetic chars, and change uppercase to lower then it has to be printed to the screen 80 chars per line.
this is done in c.
My coding is super weak and don't know where to begin.
Any help is appreciated

A: given the requirement of change upper case to lower case, will need:
#include <ctype.h>

for the tolower() function and isalnum() function
............
to input the characters from the file, and since each char needs to be processed, will need:
#include <stdio.h>

for the function: getchar() and for the definition of EOF and for the function: putc()
.............
To count the number of characters currently displayed on the current line, will need:
size_t lineLen = 0;

................
to know when to go to the next output line will need that number 80
#define MAX_LINE_LEN (80)

.........
If the command line contains:
myprogram < inputFile.txt

then will not need to open/close the file within the program.
...........
naturally, will need a main() function with no parameters:
int main( void )
{
...
} // end function: main

.........
Since we will be reading a lot of characters, one at a time, will need:
The following while() statement edited so can handle any input char.
int ch;
while( (ch = getchar()) != EOF )
{
...
}

........
Since only displaying printable characters, will need a line like:
if( isalnum( ch ) )
}
....
}

..........
Since displaying only in lower case will need a line like:
ch = tolower( ch );

............
need to actually output the char, and track the length of the line
putc( ch );
lineLen++;

............
need to output a new line after 80 chars and reset counter
if( MAX_LINE_LEN >= lineLen )
{
    lineLen = 0;
    putc( '\n' );
}

............
After the EOF is encountered, will need to output a final newline so all characters are displayed
putc( '\n' );

............
That is really all there is to it.


text:
Q: OpenGL GLSL shaders statistic I am searching program or gl function to get number of local parameter, instructions and another parameters for my GLSL shader. I tried to use GPU ShaderAnalyzer, but it does not help me.

A: I'm not sure what kind of statistics you're looking for, or what exactly you're referring to by "local parameters", but you can get some information back from compiled shaders through the OpenGL API glGetProgram and the functions in the "Associated Gets" section of that article.


text:
Q: Extensions with stored properties I'm still learning Swift, and I'm trying to create an extension to add a placeholder to UITextView.
My idea for it is to create 2 UITextViews, one with a text as a placeholder, and when the user starts editing the text, it's actually hidden and the user is modifying the other UITextView.
However, my question here is not for having a placeholder in UITextView, but it's in regards of how-to use extensions to solve this problem.
My question is, what do I have to change in my implementation to create an extension that would look from the caller side as:
myTextView.placeholder("a placeholder text..")
So far, I have created it in my UIViewController, and need to move it to an extension, but I have a lot of stored properties, so it wouldn't work.
Here's my code:
import UIKit

class ViewController: UIViewController, UITextViewDelegate {

    let myTextView: UITextView = {
        let textView = UITextView()
        textView.tag = 0
        textView.backgroundColor = UIColor.yellow
        textView.layer.cornerRadius = 8
        textView.translatesAutoresizingMaskIntoConstraints = false
        return textView
    }()

    let textViewPlaceHolder: UITextView = {
        let textViewPlaceHolder = UITextView()
        textViewPlaceHolder.tag = 1
        textViewPlaceHolder.text = "Placeholder text.."
        textViewPlaceHolder.textColor = UIColor.lightGray
        textViewPlaceHolder.backgroundColor = UIColor.clear
        textViewPlaceHolder.translatesAutoresizingMaskIntoConstraints = false
        return textViewPlaceHolder
    }()

    func textViewDidChange(_ textView: UITextView) {
        myTextView.becomeFirstResponder()
        if textView.tag == 1 && (myTextView.text != nil || myTextView.text != "") {
            textView.isHidden = true
            textViewPlaceHolder.resignFirstResponder()
        } else if textView.tag == 0 {
            if myTextView.text == nil || myTextView.text == "" {
                textViewPlaceHolder.becomeFirstResponder()
                myTextView.resignFirstResponder()
                textViewPlaceHolder.isHidden = false
                textViewPlaceHolder.text = "Placeholder text.."

            }
        }
    }

    func textViewDidBeginEditing(_ textView: UITextView) {
        DispatchQueue.main.async {
            self.textViewPlaceHolder.selectedRange = NSMakeRange(0, 0)
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.lightGray
        view.addSubview(myTextView)
        textViewConstraints()
        view.addSubview(textViewPlaceHolder)
        myTextViewPHConstraints()

        myTextView.delegate = self
        textViewPlaceHolder.delegate = self

    }

    func textViewConstraints() {
        myTextView.widthAnchor.constraint(equalTo: self.view.widthAnchor, constant: -16).isActive = true
        myTextView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
        myTextView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
        myTextView.heightAnchor.constraint(equalToConstant: 200).isActive = true
    }

    func myTextViewPHConstraints() {
        textViewPlaceHolder.widthAnchor.constraint(equalTo: self.view.widthAnchor, constant: -16).isActive = true
        textViewPlaceHolder.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
        textViewPlaceHolder.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
        textViewPlaceHolder.heightAnchor.constraint(equalToConstant: 200).isActive = true
    }

}

As I mentioned above, I'm still learning Swift and this question is not for solving a very specific problem, it's more than that, it's meant to learn how to solve problems in Swift extensions.
Note: Don't use the code above to solve placeholder problem as it's no perfectly working.

A: You can do something like this:
extension UITextView {

    private struct AssociatedKeys {
        static var placeholder = "placeholder"
    }

    var placeholder: String! {
        get {
            guard let placeholder = objc_getAssociatedObject(self, &AssociatedKeys.placeholder) as? String else {
                return String()
            }

            return placeholder
        }

        set(value) {
            objc_setAssociatedObject(self, &AssociatedKeys.placeholder, value, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
}

A: It's impossible to access stored properties directly in extension.
Create a global class aside, call your global class in you view controllers and in your extension. There you can see all stored variables inside in your extension.


text:
Q: Проверка формы на выбор всех необходимых файлов Есть форма, конкретный фреймворк тут не важен, в которой лейблы и кнопки для выбора файлов. Из файлов формируется отчет и необходимо проверить, что все файлы выбраны. Придумал 2 способа:

*

*При запуске у всех лейблов шаблонная надпись, и при обработке все лейблы просто проверяются соответствие этой шаблонной надписи.

*Создал enum
from enum import Flag, auto

class Form_Flags(Flag):
    File_1 = auto()
    File_2 = auto()
    File_3 = auto()
    All_Files = File_1 | File_2 | File_3

В классе формы переменная selected_files, которая при выборе, допустим, файла 1 изменяется selected_files |= Form_Flags.File_1. И запуске обработки проверяется Form_Flags.All_Files in selected_files.
Вопрос следующий: может есть какой-то другой, более простой и правильный способ?


text:
Q: Finding emails from one file in another I want to find emails from one file listed as such:
john@blogs.com
joe@blogs.com
james@blogs.com

in another file listed as so:
john@blogs.com:+123456789
jack@blogs.com:+123456789
jeff@blogs.com:+123456789
james@blogs.com:+123456789

and output the lines from the second file that match with the first file also keeping in mind it needs to match the entire email from start to finish so it won't match robertjohn@blogs.com accidently.
Desired output:
john@blogs.com:+123456789
james@blogs.com:+123456789

Thanks!

A: With grep, get the newline separated patterns (strings here, -F) from an input file with -f, and match with the other file:
grep -Ff email.txt file.txt

With awk, keeping an array with emails as indexes and checking if the first field of each record in the second file is an index:
awk -F: 'NR==FNR{a[$0]=1; next} a[$1]' email.txt file.txt

Example:
% cat email.txt
john@blogs.com
joe@blogs.com
james@blogs.com

% cat file.txt
john@blogs.com:+123456789
jack@blogs.com:+123456789
jeff@blogs.com:+123456789
james@blogs.com:+123456789

% grep -Ff email.txt file.txt
john@blogs.com:+123456789
james@blogs.com:+123456789

% cat email.txt
john@blogs.com
joe@blogs.com
james@blogs.com

% cat file.txt
john@blogs.com:+123456789
jack@blogs.com:+123456789
jeff@blogs.com:+123456789
james@blogs.com:+123456789

% awk -F: 'NR==FNR{a[$0]=1; next} a[$1]' email.txt file.txt
john@blogs.com:+123456789
james@blogs.com:+123456789


text:
Q: Android Layer List Drawable Move Adjust Item Position How to positon the <item> inside <layer-list> Drawable? Thanks for any help.
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@drawable/radio_uncheck" />    //24dp from vector assset

    <item
        android:drawable="@drawable/check_mark" />    //24dp from vector asset

</layer-list>

A: Using android:left and android:top of the item tag for the check mark will shift the check up and to the right, but it will also shrink the check mark which I don't think you are looking for.
I can think of two other ways to approach this: The first is to just edit the check mark drawable to shift it. You can do this with an editor such as InkScape and there are others. You may need to adjust the overall size slightly to accommodate the shifted check mark. I prefer this approach.
The second approach would be to write a custon LayerDrawable that would override the draw() method to offset the check mark. I might prefer this method if this is something you may need to do with other drawables. If not, I suggest just doing the first suggestion.
If you are willing to abandon the layer drawable, you can also accomplish what you need with a couple of views using translateX and translateY. I am sure that there are other approaches, too.

A: I finally choose to modify the SVG image to meet my needs, following is the process:

*

*Go to "https://materialdesignicons.com/" -> find image -> download SVG image.

*Go to "https://editor.method.ac/" -> "File" -> "Open SVG..." -> choose SVG file -> "Open".

*Adjust canvas width and height on the right panel.

*Adjust the positon of the imported SVG image.

*"File" -> "Save Image..." -> rename file -> "Download".

*Import the SVG image to Android Studio as vector asset.


text:
Q: iCloud Drive taking up space on local drive? My computer seems to be keeping a local copy of my iCloud Drive folder. Is there any way to disable this?
I know this because in my "Library" folder, there is another folder called "Mobile Documents" that links to the contents in my iCloud Drive folder.
Also, when I click on "About This Mac", under "Storage", it includes the iCloud Drive folder's contents.
Is there a way for me to not keep a local copy of the iCloud Drive folder? I don't want it taking up space on my hard drive...

A: No, I don't believe this can be done. This is how the service works - copies of everything in the drive is copied to all devices that have the drive enabled.
You can choose to disable iCloud drive entirely, but you can't pick and choose what files arrive on which device.
Other cloud storage service like Dropbox and Google Drive behave in this way as well.


text:
Q: how to loop javascript for creating bubble popup form more than 1 content for my website mobileapps.co which is in php dynamically driven, it is pulling products from the database. I am also running jquery for creating bubble popup for each products.
How can I loop my javascript for all the products, i am using the following code

<?php foreach ($fetchapps->arr as $result): ?>
  <li id="app-<?php echo $result['appid']; ?>" class="popup0">

  <a href="app-details.php?result=<?php echo $result['appid']; ?>"><?php echo      $result['embeddedcode']; ?>

      <a href="app-details.php?result=<?php echo $result['appid']; ?>"><?php echo substr($result['apptitle'], 0, 15); ?>
  <a href="app-details.php?result=<?php echo $result['appid']; ?>"><?php echo $result['category']; ?>
  <?php if($result['appprice'] != 'free') echo $result['appprice']; ?>
  <?php if($result['appprice']!='free'){ ?>$.<?php } ?><?=$result['appprice']?>

<?php endforeach; ?>

A: try this..
            $(document).ready(function() {
                // notice what i've added..
                // i added a forloop and tried to get the number of popup0 class
                for (var i = 0; i < $('.popup0').length(); i++) {
                    $('.popup0').eq(i).CreateBubblePopup({
                        position: 'top',
                        align: 'center',
                        innerHtml: '<?php echo $result['
                        embeddedcode ']; ?>
<?php echo substr($result['
                        appdesc '], 0, 100); ?>
',
                        innerHtmlStyle: {
                            color: '#FFFFFF',
                            'text-align': 'center'
                        },
                        themeName: 'all-black',
                        themePath: 'images/jquerybubblepopup-theme'
                    });
                }
            });

hope this helps

A: maybe this one?
<?php $rid = rand(0, pow(10, 7)); ?>

$(document).ready(function() {
    $('.<?php echo $rid; ?>').CreateBubblePopup({
        ....
    });
});

markup ...

<li id="app-<?php echo $result['appid']; ?>" class="popup0 <?php echo $rid; ?>">


text:
Q: Add initial note I am looking at adding an inital note to the note page within my app. this is so that when people click to the notes part there will be some detail on how to use it rather than just a big empty screen. I have no idea where to implement this though. Could you please help, below is the page where it talks about the dictionaries.
import UIKit
import MessageUI

class DetailViewController: UIViewController, MFMailComposeViewControllerDelegate, UITextViewDelegate {

@IBOutlet weak var tView: UITextView!
@IBAction func BarButton(sender: UIBarButtonItem) {
        let textToShare = ""

        if let myWebsite = NSURL(string: "")
        {
            let objectsToShare = [textToShare, myWebsite]
            let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)

            self.presentViewController(activityVC, animated: true, completion: nil)
        }

    OpenMail()
}

 override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    tView.text = (allNotes[currentNoteIndex] as Note).note
    tView.becomeFirstResponder()
    // Set controller as swipe gesture recogniser, to allow keyboard dismissal for text box
    var swipe: UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: "dismissKeyboard")

    swipe.direction = UISwipeGestureRecognizerDirection.Down

    self.view.addGestureRecognizer(swipe)
    self.tView.delegate = self

}

 override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated)
    if tView.text == "" {
        allNotes.removeAtIndex(currentNoteIndex)
    }
    else {
        (allNotes[currentNoteIndex] as Note).note = tView.text
    }
    Note.saveNotes()
    noteTable?.reloadData()
}

 override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func configuredMailComposeViewController() -> MFMailComposeViewController {
    // Open mail controller on screen and prepare with preset values.
    let mailComposerVC = MFMailComposeViewController()
    var MessageText: String!
    MessageText = tView.text
    mailComposerVC.mailComposeDelegate = self
    mailComposerVC.setToRecipients([""])
    mailComposerVC.setSubject("")
    mailComposerVC.setMessageBody(MessageText, isHTML: false)

    return mailComposerVC
}

func showSendMailErrorAlert() {
    // Alert user to email error
    let sendMailErrorAlert = UIAlertView(title: "Could Not Send Email", message: "Your device could not send e-mail.  Please check e-mail configuration and try again.", delegate: self, cancelButtonTitle: "OK")
    sendMailErrorAlert.show()
}

// MARK: MFMailComposeViewControllerDelegate Method
func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!) {
    controller.dismissViewControllerAnimated(true, completion: nil)
}

func OpenMail() {
    //Function to open mail composer on screen

    let mailComposeViewController = configuredMailComposeViewController()
    if MFMailComposeViewController.canSendMail() {
        self.presentViewController(mailComposeViewController, animated: true, completion: nil)
    } else {
        self.showSendMailErrorAlert()
    }

}
func dismissKeyboard() {
    // Dismiss keyboard for textfield
    self.tView.resignFirstResponder()

}

}

note.swift
import UIKit

var allNotes:[Note] = []
var currentNoteIndex:NSInteger = -1
var noteTable:UITableView?

let KAllNotes:String = "notes"

class Note: NSObject {
var date:String
var note:String

override init() {
    date = NSDate().description
    note = ""
}

func dictionary() -> NSDictionary {
    return ["note":note, "date":date]
}

class func saveNotes() {
    var aDictionaries:[NSDictionary] = []
    for (var i:NSInteger = 0; i < allNotes.count; i++) {
        aDictionaries.append(allNotes[i].dictionary())
    }
    NSUserDefaults.standardUserDefaults().setObject(aDictionaries, forKey: KAllNotes)
    //        aDictionaries.writeToFile(filePath(), atomically: true)
}

class func loadnotes() {
    allNotes.removeAll(keepCapacity: true)
    var defaults:NSUserDefaults =   NSUserDefaults.standardUserDefaults()
    var savedData:[NSDictionary]? = defaults.objectForKey(KAllNotes) as? [NSDictionary]
    //        var savedData:NSArray? = NSArray(contentsOfFile: filePath())
    if let data:[NSDictionary] = savedData {
        for (var i:NSInteger = 0; i < data.count; i++) {
            var n:Note = Note()
            n.setValuesForKeysWithDictionary(data[i] as [NSObject : AnyObject])
            allNotes.append(n)
        }
    }
}

class func filePath() -> String {
    var d:[String]? = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true) as? [String]
    if let directories:[String] = d {
        var docsDirectory:String = directories[0]
        var path:String = docsDirectory.stringByAppendingPathComponent("\(KAllNotes).notes")
        return path;
    }
    return ""
}

}
Thanks in advance
Sam

A: Add an NSUserDefault boolean that stores whether or not the initial note should be shown, e.g. that the app has been launched for the first time. Then load an initial note accordingly. When a note is added or the initial note is deleted, then change the boolean accordingly so the initial note doesn't show up next time.
You could also initialize your database with an initial note. Not clear from your code how the notes are saved, but this approach would probably rely on the NSUserDefault approach above, except it could be done in the AppDelegate or something.
example:
let InitialSetupComplete = "InitialSetupComplete"   // Note: I would define this at the top of a file
let defaults = NSUserDefaults.standardUserDefaults()
if defaults.boolForKey(InitialSetupComplete) {
    // Show initial note
}

// Later on when the note is deleted, or modified (or immediately after initial note loaded into the database, see below)
defaults.setBool(true, forKey: InitialSetupComplete)

Would be easier/cleaner just to initialize your database with the initial note in the app delegate (e.g. call within applicationDidFinishLaunching), so your view controller doesn't have to figure this out. Similar code, except you would use setBool right away after the initial note has been saved to the database. I don't know anything about your database from the question, so can't really provide a more detailed example than this. Hope this helps.