问:
Parsing through Retrofit and set Data to the Base Adapter
I am working with Retrofit (JSON Parsing Android) and I am new with this I am so confused to set the response with the Base Adapter.

This is my Example Class

```<code>public class Example {

@SerializedName("Totalrecord")
@Expose
private List<Totalrecord> totalrecord = null;
@SerializedName("Table1")
@Expose
private List<Table1> table1 = null;
@SerializedName("Table2")
@Expose
private List<Table2> table2 = null;

public List<Totalrecord> getTotalrecord() {
    return totalrecord;
}

public void setTotalrecord(List<Totalrecord> totalrecord) {
    this.totalrecord = totalrecord;
}

public List<Table1> getTable1() {
    return table1;
}

public void setTable1(List<Table1> table1) {
    this.table1 = table1;
}

public List<Table2> getTable2() {
    return table2;
}

public void setTable2(List<Table2> table2) {
    this.table2 = table2;
}
}
</code>```

Here I am trying to retrieve Response in ArrayList so that I can set it to Adapter

```<code>    ApiService api = RetroClient.getApiService();
            Call<Example> call = api.getMyJson(38, 109);
            call.enqueue(new Callback<Example>() {
                @Override
                public void onResponse(Call<Example> call, Response<Example> response) {
                    dialog.dismiss();
                    if (response.isSuccessful()) {
                   //     Response_list = response.body().get...
                        adapter_view = new Adapter_view(Response_list, MainActivity.this);
                        listView.setAdapter(adapter_view);
                    }
                }
                @Override
                public void onFailure(Call<Example> call, Throwable t) {
                    dialog.dismiss();
                    System.out.println("failed");
                }
            });
</code>```

But I am confused to set The type of ArrayList and also Type of Callback<> so that I can get the response properly and set ArrayList to the Adapter.

答:
```<code>List<Table1> mList=new ArrayList();
ApiService api = RetroClient.getApiService();
        Call<Example> call = api.getMyJson(38, 109);
        call.enqueue(new Callback<Example>() {
        @Override
  public void onResponse(Call<Example> call, Response<Example> response) {
                dialog.dismiss();
                if (response.body.isSuccessful()) {
                   mList=response.body.getTable1();
                   adapter_view = new Adapter_view(mList,MainActivity.this);
                    listView.setAdapter(adapter_view);
                }
            }
            @Override
            public void onFailure(Call<Example> call, Throwable t) {
                dialog.dismiss();
                System.out.println("failed");
            }
        });
</code>```

Body:
I am working with Retrofit (JSON Parsing Android) and I am new with this I am so confused to set the response with the Base Adapter.

This is my Example Class

public class Example {

@SerializedName("Totalrecord")
@Expose
private List<Totalrecord> totalrecord = null;
@SerializedName("Table1")
@Expose
private List<Table1> table1 = null;
@SerializedName("Table2")
@Expose
private List<Table2> table2 = null;

public List<Totalrecord> getTotalrecord() {
    return totalrecord;
}

public void setTotalrecord(List<Totalrecord> totalrecord) {
    this.totalrecord = totalrecord;
}

public List<Table1> getTable1() {
    return table1;
}

public void setTable1(List<Table1> table1) {
    this.table1 = table1;
}

public List<Table2> getTable2() {
    return table2;
}

public void setTable2(List<Table2> table2) {
    this.table2 = table2;
}
}

Here I am trying to retrieve Response in ArrayList so that I can set it to Adapter

    ApiService api = RetroClient.getApiService();
            Call<Example> call = api.getMyJson(38, 109);
            call.enqueue(new Callback<Example>() {
                @Override
                public void onResponse(Call<Example> call, Response<Example> response) {
                    dialog.dismiss();
                    if (response.isSuccessful()) {
                   //     Response_list = response.body().get...
                        adapter_view = new Adapter_view(Response_list, MainActivity.this);
                        listView.setAdapter(adapter_view);
                    }
                }
                @Override
                public void onFailure(Call<Example> call, Throwable t) {
                    dialog.dismiss();
                    System.out.println("failed");
                }
            });

But I am confused to set The type of ArrayList and also Type of Callback<> so that I can get the response properly and set ArrayList to the Adapter.


来源: stackexchange

问:
.Net Screen scraping and session
I am trying to screen scrape using C#.It works for few times,after which i receive Session expired error.Any help will be appreciated.</p>

答:
I put together an extension method sometime back, to scrape and email to me remote jobs on Fridays from a couple of job sites. I housed the code in a console app and tied the app to Windows Task Scheduler.</p>

```<code>// Scrapes html pages from given Uri
// Usage: this.Literal1.Text = new System.Uri("https://www.amazon.com/gp/goldbox/ref=nav_cs_gb").Scrape();
public static string Scrape(this System.Uri uri)
{
    using (var sr = new System.IO.StreamReader(System.Net.HttpWebRequest.Create(uri.GetLeftPart(System.UriPartial.Query)).GetResponse().GetResponseStream()))
    {
        return sr.ReadToEnd();

    }

}
</code>```

ContentLicense: CC BY-SA 2.5

Title: .Net Screen scraping and session

Body:
I put together an extension method sometime back, to scrape and email to me remote jobs on Fridays from a couple of job sites. I housed the code in a console app and tied the app to Windows Task Scheduler.

// Scrapes html pages from given Uri
// Usage: this.Literal1.Text = new System.Uri("https://www.amazon.com/gp/goldbox/ref=nav_cs_gb").Scrape();
public static string Scrape(this System.Uri uri)
{
    using (var sr = new System.IO.StreamReader(System.Net.HttpWebRequest.Create(uri.GetLeftPart(System.UriPartial.Query)).GetResponse().GetResponseStream()))
    {
        return sr.ReadToEnd();

    }

}

ContentLicense: CC BY-SA 3.0


问:
WPF Rotate line with angle from center point
I am trying to draw lines using WPF and c# and Facing the below problem.

Imaging I have to draw  a line with fixed length, I need to rotate this line with the given angle. suppose 45 degree.
But the condition is I should rotate this from center point.
I am attaching the image for clean understanding.

Can any one please help me to write a C# program.

答:
here's the idea, you need to improve it, shape it to what you need

```<code>    private void Rotate()
    {
        while (Degrees >= 360)
            Degrees -= 360;
        while (Degrees <= -360)
            Degrees += 360;

        X1 = 0;
        Y1 = 0;
        var rad = Degrees * Math.PI / 180;
        const int radius = 100;
        var sin = Math.Sin(rad);
        var cos = Math.Cos(rad);
        var tan = Math.Tan(rad);

        Y2 = sin * radius;
        X2 = cos * radius;

    }
</code>```

XAML

```<code><Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="0" Orientation="Horizontal" >
        <Label Content="Rotation" />
        <TextBox  Text="{Binding Degrees}" Width="50" Margin="5,5,0,5" HorizontalContentAlignment="Right" VerticalContentAlignment="Center"/>
        <Label Content="°" />
        <Button Content="Rotate" Margin="5" Command="{Binding RotateCommand}"/>
    </StackPanel>
    <Grid    Grid.Row="1"  HorizontalAlignment="Center" VerticalAlignment="Center" >
        <Line Stroke="Red" X1="{Binding X1}" X2="{Binding X2}" Y1="{Binding Y1}" Y2="{Binding Y2}"/>
    </Grid>
</Grid>
</code>```

Body:
here's the idea, you need to improve it, shape it to what you need

    private void Rotate()
    {
        while (Degrees >= 360)
            Degrees -= 360;
        while (Degrees <= -360)
            Degrees += 360;

        X1 = 0;
        Y1 = 0;
        var rad = Degrees * Math.PI / 180;
        const int radius = 100;
        var sin = Math.Sin(rad);
        var cos = Math.Cos(rad);
        var tan = Math.Tan(rad);

        Y2 = sin * radius;
        X2 = cos * radius;

    }

XAML

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="0" Orientation="Horizontal" >
        <Label Content="Rotation" />
        <TextBox  Text="{Binding Degrees}" Width="50" Margin="5,5,0,5" HorizontalContentAlignment="Right" VerticalContentAlignment="Center"/>
        <Label Content="°" />
        <Button Content="Rotate" Margin="5" Command="{Binding RotateCommand}"/>
    </StackPanel>
    <Grid    Grid.Row="1"  HorizontalAlignment="Center" VerticalAlignment="Center" >
        <Line Stroke="Red" X1="{Binding X1}" X2="{Binding X2}" Y1="{Binding Y1}" Y2="{Binding Y2}"/>
    </Grid>
</Grid>


问:
Circular-dependency best practice
I'm currently writing a web scraper which retrieves information from the internet. Simplified it looks like this.

Data access project

Objects to retrieve raw data

Objects to parse the the raw data into objects (!!)

The entities that the parser returns.

Now, I'm creating the actual parser, and I'm going to use it like this:

```<code>using Application.DataAccess;
using Application.DataAccess.Entities;

namespace Application{
 public class TestScraper{
  public static ScrapeIt()
  {
   var source = DataAcces.Retriever.Retrieve("http://example.com");
   DataAccess.Entities.Entity entity = DataAccess.Parser.Parse(source);

   //Do stuf with source here.
  }
 }
}
</code>```

As you can see, the Parser returns a Entity. However this is in the DataAccess namespace, yet, it makes no sense... it´s a circle, and I don´t really know how to fix this. Well I could come up with a few things, like creating another layer between those layers.

But I just want to know, how would YOU solve this. And what is a good (or the best practice) for this.

答:
You can fix a circular reference by factoring out the things that both classes refer to into a new class, and then the old classes both refer to the new class.

So in your case you could move the entities out of DataAccess and into perhaps a new Entities namespace, used by both DataAccess and Application.

By doing this you start with

```<code>A <--> D
</code>```

and end up with

```<code>A --> E
D --> E
</code>```

Title: Circular-dependency best practice

Body:
I'm currently writing a web scraper which retrieves information from the internet. Simplified it looks like this.

Data access project

Objects to retrieve raw data

Objects to parse the the raw data into objects (!!)

The entities that the parser returns.

Now, I'm creating the actual parser, and I'm going to use it like this:

using Application.DataAccess;
using Application.DataAccess.Entities;

namespace Application{
 public class TestScraper{
  public static ScrapeIt()
  {
   var source = DataAcces.Retriever.Retrieve("http://example.com");
   DataAccess.Entities.Entity entity = DataAccess.Parser.Parse(source);

   //Do stuf with source here.
  }
 }
}

As you can see, the Parser returns a Entity. However this is in the DataAccess namespace, yet, it makes no sense... it´s a circle, and I don´t really know how to fix this. Well I could come up with a few things, like creating another layer between those layers.

