问:
Want VBA in excel to read very large CSV and create output file of a small subset of the CSV
I have a csv file of 1.2 million records of text.  The alphanumeric fields are wrapped in quotation marks, the date/time or numeric fields are not.

For example
"Fred","Smith",01/07/1967,2,"7, The High Street","Anytown","Anycounty","LS1 7AA"

What I want do is write some VBA in Excel (more or less the only tool available to me that I am reasonably proficient in the use of) that reads the CSV record by record, performs a check (as it happens on the last field, the post code) and then outputs a small subset of the 1.2m records to a new output file.

I understand how to open the two files, read the record, do what I need to do with the data and write it out (I will just output the input record with a prefix denoting an exception type)

What I don't know is how to parse the CSV in VBA properly.  I can't do a simple text scan and search for commas as the text sometimes has commas in (hence why the text fields are text delimited)

Is there a fantastic command that would let me quicky get the data from the nth field in my record?

What I want is
    s_work = field(s_input_record,5) where 5 is the field number in my CSV....

Many thanks,
C

答:
I used the following derivative of the code given above to successfully open an arbitrary csv file from VBA in Excel.

Option Explicit

  Public cn As Connection

  Public Sub DoIt()

  Dim strcon As String

  Dim strsql As String

  Dim rs As Recordset

Set cn = CreateObject("ADODB.Connection")

strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\bin\HomePlanet\;" _

  & "Extended Properties=""text;HDR=Yes;FMT=Delimited"";"

cn.Open strcon

strsql = "SELECT * FROM astuname.csv "

  Set rs = New ADODB.Recordset

  rs.Open strsql, cn

  DoEvents ' pause here to inspect objects and properties
  rs.Close

  End Sub

The rs (recordset) has a collection of fields, with a Count property. Each field as a Type property.

You can reference the fields by sequence number ...

Debug.Print rs.Fields(rs.Fields.Count - 1).Type

Is this sufficient?

If not, post the first several rows of the input file and I'll take it the rest of the way.

OwnerDisplayName: C J

LastEditorDisplayName: eJames

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: le dorfier

LastEditorDisplayName: le dorfier


来源: stackexchange

问:
I'm creating an array in C which calculates the product of an array
It needs to return NAN if the product is 0. At the moment it's calculating some weird values and I'm not quite sure whats wrong.

```<code>#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <math.h>

double array_product( double arr[], int n ) {
    double product = 1;

    for(int i = 0; i <= n; i++){
        if(isfinite(arr[1]) == true){
            product *= arr[1];
        }
    }

    if(product == 1){
    return NAN;
    } else {
    return product;
    }
}

void call_function( const char * label, double x[], int count ) {
    double prod = array_product( x, count );
    printf( "%s\n", label );
    printf( "\tInput data:\n" );

    for ( int i = 0; i < count; i++ ) {
        printf( "\t%d\t%f\n", i, x[i] );
    }

    printf( "\tProduct = %f\n\n", prod );
}

int main( void ) {
    double x1[] = {0};
    call_function( "Count == 0", x1, 0 );

    double x2[] = { NAN, +INFINITY, -INFINITY };
    call_function( "No finite values", x2, 3 );

    double x3[] = { 1, 2, 3, 4, 5, 6, 7 };
    call_function( "Several finite values", x3, 7 );

    double x4[] = { 2, M_PI, NAN, 3, INFINITY, 4 };
    call_function( "A mix of finite values and infinities", x4, 6 );

    return 0;
}
</code>```

The values calculated look correct but when I do the manual calculations the values are much larger.
Thank you in advance for the help

答:
You wrote that you have to return NAN if the product is 0 but your code returns NAN if the product is 1.

Now pay attention that you multiply all the time only the element at position 1 and the loop should iterate till n but not including.

```<code>double array_product( double arr[], int n ) {
    double product = 1.0;
    bool multPerformed = false;

    for(int i = 0; i < n; i++){
        if(isfinite(arr[i])){
            product *= arr[i];
            multPerformed = true;
        }
    }

    if(product == 0.0 || !multPerformed){
        return NAN;
    } else {
        return product;
    }
}
</code>```

Also note that comparing double using == oprator is very dangerous.

ContentLicense: CC BY-SA 3.0

Body:
It needs to return NAN if the product is 0. At the moment it's calculating some weird values and I'm not quite sure whats wrong.

#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <math.h>

double array_product( double arr[], int n ) {
    double product = 1;

    for(int i = 0; i <= n; i++){
        if(isfinite(arr[1]) == true){
            product *= arr[1];
        }
    }

    if(product == 1){
    return NAN;
    } else {
    return product;
    }
}

void call_function( const char * label, double x[], int count ) {
    double prod = array_product( x, count );
    printf( "%s\n", label );
    printf( "\tInput data:\n" );

    for ( int i = 0; i < count; i++ ) {
        printf( "\t%d\t%f\n", i, x[i] );
    }

    printf( "\tProduct = %f\n\n", prod );
}

int main( void ) {
    double x1[] = {0};
    call_function( "Count == 0", x1, 0 );

    double x2[] = { NAN, +INFINITY, -INFINITY };
    call_function( "No finite values", x2, 3 );

    double x3[] = { 1, 2, 3, 4, 5, 6, 7 };
    call_function( "Several finite values", x3, 7 );

    double x4[] = { 2, M_PI, NAN, 3, INFINITY, 4 };
    call_function( "A mix of finite values and infinities", x4, 6 );

    return 0;
}

The values calculated look correct but when I do the manual calculations the values are much larger.
Thank you in advance for the help

Body:
You wrote that you have to return NAN if the product is 0 but your code returns NAN if the product is 1.

Now pay attention that you multiply all the time only the element at position 1 and the loop should iterate till n but not including.

double array_product( double arr[], int n ) {
    double product = 1.0;
    bool multPerformed = false;

    for(int i = 0; i < n; i++){
        if(isfinite(arr[i])){
            product *= arr[i];
            multPerformed = true;
        }
    }

    if(product == 0.0 || !multPerformed){
        return NAN;
    } else {
        return product;
    }
}

Also note that comparing double using == oprator is very dangerous.


问:
MVVM Pattern tutorial for UWP but it wont bind Commands why?
Ok. I'm following a tutorial to master MVVM Pattern to my app.

I've followed the tutorial quite well, I got to the part of commandings and when I try to apply command to a button it doesnt seem to work at all, my button never disables.
I've seen other MVVM sources and my code seems to be fine besides I found this tutorial on internet it was meant for WPF, but it also apply for UWP Windows 10 Apps.

So I'll paste my classes and Xaml views.

this is my Model:

```<code>using System.ComponentModel;

namespace MVVMDemo.Model
{
public class Student : INotifyPropertyChanged
{
    private string firstName;
    private string lastName;

    public string FirstName
    {
        get
        {
            return firstName;
        }

        set
        {
            if (firstName != value)
            {
                firstName = value;
                RaisePropertyChanged("FirstName");
                RaisePropertyChanged("FullName");
            }
        }
    }

    public string LastName
    {
        get { return lastName; }

        set
        {
            if (lastName != value)
            {
                lastName = value;
                RaisePropertyChanged("LastName");
                RaisePropertyChanged("FullName");
            }
        }
    }

    public string FullName
    {
        get
        {
            return firstName + " " + lastName;
        }
    }

    public event PropertyChangedEventHandler PropertyChanged = delegate { };

    private void RaisePropertyChanged(string property)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
    }
}
}
</code>```

The model code I believe has no errors on it.
this is my ViewModel:

```<code>using MVVMDemo.Model;
using System.Collections.ObjectModel;

namespace MVVMDemo.ViewModel
{
public class StudentViewModel
{
    /*Let’s add a property of MyICommand type in StudentView Model class.
     * Now we need to construct an instance in the StudentViewModel. We will
     * use the overloaded constructor of MyICommand that takes two parameters.*/
    public MyICommand DeleteCommand { get; set; }

    /*Now add the implementation of OnDelete and CanDelete methods.*/
    public StudentViewModel()
    {
        LoadStudents();
        DeleteCommand = new MyICommand(OnDelete, CanDelete);
    }

    private bool CanDelete()
    {
        //if (SelectedStudent != null)
        //    return true;
        //return false;
        return SelectedStudent != null;
    }

    private void OnDelete()
    {
        Students.Remove(SelectedStudent);
    }

    /*We also need to add a new SelectedStudent so that the user
     * can delete the Selected Item from ListBox.*/
    private Student _selectedStudent;

    public Student SelectedStudent
    {
        get
        {
            return _selectedStudent;
        }
        set
        {
            _selectedStudent = value;
            DeleteCommand.RaiseCanExecuteChanged();
        }
    }
    public ObservableCollection<Student> Students
    {
        get;
        set;
    }

    public void LoadStudents()
    {
        ObservableCollection<Student> students = new ObservableCollection<Student>();

        students.Add(new Student { FirstName = "Mark", LastName = "Allain" });
        students.Add(new Student { FirstName = "Allen", LastName = "Brown" });
        students.Add(new Student { FirstName = "Linda", LastName = "Hamerski" });

        Students = students;
    }
}
}
</code>```