But I just want to know, how would YOU solve this. And what is a good (or the best practice) for this.

Body:
You can fix a circular reference by factoring out the things that both classes refer to into a new class, and then the old classes both refer to the new class.

So in your case you could move the entities out of DataAccess and into perhaps a new Entities namespace, used by both DataAccess and Application.

By doing this you start with

A <--> D

and end up with

A --> E
D --> E


问:
In Android Studio 2.0, Cannot find local variable of method in debug mode
After Updating the android version 1.5 to 2.0 Preview4. Android studio Debugger unable to find the local variable defined in method definition. For reference, find the below screenshot.

答:
if you have  minifyEnabled true in

debug {
            minifyEnabled true
            debuggable true
        }

remove that and using just like that
  debug {
            debuggable true
        }

its work for me


问:
Express.js req.ip is returning ::ffff:127.0.0.1
I am currently trying to get the IP of the requested user. The problem is the IP is returning ::ffff:127.0.0.1 instead of 127.0.0.1. I tried using trusted proxy option (though not using a proxy) and the req.ips is blank. Using 4.x Express.js.

```<code>router.get('/', function(req, res, next) {
    console.log('ip', req.ip)
    res.send({})
});
</code>```

答:
You can Get your Ip address alone or with The specified family using sockets</p>

```<code>     var app = require('express')();

 app.get("/ip", (req, res) => {
        console.log(req.ip)
       let ip = req.ip.split(':');
        let ip_details = req.socket.address();
          console.log(ip_details);
   // { address: '::ffff:127.0.0.1', family: 'IPv6', port: 3001

           console.log(ip[3]);//127.0.0.1
                            res.json(ip[3]);
      }
</code>```

Body:
I am currently trying to get the IP of the requested user. The problem is the IP is returning ::ffff:127.0.0.1 instead of 127.0.0.1. I tried using trusted proxy option (though not using a proxy) and the req.ips is blank. Using 4.x Express.js.

router.get('/', function(req, res, next) {
    console.log('ip', req.ip)
    res.send({})
});

Body:
You can Get your Ip address alone or with The specified family using sockets

     var app = require('express')();

 app.get("/ip", (req, res) => {
        console.log(req.ip)
       let ip = req.ip.split(':');
        let ip_details = req.socket.address();
          console.log(ip_details);
   // { address: '::ffff:127.0.0.1', family: 'IPv6', port: 3001

           console.log(ip[3]);//127.0.0.1
                            res.json(ip[3]);
      }


问:
Incorrect method suggestion by Xcode
I am trying to create a directory in my OS X app. The method was suggested as I started typing. But the method seems to be incorrectly suggested. The attributes parameter of the method in NSFileManger normally takes a [FileAttributeKey:Any] dictionary, but here in the suggestion it takes a [String:Any] library.

I checked the NSFileManager APIs and I could not find any like this. Can anyone explain what is happening here?

答:
Your deployment target or your Xcode version is old. FileAttributeKey is new.

https://developer.apple.com/documentation/foundation/fileattributekey

Title: Incorrect method suggestion by Xcode


问:
Ignite SqlQuery for two clients
I use next process for my Ignite cache with third party persistence:

empty database

start two instances in server mode

start first instance in client mode.

The client in cycle

creates entities

reads entities by a simple SqlQuery

So far all right. All the code works properly.

Then I start second instance in client mode. The code is the same.
The second client also in cycle

creates entities

reads entities by the SqlQuery

And the second client gets empty ResultSet. While the first client still reads the data properly. BTW. Both clients can get entities by keys.

Off course all the data in memory.

So why the second client can't read by SqlQuery?

Three options of code are below. All of them work identically: The first started client always gets correct result. The second started client always gets empty ResultSet.

```<code>    SqlQuery<EntryKey, Entry> sql = new SqlQuery<>(Entry.class, "accNumber = ?");
    sql.setArgs(number);
    List<Cache.Entry<EntryKey, Entry>> res = entryCache.query(sql).getAll();
</code>```

...

```<code>    SqlFieldsQuery sql = new SqlFieldsQuery("select d_c, summa from Entry where accNumber = ?");
    sql.setArgs(number);
    List<List<?>> res = entryCache.query(sql).getAll();
</code>```

...

```<code>    SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Entry.class, "accNumber = ?");
    QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> entryCursor = binaryEntry
            .query(query.setArgs(number));
    List<javax.cache.Cache.Entry<BinaryObject, BinaryObject>> res = entryCursor.getAll();
</code>```

XML configuration is below:

```<code>                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <!-- Set a cache name. -->
                <property name="name" value="entryCache" />
                <!-- Set cache mode. -->
                <property name="cacheMode" value="PARTITIONED" />
                <property name="atomicityMode" value="TRANSACTIONAL" />
                <!-- Number of backup nodes. -->
                <property name="backups" value="1" />

                <property name="cacheStoreFactory">
                    <bean class="javax.cache.configuration.FactoryBuilder"
                        factory-method="factoryOf">
                        <constructor-arg
                            value="ru.raiffeisen.cache.store.jdbc.CacheJdbcEntryStore" />
                    </bean>
                </property>
                <property name="readThrough" value="true" />
                <property name="writeThrough" value="true" />

                <property name="queryEntities">
                    <list>
                        <bean class="org.apache.ignite.cache.QueryEntity">
                            <!-- Setting indexed type's key class -->
                            <property name="keyType"
                                value="ru.raiffeisen.cache.repository.EntryKey" />
                            <!-- Setting indexed type's value class -->
                            <property name="valueType" value="ru.raiffeisen.cache.repository.Entry" />

                            <!-- Defining fields that will be either indexed or queryable. Indexed
                                fields are added to 'indexes' list below. -->
                            <property name="fields">
                                <map>
                                    <entry key="key.accNumber" value="java.lang.String" />
                                    <entry key="key.d_c" value="ru.raiffeisen.cache.repository.EntryKey.DEB_CRE" />
                                    <entry key="key.valuedate" value="java.util.Date" />
                                    <entry key="summa" value="java.lang.Integer " />
                                </map>
                            </property>

                            <!-- Defining indexed fields. -->
                            <property name="indexes">
                                <list>
                                    <!-- Single field (aka. column) index -->
                                    <bean class="org.apache.ignite.cache.QueryIndex">
                                        <constructor-arg value="key.accNumber" />
                                    </bean>
                                </list>
                            </property>

                        </bean>
                    </list>
                </property>
            </bean>
</code>```

答:
In case of a Third party store, readThrough works only for key-value API, for SQL you need to run loadCache method before performing queries on Ignite.

If you want to use read from disk with persistence, I would recommend using Ignite native persistence store: https://apacheignite.readme.io/docs/distributed-persistent-store

Also, I see in you configuration:

```<code> <property name="indexedTypes" value="true" />
</code>```

It's definitely a mistake, it should be configured like:

```<code><property name="indexedTypes">
    <list>
        <value>java.lang.Integer</value>
        <value>java.lang.Long</value>
    </list>
</property>
</code>```

IndexedTypes and QueryEntity configure the same things, actually, internally, IndexedTypes will create a configuration of QueryEntity. So, it's redundantly to configure both.

Title: Ignite SqlQuery for two clients

Body:
I use next process for my Ignite cache with third party persistence:

empty database

start two instances in server mode

start first instance in client mode.

The client in cycle

creates entities

reads entities by a simple SqlQuery

So far all right. All the code works properly.

Then I start second instance in client mode. The code is the same.
The second client also in cycle

creates entities

reads entities by the SqlQuery

And the second client gets empty ResultSet. While the first client still reads the data properly. BTW. Both clients can get entities by keys.

Off course all the data in memory.

So why the second client can't read by SqlQuery?

Three options of code are below. All of them work identically: The first started client always gets correct result. The second started client always gets empty ResultSet.

    SqlQuery<EntryKey, Entry> sql = new SqlQuery<>(Entry.class, "accNumber = ?");
    sql.setArgs(number);
    List<Cache.Entry<EntryKey, Entry>> res = entryCache.query(sql).getAll();

...

    SqlFieldsQuery sql = new SqlFieldsQuery("select d_c, summa from Entry where accNumber = ?");
    sql.setArgs(number);
    List<List<?>> res = entryCache.query(sql).getAll();

...

    SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Entry.class, "accNumber = ?");
    QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> entryCursor = binaryEntry
            .query(query.setArgs(number));
    List<javax.cache.Cache.Entry<BinaryObject, BinaryObject>> res = entryCursor.getAll();

XML configuration is below:

                <bean class="org.apache.ignite.configuration.CacheConfiguration">

                <property name="name" value="entryCache" />

                <property name="cacheMode" value="PARTITIONED" />
                <property name="atomicityMode" value="TRANSACTIONAL" />

                <property name="backups" value="1" />

                <property name="cacheStoreFactory">
                    <bean class="javax.cache.configuration.FactoryBuilder"
                        factory-method="factoryOf">
                        <constructor-arg
                            value="ru.raiffeisen.cache.store.jdbc.CacheJdbcEntryStore" />
                    </bean>
                </property>
                <property name="readThrough" value="true" />
                <property name="writeThrough" value="true" />

                <property name="queryEntities">
                    <list>
                        <bean class="org.apache.ignite.cache.QueryEntity">

                            <property name="keyType"
                                value="ru.raiffeisen.cache.repository.EntryKey" />

                            <property name="valueType" value="ru.raiffeisen.cache.repository.Entry" />

                            <property name="fields">
                                <map>
                                    <entry key="key.accNumber" value="java.lang.String" />
                                    <entry key="key.d_c" value="ru.raiffeisen.cache.repository.EntryKey.DEB_CRE" />
                                    <entry key="key.valuedate" value="java.util.Date" />
                                    <entry key="summa" value="java.lang.Integer " />
                                </map>
                            </property>

                            <property name="indexes">
                                <list>

                                    <bean class="org.apache.ignite.cache.QueryIndex">
                                        <constructor-arg value="key.accNumber" />
                                    </bean>
                                </list>
                            </property>

                        </bean>
                    </list>
                </property>
            </bean>

Body:
In case of a Third party store, readThrough works only for key-value API, for SQL you need to run loadCache method before performing queries on Ignite.

If you want to use read from disk with persistence, I would recommend using Ignite native persistence store: https://apacheignite.readme.io/docs/distributed-persistent-store

Also, I see in you configuration:

 <property name="indexedTypes" value="true" />

It's definitely a mistake, it should be configured like:

<property name="indexedTypes">
    <list>
        <value>java.lang.Integer</value>
        <value>java.lang.Long</value>
    </list>
</property>

IndexedTypes and QueryEntity configure the same things, actually, internally, IndexedTypes will create a configuration of QueryEntity. So, it's redundantly to configure both.


问:
Parse error: syntax error, unexpected '<' in /tmp/... wordpress
I have jupiter theme installed and activated on my wordpress website. And it's working very fine till yesterday. But now the site is not opening and showing below error. Also same error comes when I tries to open admin panel (http://growthworldwide.in/wp-admin/)

```<code>Parse error: syntax error, unexpected '<' in /tmp/theme_temp_setupYD75Y9 on line 2.
</code>```

every time it comes with some different string at last (after theme_temp_setup).
This is shared hosting with cPanel on it. When I goes to File Manager there are many folders like public_html, public_ftp, mail, .cagefs, .cpanel, .cphorde, .cl.selector, .pki, .htpasswds, .softaculous, .trash, logs, softaculous_backups, ssl, tmp, and many more.
Screen shot showing folders under home

When I goes into .cagefs folder there comes three folders opt, tmp, var. and this error is related to files listed under this tmp folder. There is one file named mysql.sock. When I deleted it then the site started showing different error that problem connecting with database or some other problems. So I think there is some service stopped or something else.

If you could please help me resolve this issue. Thank You.

Attached two log files which is generated under tmp folder.
growthwo_26_75141_upgrade_err.log

```<code>NOTICE Undefined offset: 1 /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 11536
NOTICE Undefined index: pgtimezone /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 68
WARNING
WARNING
WARNING
WARNING
</code>```

growthwo_26_97197_upgrade_err.log

```<code>NOTICE Undefined offset: 1 /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 11536
WARNING
WARNING
WARNING
NOTICE Undefined index: pgtimezone /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 68
NOTICE Undefined index: no_dir_exists /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/backup.php 245
NOTICE Undefined offset: 1 /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 11536
WARNING
WARNING
WARNING
NOTICE Undefined index: pgtimezone /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 68
NOTICE Undefined index: no_dir_exists /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/backup.php 245
</code>```

答:
Via ftp delete or rename the current theme. Then try accessing your wp-admin. If this works then you should get a fresh copy of the theme and install it again. If this doesn't work rename the 'plugins' folder.

Now try again.

If you still get the same error message then try uploading a fresh set of WP core files.

Failing that, it would seem like some issue at the server level.

Body:
I have jupiter theme installed and activated on my wordpress website. And it's working very fine till yesterday. But now the site is not opening and showing below error. Also same error comes when I tries to open admin panel (http://growthworldwide.in/wp-admin/)

Parse error: syntax error, unexpected '<' in /tmp/theme_temp_setupYD75Y9 on line 2.

every time it comes with some different string at last (after theme_temp_setup).
This is shared hosting with cPanel on it. When I goes to File Manager there are many folders like public_html, public_ftp, mail, .cagefs, .cpanel, .cphorde, .cl.selector, .pki, .htpasswds, .softaculous, .trash, logs, softaculous_backups, ssl, tmp, and many more.
Screen shot showing folders under home

When I goes into .cagefs folder there comes three folders opt, tmp, var. and this error is related to files listed under this tmp folder. There is one file named mysql.sock. When I deleted it then the site started showing different error that problem connecting with database or some other problems. So I think there is some service stopped or something else.

If you could please help me resolve this issue. Thank You.

Attached two log files which is generated under tmp folder.
growthwo_26_75141_upgrade_err.log

NOTICE Undefined offset: 1 /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 11536
NOTICE Undefined index: pgtimezone /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 68
WARNING
WARNING
WARNING
WARNING

growthwo_26_97197_upgrade_err.log

NOTICE Undefined offset: 1 /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 11536
WARNING
WARNING
WARNING
NOTICE Undefined index: pgtimezone /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 68
NOTICE Undefined index: no_dir_exists /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/backup.php 245
NOTICE Undefined offset: 1 /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 11536
WARNING
WARNING
WARNING
NOTICE Undefined index: pgtimezone /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/functions.php 68
NOTICE Undefined index: no_dir_exists /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/main/backup.php 245


问:
Limiting number of displayed results when using ngRepeat
I find the AngularJS tutorials hard to understand; this one is walking me through building an app that displays phones. I’m on step 5 and I thought as an experiment I’d try to allow users to specify how many they’d like to be shown. The view looks like this:

```<code><body ng-controller="PhoneListCtrl">

  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span2">
        <!--Sidebar content-->

        Search: <input ng-model="query">
        How Many: <input ng-model="quantity">
        Sort by:
        <select ng-model="orderProp">
          <option value="name">Alphabetical</option>
          <option value="age">Newest</option>
        </select>

      </div>
      <div class="span10">
        <!--Body content-->

        <ul class="phones">
          <li ng-repeat="phone in phones | filter:query | orderBy:orderProp">
            {{phone.name}}
            <p>{{phone.snippet}}</p>
          </li>
        </ul>

      </div>
    </div>
  </div>
</body>
</code>```

I’ve added this line where users can enter how many results they want shown:

How Many: <input ng-model="quantity">
```

<p>Here’s my controller:</p>

```function PhoneListCtrl($scope, $http) {
  $http.get('phones/phones.json').success(function(data) {
    $scope.phones = data.splice(0, 'quantity');
  });

  $scope.orderProp = 'age';
  $scope.quantity = 5;
}
```

<p>The important line is:</p>

```$scope.phones = data.splice(0, 'quantity');
```

I can hard-code in a number to represent how many phones should be shown. If I put 5 in, 5 will be shown. All I want to do is read the number in that input from the view, and put that in the data.splice line. I’ve tried with and without quotes, and neither work. How do I do this?

答:
Use limitTo filter to display a limited number of results in ng-repeat.</p>

```<code><ul class="phones">
      <li ng-repeat="phone in phones | limitTo:5">
        {{phone.name}}
        <p>{{phone.snippet}}</p>
      </li>
</ul>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I find the AngularJS tutorials hard to understand; this one is walking me through building an app that displays phones. I’m on step 5 and I thought as an experiment I’d try to allow users to specify how many they’d like to be shown. The view looks like this:

        Search: <input ng-model="query">
        How Many: <input ng-model="quantity">
        Sort by:
        <select ng-model="orderProp">
          <option value="name">Alphabetical</option>
          <option value="age">Newest</option>
        </select>

            {{phone.name}}

{{phone.snippet}}

I’ve added this line where users can enter how many results they want shown:

How Many: <input ng-model="quantity">

Here’s my controller:

function PhoneListCtrl($scope, $http) {
  $http.get('phones/phones.json').success(function(data) {
    $scope.phones = data.splice(0, 'quantity');
  });

  $scope.orderProp = 'age';
  $scope.quantity = 5;
}

The important line is:

$scope.phones = data.splice(0, 'quantity');

I can hard-code in a number to represent how many phones should be shown. If I put 5 in, 5 will be shown. All I want to do is read the number in that input from the view, and put that in the data.splice line. I’ve tried with and without quotes, and neither work. How do I do this?

Body:
Use limitTo filter to display a limited number of results in ng-repeat.

<ul class="phones">
      <li ng-repeat="phone in phones | limitTo:5">
        {{phone.name}}
        <p>{{phone.snippet}}</p>
      </li>
</ul>


问:
Overhang notification at bottom of the screen
I am using overhang to display a notification whenever user lands on my website. The notification appears from top of my screen and remains there when I scroll down. I want the same functionality but at the bottom of the screen. Basically, I want the notification to appear at the bottom of the screen rather than top and then remain there even if I scroll down/top. How can I do that?

The code for overhang is as follows:

```<code>$("body").overhang({
  custom: true,
  message: "Upcoming event",
  closeConfirm: true
});
</code>```

Thanks in advance!

答:
In overhang.min.css you'll find

```<code>.overhang,.overhang-overlay{position:fixed;top:0;left:0;right:0}
</code>```

If you replace top:0; by bottom:0; it should be fixed at the bottom of the window.

Body:
I am using overhang to display a notification whenever user lands on my website. The notification appears from top of my screen and remains there when I scroll down. I want the same functionality but at the bottom of the screen. Basically, I want the notification to appear at the bottom of the screen rather than top and then remain there even if I scroll down/top. How can I do that?

The code for overhang is as follows:

$("body").overhang({
  custom: true,
  message: "Upcoming event",
  closeConfirm: true
});

Thanks in advance!

Body:
In overhang.min.css you'll find

.overhang,.overhang-overlay{position:fixed;top:0;left:0;right:0}

If you replace top:0; by bottom:0; it should be fixed at the bottom of the window.


问:
hover effect doesn't workon stacked fontawesome icon
I have no idea why :hover doesn't work on my fontawesome element. I want to change circle element to be red on hover. I think I tried already all possible selectors and only .fa react somehow (inside icon color changed, which is not the desired effect I want.)

HTML

```<code>    <ul class="nav__social-items">
        <li><a class="nav--links"  href="#"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-facebook fa-stack-1x fa-inverse" aria-hidden="true"></i></span>
        </a></li>
        <li><a class="nav--links"  href="#"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-youtube fa-stack-1x fa-inverse" aria-hidden="true"></i></span>
        </a></li>
        <li><a class="nav--links"  href="#"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-instagram fa-stack-1x fa-inverse" aria-hidden="true"></i></span>
        </a></li>
    </ul>
</code>```

CSS

```<code>.nav__social-items {
    display: flex;
    flex: 3 1 0;
    justify-content: flex-end;
    @include mQ(485px){
        li {
        display: block;
        width: 20%;
             }

    }
    .nav--links{
        margin-left: 30px;
        .fa-circle{
            color: #000;
        }
    }
}
</code>```

答:
I've modified the code very quickly to show an alternate way of doing it. Just hit 'run snippet' below to see if this is what you're after :)