This is my ViewModelLocator:

```<code>using MVVMDemo.ViewModel;

namespace MVVMDemo.VML
{
public class ViewModelLocator
{
private static StudentViewModel studentViewModel = new StudentViewModel();

    public static StudentViewModel StudentViewModel
    {
        get { return studentViewModel; }
    }
}
}
</code>```

and at Last this is my View my UserControl StudentView

```<code><UserControl
    x:Class="MVVMDemo.Views.StudentView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MVVMDemo.Views"
    xmlns:vml="using:MVVMDemo.VML"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    DataContext="{Binding Source={StaticResource mainViewModelLocator}, Path=StudentViewModel}"
    d:DesignHeight="300"
    d:DesignWidth="400">

<!--We will apply MVVM Using ItemTemplates-->
<UserControl.Resources>
    <DataTemplate x:Key = "studentsTemplate">

        <StackPanel Orientation = "Horizontal">
            <TextBox Text = "{Binding Path = FirstName, Mode = TwoWay}"
        Width = "100" Margin = "3 5 3 5"/>

            <TextBox Text = "{Binding Path = LastName, Mode = TwoWay}"
        Width = "100" Margin = "0 5 3 5"/>

            <TextBlock Text = "{Binding Path = FullName, Mode = OneWay}"
        Margin = "0 5 3 5"/>
        </StackPanel>

    </DataTemplate>
</UserControl.Resources>

<Grid>
    <StackPanel Orientation="Horizontal">
        <!--In StudentView.xaml, we need to add SelectedItem property in a ListBox
        which will bind to the SelectStudent property.-->
        <ListView ItemsSource="{Binding Students}"
                  ItemTemplate="{StaticResource studentsTemplate}"
                  SelectedItem="{Binding SelectedStudent}"/>

        <Button Content = "Delete"
                Command="{Binding DeleteCommand}"
                HorizontalAlignment = "Left"
                VerticalAlignment = "Top"
                Width = "75"/>
    </StackPanel>
</Grid>
</UserControl>
</code>```

I'm applying the viewmodellocator on the app.xaml file at application level:

```<code><Application.Resources>
    <vml:ViewModelLocator x:Key="mainViewModelLocator"/>
</Application.Resources>
</code>```

and I call my view on the main page like this:

can somebody help me, I've run this code on VS2015 and VS2017 and the Delete button never gets enabled and it also doesnt delete the rows from the listview or listbox i've tried changing them and nothing seems to be different.

I've even had a commanding implemetation without using the relaycommand pattern as it is used here.
I would appreciate your help.

Thanks!!!

答:
Edit : (this is not an answer but another way to do it)

Do you know you can bind methods directly to events with {x:Bind}. You don't need to use ICommand.

XAML

```<code>     <Button Grid.Row="4"
      x:Uid="Send"
      VerticalAlignment="Top"
      HorizontalAlignment="Left"
      MinWidth="80"
      Click="{x:Bind ViewModel.SendFeedback}"/>
</code>```

Code Behind

```<code>    public async void SendFeedback()
    {
        // Code
    }
</code>```

Easier with this way :)

Body:
Ok. I'm following a tutorial to master MVVM Pattern to my app.

I've followed the tutorial quite well, I got to the part of commandings and when I try to apply command to a button it doesnt seem to work at all, my button never disables.
I've seen other MVVM sources and my code seems to be fine besides I found this tutorial on internet it was meant for WPF, but it also apply for UWP Windows 10 Apps.

So I'll paste my classes and Xaml views.

this is my Model:

using System.ComponentModel;

namespace MVVMDemo.Model
{
public class Student : INotifyPropertyChanged
{
    private string firstName;
    private string lastName;

    public string FirstName
    {
        get
        {
            return firstName;
        }

        set
        {
            if (firstName != value)
            {
                firstName = value;
                RaisePropertyChanged("FirstName");
                RaisePropertyChanged("FullName");
            }
        }
    }

    public string LastName
    {
        get { return lastName; }

        set
        {
            if (lastName != value)
            {
                lastName = value;
                RaisePropertyChanged("LastName");
                RaisePropertyChanged("FullName");
            }
        }
    }

    public string FullName
    {
        get
        {
            return firstName + " " + lastName;
        }
    }

    public event PropertyChangedEventHandler PropertyChanged = delegate { };

    private void RaisePropertyChanged(string property)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
    }
}
}

The model code I believe has no errors on it.
this is my ViewModel:

using MVVMDemo.Model;
using System.Collections.ObjectModel;

namespace MVVMDemo.ViewModel
{
public class StudentViewModel
{
    /*Let’s add a property of MyICommand type in StudentView Model class.
     * Now we need to construct an instance in the StudentViewModel. We will
     * use the overloaded constructor of MyICommand that takes two parameters.*/
    public MyICommand DeleteCommand { get; set; }

    /*Now add the implementation of OnDelete and CanDelete methods.*/
    public StudentViewModel()
    {
        LoadStudents();
        DeleteCommand = new MyICommand(OnDelete, CanDelete);
    }

    private bool CanDelete()
    {
        //if (SelectedStudent != null)
        //    return true;
        //return false;
        return SelectedStudent != null;
    }

    private void OnDelete()
    {
        Students.Remove(SelectedStudent);
    }

    /*We also need to add a new SelectedStudent so that the user
     * can delete the Selected Item from ListBox.*/
    private Student _selectedStudent;

    public Student SelectedStudent
    {
        get
        {
            return _selectedStudent;
        }
        set
        {
            _selectedStudent = value;
            DeleteCommand.RaiseCanExecuteChanged();
        }
    }
    public ObservableCollection<Student> Students
    {
        get;
        set;
    }

    public void LoadStudents()
    {
        ObservableCollection<Student> students = new ObservableCollection<Student>();

        students.Add(new Student { FirstName = "Mark", LastName = "Allain" });
        students.Add(new Student { FirstName = "Allen", LastName = "Brown" });
        students.Add(new Student { FirstName = "Linda", LastName = "Hamerski" });

        Students = students;
    }
}
}

This is my ViewModelLocator:

using MVVMDemo.ViewModel;

namespace MVVMDemo.VML
{
public class ViewModelLocator
{
private static StudentViewModel studentViewModel = new StudentViewModel();

    public static StudentViewModel StudentViewModel
    {
        get { return studentViewModel; }
    }
}
}

and at Last this is my View my UserControl StudentView

<UserControl
    x:Class="MVVMDemo.Views.StudentView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MVVMDemo.Views"
    xmlns:vml="using:MVVMDemo.VML"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    DataContext="{Binding Source={StaticResource mainViewModelLocator}, Path=StudentViewModel}"
    d:DesignHeight="300"
    d:DesignWidth="400">

<UserControl.Resources>
    <DataTemplate x:Key = "studentsTemplate">

        <StackPanel Orientation = "Horizontal">
            <TextBox Text = "{Binding Path = FirstName, Mode = TwoWay}"
        Width = "100" Margin = "3 5 3 5"/>

            <TextBox Text = "{Binding Path = LastName, Mode = TwoWay}"
        Width = "100" Margin = "0 5 3 5"/>

            <TextBlock Text = "{Binding Path = FullName, Mode = OneWay}"
        Margin = "0 5 3 5"/>
        </StackPanel>

    </DataTemplate>
</UserControl.Resources>

<Grid>
    <StackPanel Orientation="Horizontal">

        <ListView ItemsSource="{Binding Students}"
                  ItemTemplate="{StaticResource studentsTemplate}"
                  SelectedItem="{Binding SelectedStudent}"/>

        <Button Content = "Delete"
                Command="{Binding DeleteCommand}"
                HorizontalAlignment = "Left"
                VerticalAlignment = "Top"
                Width = "75"/>
    </StackPanel>
</Grid>
</UserControl>

I'm applying the viewmodellocator on the app.xaml file at application level:

<Application.Resources>
    <vml:ViewModelLocator x:Key="mainViewModelLocator"/>
</Application.Resources>

and I call my view on the main page like this:

can somebody help me, I've run this code on VS2015 and VS2017 and the Delete button never gets enabled and it also doesnt delete the rows from the listview or listbox i've tried changing them and nothing seems to be different.

I've even had a commanding implemetation without using the relaycommand pattern as it is used here.
I would appreciate your help.

Thanks!!!

Body:
Edit : (this is not an answer but another way to do it)

Do you know you can bind methods directly to events with {x:Bind}. You don't need to use ICommand.

XAML

     <Button Grid.Row="4"
      x:Uid="Send"
      VerticalAlignment="Top"
      HorizontalAlignment="Left"
      MinWidth="80"
      Click="{x:Bind ViewModel.SendFeedback}"/>

Code Behind

    public async void SendFeedback()
    {
        // Code
    }

Easier with this way :)


问:
Making the data from the csv file double when put in the Textbox
txtRate.setText(emp.getRate());

I cant display the data from the csv file in the textbox because it keeps on saying

double cannot be converted to java.lang.String.
My method is public Double getRate()
If i try to make is public String it would work but i cant use the value for calculation because it already has been set
to String