Example with icon here: https://codepen.io/anon/pen/bYYMJO

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
ul li a {
  width: 30px;
  height: 30px;
  background: blue;
  border-radius: 50%;
  float: left;
  text-align: center;
  box-sizing: border-box;
  padding-top: 6px;
  cursor: pointer;
}
ul li a:hover {
  background: red;
}
ul li i {
  text-align: center;
  color: white;
  font-size: 14px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><ul>
  <li>

      <i class="fa fa-facebook" aria-hidden="true"></i>

  </li>
</ul></code>```

Body:
I have no idea why :hover doesn't work on my fontawesome element. I want to change circle element to be red on hover. I think I tried already all possible selectors and only .fa react somehow (inside icon color changed, which is not the desired effect I want.)

HTML

CSS

.nav__social-items {
    display: flex;
    flex: 3 1 0;
    justify-content: flex-end;
    @include mQ(485px){
        li {
        display: block;
        width: 20%;
             }

    }
    .nav--links{
        margin-left: 30px;
        .fa-circle{
            color: #000;
        }
    }
}

Body:
I've modified the code very quickly to show an alternate way of doing it. Just hit 'run snippet' below to see if this is what you're after :)

Example with icon here: https://codepen.io/anon/pen/bYYMJO

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
ul li a {
  width: 30px;
  height: 30px;
  background: blue;
  border-radius: 50%;
  float: left;
  text-align: center;
  box-sizing: border-box;
  padding-top: 6px;
  cursor: pointer;
}
ul li a:hover {
  background: red;
}
ul li i {
  text-align: center;
  color: white;
  font-size: 14px;
}

<ul>
  <li>
    <a href="/">
      <i class="fa fa-facebook" aria-hidden="true"></i>
    </a>
  </li>
</ul>


问:
PHP5 cURL - When attempting to scrape a page, it loads a blank page
I'm trying to scrape some recipes off a page to use as samples for a school project, but the page just keeps loading a blank page.

I'm following this tutorial - here

This is my code:

```<code><?php

function curl($url) {
    $ch = curl_init();  // Initialising cURL
    curl_setopt($ch, CURLOPT_URL, $url);    // Setting cURL's URL option with the $url variable passed into the function
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL's option to return the webpage data
    $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
    curl_close($ch);    // Closing cURL
    return $data;   // Returning the data from the function
}
function scrape_between($data, $start, $end){
    $data = stristr($data, $start); // Stripping all data from before $start
    $data = substr($data, strlen($start));  // Stripping $start
    $stop = stripos($data, $end);   // Getting the position of the $end of the data to scrape
    $data = substr($data, 0, $stop);    // Stripping all data from after and including the $end of the data to scrape
    return $data;   // Returning the scraped data from the function
}

$continue = true;

$url = curl("https://www.justapinch.com/recipes/main-course/");

while ($continue == true) {
    $results_page = curl($url);
    $results_page = scrape_between($results_page,"<div id=\"grid-normal\">","<div id=\"rightside-content\"");
    $separate_results = explode("<h3 class=\"tight-margin\"",$results_page);

    foreach ($separate_results as $separate_result) {
        if ($separate_result != "") {
            $results_urls[] = "https://www.justapinch.com" . scrape_between($separate_result,"href=\"","\" class=\"");
        }
    }

    // Commented out to test code above

    // if (strpos($results_page,"Next Page")) {
    //     $continue = true;
    //     $url = scrape_between($results_page,"<nav><div class=\"col-xs-7\">","</div><nav>");
    //     if (strpos($url,"Back</a>")) {
    //         $url = scrape_between($url,"Back</a>",">Next Page");
    //     }
    //     $url = "https://www.justapinch.com" . scrape_between($url, "href=\"", "\"");
    // } else {
    //     $continue = false;
    // }
    // sleep(rand(3,5));

    print_r($results_urls);
}
?>
</code>```

I'm using cloud9 and I've installed php5 cURL, and am running apache2. I would appreciate any help.

答:
why do people do this? code completely void of error checking, then they go to some forum and ask why is this code, which completely ignores any and all errors, not working? I DONT FKING KNOW, BUT AT LEAST YOU COULD PUT UP SOME ERROR CHECKING AND RUN IT BEFORE ASKING. it's not just you, lots of people are doing it, and its annoying af, and you should all feel bad for doing it. curl_setopt returns bool(false) if there's an error setting the option. curl_exec returns bool(false) if there was an error in the transfer. curl_init returns bool(false) if there was an error creating the curl handle. extract the error description with curl_error, and report it with \RuntimeException. now delete this thread, add some error checking, and if the error checking does not reveal the problem, or it does but you're not sure how to fix it, THEN make a new thread about it.

here's some error-checking function wrappers to get you started:

```<code>function ecurl_setopt ( /*resource*/$ch , int $option , /*mixed*/ $value ):bool{
    $ret=curl_setopt($ch,$option,$value);
    if($ret!==true){
        //option should be obvious by stack trace
        throw new RuntimeException ( 'curl_setopt() failed. curl_errno: ' . return_var_dump ( curl_errno ($ch) ).'. curl_error: '.curl_error($ch) );
    }
    return true;
}
function ecurl_exec ( /*resource*/$ch):bool{
    $ret=curl_exec($ch);
    if($ret!==true){
        throw new RuntimeException ( 'curl_exec() failed. curl_errno: ' . return_var_dump ( curl_errno ($ch) ).'. curl_error: '.curl_error($ch) );
    }
    return true;
}

function return_var_dump(/*...*/){
    $args = func_get_args ();
    ob_start ();
    call_user_func_array ( 'var_dump', $args );
    return ob_get_clean ();
}
</code>```

Body:
I'm trying to scrape some recipes off a page to use as samples for a school project, but the page just keeps loading a blank page.

I'm following this tutorial - here

This is my code:

<?php

function curl($url) {
    $ch = curl_init();  // Initialising cURL
    curl_setopt($ch, CURLOPT_URL, $url);    // Setting cURL's URL option with the $url variable passed into the function
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL's option to return the webpage data
    $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
    curl_close($ch);    // Closing cURL
    return $data;   // Returning the data from the function
}
function scrape_between($data, $start, $end){
    $data = stristr($data, $start); // Stripping all data from before $start
    $data = substr($data, strlen($start));  // Stripping $start
    $stop = stripos($data, $end);   // Getting the position of the $end of the data to scrape
    $data = substr($data, 0, $stop);    // Stripping all data from after and including the $end of the data to scrape
    return $data;   // Returning the scraped data from the function
}

$continue = true;

$url = curl("https://www.justapinch.com/recipes/main-course/");

while ($continue == true) {
    $results_page = curl($url);
    $results_page = scrape_between($results_page,"
","<div id=\"rightside-content\"");
    $separate_results = explode("<h3 class=\"tight-margin\"",$results_page);

    foreach ($separate_results as $separate_result) {
        if ($separate_result != "") {
            $results_urls[] = "https://www.justapinch.com" . scrape_between($separate_result,"href=\"","\" class=\"");
        }
    }

    // Commented out to test code above

    // if (strpos($results_page,"Next Page")) {
    //     $continue = true;
    //     $url = scrape_between($results_page,"
","
");
    //     if (strpos($url,"Back")) {
    //         $url = scrape_between($url,"Back",">Next Page");
    //     }
    //     $url = "https://www.justapinch.com" . scrape_between($url, "href=\"", "\"");
    // } else {
    //     $continue = false;
    // }
    // sleep(rand(3,5));

    print_r($results_urls);
}
?>

I'm using cloud9 and I've installed php5 cURL, and am running apache2. I would appreciate any help.

Body:
why do people do this? code completely void of error checking, then they go to some forum and ask why is this code, which completely ignores any and all errors, not working? I DONT FKING KNOW, BUT AT LEAST YOU COULD PUT UP SOME ERROR CHECKING AND RUN IT BEFORE ASKING. it's not just you, lots of people are doing it, and its annoying af, and you should all feel bad for doing it. curl_setopt returns bool(false) if there's an error setting the option. curl_exec returns bool(false) if there was an error in the transfer. curl_init returns bool(false) if there was an error creating the curl handle. extract the error description with curl_error, and report it with \RuntimeException. now delete this thread, add some error checking, and if the error checking does not reveal the problem, or it does but you're not sure how to fix it, THEN make a new thread about it.

here's some error-checking function wrappers to get you started:

function ecurl_setopt ( /*resource*/$ch , int $option , /*mixed*/ $value ):bool{
    $ret=curl_setopt($ch,$option,$value);
    if($ret!==true){
        //option should be obvious by stack trace
        throw new RuntimeException ( 'curl_setopt() failed. curl_errno: ' . return_var_dump ( curl_errno ($ch) ).'. curl_error: '.curl_error($ch) );
    }
    return true;
}
function ecurl_exec ( /*resource*/$ch):bool{
    $ret=curl_exec($ch);
    if($ret!==true){
        throw new RuntimeException ( 'curl_exec() failed. curl_errno: ' . return_var_dump ( curl_errno ($ch) ).'. curl_error: '.curl_error($ch) );
    }
    return true;
}

function return_var_dump(/*...*/){
    $args = func_get_args ();
    ob_start ();
    call_user_func_array ( 'var_dump', $args );
    return ob_get_clean ();
}


问:
How to use curl and an array of URLs together
I found this code that does what I'm looking for on a single domain check. But I have a list of URLs that I would like to check.
Can you and how would you create an array with curl?</p>

```<code>$url = 'http://www.example.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true);    // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true);    // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo 'HTTP code: ' . $httpcode;
</code>```

答:
If all you want are headers, then instead of curl try:

```<code>$urls = array('http://www.example.com','http://www.example.com2','http://www.example.com3','http://www.example4.com');

$httpCodes = [];
foreach($urls as $url)
{
    $httpCodes[$url] = get_headers($url)[0];
}

var_dump($httpCodes);
</code>```

This uses get_headers() to get the header data from a URL's response.

Edit: Or if you really want to use curl. you can use the following code with curl_multi instead:

```<code>$urls = array('http://www.example.com','http://www.example.com2','http://www.example.com3','http://www.example4.com');

$curlMultiReq = curl_multi_init();
$ch = [];
foreach($urls as $key => $url)
{
    $ch[$key] = curl_init($url);
    curl_setopt($ch[$key], CURLOPT_HEADER, true);    // we want headers
    curl_setopt($ch[$key], CURLOPT_NOBODY, true);    // we don't need body
    curl_setopt($ch[$key], CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch[$key], CURLOPT_TIMEOUT,10);
    curl_multi_add_handle($curlMultiReq, $ch[$key]);
}
$running = '';

do {
  curl_multi_exec($curlMultiReq, $running);
  curl_multi_select($curlMultiReq);
} while ($running > 0);

foreach(array_keys($ch) as $key){
  echo curl_getinfo($ch[$key], CURLINFO_HTTP_CODE);
  echo "\n";
  curl_multi_remove_handle($curlMultiReq, $ch[$key]);
}
curl_multi_close($curlMultiReq);
</code>```

Body:
I found this code that does what I'm looking for on a single domain check. But I have a list of URLs that I would like to check.
Can you and how would you create an array with curl?

$url = 'http://www.example.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true);    // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true);    // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo 'HTTP code: ' . $httpcode;

Body:
If all you want are headers, then instead of curl try:

$urls = array('http://www.example.com','http://www.example.com2','http://www.example.com3','http://www.example4.com');

$httpCodes = [];
foreach($urls as $url)
{
    $httpCodes[$url] = get_headers($url)[0];
}

var_dump($httpCodes);

This uses get_headers() to get the header data from a URL's response.

Edit: Or if you really want to use curl. you can use the following code with curl_multi instead:

$urls = array('http://www.example.com','http://www.example.com2','http://www.example.com3','http://www.example4.com');

$curlMultiReq = curl_multi_init();
$ch = [];
foreach($urls as $key => $url)
{
    $ch[$key] = curl_init($url);
    curl_setopt($ch[$key], CURLOPT_HEADER, true);    // we want headers
    curl_setopt($ch[$key], CURLOPT_NOBODY, true);    // we don't need body
    curl_setopt($ch[$key], CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch[$key], CURLOPT_TIMEOUT,10);
    curl_multi_add_handle($curlMultiReq, $ch[$key]);
}
$running = '';

do {
  curl_multi_exec($curlMultiReq, $running);
  curl_multi_select($curlMultiReq);
} while ($running > 0);

foreach(array_keys($ch) as $key){
  echo curl_getinfo($ch[$key], CURLINFO_HTTP_CODE);
  echo "\n";
  curl_multi_remove_handle($curlMultiReq, $ch[$key]);
}
curl_multi_close($curlMultiReq);


问:
select html till i reach a specific class
I have a html like this:

```<code><table>
<tr>
<td>a1</td>
<td>a2</td>

</tr>

<tr>
<td>b1</td>
<td>b2</td>

</tr>

<tr>
<td>c1</td>
<td>c2</td>

</tr>

<tr class="total">
<td>d1</td>
<td>d2</td>

</tr>

<tr>
<td>e1</td>
<td>e2</td>

</tr>

</table>
</code>```

now i want to select only the html till i reach 'total' class, so the hmtl i want jquery to select is:

```<code><tr>
<td>a1</td>
<td>a2</td>

</tr>

<tr>
<td>b1</td>
<td>b2</td>

</tr>

<tr>
<td>c1</td>
<td>c2</td>

</tr>

<tr class="total">
<td>d1</td>
<td>d2</td>

</tr>
</code>```

the code i tried for this was:

```<code>console.log($("table .total").parentsUntil("table").html());
</code>```

but this gives all the tr's (that is, including e1,e2 rows, which i dont want)

if i had gotten the correct html, (ie, till d series), i would perform an action on the each of the tr's to get a perticular value (i mean for ex i want a1, b1, c1, and d1 only, not e1, so i put total class on the d series only).

can anyone help me to get only html till 'total'?

Thanks in advance...

答:
I think this will serve your purpose!</p>

```<code>var neededHTML = "";
var allHTML = "";
$('table tr').each(function(){
    allHTML += $(this).get(0).outerHTML;
    if ($(this).hasClass('total')){
        neededHTML = allHTML;
    }
})
console.log(neededHTML);
</code>```

Body:
I have a html like this:

a1
a2

b1
b2

c1
c2

d1
d2

e1
e2

now i want to select only the html till i reach 'total' class, so the hmtl i want jquery to select is:

a1
a2

b1
b2

c1
c2

d1
d2

the code i tried for this was:

console.log($("table .total").parentsUntil("table").html());

but this gives all the tr's (that is, including e1,e2 rows, which i dont want)

if i had gotten the correct html, (ie, till d series), i would perform an action on the each of the tr's to get a perticular value (i mean for ex i want a1, b1, c1, and d1 only, not e1, so i put total class on the d series only).

can anyone help me to get only html till 'total'?

Thanks in advance...

Body:
I think this will serve your purpose!

var neededHTML = "";
var allHTML = "";
$('table tr').each(function(){
    allHTML += $(this).get(0).outerHTML;
    if ($(this).hasClass('total')){
        neededHTML = allHTML;
    }
})
console.log(neededHTML);


问:
JavaScript in Mirth Connection
What are the use of JavaScript in Mirth Connection
and types of Mirth Connection routes. I am new to mirth connect and what to find out the various coding in JavaScript while creating or deploying channel.</p>

答:
I feel the qestion is very broad. I try my best to make u understand shortly.

Yes mirth uses javascript. It is made with Rhino engine. Which also means you can write your program in JAVA as well as Javascript. Tool provides very effective functionality to connect from one end system to another, parse incoming data, receives acknowledgement from the end system etc.

We need to use javascript for other interoperability/storing/retriving functionality. The Javascript used is not unobtrusive javascript or framework driven javascript.

You will be given much liberty to write functions, that can be used in multiple channels, or for single channel and execute whatever you do in Java the same can be implemented via Javascript inside Mirth as well.

Here are some of tutorials to start learning how to use javascript and Mirth Tool:

```<code>http://www.mirthcorp.com/community/wiki/display/mirth/Mirth+for+Dummies
http://www.mirthcorp.com/community/wiki/pages/viewpage.action?pageId=4358193
https://amarnathks.wordpress.com/tag/mirth-beginner-tutorial/
http://wiki.patesco.ca/doku.php?id=hl7:mirth:tutorial
https://hl7engine.wordpress.com/category/mirth-tool/
</code>```

Title: JavaScript in Mirth Connection

Body:
I feel the qestion is very broad. I try my best to make u understand shortly.

Yes mirth uses javascript. It is made with Rhino engine. Which also means you can write your program in JAVA as well as Javascript. Tool provides very effective functionality to connect from one end system to another, parse incoming data, receives acknowledgement from the end system etc.

We need to use javascript for other interoperability/storing/retriving functionality. The Javascript used is not unobtrusive javascript or framework driven javascript.

You will be given much liberty to write functions, that can be used in multiple channels, or for single channel and execute whatever you do in Java the same can be implemented via Javascript inside Mirth as well.

Here are some of tutorials to start learning how to use javascript and Mirth Tool:

http://www.mirthcorp.com/community/wiki/display/mirth/Mirth+for+Dummies
http://www.mirthcorp.com/community/wiki/pages/viewpage.action?pageId=4358193
https://amarnathks.wordpress.com/tag/mirth-beginner-tutorial/
http://wiki.patesco.ca/doku.php?id=hl7:mirth:tutorial
https://hl7engine.wordpress.com/category/mirth-tool/


问:
ASP.NET code to receive IM using lync SDK 2013 (c#)
I am a beginner in this field and learning how to send and receive IM using lync SDK 2013.
i have gone through and understood how to send IM using lync SDK 2013.
Now I want to learn how to receive IM using the same.
can anyone help me with the code ?</p>

答:
There are plenty resources in the internet which can be helpful:

Learn Skype Web SDK Day 15 : Receiving Instant Messages

Send and receive text in a conversation

Receive an Incoming IM Call

Skype Web SDK Sending an Instant Message

However it totally depends on your needs and what you wish to build, so its not that easy to answer (e.g. Error Handling if the user is offline or not, and such stuff).


问:
eclipseLink 2.7.0: Static weaving error for "javax.persistence.AttributeConverter"'s signer information does not match
On running gradle task for static weaving in eclipseLink 2.7.0 getting below error.

21:50:14.206 [ERROR] [system.err] Exception Description: Predeployment of PersistenceUnit [default] failed.

  21:50:14.206 [ERROR] [system.err] Internal Exception: java.lang.SecurityException: class "javax.persistence.AttributeConverter"'s signer information does not match signer info
  rmation of other classes in the same package

  21:50:14.206 [ERROR] [system.err]       at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:20
  80)

  21:50:14.206 [ERROR] [system.err]       at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2071)

  21:50:14.206 [ERROR] [system.err] Exception Description: Predeployment of PersistenceUnit [default] failed.

  21:50:14.206 [ERROR] [system.err] Internal Exception:
  java.lang.SecurityException: class "javax.persistence.AttributeConverter"'s signer information does not match signer info
  rmation of other classes in the same package

I am aware that these conflicts comes when class is referred by different jars.
Checked on the same lines.AttributeConverter is present in javax.persistence 2.2.0 as well as eclipselink 2.7.0 causing the conflict.
javax.persistence 2.2.0 is required dependency for eclipselink 2.7.0.

I am gussesing have to exclude one of the jar so that AttributeConverter can be referred from 1 jar.But not sure how.

Any thoughts on resolving this issue ?

答:
In my case, excluding the bundled JPA API dependency and including the standalone one has helped:

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa</artifactId>
        <version>2.7.0</version>
        <exclusions>
            <exclusion>

                <groupId>org.eclipse.persistence</groupId>
                <artifactId>javax.persistence</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>javax.persistence-api</artifactId>
        <version>2.2</version>
    </dependency>
```

Body:
In my case, excluding the bundled JPA API dependency and including the standalone one has helped:

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa</artifactId>
        <version>2.7.0</version>
        <exclusions>
            <exclusion>
                <!-- The JPA API imported separately due to problems with JAR signature. -->
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>javax.persistence</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>javax.persistence-api</artifactId>
        <version>2.2</version>
    </dependency>


问:
InstrumentationTestCase is deprecate in api24
The InstrumentationTestCase is deprecate in api24.

What could I use to replace keeping the same functions?

Ex:

```<code>// Start the MainActivity as the first activity...
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClassName(instrumentation.getTargetContext(), MainActivity.class.getName());
    instrumentation.startActivitySync(intent);
</code>```

I have read a few things about InstrumentationRegistry, but the functions are quite different.

答:
Use class IntstrumentRegistry and from its method

getInstrumentation()
  Returns the instrumentation currently running.

you can use any method like:

startActivitySync(Intent intent)
  Start a new activity and wait for it to begin running before returning.

Edit: This is instrumentation reference link: https://developer.android.com/reference/android/app/Instrumentation.html

Body:
The InstrumentationTestCase is deprecate in api24.

What could I use to replace keeping the same functions?

Ex:

// Start the MainActivity as the first activity...
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClassName(instrumentation.getTargetContext(), MainActivity.class.getName());
    instrumentation.startActivitySync(intent);

I have read a few things about InstrumentationRegistry, but the functions are quite different.


问:
How can i Iterate through data returned in Ajax success?
How can I iterate to get id value? This is my array:

```<code>[{"email_id":"gayatri.dsf@detedu.org","Id":"216"}]
</code>```

tried

```<code><?php
    foreach($faculty as $value)
    {
       echo $value['Id'];
    }
?>
</code>```

Gives an error

Use of undefined constant Id - assumed Id

答:
This is JSON format. First you have to decode it. Example:

```<code>$a = '[{"email_id":"gayatri.dsf@detedu.org","Id":"216"}]';

$dec = json_decode($a);

echo $dec[0]->Id;
</code>```

Result: 216

Decoded you have an array, containing exactly one object. You have to access the object properties with -> then.

With JSON [] brackets means an array, while {} brackets mean objects. Learn more: https://en.wikipedia.org/wiki/JSON

Body:
How can I iterate to get id value? This is my array:

[{"email_id":"gayatri.dsf@detedu.org","Id":"216"}]

tried

<?php
    foreach($faculty as $value)
    {
       echo $value['Id'];
    }
?>

Gives an error

Use of undefined constant Id - assumed Id

Body:
This is JSON format. First you have to decode it. Example:

$a = '[{"email_id":"gayatri.dsf@detedu.org","Id":"216"}]';

$dec = json_decode($a);

echo $dec[0]->Id;

Result: 216

Decoded you have an array, containing exactly one object. You have to access the object properties with -> then.

With JSON [] brackets means an array, while {} brackets mean objects. Learn more: https://en.wikipedia.org/wiki/JSON


问:
angular 2 material matTooltip multiline
I'm new to Angular 2 Material. What's the preferred way to make a tool tip multi-line?

For example, I might have the following tool tip:

```<code>AA BBBBBBBBBB CCCC DDDDD
</code>```

And, I may want to to have it display in a multi-line format like this:

```<code>AA BBBBBBBBBB
CCCC
DDDDD
</code>```

答:
First, create a class for your tooltip, to make it break lines on line breaks.

```<code>.my-tooltip {
    white-space: pre-line;
}
</code>```

Then, add the class to your tooltip and insert line breaks with the Unicode code

```<code><span
    matTooltip="First line
Second line"
    matTooltipClass="my-tooltip">
</span>
</code>```

Title: angular 2 material matTooltip multiline

Body:
I'm new to Angular 2 Material. What's the preferred way to make a tool tip multi-line?

For example, I might have the following tool tip:

AA BBBBBBBBBB CCCC DDDDD

And, I may want to to have it display in a multi-line format like this:

AA BBBBBBBBBB
CCCC
DDDDD

Body:
First, create a class for your tooltip, to make it break lines on line breaks.

.my-tooltip {
    white-space: pre-line;
}

Then, add the class to your tooltip and insert line breaks with the Unicode code &#13;

<span
    matTooltip="First line&#13;Second line"
    matTooltipClass="my-tooltip">
</span>


问:
Format Date output in JSF
If #{myBean.birthdate} is of java.util.Calendar or java.util.Date type, can I possibly format this inside the EL itself using an existing function perhaps, with the output of like the one produced by the DateFormat's SHORT, MEDIUM,LONG abd FULL output type?

Instead of outputting the complete form for the #{myBean.birthdate}: Wed Jan 19 19:01:42 WIT 2011, I just prefer a simple output of Jan 19, 2011.

Should I use #{formatBean.format(myBean.birthdate)} instead?

答:
Use <f:convertDateTime>. You can nest this in any input and output component. Pattern rules are same as java.text.SimpleDateFormat.

```<code><h:outputText value="#{someBean.dateField}" >
    <f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
</h:outputText>
</code>```

Title: Format Date output in JSF

Body:
Use <f:convertDateTime>. You can nest this in any input and output component. Pattern rules are same as java.text.SimpleDateFormat.

<h:outputText value="#{someBean.dateField}" >
    <f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
</h:outputText>


问:
Master position not updating on slave-master server
I have 1 master-slave replication and at the same time the slave is master for a MariaDB cluster which will be replacing the actual two DB servers. everything looks fine but the master position on the slave hasn't updated since the cluster was set up the last month.

Slave is doing ok writing from the Master server but the cluster has not been updated ever since.In fact no errors can be observed but noticed the cluster is just the same it was set up since the beginning.

I know that cluster not wirtting new data ha to do with the mater position on the slave.

So the question would be why the master position on the slave is not updating?

On my MASTER

mysql> show master status\G;

*************************** 1. row ***************************

File: mysql-bin.000775

Position: 6593494

Binlog_Do_DB:

Binlog_Ignore_DB: mysql,performance_schema,phpmyadmin,information_schema

1 row in set (0.00 sec)

On my SLAVE:

MariaDB [(none)]> show slave status\G;

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: master_IP

Master_User: replication

Master_Port: 3306

Connect_Retry: 10

Master_Log_File: mysql-bin.000775

Read_Master_Log_Pos: 4192372

Relay_Log_File: slave-relay-bin.002921

Relay_Log_Pos: 2315832

Relay_Master_Log_File: mysql-bin.000775

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Also on the SLAVE

MariaDB [(none)]> show master status\G;

*************************** 1. row ***************************

File: mysql-replication.000003

Position: 342

Binlog_Do_DB:

Binlog_Ignore_DB:

1 row in set (0.00 sec)

On the CLUSTER

MariaDB [none]> show slave status\G;

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: slave_IP

Master_User: replica

Master_Port: 3306

Connect_Retry: 10

Master_Log_File: mysql-replication.000003

Read_Master_Log_Pos: 342

Relay_Log_File: cluster-relay-bin.000004

Relay_Log_Pos: 645

Relay_Master_Log_File: mysql-replication.000003

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

答:
A machine will not replicate incoming events to downstream replicas unless you enable log_slave_updates on it.

Normally, a slave does not write any updates that are received from a master server to its own binary log. This option causes the slave to write the updates performed by its SQL thread to its own binary log.

https://dev.mysql.com/doc/refman/5.7/en/replication-options-slave.html#option_mysqld_log-slave-updates

(MySQL docs cited, but accurate for MariaDB as well.)

Unrelated, but Binlog_Ignore_Db is usually unnecessary and potentially problematic.


问:
Xcode assistant editor won't show some of the code
First of all, I would like you to know that the class IS set to the correct file in each ViewController - I know that because it did work before, but then I got a "crash" in Xcode that blinked quickly without me being able to read it before it went off again.

MY PROBLEM IS:

I have a lot of ViewControllers in my Xcode, everything was working fine, I was making some more features to the ViewControllers.

Then I got the "crash" as mentioned above, and it would not show any of the files/classes related to their ViewController in assistant editor.

Assistant editor just said: No Assistant Results. Then I read that I could just show the files inside my XCode project and delete project.xcworkplace and xcuserdata. And I thought it worked at first, but it did not work on every viewcontroller unfortunately - only on some of them.

Now, I still have plenty of ViewControllers left to edit that aren't working, and I would hate if I had to recreate every single one.

Does anyone have a better solution to this? I really hope you do :-)

答:
xcode 9.0

Open project.

Click on "Show the assistant editor".(top right side middle button - circle shape)

Code was show after do second step.


答:
You are on the right track. $("table tr.total").prevUntil("table") does indeed give you the set of
 elements preceding the selected tr element.

You could even use $("table tr.total").prevAll() for this as it doesn't explore the parent elements.

You can create an array from the returned tr elements using Array.from, and generate an array of the outer HTML string of each tr using Array#map.

Note that Array.from is not supported in IE11. An alternative would be to iterate the elements using a for loop.

Finally, you can join them using Array#join.

console.log($("table tr.total").prevUntil("table"));
console.log(
  Array.from(
    $("table tr.total").prevAll()
  ).map(t => t.outerHTML).join("")
);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table>
  <tr>
    <td>a1</td>
    <td>a2</td>
  </tr>

  <tr>
    <td>b1</td>
    <td>b2</td>
  </tr>

  <tr>
    <td>c1</td>
    <td>c2</td>
  </tr>

  <tr class="total">
    <td>d1</td>
    <td>d2</td>
  </tr>

  <tr>
    <td>e1</td>
    <td>e2</td>
  </tr>
</table></code>```

Title: select html till i reach a specific class

Body:
You are on the right track. $("table tr.total").prevUntil("table") does indeed give you the set of <tr> elements preceding the selected tr element.

You could even use $("table tr.total").prevAll() for this as it doesn't explore the parent elements.

You can create an array from the returned tr elements using Array.from, and generate an array of the outer HTML string of each tr using Array#map.

Note that Array.from is not supported in IE11. An alternative would be to iterate the elements using a for loop.

Finally, you can join them using Array#join.

console.log($("table tr.total").prevUntil("table"));
console.log(
  Array.from(
    $("table tr.total").prevAll()
  ).map(t => t.outerHTML).join("")
);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table>
  <tr>
    <td>a1</td>
    <td>a2</td>
  </tr>

  <tr>
    <td>b1</td>
    <td>b2</td>
  </tr>

  <tr>
    <td>c1</td>
    <td>c2</td>
  </tr>

  <tr class="total">
    <td>d1</td>
    <td>d2</td>
  </tr>

  <tr>
    <td>e1</td>
    <td>e2</td>
  </tr>
</table>


问:
How to change AJAX call target when calling from different view/page?
I am testing a .js script using Qunit.

I have a static .html test harness that includes the .js "code under test" (CUT) and contains appropriate markup. I am testing using QUnit in another script that is included.

This harness and the test script resides in a project: Application.UI.Tests.JScript.

There are AJAX calls in the CUT that have a target relative to the location of the view that uses it.

The views and scripts reside in the conventional folders in an MVC project: Application.UI.

The build event of Application.UI.Tests.JScript does a Del and XCopy of the Scripts and Content folders to ensure the tests are running against a copy of the latest version of the CUT.

Example code:

```<code>sendDataToServerViaAjax: function () {
    var dataToSend = somefunctionThatReturnsData();

    $.ajax({
         url: 'actionName'
        , type: 'post'
        , data: dataToSend
        , dataType: 'json'
        , success: function (returnedData) {
            alert('This was received by server: ' + returnedData);
        }
    });
}
</code>```

The actionName goes to an action:

```<code>[ValidateInput(false)] //TODO for now
public JsonResult actionName(FormCollection formIn)
{
    string jsonData = formIn[0];
    JsonResult result = new JsonResult();
    result.Data = jsonData;
    return result;
}
</code>```

which just returns the data for now and will eventually have calls to proper logic in the Domain layer.

Question:
How can I make the CUT call the AJAX action on the controller in the running Application.UI project from the static .html page in Application.UI.Tests.JScript without editing the CUT to include information specific for testing?

答:
Changing the url value from actionName to /Controller/actionName will make the url relative to the root of the site e.g.

```<code>$.ajax({
     url: 'actionName'
    , type: 'post'
    , data: dataToSend
    , dataType: 'json'
    , success: function (returnedData) {
        alert('This was received by server: ' + returnedData);
    }
});
</code>```

Body:
I am testing a .js script using Qunit.

I have a static .html test harness that includes the .js "code under test" (CUT) and contains appropriate markup. I am testing using QUnit in another script that is included.

This harness and the test script resides in a project: Application.UI.Tests.JScript.

There are AJAX calls in the CUT that have a target relative to the location of the view that uses it.

The views and scripts reside in the conventional folders in an MVC project: Application.UI.

The build event of Application.UI.Tests.JScript does a Del and XCopy of the Scripts and Content folders to ensure the tests are running against a copy of the latest version of the CUT.

Example code:

sendDataToServerViaAjax: function () {
    var dataToSend = somefunctionThatReturnsData();

    $.ajax({
         url: 'actionName'
        , type: 'post'
        , data: dataToSend
        , dataType: 'json'
        , success: function (returnedData) {
            alert('This was received by server: ' + returnedData);
        }
    });
}

The actionName goes to an action:

[ValidateInput(false)] //TODO for now
public JsonResult actionName(FormCollection formIn)
{
    string jsonData = formIn[0];
    JsonResult result = new JsonResult();
    result.Data = jsonData;
    return result;
}

which just returns the data for now and will eventually have calls to proper logic in the Domain layer.

Question:
How can I make the CUT call the AJAX action on the controller in the running Application.UI project from the static .html page in Application.UI.Tests.JScript without editing the CUT to include information specific for testing?

Body:
Changing the url value from actionName to /Controller/actionName will make the url relative to the root of the site e.g.

$.ajax({
     url: 'actionName'
    , type: 'post'
    , data: dataToSend
    , dataType: 'json'
    , success: function (returnedData) {
        alert('This was received by server: ' + returnedData);
    }
});


问:
Unable to run cordova run android in IONIC project?
I installed ionic in my Mac and created project using

$ ionic start MyIonicProject tutorial

Now i run

```<code>$ cd MyIonicProject
$ ionic serve
</code>```

Now it is serving successfully in browser working fine. So I would like to see the same in android mobile so tried using the below command,

ionic cordova run android --prod --release

This is the pretty concise issue and i can't able to rectify my OSX error's below are the issues when i run above in my Mac..

```<code> > cordova run android --release
ANDROID_HOME=/usr/local/Caskroom/android-sdk/3859397,26.0.2
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
Error: spawn EACCES