答: Displaying data on the textbox require variable to be string, But calculation require variable to be double the answer is when displaying cast to string and when calculation don't </p>


问:
Video keeps on playing even when modal box is closed
I am embedding a Wistia video to open in a modal box.
I have embedded the same fine, but the video still keeps on playing when I close the modal box.

Code as below.

The HTML

```<code><a target="_self" class="wistia_embed" name="wistia_embed" id="myImg">Watch Now</a>
<div id="myModal" class="modal">
  <iframe allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed modal-content" name="wistia_embed" src="https://fast.wistia.com/embed/iframe/g5pnf59ala" width="480" height="273"></iframe>
  <div id="caption"></div>
</div>
</code>```

The Script:

```<code>var modal = document.getElementById('myModal');
var img = document.getElementById('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function(){
    modal.style.display = "block";
    modalImg.src = this.src;
    captionText.innerHTML = this.alt;
}
var modal = document.getElementsByClassName("modal")[0];
modal.onclick = function() {
    modal.style.display = "none";
}
</code>```

JSFiddle demo link:

FIDDLE LIVE DEMO

When you click on Watch now, the video opens. When you click outside, the modal closes, but the video still plays.

I want the video to close when the modal is closed, but its not working for me.
Secondly, I would also want the video to autoplay when you click on "watch Now".

答:
Try this (updated):

https://jsfiddle.net/tonnjngm/

```<code>var modal = document.getElementsByClassName("modal")[0];
modal.onclick = function() {
    modal.style.display = "none";
    var src = modal.querySelector('iframe').getAttribute('src');
    modal.querySelector('iframe').setAttribute('src', src);
}
</code>```

Resetting src kind of stops the video.

Body:
I am embedding a Wistia video to open in a modal box.
I have embedded the same fine, but the video still keeps on playing when I close the modal box.

Code as below.

The HTML

Watch Now

The Script:

var modal = document.getElementById('myModal');
var img = document.getElementById('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function(){
    modal.style.display = "block";
    modalImg.src = this.src;
    captionText.innerHTML = this.alt;
}
var modal = document.getElementsByClassName("modal")[0];
modal.onclick = function() {
    modal.style.display = "none";
}

JSFiddle demo link:

FIDDLE LIVE DEMO

When you click on Watch now, the video opens. When you click outside, the modal closes, but the video still plays.

I want the video to close when the modal is closed, but its not working for me.
Secondly, I would also want the video to autoplay when you click on "watch Now".

Body:
Try this (updated):

https://jsfiddle.net/tonnjngm/

var modal = document.getElementsByClassName("modal")[0];
modal.onclick = function() {
    modal.style.display = "none";
    var src = modal.querySelector('iframe').getAttribute('src');
    modal.querySelector('iframe').setAttribute('src', src);
}

Resetting src kind of stops the video.


问:
Change Name of Text with CSS
I am trying to change the text from "Menu" to "Close Menu" when Menu is open. I have no idea how to do it.

This is my HTML:

```<code><input type="checkbox" id="responsive-nav">
<label for="responsive-nav" class="responsive-nav-label">
    <span>☰</span> Menu
</label>

<nav>
    <ul>
        <li><a href="download.php">Download Apps</a></li>
        <li><a href="manual.php">Download Manuals</a></li>
    </ul>
</nav>
</code>```

This is my CSS:

```<code>/* MENU */

/* hide the checkbox and the label */
input#responsive-nav,
label.responsive-nav-label {
    display: none;
    font-size: 15pt;
}

/* declarations for the not-responsove-menu */
nav {
    width: 220px;  /* Darüber laesst sich die breite des Aufklappmenue steuern */
    margin-left: -10px;
    background: black
}

nav ul {
    padding: 0px;
    margin-left: -10px;
    margin-top: 43px;
}

nav a {
    display: block;
    background: #FFF;
    text-decoration: none;
    color: white;
    font-size: 15pt;
}

nav ul li {
    position: relative;
    float: left;
    list-style: none;
    color: #FFF;
    transition: 0.5s;
}

/* Declarations for the responsive menu 1680px */
@media screen and (max-width: 15360px) {

    * {
        font-size: 15pt;
    }

    label.responsive-nav-label {
        position: relative;
        display: block;
        padding: 0px;
        background: black;
        cursor: pointer;
        color: #fff;
    }

    nav {
        position: absolute;
        top: -9999px;
        padding: 0px;
    }

    input#responsive-nav[type=checkbox]:checked ~ nav {
        position: relative;
        top: 0;
    }

    nav a:after {
        display: none;
    }

    nav li {
        float: none !important;
        width: 100% !important;
        border-bottom: none !important;
    }

    nav li a {
        margin-bottom: 10px !important;
        padding: 10px 20px !important;
        background: black;
    }

    nav ul li:hover {
        background: none;
    }

    nav ul li a:hover {
        background: black;
        color: #11BEE0
    }
}
/* END OF MENU */
</code>```

答:
There is a similar question to yours.

if you are insistent to replace text content with css, you can visit the link below.

How to change content on hover

otherwise it's highly recommended to use javascript instead of css to replace or toggle content.

$(document).on("click","#menu-label",function(){
var $this = $(this);

 if ($this.text() === "Menu"){
      $this.text("Close")
 }else {
      $this.text("Menu")
 }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>/* hide the checkbox and the label */

input#responsive-nav,
label.responsive-nav-label {
display: none;
font-size: 15pt;
}

/* declarations for the not-responsove-menu */

nav {
  width: 220px;  /* Darüber laesst sich die breite des Aufklappmenue steuern */
  margin-left: -10px;
background: black
}

nav ul {
  padding: 0px;
  margin-left: -10px;
  margin-top: 43px;
}

nav a {
  display: block;
  background: #FFF;
  text-decoration: none;
 color: white;
 font-size: 15pt;
}

nav ul li {
  position: relative;
  float: left;
  list-style: none;
  color: #FFF;
  transition: 0.5s;
}

/* Declarations for the responsive menu 1680px */
@media screen and (max-width: 15360px) {

* {
font-size: 15pt;
}

label.responsive-nav-label {
  position: relative;
  display: block;
  padding: 0px;
  background: black;
  cursor: pointer;
  color: #fff;
}

nav {
  position: absolute;
  top: -9999px;
  padding: 0px;
}

input#responsive-nav[type=checkbox]:checked ~ nav {
  position: relative;
  top: 0;
}

nav a:after {
  display: none;
}

nav li {
  float: none !important;
  width: 100% !important;
  border-bottom: none !important;
}

nav li a {
  margin-bottom: 10px !important;
  padding: 10px 20px !important;
background: black;
}

nav ul li:hover {
  background: none;
}

nav ul li a:hover {
  background: black;
  color: #11BEE0
}

}
/* END OF MENU */</code>```

<input type="checkbox" id="responsive-nav">
☰ Menu

Download Apps

Download Manuals

```

Title: Change Name of Text with CSS

Body:
I am trying to change the text from "Menu" to "Close Menu" when Menu is open. I have no idea how to do it.

This is my HTML:

<input type="checkbox" id="responsive-nav">

    ☰ Menu

Download Apps

Download Manuals

This is my CSS:

/* MENU */

/* hide the checkbox and the label */
input#responsive-nav,
label.responsive-nav-label {
    display: none;
    font-size: 15pt;
}

/* declarations for the not-responsove-menu */
nav {
    width: 220px;  /* Darüber laesst sich die breite des Aufklappmenue steuern */
    margin-left: -10px;
    background: black
}

nav ul {
    padding: 0px;
    margin-left: -10px;
    margin-top: 43px;
}

nav a {
    display: block;
    background: #FFF;
    text-decoration: none;
    color: white;
    font-size: 15pt;
}

nav ul li {
    position: relative;
    float: left;
    list-style: none;
    color: #FFF;
    transition: 0.5s;
}

/* Declarations for the responsive menu 1680px */
@media screen and (max-width: 15360px) {

    * {
        font-size: 15pt;
    }

    label.responsive-nav-label {
        position: relative;
        display: block;
        padding: 0px;
        background: black;
        cursor: pointer;
        color: #fff;
    }

    nav {
        position: absolute;
        top: -9999px;
        padding: 0px;
    }

    input#responsive-nav[type=checkbox]:checked ~ nav {
        position: relative;
        top: 0;
    }

    nav a:after {
        display: none;
    }

    nav li {
        float: none !important;
        width: 100% !important;
        border-bottom: none !important;
    }

    nav li a {
        margin-bottom: 10px !important;
        padding: 10px 20px !important;
        background: black;
    }

    nav ul li:hover {
        background: none;
    }

    nav ul li a:hover {
        background: black;
        color: #11BEE0
    }
}
/* END OF MENU */

Body:
There is a similar question to yours.

if you are insistent to replace text content with css, you can visit the link below.

How to change content on hover

otherwise it's highly recommended to use javascript instead of css to replace or toggle content.

$(document).on("click","#menu-label",function(){
var $this = $(this);

 if ($this.text() === "Menu"){
      $this.text("Close")
 }else {
      $this.text("Menu")
 }
});

/* hide the checkbox and the label */

input#responsive-nav,
label.responsive-nav-label {
display: none;
font-size: 15pt;
}