[ERROR] An error occurred while running cordova run android --release (exit code 1).

[17:54:52]  lint finished in 2.69 s
</code>```

Please help me someone on how to rectify these error when running the IONIC project on Android natively.

Thanks,

答:
I had run into a similar issue.<s>I had to set executable permissions in the android platform gradle.</s> Correction: It was actually executable permissions in the android gradle installation. It seems to be a reported issue here and the actual issue in cordova is tracked here.

Run the command:

```<code>chmod -R +x <location_of_android_studo>/gradle/gradle-<version>/bin
</code>```

NOTE: -R will run the command recursively from the given directory.

Body:
I installed ionic in my Mac and created project using

$ ionic start MyIonicProject tutorial

Now i run

$ cd MyIonicProject
$ ionic serve

Now it is serving successfully in browser working fine. So I would like to see the same in android mobile so tried using the below command,

ionic cordova run android --prod --release

This is the pretty concise issue and i can't able to rectify my OSX error's below are the issues when i run above in my Mac..

 > cordova run android --release
ANDROID_HOME=/usr/local/Caskroom/android-sdk/3859397,26.0.2
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
Error: spawn EACCES

[ERROR] An error occurred while running cordova run android --release (exit code 1).

[17:54:52]  lint finished in 2.69 s

Please help me someone on how to rectify these error when running the IONIC project on Android natively.

Thanks,

Body:
I had run into a similar issue.<s>I had to set executable permissions in the android platform gradle.</s> Correction: It was actually executable permissions in the android gradle installation. It seems to be a reported issue here and the actual issue in cordova is tracked here.

Run the command:

chmod -R +x <location_of_android_studo>/gradle/gradle-<version>/bin

NOTE: -R will run the command recursively from the given directory.


问:
How do I select multiple lines going upwards on Kakoune?
In Vim I would enter visual mode with V then just move the cursor up (with k).

In kak I can select a line with x and I can extend the selection downwards by pressing X multiple times or by moving the cursor down while still pressing shift with J, but if I go up while still pressing shift, with K I keep the selection, but not for the entire line, the selection on the first selected line somehow jumps to column 0.

答:
That's because Kakoune's selections are oriented. When you select a line with x, the cursor is at the end of the line and the anchor at the beginning. shiftk means "extend the selection to the character above", but extend mean "select to there while keeping the same anchor" and the "character above" is the last character of the previous line.

In short, you need to switch the direction of the selection before extending up: x + alt; + shiftk.


问:
Identifying URI of my red5 server
I've installed red5 on my Win7 PC. I want to use shared objects with Flash and Red5. The documentation says that I need URI, and it looks like a URL, but my home server doesn’t have a URL. Is there a way to find out its URI?</p>

答: Read the wikipedia page on URI. Then just use your server's IP address and port number.</p>

Title: Identifying URI of my red5 server


问:
Good implementation/support for java.util.concurrent.Flow.Processor<T,R>
Recently, I found a good support for Publisher by projectreactor.io:

```<code>Flux.create(fluxSink -> {
           for (int i = 0; i < 10; i++)
            fluxSink.next(i);
           fluxSink.complete();
        })
                .map(...)
                .subscribe(...);
</code>```

Is there any good support for Proccessor?
I mean something like or simular:

```<code>XXX process = new XXX((inputValue, output) -> {
    if(inputValue == 0)
       output.error();
    else
       output.next(inputValue);
});

publisher.subscribe(process);
process.subscribe(...);
</code>```

If not, how can I implement my own or why I cannot do this?

Update 1:

After discussion (see comments) it appeared that in my use case I need use flatMap (see answer), my question was Good implementation of processor by this I meant some functionality that if it's fails I able to take control and emit error instead. I think flatMap will give you quite enough functionality. In my case I used:

```<code>        import org.jsoup.Jsoup;

        Flux.just("url")
            .flatMap(url -> {
                try {
                    Document document = Jsoup.connect(url).get();
                    return Flux.just(document);
                } catch (IOException e) {
                    return Flux.error(e);
                }
            })
            .subscribe();
</code>```

答:
It really depends on what you want to do.

Most of the methods on Flux create such processors and just return them as a Flux making sure they subscribe in the correct way to the upstream Flux.

So if your Processor should just emit an event for each one it receives, but a different one map is your simple way to create your Processor. If it creates multiple (or no) event for each event received use flatMap and so on.

You can create even more complex ones by chaining those methods.
I'd expect 99% of the use cases to be handled this way just fine.

If that is not sufficient, consider the various overloads of subscribe where you can use Consumer to handle elements of a Flux as well as state changes like error, completion and subscription. And you can combine those with, among others with Flux.create(fluxSink -> ...) to construct pretty flexible Processors.

Body:
Recently, I found a good support for Publisher by projectreactor.io:

Flux.create(fluxSink -> {
           for (int i = 0; i < 10; i++)
            fluxSink.next(i);
           fluxSink.complete();
        })
                .map(...)
                .subscribe(...);

Is there any good support for Proccessor?
I mean something like or simular:

XXX process = new XXX((inputValue, output) -> {
    if(inputValue == 0)
       output.error();
    else
       output.next(inputValue);
});

publisher.subscribe(process);
process.subscribe(...);

If not, how can I implement my own or why I cannot do this?

Update 1:

After discussion (see comments) it appeared that in my use case I need use flatMap (see answer), my question was Good implementation of processor by this I meant some functionality that if it's fails I able to take control and emit error instead. I think flatMap will give you quite enough functionality. In my case I used:

        import org.jsoup.Jsoup;

        Flux.just("url")
            .flatMap(url -> {
                try {
                    Document document = Jsoup.connect(url).get();
                    return Flux.just(document);
                } catch (IOException e) {
                    return Flux.error(e);
                }
            })
            .subscribe();


问:
Tensorboard Error: No dashboards are active for current data set
I am trying to use Tensorboard but every time I run any program with Tensorflow, I get an error when I go to localhost:6006 to view the Visualization

Here is my code

```<code>a = tf.add(1, 2,)
b = tf.multiply(a, 3)

with tf.Session() as sess:
    writer = tf.summary.FileWriter("output", sess.graph)
    print(sess.run(b))
    writer.close()
</code>```

When I go to the command prompt and enter

```<code>tensorboard --logdir=C:\path\to\output\folder
</code>```

It returns with

```<code>TensorBoard 0.1.8 at http://MYCOMP:6006 (Press CTRL+C to quit)
</code>```

When I go to localhost:6006 it states

No dashboards are active for the current data set.
  Probable causes:
  - You haven’t written any data to your event files.
  - TensorBoard can’t find your event files.

I have looked at this link (Tensorboard: No dashboards are active for the current data set) but it doesn't seem to fix this issue

And I am running this on Windows 10

What do I do to fix this issue? Am I giving the right path for Tensorboard in the command prompt?

Thank you in advance

答:
Well, you have several issues with your code.

You are creating a summary writer (tf.summary.FileWriter) but you don't actually write anything with it. print(sess.run(b)) has nothing to do with tensorboard if you expected this to has some effect on it. It just prints the value of b

You don't create and summary object to connect some value with.

You are probably entering wrong folder for tensorboard.

More analytically:

You need a summary object to write a summary. For example a tf.summary.scalar to write a scalar to a summary. Something like
tf.summary.scalar("b_value", b) to write the value of b to a summary.

Then you actually need to run your summary operation into a session to get it working, like: summary = sess.run(summary_scalar).

Write the value with the writer you defined previously: writer.add_summary(summary).

Now there is something to see in tensorboard, using
tensorboard --logdir=output in a terminal

In general use you will probably need tf.summary.merge_all() to pass to run in order to gather all your summaries together.

Hope this helps.

Body:
I am trying to use Tensorboard but every time I run any program with Tensorflow, I get an error when I go to localhost:6006 to view the Visualization

Here is my code

a = tf.add(1, 2,)
b = tf.multiply(a, 3)

with tf.Session() as sess:
    writer = tf.summary.FileWriter("output", sess.graph)
    print(sess.run(b))
    writer.close()

When I go to the command prompt and enter

tensorboard --logdir=C:\path\to\output\folder

It returns with

TensorBoard 0.1.8 at http://MYCOMP:6006 (Press CTRL+C to quit)

When I go to localhost:6006 it states

No dashboards are active for the current data set.
  Probable causes:
  - You haven’t written any data to your event files.
  - TensorBoard can’t find your event files.

I have looked at this link (Tensorboard: No dashboards are active for the current data set) but it doesn't seem to fix this issue

And I am running this on Windows 10

What do I do to fix this issue? Am I giving the right path for Tensorboard in the command prompt?

Thank you in advance


问:
Nightwatch.js execute scenarios with specific tags
I'm trying run some specific scenarios using tags but I'm unable to finsh some documentation regarding that. What I want to do is run all scenarios that are marked with a specific tag. Look at the example provided on the github but it doesn't say much. What I want to do is:

```<code>   @onlyone
  Scenario: a random feature
    Given: something
    When: I do something
    Then only this test should be ran