/* declarations for the not-responsove-menu */

nav {
  width: 220px;  /* Darüber laesst sich die breite des Aufklappmenue steuern */
  margin-left: -10px;
background: black
}

nav ul {
  padding: 0px;
  margin-left: -10px;
  margin-top: 43px;
}

nav a {
  display: block;
  background: #FFF;
  text-decoration: none;
 color: white;
 font-size: 15pt;
}

nav ul li {
  position: relative;
  float: left;
  list-style: none;
  color: #FFF;
  transition: 0.5s;
}

/* Declarations for the responsive menu 1680px */
@media screen and (max-width: 15360px) {

* {
font-size: 15pt;
}

label.responsive-nav-label {
  position: relative;
  display: block;
  padding: 0px;
  background: black;
  cursor: pointer;
  color: #fff;
}

nav {
  position: absolute;
  top: -9999px;
  padding: 0px;
}

input#responsive-nav[type=checkbox]:checked ~ nav {
  position: relative;
  top: 0;
}

nav a:after {
  display: none;
}

nav li {
  float: none !important;
  width: 100% !important;
  border-bottom: none !important;
}

nav li a {
  margin-bottom: 10px !important;
  padding: 10px 20px !important;
background: black;
}

nav ul li:hover {
  background: none;
}

nav ul li a:hover {
  background: black;
  color: #11BEE0
}

}
/* END OF MENU */

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" id="responsive-nav">
<label for="responsive-nav" class="responsive-nav-label" ><span>&#9776;</span> <span id="menu-label">Menu</span></label>

<nav>
  <ul>
    <li><a href="download.php">Download Apps</a></li>
    <li><a href="manual.php">Download Manuals</a></li>
  </ul>
</nav>


问:
Smarty : evaluate a template stored in a PHP variable
i have a php variable which has html/smarty code in it

```<code>$x='<a href="{$link}" >{$title}</a>';
</code>```

This data is fetched from database , i want to evaluate it using smarty and put the output into a php variable (to print it out or to save it to the database again) .

Thanks

Edit :

i want the content of X to be evaluated using smarty , as if the content of x is stored in a file.tpl then $y=$smarty->fetch('file.tpl'); ... want to do it without the need to save the content of x into a file

答:
If you're using Smarty 3, you can easily do it by

```<code>$smarty->fetch('string:'.$template_string);
</code>```

or 'eval:'.$template_string.
more about it in the manual

Body:
i have a php variable which has html/smarty code in it

$x='{$title}';

This data is fetched from database , i want to evaluate it using smarty and put the output into a php variable (to print it out or to save it to the database again) .

Thanks

Edit :

i want the content of X to be evaluated using smarty , as if the content of x is stored in a file.tpl then $y=$smarty->fetch('file.tpl'); ... want to do it without the need to save the content of x into a file

Body:
If you're using Smarty 3, you can easily do it by

$smarty->fetch('string:'.$template_string);

or 'eval:'.$template_string.
more about it in the manual


问:
What is the date format for this string?
I've got the following date as a string

```<code>2017-03-01T10:15:41-0800
</code>```

that I'm trying to use with

```<code>new Date().parse('dd/mm/yyyy', dateString)
</code>```

However, I can't figure out the format.

答:
Your dateString and date format dont match.
Groovy Style:

```<code>def dateString =  "2017-03-01T10:15:41-0800"
new Date().parse("yyyy-MM-dd'T'HH:mm:ssZ", dateString)
</code>```

Result:

```<code>Wed Mar 01 21:15:41 EAT 2017
</code>```

You can refer here for more information about the date format pattern.

Body:
I've got the following date as a string

2017-03-01T10:15:41-0800

that I'm trying to use with

new Date().parse('dd/mm/yyyy', dateString)

However, I can't figure out the format.

Body:
Your dateString and date format dont match.
Groovy Style:

def dateString =  "2017-03-01T10:15:41-0800"
new Date().parse("yyyy-MM-dd'T'HH:mm:ssZ", dateString)

Result:

Wed Mar 01 21:15:41 EAT 2017

You can refer here for more information about the date format pattern.


问:
UITableView and custom UITableViewCell using .xib
In my app I am using a custom tableViewCell using a xib file. I create the .xib file outlet the labels etc to my TableViewCell class

In my ViewController the code I used to populate and show the cell on the table view is as follows:

```<code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let transaction = statementArray[indexPath.row]
    let cell = Bundle.main.loadNibNamed("StatementCell", owner: self, options: nil)?.first as! StatementCell

    cell.transAmount.text = String(transaction.transAmount)
    cell.transDesc.text = transaction.transDesc
    cell.transFees.text = String(transaction.transFees)

    return cell
}
</code>```

I am aware that the way tableViews work is that they reuse the cell that goes off the screen. Is the way i am loading the .xib and populating the cell correct? Or do I have to add something to my code?

答:
One more thing is you need to register your class for reuse identifier in viewDidLoad method.

```<code>YourTable.registerclass(tablecell, forCellReuseIdentifier: "identifier"
</code>```

And make sure you have connect all the required outlets.

ContentLicense: CC BY-SA 4.0

Body:
In my app I am using a custom tableViewCell using a xib file. I create the .xib file outlet the labels etc to my TableViewCell class

In my ViewController the code I used to populate and show the cell on the table view is as follows:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let transaction = statementArray[indexPath.row]
    let cell = Bundle.main.loadNibNamed("StatementCell", owner: self, options: nil)?.first as! StatementCell

    cell.transAmount.text = String(transaction.transAmount)
    cell.transDesc.text = transaction.transDesc
    cell.transFees.text = String(transaction.transFees)

    return cell
}

I am aware that the way tableViews work is that they reuse the cell that goes off the screen. Is the way i am loading the .xib and populating the cell correct? Or do I have to add something to my code?

Body:
One more thing is you need to register your class for reuse identifier in viewDidLoad method.