</code>```

So what I want to do is run the following command nightwatch --tag @onlyone only the scenarios with that tag should be ran.

答: Found the appropiate documentation, Nightwatch Documentation it was an error on my part.</p>

Body:
I'm trying run some specific scenarios using tags but I'm unable to finsh some documentation regarding that. What I want to do is run all scenarios that are marked with a specific tag. Look at the example provided on the github but it doesn't say much. What I want to do is:

   @onlyone
  Scenario: a random feature
    Given: something
    When: I do something
    Then only this test should be ran

So what I want to do is run the following command nightwatch --tag @onlyone only the scenarios with that tag should be ran.


问:
Computing Growth of a Variable in R
I want to compute a growth variable in a data frame with R.

Lets say I have a starting variable X=100
and a vector Y of time length 10 with growth rates f.e

```<code>Y<-c(0.04, 0.03, -0.02 ... 0.02)
</code>```

Is there a solution to compute the growth rate of X o.v.t., so that I get a vector for my starting value X, e.g. : (100, 100*(1+0,04), (100*(1+0,04)*(1,03),... etc)

I hope I could make it clear.

Thanks,

答:
Great and easy answer from @AEF in the comments above.
Just posting another solution using purrr package and function accumulate. Maybe a bit too much for your specific example, but useful if you wanted to apply a more complex function/pattern/methodology:

```<code>library(purrr)

# set of growth rates
gr_rates = c(0.04, 0.03, -0.02, 0.02)

# function to apply the general formula
f = function(x,r) {x*(1+r)}

# apply the function recursively and show intermediate results
# set the starting point as 100
accumulate(gr_rates, f, .init = 100)

# [1] 100.0000 104.0000 107.1200 104.9776 107.0772
</code>```

Title: Computing Growth of a Variable in R

Body:
I want to compute a growth variable in a data frame with R.

Lets say I have a starting variable X=100
and a vector Y of time length 10 with growth rates f.e

Y<-c(0.04, 0.03, -0.02 ... 0.02)

Is there a solution to compute the growth rate of X o.v.t., so that I get a vector for my starting value X, e.g. : (100, 100*(1+0,04), (100*(1+0,04)*(1,03),... etc)

I hope I could make it clear.

Thanks,

Body:
Great and easy answer from @AEF in the comments above.
Just posting another solution using purrr package and function accumulate. Maybe a bit too much for your specific example, but useful if you wanted to apply a more complex function/pattern/methodology:

library(purrr)

# set of growth rates
gr_rates = c(0.04, 0.03, -0.02, 0.02)

# function to apply the general formula
f = function(x,r) {x*(1+r)}

# apply the function recursively and show intermediate results
# set the starting point as 100
accumulate(gr_rates, f, .init = 100)

# [1] 100.0000 104.0000 107.1200 104.9776 107.0772


问:
C# restrict a overriding method to return a specific type
I have an abstract class which should have a method returning an instance of a class which should inherit from a base class as well implement an interface.

```<code>public abstract class AbstractClass
{
    abstract [DonotKnowTheType] GetClassInstance() //The Return type should be an instance of a class which implements TestClass and ISample
}

public class ChildClass : AbstractClass
{
    override [DonotKnowTheType] GetClassInstance()
    {
        //Need to return instance of SampleClass in this example. This could vary, this should be an instance of a class which implements TestClass and ISample
    }
}

public class SampleClass : TestClass,ISample
{
    //Implementation
}
</code>```

Please help to achieve this with a good design. Need to restrict developers who writes the overriding method in ChildClass to return only an instance of a class which implements TestClass and ISample. If not, it has to show a compile time error.

答:
Try this:

```<code>public abstract class TheEnforcer<T> where T: TestClass, IMyInterface
    {
        protected abstract T GetClassInstance();
    }

    public class ThePoorClass : TheEnforcer<DerivedTestClass>
    {
        protected override DerivedTestClass GetClassInstance()
        {
            throw new NotImplementedException();
        }
    }

    public class TestClass
    {

    }

    public class DerivedTestClass : TestClass, IMyInterface
    {

    }

    public interface IMyInterface
    {

    }
</code>```

After your comment:

```<code>namespace First {
    public abstract class TheEnforcer<T> where T : IMarkerInterface
    {
        protected abstract T GetClassInstance();
    }

    public interface IMarkerInterface
    {

    } }

namespace Second {
    using First;

    // All this is in separate name space
    public class TestClass: IMarkerInterface
    {

    }

    public class DerivedTestClass : TestClass, IMyInterface
    {

    }

    public interface IMyInterface
    {

    }

    public class ThePoorClass : TheEnforcer<DerivedTestClass>
    {
        protected override DerivedTestClass GetClassInstance()
        {
            throw new NotImplementedException();
        }
    } }
</code>```

Body:
I have an abstract class which should have a method returning an instance of a class which should inherit from a base class as well implement an interface.

public abstract class AbstractClass
{
    abstract [DonotKnowTheType] GetClassInstance() //The Return type should be an instance of a class which implements TestClass and ISample
}

public class ChildClass : AbstractClass
{
    override [DonotKnowTheType] GetClassInstance()
    {
        //Need to return instance of SampleClass in this example. This could vary, this should be an instance of a class which implements TestClass and ISample
    }
}

public class SampleClass : TestClass,ISample
{
    //Implementation
}

Please help to achieve this with a good design. Need to restrict developers who writes the overriding method in ChildClass to return only an instance of a class which implements TestClass and ISample. If not, it has to show a compile time error.

Body:
Try this:

public abstract class TheEnforcer<T> where T: TestClass, IMyInterface
    {
        protected abstract T GetClassInstance();
    }

    public class ThePoorClass : TheEnforcer<DerivedTestClass>
    {
        protected override DerivedTestClass GetClassInstance()
        {
            throw new NotImplementedException();
        }
    }

    public class TestClass
    {

    }

    public class DerivedTestClass : TestClass, IMyInterface
    {

    }

    public interface IMyInterface
    {

    }

After your comment:

namespace First {
    public abstract class TheEnforcer<T> where T : IMarkerInterface
    {
        protected abstract T GetClassInstance();
    }

    public interface IMarkerInterface
    {

    } }

namespace Second {
    using First;

    // All this is in separate name space
    public class TestClass: IMarkerInterface
    {

    }

    public class DerivedTestClass : TestClass, IMyInterface
    {

    }

    public interface IMyInterface
    {

    }

    public class ThePoorClass : TheEnforcer<DerivedTestClass>
    {
        protected override DerivedTestClass GetClassInstance()
        {
            throw new NotImplementedException();
        }
    } }


问:
Dynamic function name in JavaScript
I have this:

```<code>this.f = function instance(){};
</code>```

I would like to have this:

```<code>this.f = function ["instance:" + a](){};
</code>```

答:
The most voted answer has got already defined [String] function body. I was looking for the solution to rename already declared function's name and finally after an hour of struggling I've dealt with it. It:

takes the alredy declared function

parses it to [String] with .toString() method

then overwrites the name (of named function) or appends the new one (when anonymous) between function and (

then creates the new renamed function with new Function() constructor

function nameAppender(name,fun){
  const reg = /^(function)(?:\s*|\s+([A-Za-z0-9_$]+)\s*)(\()/;
  return (new Function(`return ${fun.toString().replace(reg,`$1 ${name}$3`)}`))();
}

//WORK FOR ALREADY NAMED FUNCTIONS:
function hello(name){
  console.log('hello ' + name);
}

//rename the 'hello' function
var greeting = nameAppender('Greeting', hello);

console.log(greeting); //function Greeting(name){...}

//WORK FOR ANONYMOUS FUNCTIONS:
//give the name for the anonymous function
var count = nameAppender('Count',function(x,y){
  this.x = x;
  this.y = y;
  this.area = x*y;
});

console.log(count); //function Count(x,y){...}```

Title: Dynamic function name in JavaScript

Body:
I have this:

this.f = function instance(){};

I would like to have this:

this.f = function ["instance:" + a](){};


问:
Oracle forms 10g developer suite
I want to deploy the Oracle forms.
I have installed Oracle forms 10g Developer site and created forms.
Now, what i need to install to deploy it and use over web
And how to deploy forms.</p>

答:
There is a lot to do, You'd need to install oracle on a server machine, and all related services in order to run forms, please find a full guide here:

Fusion Middleware Installation Guide for Oracle Forms and Reports

Good luck.

Title: Oracle forms 10g developer suite


问:
Error Alert in the Eclipse Console
this:

[2011-01-19 12:25:46 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for C:\Praxiseinsatz\AndroidManifest.xml: Element or attribute do not match QName production: QName::=(NCName':')?NCName.

This the alert I get no matter what I do in my android project.

When I try to start my app I am being given the alert:

The app has stopped working unexpectedly

and I am going nuts!
I hope you can help me and tell me what to do :(

答:
Productions are rules that specify syntax or "grammar". QName is the production for a name or an attribute in a tag, like "activity" in:

```<code><activity .... >
    ...
</activity>
</code>```

So there must be an error in one (or more) of them, like not prefixing a needed namespace

(Usually when I get some strange error I copy and paste it in google, in double quotes. I often find discussions about that.)

Title: Error Alert in the Eclipse Console

Body:
Productions are rules that specify syntax or "grammar". QName is the production for a name or an attribute in a tag, like "activity" in:

<activity .... >
    ...
</activity>

So there must be an error in one (or more) of them, like not prefixing a needed namespace

(Usually when I get some strange error I copy and paste it in google, in double quotes. I often find discussions about that.)


问:
Delphi 5 cast type to evaluated type causes Invalid typecast error

I need to convert a Variant to TNotifyEvent, but can't.

As the image shows I use GetPropValue to get the OnClick property of a TMenuItem. I must compare this to another TNotifyEvent, so I must convert it also to TNotifyEvent.

In runtime this is always type of TNotifyEvent, but the code not compile, when I try to cast it to TNotifyEvent.

How can I make it work? Unfortunately I have only Delphi version 5, so the RTTI capabilities are limited.

答:
You are calling the wrong method. Instead of GetPropValue you need GetMethodProp. Like so:

```<code>TNotifyEvent(GetMethodProp(MenuItem, 'OnClick'));
</code>```

Body:
You are calling the wrong method. Instead of GetPropValue you need GetMethodProp. Like so:

TNotifyEvent(GetMethodProp(MenuItem, 'OnClick'));