YourTable.registerclass(tablecell, forCellReuseIdentifier: "identifier"

And make sure you have connect all the required outlets.


问:
how to generate a series of data frame using loops in R
In R how to use a for loop to create a series of data frame? Just for illustration purpose, if need to keep all setosa species of iris data frame to df_setosa, all versicolor in df_versicolor, how to do so? </p>

答: You could use split which will will give you a list with your dataframes.


问:
Data truncated for column?
After changing the data type of a MySql column in order to store Twilio call ids (34 char strings), I try to manually change the data in that column with:

```<code>update calls
   set incoming_Cid='CA9321a83241035b4c3d3e7a4f7aa6970d'
 where id='1';
</code>```

However I get an error which doesn't make sense seeing as the column's data type was properly modified?

| Level ||| Code | Message
  | Warning | 1265 | Data truncated for column 'incoming_Cid' at row 1

答:
I had the same problem because of an table column which was defined as ENUM('x','y','z') and later on I was trying to save the value 'a' into this column, thus I got the mentioned error.

Solved by altering the table column definition and added value 'a' into the enum set.

Title: Data truncated for column?

Body:
After changing the data type of a MySql column in order to store Twilio call ids (34 char strings), I try to manually change the data in that column with:

update calls
   set incoming_Cid='CA9321a83241035b4c3d3e7a4f7aa6970d'
 where id='1';

However I get an error which doesn't make sense seeing as the column's data type was properly modified?

| Level ||| Code | Message
  | Warning | 1265 | Data truncated for column 'incoming_Cid' at row 1


问:
Jquery exclude element that not have  inside
how can I exclude from this selection element that not have a href="#" inside of it?
I want my stuff is executed only for .leading that have a href="#"...
thank you

```<code>//js
$(".leading").hover(function(){
// do stuff
}

//DOM
<div class=".leading"><div ><a href="#"> <img src="img1.jpg" /> jquery affected </a></div></div>
<div class=".leading"><div ><img src="img2.jpg" /> jquery not affected </div></div>
</code>```

答:
Something like this I believe:

```<code>$('.leading:has(a[href=#])');
</code>```

Note, your classes should not have a dot . prefix in the HTML itself.

Title: Jquery exclude element that not have <a href="#"> inside

Body:
how can I exclude from this selection element that not have a href="#" inside of it?
I want my stuff is executed only for .leading that have a href="#"...
thank you

//js
$(".leading").hover(function(){
// do stuff
}

//DOM

  jquery affected

 jquery not affected

Body:
Something like this I believe:

$('.leading:has(a[href=#])');

Note, your classes should not have a dot . prefix in the HTML itself.


问:
Unity3D movement way (Translate, MovePosition, velocity=, AddForce)
I'm confused about movement in Unity3D.
Let me clarify my understanding.

I think that movement depends on

methods(Translate, MovePosition, velocity=, AddForce)

Rigidbody.isKinematic

And the relationship can summarize below tabulated list.

information source

information source is docs.unity3d.com and my experiment script

doc says that MovePosition cause a smooth transition When isKinematic == true, however, I can't reproduce it.

Question.

is this table correct?

答: You need to set Interpolate dropdown list to Interpolate on the rigibody then it will smooth out the transition using MovePosition when isKinimatic. Note: It will still move very fast, it will move there in 1 FixedUpdate but if you step update you will see that it tries to smooth the transition.


问:
Shared library with freeglut - undefined symbol
I'm actually experiencing some issues while linking an OpenGL/freeglut shared library (.so) with a C++ project. I'm sure that the problem is in my Makefile since the code I use to load (using the dlopen/dlsym/dlclose functions) works fine with other shared libraries.
I thought it comes from headers inclusions but the OpenGL project I'm trying to work with compiles when I create an executable of it. I've also checked the glut FAQ but the solution now redirect to a dead link So there is my Makefile content, does anyone see where I am wrong ?

```<code>TARGET   = lib_opengl.so
CC       = g++

SRC      = GL_Handler.cpp       \
           GL_Utils.cpp

DEVIL_CFLAGS    := $(shell pkg-config --cflags IL)
DEVIL_LIBS      := $(shell pkg-config --libs IL)

LIBS    += -lGL -lGLU -lglut $(DEVIL_CFLAGS) $(DEVIL_LIBS)

CFLAGS   = -W -Werror -Wall -ansi -pedantic -fPIC -shared  -L/usr/X11R6/lib/ $(LIBS)

SRCDIR   = src
OBJDIR   = obj

SOURCES  := $(addprefix src/, $(SRC))

OBJECTS  := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)

rm       = rm -rf
mkdir    = mkdir -p

$(TARGET): $(OBJECTS)
        @$(CC) $(CFLAGS) -o $@ $(OBJECTS)
        @echo $(TARGET)" compiled !"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
        @$(mkdir) $(OBJDIR)
        @$(CC) $(CFLAGS) -c $< -o $@

all     : $(TARGET)

clean   :
        @$(rm) $(OBJDIR)
        @echo "Binary files deleted"

fclean  : clean
        @$(rm) $(TARGET) $(LINK)
        @echo "Binary and executable files are deleted"

re      : fclean all

.PHONY: all clean fclean re
</code>```

And there is the result when I'm trying to link it with my shared libraries loader.

```<code>./so_loader ./lib/lib_opengl.so
./so_loader: symbol lookup error: ./lib/lib_opengl.so: undefined symbol: glutInit
</code>```

I hope that my problem is understandable and thanks for reading.

答:
As a start, use variable LDFLAGS for linking instead of CFLAGS which is meant for compilation. Something like this:</p>

```<code>LDFLAGS   = -L/usr/X11R6/lib
...
$(TARGET): LDFLAGS += -shared -Wl,--no-undefined
$(TARGET): $(OBJECTS)
        @$(CC) $(LDFLAGS) -o $@ $(OBJECTS) ${LIBS}
</code>```

Body:
I'm actually experiencing some issues while linking an OpenGL/freeglut shared library (.so) with a C++ project. I'm sure that the problem is in my Makefile since the code I use to load (using the dlopen/dlsym/dlclose functions) works fine with other shared libraries.
I thought it comes from headers inclusions but the OpenGL project I'm trying to work with compiles when I create an executable of it. I've also checked the glut FAQ but the solution now redirect to a dead link So there is my Makefile content, does anyone see where I am wrong ?

TARGET   = lib_opengl.so
CC       = g++

SRC      = GL_Handler.cpp       \
           GL_Utils.cpp

DEVIL_CFLAGS    := $(shell pkg-config --cflags IL)
DEVIL_LIBS      := $(shell pkg-config --libs IL)

LIBS    += -lGL -lGLU -lglut $(DEVIL_CFLAGS) $(DEVIL_LIBS)

CFLAGS   = -W -Werror -Wall -ansi -pedantic -fPIC -shared  -L/usr/X11R6/lib/ $(LIBS)

SRCDIR   = src
OBJDIR   = obj

SOURCES  := $(addprefix src/, $(SRC))

OBJECTS  := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)

rm       = rm -rf
mkdir    = mkdir -p

$(TARGET): $(OBJECTS)
        @$(CC) $(CFLAGS) -o $@ $(OBJECTS)
        @echo $(TARGET)" compiled !"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
        @$(mkdir) $(OBJDIR)
        @$(CC) $(CFLAGS) -c $< -o $@

all     : $(TARGET)

clean   :
        @$(rm) $(OBJDIR)
        @echo "Binary files deleted"

fclean  : clean
        @$(rm) $(TARGET) $(LINK)
        @echo "Binary and executable files are deleted"

re      : fclean all

.PHONY: all clean fclean re

And there is the result when I'm trying to link it with my shared libraries loader.

./so_loader ./lib/lib_opengl.so
./so_loader: symbol lookup error: ./lib/lib_opengl.so: undefined symbol: glutInit

I hope that my problem is understandable and thanks for reading.

Body:
As a start, use variable LDFLAGS for linking instead of CFLAGS which is meant for compilation. Something like this:

LDFLAGS   = -L/usr/X11R6/lib
...
$(TARGET): LDFLAGS += -shared -Wl,--no-undefined
$(TARGET): $(OBJECTS)
        @$(CC) $(LDFLAGS) -o $@ $(OBJECTS) ${LIBS}


问:
function "onclick" is called even though it is not set in button
I have following code. I haven't been able able to figure out why click event occurs even though I haven't set the function to onclick attribute of button.

var x = 0;
var onclick = function() {
  console.log("x = " + ++x);
};```
<pre class="snippet-code-html lang-html prettyprint-override"><code><button type="button" onclick="">Click</button></code>```

答:
Well you set global variable onclick, which translates to global object window property onclick. This is basically the same as if you were to set it directly:

```<code>window.onclick = function() {
    console.log("x = " + ++x);
};
</code>```

And because you have set click event on entire window object, it will fire not only on button click but on click on anything within your document (unless event propagation is stopped).

Body:
I have following code. I haven't been able able to figure out why click event occurs even though I haven't set the function to onclick attribute of button.

var x = 0;
var onclick = function() {
  console.log("x = " + ++x);
};

<button type="button" onclick="">Click</button>

Body:
Well you set global variable onclick, which translates to global object window property onclick. This is basically the same as if you were to set it directly:

window.onclick = function() {
    console.log("x = " + ++x);
};

And because you have set click event on entire window object, it will fire not only on button click but on click on anything within your document (unless event propagation is stopped).


问:
Can I execute a shell or system call without a fork?
I have a TCP server application which occasionally needs to reconfigure the bound ports by closing them and then opening them at a later time.

The application also needs to execute an external binary with communication to it. This is currently done using a popen() call. The external binary run time can span the period when the network ports need to be reconfigured.

The problem is, when the main application closes a port it is taken on by the 'forked' process which popen has created to run the binary.

That makes sense (it's discussed at What happens when a tcp server binds and forks before doing an accept ? Which process would handle the client requests? ), but is undesirable, as the main application is then unable to reopen the port.

Is this where FD_CLOEXEC O_CLOEXEC as available in popen(3) can be used? The application needs the pipe that popen(3) offers as stdin to the binary which is executed, is that filehandle left open when CLOEXEC closes the others.

Is there a better way to run the binary, which won't result in a forked process which will hold on to a closed port?

There is another, possibly related question at How to fork process without inheriting handles?

答: You can definitely use the close-on-exec flag to avoid newly started processes inheriting open files or sockets (and there's no other way I'm aware of). If you open a file with open(2) you can set the flag at that moment by adding O_CLOEXEC to the file creation flags. If the file is already open you can set it using fcntl() (and if you opened the file using fopen(3) you can get the file descriptor required for this via fileno(3)). For a socket you can also set the flag when opening it with socket(2) by setting SOCK_CLOEXEC. No file with this flag set will be inherited by a process spawned by your program, be it directly via fork + exec or any other "disguise" of that combination, like system(3) or popen(3).


问:
Where is Smalltalk-80 best used?
I want to know in which applications/programming domain are most suitable for Smalltalk. Could anyone please provide me some useful links that could answer my query?

Through googling I learned that some companies use it for:

logistics and foreign trade application

desktop, server and script development

data processing and logistics, scripts and presentations

but I cant find documents/research papers that can tell me which programming domain Smalltalk-80 (or Smalltalk) is best suited.

Some of the programming domains are:
 - Artificial intelligence reasoning
 - General purpose applications
 - Financial time series analysis
 - Natural language processing
 - Relational database querying
 - Application scripting
 - Internet
 - Symbolic mathematics
 - Numerical mathematics
 - Statistical applications
 - Text processing
 - Matrix algorithms

I hope you guys can help me. I am doing this for my case study. Thanks in advance.

答:
perhaps another way of answering the question would be by stating what it might not be suitable for. One domain would be where you have "real" real time constraints i.e. you would need to control the garbage collector from kicking off. If I recall IBM's (OTI) Smalltalk embedded had a mechanism for turning off the gc, but IBM dropped that a while ago. The other domain I have not seen much of is cell phone apps. As far as I know none of the viable Smalltalk's can run on Android but that may change. One hears of folks in Squeak/Pharo working on that. I would love to see ST running well on Android. I think that the Android tablet market will be a hot one.

I should conclude by saying that in all the years I have been coding in ST i.e. since 94, I have seen Smalltalk in just about everything else.

Title: Where is Smalltalk-80 best used?


问:
How to check whether the Input Text Field is visible or hidden in Javascript?
I have an input text field which has

```<code>style: "visibility: visible"
</code>```

or

```<code>style: "visibility: hidden"
</code>```

What is the easiest way to find out if it is visible or not ?

Suppose the input text field is E. What should be the condition here:

```<code>if <something with E> {
    alert("The text filed is visible !!");
}
</code>```

?

Thanks in advance !

答:
You can also use </p>

```<code>is(":visible");
</code>```

<p>something like </p>

```<code>$(this).is(":visible"); //here $(this) is your element
</code>```

Body:
I have an input text field which has

style: "visibility: visible"

or

style: "visibility: hidden"

What is the easiest way to find out if it is visible or not ?

Suppose the input text field is E. What should be the condition here:

if <something with E> {
    alert("The text filed is visible !!");
}

?

Thanks in advance !

Body:
You can also use

is(":visible");

something like

$(this).is(":visible"); //here $(this) is your element


问:
Could not launch './qemu/linux-x86_64/qemu-system-i386': No such file or directory
With 25rc1 of the SDK tools I am having a problem when starting the emulators from $PATH

```<code>➜  ~  which emulator
/home/ligi/bin/android-sdk/tools/emulator
➜  ~  emulator @M
Could not launch './qemu/linux-x86_64/qemu-system-i386': No such file or directory
➜  ~  /home/ligi/bin/android-sdk/tools/emulator @M
console on port 5554, ADB on port 5555
</code>```

Anyone knows a workaround? I could write a script to start emulators and cd in tools before but perhaps there is a better solution.

答:
I encounter this one in android studio 2.3 which use new path for the emulator so try the following:

do not use emulator executable in the: sdk-path/tools/ directory but instead use the one found in the : sdk-path/emulator/

and also remove or rename the emulator found in the sdk-path/tools directory.

and because android sdk shipped with it's own libstdc++.so.6 you need to do the following to avoid the libGL error:

```<code>cd $ANDROID_HOME/emulator/lib64/libstdc++
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib64/libstdc++.so.6 $ANDROID_HOME/emulator/lib64/libstdc++
</code>```

Body:
With 25rc1 of the SDK tools I am having a problem when starting the emulators from $PATH

➜  ~  which emulator
/home/ligi/bin/android-sdk/tools/emulator
➜  ~  emulator @M
Could not launch './qemu/linux-x86_64/qemu-system-i386': No such file or directory
➜  ~  /home/ligi/bin/android-sdk/tools/emulator @M
console on port 5554, ADB on port 5555

Anyone knows a workaround? I could write a script to start emulators and cd in tools before but perhaps there is a better solution.

Body:
I encounter this one in android studio 2.3 which use new path for the emulator so try the following:

do not use emulator executable in the: sdk-path/tools/ directory but instead use the one found in the : sdk-path/emulator/

and also remove or rename the emulator found in the sdk-path/tools directory.

and because android sdk shipped with it's own libstdc++.so.6 you need to do the following to avoid the libGL error:

cd $ANDROID_HOME/emulator/lib64/libstdc++
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib64/libstdc++.so.6 $ANDROID_HOME/emulator/lib64/libstdc++


问:
PHP SOAP response
I am using the PHP specific SOAPClient in order to call for a soap API and get responses.
The problem I have is that I do not manage to get in order the results, neither to extract them.

The code I am using is:

```<code><?php

$wsdl = 'http://portalquery.just.ro/Query.asmx?wsdl';
$client = new SoapClient($wsdl);

$xml_array['numarDosar'] = '10080/3/2013';
$response = $client->CautareDosare2($xml_array);

var_dump($response);

?>
</code>```

The results I get are:

```<code>object(stdClass)#2 (1) { ["CautareDosare2Result"]=> object(stdClass)#3 (1) { ["Dosar"]=> array(2) { [0]=> object(stdClass)#4 (13) { ["parti"]=> object(stdClass)#5 (1) { ["DosarParte"]=> array(3) { [0]=> object(stdClass)#6 (2) { ["nume"]=> string(22) "Mocanu Andrei Cristian" ["calitateParte"]=> string(17) "Recurent Inculpat" } [1]=> object(stdClass)#7 (2) { ["nume"]=> string(21) "Mocanu Răzvan George" ["calitateParte"]=> string(17) "Recurent Inculpat" } [2]=> object(stdClass)#8 (2) { ["nume"]=> string(11) "Mica Marian" ["calitateParte"]=> string(17) "Recurent Inculpat" } } } ["sedinte"]=> object(stdClass)#9 (1) { ["DosarSedinta"]=> object(stdClass)#10 (9) { ["complet"]=> string(26) "S2 Complet urgentă recurs" ["data"]=> string(19) "2013-03-14T00:00:00" ["ora"]=> string(5) "12:00" ["solutie"]=> string(14) "Respins recurs" ["solutieSumar"]=> string(408) "Înc. 82/R/În majoritate :Respinge ca nefondate recursurile declararate de recurenţii inculpaţi Mocanu Andrei Cristian, Mocanu Răzvan George şi Mica Marian. Obligă pe fiecare recurent la câte 300 lei cheltuieli judiciare către stat. Pronunţată în şedinţă publică, azi, 14.03.2013. Opinie separată în sensul admiterii recursurilor şi luării măsurii obligării de a nu părăsi localitatea." ["dataPronuntare"]=> string(19) "2013-03-14T00:00:00" ["documentSedinta"]=> string(33) "incheieremasuripreventivefazadeUP" ["numarDocument"]=> string(7) "82/2013" ["dataDocument"]=> string(19) "2013-03-14T00:00:00" } } ["numar"]=> string(12) "10080/3/2013" ["numarVechi"]=> string(8) "831/2013" ["data"]=> string(19) "2013-03-14T00:00:00" ["institutie"]=> string(21) "CurteadeApelBUCURESTI" ["departament"]=> string(22) "Secţia a II-a penală" ["categorieCaz"]=> string(5) "Penal" ["stadiuProcesual"]=> string(6) "Recurs" ["obiect"]=> string(113) "prelungirea duratei arestării preventive dispuse în cursul urmăririi penale (art. 156 şi următoarele C.p.p.)" ["dataModificare"]=> string(23) "2017-01-18T06:48:34.467" ["categorieCazNume"]=> string(5) "Penal" ["stadiuProcesualNume"]=> string(6) "Recurs" } [1]=> object(stdClass)#11 (14) { ["parti"]=> object(stdClass)#12 (1) { ["DosarParte"]=> array(3) { [0]=> object(stdClass)#13 (2) { ["nume"]=> string(22) "MOCANU ANDREI CRISTIAN" ["calitateParte"]=> string(8) "Inculpat" } [1]=> object(stdClass)#14 (2) { ["nume"]=> string(20) "MOCANU RAZVAN GEORGE" ["calitateParte"]=> string(8) "Inculpat" } [2]=> object(stdClass)#15 (2) { ["nume"]=> string(11) "MICA MARIAN" ["calitateParte"]=> string(8) "Inculpat" } } } ["sedinte"]=> object(stdClass)#16 (1) { ["DosarSedinta"]=> object(stdClass)#17 (9) { ["complet"]=> string(5) "CC1 -" ["data"]=> string(19) "2013-03-12T00:00:00" ["ora"]=> string(5) "23:59" ["solutie"]=> string(12) "Soluţionare" ["solutieSumar"]=> string(311) "În baza prevederilor art. 155 şi urm. C.p.p. dispune prelungirea măsurii arestării preventive a inculpaţilor Mocanu Andrei Cristian, Mocanu Răzvan George şi Mica Marius pe o perioadă de 20 de zile, de la 15.03.2013 - 03.04.2013, inclusiv. Cu recurs. Pronunţată în şedinţă publică azi, 12.03.2013." ["dataPronuntare"]=> string(19) "2013-03-12T00:00:00" ["documentSedinta"]=> string(27) "incheierefinaladezinvestire" ["numarDocument"]=> string(0) "" ["dataDocument"]=> string(19) "2013-03-12T00:00:00" } } ["caiAtac"]=> object(stdClass)#18 (1) { ["DosarCaleAtac"]=> object(stdClass)#19 (3) { ["dataDeclarare"]=> string(19) "2013-03-13T00:00:00" ["parteDeclaratoare"]=> string(37) " MICA MARIAN, MOCANU RAZVAN GEORGE, " ["tipCaleAtac"]=> string(6) "Recurs" } } ["numar"]=> string(12) "10080/3/2013" ["numarVechi"]=> string(0) "" ["data"]=> string(19) "2013-03-11T00:00:00" ["institutie"]=> string(19) "TribunalulBUCURESTI" ["departament"]=> string(22) "Secţia a-II-a Penală" ["categorieCaz"]=> string(5) "Penal" ["stadiuProcesual"]=> string(4) "Fond" ["obiect"]=> string(113) "prelungirea duratei arestării preventive dispuse în cursul urmăririi penale (art. 156 şi următoarele C.p.p.)" ["dataModificare"]=> string(23) "2017-01-18T08:33:50.877" ["categorieCazNume"]=> string(5) "Penal" ["stadiuProcesualNume"]=> string(4) "Fond" } } } }
</code>```

I tried to explode on the results, also used $response[1]->array and such, nothing works.

答:
```<code><?php
ini_set("display_errors", 1);
$wsdl = 'http://portalquery.just.ro/Query.asmx?wsdl';
$client = new SoapClient($wsdl);

$xml_array['numarDosar'] = '10080/3/2013';
$response = $client->CautareDosare2($xml_array);
$resultArray=  json_decode(json_encode($response),true);
$arrayOnfirstKey=$resultArray[key($resultArray)];
$arrayOnSecondKey=  $arrayOnfirstKey[key($arrayOnfirstKey)];
echo "<table>";
echo "<tr>";
echo "<td>nume</td>";
echo "<td>CalitateParte</td>";
echo "</tr>";
foreach($arrayOnSecondKey as $value)
{
    foreach($value["parti"]["DosarParte"] as $data)
    {
        echo "<tr>";
        echo "<td>" .$data["nume"]."</td>";
        echo "<td>" .$data["calitateParte"]."</td>";
        echo "</tr>";
    }
}
echo "</table>";
</code>```

Title: PHP SOAP response

Body:
I am using the PHP specific SOAPClient in order to call for a soap API and get responses.
The problem I have is that I do not manage to get in order the results, neither to extract them.

The code I am using is:

<?php

$wsdl = 'http://portalquery.just.ro/Query.asmx?wsdl';
$client = new SoapClient($wsdl);

$xml_array['numarDosar'] = '10080/3/2013';
$response = $client->CautareDosare2($xml_array);

var_dump($response);

?>

The results I get are:

object(stdClass)#2 (1) { ["CautareDosare2Result"]=> object(stdClass)#3 (1) { ["Dosar"]=> array(2) { [0]=> object(stdClass)#4 (13) { ["parti"]=> object(stdClass)#5 (1) { ["DosarParte"]=> array(3) { [0]=> object(stdClass)#6 (2) { ["nume"]=> string(22) "Mocanu Andrei Cristian" ["calitateParte"]=> string(17) "Recurent Inculpat" } [1]=> object(stdClass)#7 (2) { ["nume"]=> string(21) "Mocanu Răzvan George" ["calitateParte"]=> string(17) "Recurent Inculpat" } [2]=> object(stdClass)#8 (2) { ["nume"]=> string(11) "Mica Marian" ["calitateParte"]=> string(17) "Recurent Inculpat" } } } ["sedinte"]=> object(stdClass)#9 (1) { ["DosarSedinta"]=> object(stdClass)#10 (9) { ["complet"]=> string(26) "S2 Complet urgentă recurs" ["data"]=> string(19) "2013-03-14T00:00:00" ["ora"]=> string(5) "12:00" ["solutie"]=> string(14) "Respins recurs" ["solutieSumar"]=> string(408) "Înc. 82/R/În majoritate :Respinge ca nefondate recursurile declararate de recurenţii inculpaţi Mocanu Andrei Cristian, Mocanu Răzvan George şi Mica Marian. Obligă pe fiecare recurent la câte 300 lei cheltuieli judiciare către stat. Pronunţată în şedinţă publică, azi, 14.03.2013. Opinie separată în sensul admiterii recursurilor şi luării măsurii obligării de a nu părăsi localitatea." ["dataPronuntare"]=> string(19) "2013-03-14T00:00:00" ["documentSedinta"]=> string(33) "incheieremasuripreventivefazadeUP" ["numarDocument"]=> string(7) "82/2013" ["dataDocument"]=> string(19) "2013-03-14T00:00:00" } } ["numar"]=> string(12) "10080/3/2013" ["numarVechi"]=> string(8) "831/2013" ["data"]=> string(19) "2013-03-14T00:00:00" ["institutie"]=> string(21) "CurteadeApelBUCURESTI" ["departament"]=> string(22) "Secţia a II-a penală" ["categorieCaz"]=> string(5) "Penal" ["stadiuProcesual"]=> string(6) "Recurs" ["obiect"]=> string(113) "prelungirea duratei arestării preventive dispuse în cursul urmăririi penale (art. 156 şi următoarele C.p.p.)" ["dataModificare"]=> string(23) "2017-01-18T06:48:34.467" ["categorieCazNume"]=> string(5) "Penal" ["stadiuProcesualNume"]=> string(6) "Recurs" } [1]=> object(stdClass)#11 (14) { ["parti"]=> object(stdClass)#12 (1) { ["DosarParte"]=> array(3) { [0]=> object(stdClass)#13 (2) { ["nume"]=> string(22) "MOCANU ANDREI CRISTIAN" ["calitateParte"]=> string(8) "Inculpat" } [1]=> object(stdClass)#14 (2) { ["nume"]=> string(20) "MOCANU RAZVAN GEORGE" ["calitateParte"]=> string(8) "Inculpat" } [2]=> object(stdClass)#15 (2) { ["nume"]=> string(11) "MICA MARIAN" ["calitateParte"]=> string(8) "Inculpat" } } } ["sedinte"]=> object(stdClass)#16 (1) { ["DosarSedinta"]=> object(stdClass)#17 (9) { ["complet"]=> string(5) "CC1 -" ["data"]=> string(19) "2013-03-12T00:00:00" ["ora"]=> string(5) "23:59" ["solutie"]=> string(12) "Soluţionare" ["solutieSumar"]=> string(311) "În baza prevederilor art. 155 şi urm. C.p.p. dispune prelungirea măsurii arestării preventive a inculpaţilor Mocanu Andrei Cristian, Mocanu Răzvan George şi Mica Marius pe o perioadă de 20 de zile, de la 15.03.2013 - 03.04.2013, inclusiv. Cu recurs. Pronunţată în şedinţă publică azi, 12.03.2013." ["dataPronuntare"]=> string(19) "2013-03-12T00:00:00" ["documentSedinta"]=> string(27) "incheierefinaladezinvestire" ["numarDocument"]=> string(0) "" ["dataDocument"]=> string(19) "2013-03-12T00:00:00" } } ["caiAtac"]=> object(stdClass)#18 (1) { ["DosarCaleAtac"]=> object(stdClass)#19 (3) { ["dataDeclarare"]=> string(19) "2013-03-13T00:00:00" ["parteDeclaratoare"]=> string(37) " MICA MARIAN, MOCANU RAZVAN GEORGE, " ["tipCaleAtac"]=> string(6) "Recurs" } } ["numar"]=> string(12) "10080/3/2013" ["numarVechi"]=> string(0) "" ["data"]=> string(19) "2013-03-11T00:00:00" ["institutie"]=> string(19) "TribunalulBUCURESTI" ["departament"]=> string(22) "Secţia a-II-a Penală" ["categorieCaz"]=> string(5) "Penal" ["stadiuProcesual"]=> string(4) "Fond" ["obiect"]=> string(113) "prelungirea duratei arestării preventive dispuse în cursul urmăririi penale (art. 156 şi următoarele C.p.p.)" ["dataModificare"]=> string(23) "2017-01-18T08:33:50.877" ["categorieCazNume"]=> string(5) "Penal" ["stadiuProcesualNume"]=> string(4) "Fond" } } } }

I tried to explode on the results, also used $response[1]->array and such, nothing works.


问:
jQuery Sortable without jQuery UI
I am in need of "Sortable Drag & Drop" functionality and I'm using jQuery. I can't really use jQuery UI, because for this project it would be an overhead (I'd need to add many KB of JS and CSS only to use small part of functionality).

Is there any plugin that you could recommend or maybe a simple implementation path, that I can follow?

The solution must be as lightweight as possible, preferably based on jQuery/Sizzle or pure JavaScript.

答:
I suggest you go for "LMDD drag and drop"
Less than 4kb gzipped and very simple to implement.
https://supraniti.github.io/Lean-Mean-Drag-and-Drop/
Simple example:</p>

```<code>div id="basic-example"> (scope)
    <div class="grid"> (container)
        <div class="item"></div> (draggable)
    </div>
</div>
<script>
    lmdd.set(document.getElementById('basic-example'), {
        containerClass: 'grid',
        draggableItemClass: 'item'
});
</script>
</code>```

Title: jQuery Sortable without jQuery UI

Body:
I suggest you go for "LMDD drag and drop"
Less than 4kb gzipped and very simple to implement.
https://supraniti.github.io/Lean-Mean-Drag-and-Drop/
Simple example:

div id="basic-example"> (scope)
    <div class="grid"> (container)
        <div class="item"></div> (draggable)
    </div>
</div>
<script>
    lmdd.set(document.getElementById('basic-example'), {
        containerClass: 'grid',
        draggableItemClass: 'item'
});
</script>


问:
How do I resume/resend a request after getting a new refresh token using Angular JS with JWT Auth/ Laravel?
Here's the case:
    On a successful login the client will get a token and I'm sending it with every request in the http header
    The user uses my app  for sometime and bit later when making a add to basket action the jwt token gets expired and I will be throwing an error like 40* something and will be issuing a new request to get the token.

My problem is that How do I resume the last failed request after getting the new token? I can write this manually on every error response part, but it takes a lot of code.

答:
Your angular save the http text to the cookies or other store every time.Then
your Laravel return a error number such as 110.If your angular get this number 110 it will resume the http requests that last time.</p>


问:
How to declare directives in angular 2
When i tried using directives,it says error

```<code>Argument of type '{ selector: string; templateUrl: string; providers: typeof HeaderClass[]; directives: typeof Moda...' is not assignable to parameter of type 'Component'.
</code>```

Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.

Here is my code,

```<code>@Component({
  selector: 'my-app',
  templateUrl: './app/common/common.component.html',
  providers: [HeaderClass],
  directives: [ModalComponent]
})
</code>```

Can anyone please help me.Thanks.

答:
In the older version Angular2 , like beta , that was how you would define a directive.

But after rc, you don't do that anymore and you declare that directive in the modules.

```<code>@NgModule({

   declarations:[ModalComponent]

})
</code>```

Title: How to declare directives in angular 2

Body:
When i tried using directives,it says error

Argument of type '{ selector: string; templateUrl: string; providers: typeof HeaderClass[]; directives: typeof Moda...' is not assignable to parameter of type 'Component'.

Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.

Here is my code,

@Component({
  selector: 'my-app',
  templateUrl: './app/common/common.component.html',
  providers: [HeaderClass],
  directives: [ModalComponent]
})

Can anyone please help me.Thanks.

Body:
In the older version Angular2 , like beta , that was how you would define a directive.

But after rc, you don't do that anymore and you declare that directive in the modules.

@NgModule({

   declarations:[ModalComponent]

})


问:
ORA-06511: PL/SQL: cursor already open
I am Closing and opening the cursor outside the loop but still its showing error .ORA-06511: PL/SQL: cursor already open. Can anyone check it out.    </p>

```<code>/* SQL*Plus prompt variable re-initialize */
    BEGIN
    ------------------------my codes------------------
    OPEN UPD;
    OPEN SEL;
    ------------------------end of my codes------------
    DBMS_OUTPUT.put_line('u2 starts at time: ' || company.sys_ts_fcn);

    /* Nested block to process UPD; cursor execution failure raises an exception
       and after exception processing, the loop body resumes for next i counter     value
       In nested block, add 1 to the d and f columns in each row of table A  */

    ------------------------my codes------------------
    --ACCEPT c_retry_count  PROMPT 'Please enter counter value: '

    ------------------------end of my codes-----------

    FOR i IN 1 .. c_retry_count LOOP        -- Update cursor retry loop
      BEGIN
           u2_try_num := i;  -- Set cursor retry counter to  next loop iteration     number
              DBMS_OUTPUT.PUT_LINE('Executing table A update in nested block');
              FOR x_rec in UPD LOOP
    ------------------------my codes------------------

              FETCH UPD INTO x_rec;

              UPDATE A SET D = x_rec.D + 1 , F = x_rec.F + 1 ;

              EXIT WHEN UPD%NOTFOUND;

    ------------------------end of my codes------------
      --      WHERE current of UPD;
              END LOOP;

              -- Commit UPD's changes to A rows
              COMMIT;
              a_updated := TRUE;

    ------------------------my codes------------------
        EXIT;

    IF a_updated = FALSE THEN

    RAISE rowsAreLocked ;

    END IF;
    ------------------------end of my codes-----------

      EXCEPTION
    /*      Returned SQL code and error message values only visible in handlers
            Example: If "ORA-00054: resource busy and acquire with NOWAIT specified" occurs
                    during PL/SQL code execution, above is posted when no handler is
                    defined; otherwise, the above msg is NOT posted, and the EXCEPTION
                     handler is entered so that the event can be dealt with;
                    When this exception section is done, control transfers to the enclosing block
       (which resumes the cursor retry loop) */
      WHEN rowsAreLocked THEN
            BEGIN
    ------------------------my codes------------------
         DBMS_OUTPUT.put_line (SQLCODE);
         DBMS_OUTPUT.put_line (SQLERRM);
         DBMS_OUTPUT.put_line ('error block one');
         dbms_lock.sleep( 5 );
    ------------------------end of my codes-----------
         END;
      WHEN OTHERS THEN
            -- Third argument TRUE means: keep error msgs returned from all stack levels
            raise_application_error(-20001, 'WHEN OTHERS exception occurred', TRUE);
           DBMS_OUTPUT.put_line ('error block 2');
      END;     -- Inner block

    END LOOP;     -- A update retry loop
    ------------------------my codes------------------
    CLOSE UPD;
    ------------------------end of my codes------------
</code>```

答:
You have not posted the whole programme unit so this might be a red herring .

At the start of the code snippet you OPEN UPD and OPEN SEL. But at the end you only CLOSE UPD.

Title: ORA-06511: PL/SQL: cursor already open

Body:
I am Closing and opening the cursor outside the loop but still its showing error .ORA-06511: PL/SQL: cursor already open. Can anyone check it out.

/* SQL*Plus prompt variable re-initialize */
    BEGIN
    ------------------------my codes------------------
    OPEN UPD;
    OPEN SEL;
    ------------------------end of my codes------------
    DBMS_OUTPUT.put_line('u2 starts at time: ' || company.sys_ts_fcn);

    /* Nested block to process UPD; cursor execution failure raises an exception
       and after exception processing, the loop body resumes for next i counter     value
       In nested block, add 1 to the d and f columns in each row of table A  */

    ------------------------my codes------------------
    --ACCEPT c_retry_count  PROMPT 'Please enter counter value: '

    ------------------------end of my codes-----------

    FOR i IN 1 .. c_retry_count LOOP        -- Update cursor retry loop
      BEGIN
           u2_try_num := i;  -- Set cursor retry counter to  next loop iteration     number
              DBMS_OUTPUT.PUT_LINE('Executing table A update in nested block');
              FOR x_rec in UPD LOOP
    ------------------------my codes------------------

              FETCH UPD INTO x_rec;

              UPDATE A SET D = x_rec.D + 1 , F = x_rec.F + 1 ;

              EXIT WHEN UPD%NOTFOUND;

    ------------------------end of my codes------------
      --      WHERE current of UPD;
              END LOOP;

              -- Commit UPD's changes to A rows
              COMMIT;
              a_updated := TRUE;

    ------------------------my codes------------------
        EXIT;

    IF a_updated = FALSE THEN

    RAISE rowsAreLocked ;

    END IF;
    ------------------------end of my codes-----------

      EXCEPTION
    /*      Returned SQL code and error message values only visible in handlers
            Example: If "ORA-00054: resource busy and acquire with NOWAIT specified" occurs
                    during PL/SQL code execution, above is posted when no handler is
                    defined; otherwise, the above msg is NOT posted, and the EXCEPTION
                     handler is entered so that the event can be dealt with;
                    When this exception section is done, control transfers to the enclosing block
       (which resumes the cursor retry loop) */
      WHEN rowsAreLocked THEN
            BEGIN
    ------------------------my codes------------------
         DBMS_OUTPUT.put_line (SQLCODE);
         DBMS_OUTPUT.put_line (SQLERRM);
         DBMS_OUTPUT.put_line ('error block one');
         dbms_lock.sleep( 5 );
    ------------------------end of my codes-----------
         END;
      WHEN OTHERS THEN
            -- Third argument TRUE means: keep error msgs returned from all stack levels
            raise_application_error(-20001, 'WHEN OTHERS exception occurred', TRUE);
           DBMS_OUTPUT.put_line ('error block 2');
      END;     -- Inner block

    END LOOP;     -- A update retry loop
    ------------------------my codes------------------
    CLOSE UPD;
    ------------------------end of my codes------------


问:
Using URL with double {} in laravel
I need to make this link working in laravel :

```<code> <a href="/single-article/{{$post->post_id}}/@lang('messages.slaglan')">
</code>```

using {{ url('/') }}

How can i make this without error ?

答:
Use named routes please.
Assuming you have something like this </p>

```<code>Route::get('/single-article/{id}/{slaglan}', array(
    'as' => 'get-this-article',
    'uses' => 'SomeController@action'
));

<a href="{{URL::route('get-this-article', [$id, $slaglan] )}}">Visit</a>
</code>```

Title: Using URL with double {} in laravel

Body:
I need to make this link working in laravel :

 post_id}}/@lang('messages.slaglan')">

using {{ url('/') }}

How can i make this without error ?

Body:
Use named routes please.
Assuming you have something like this

Route::get('/single-article/{id}/{slaglan}', array(
    'as' => 'get-this-article',
    'uses' => 'SomeController@action'
));

<a href="{{URL::route('get-this-article', [$id, $slaglan] )}}">Visit</a>


问:
Aframe - call aframe function from another javascript file
I'm trying to turn positional tracking off, and I believe that this function in the aframe code is what I'm after:

checkHasPositionalTracking();

However, in my second js file (which is defined AFTER aframe.js), if I try to call that function, I receive this error:

Uncaught ReferenceError: checkHasPositionalTracking is not defined

答: You need to call it with full reference to the window.AFRAME browser global, so use AFRAME.utils.device.checkHasPositionalTracking () in your code to access it.