问:
install wxpython for python2 and 3 on ubuntu
I am running Ubuntu 16 and have both python 2 and 3. I have downloaded wxpython and it works with the python2 interpreter but not 3. I get

```<code>Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>>
</code>```

and

```<code>Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'wx'
</code>```

What do I need to do to get installed for python 3?

答:
A similar situation arises on Fedora 25, on which I was able to solve this. Your mileage may vary on Ubuntu.

First note that wxPython is available in two major versions, let's call them wx3 and wx4. You can identify your running version through import wx; print(wx.version()). The version string on Fedora 25 reads '3.0.2.0 gtk3 (classic)', i.e. a brand of wx3. On sourceforge these versions are known as 'wxPython' and 'wxPython4', and wxpython.org calls wx4 'phoenix'.

Inspecting the source code of wx3 you will note that wx3's syntax is incompatible with python3. Conversely, wx4 is compatible both with python2.7 and python3.

wx4 doesn't seem to be available on Fedora 25, therefore python3 can't run any wx out-of-the-box. Ubuntu may or may not have the same issue.

The following worked for me to install wx4 in a python3 virtual environment:

```<code>pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/fedora-26 wxPython
</code>```

I presume the answer to your question would be

```<code>pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython
</code>```

In case you need to port a (py2, wx3) application to python3, you would be wise creating an intermediate step: (py2, wx3) -> (py2, wx4) -> (py3, wx4), noting that (py3, wx3) is an impossibility.

To create the (py2, wx4) environment was more cumbersome for me, because the above pip install command fails to find header files when run using pip2.

What ended up working for me was to download the 4.0.0b2 source https://pypi.python.org/packages/bc/6f/f7bb525517557e1c596bf22ef3f242b87afaeab57c9ad460cb94b3b0714e/wxPython-4.0.0b2.tar.gz#md5=2e3716205da8f52d8039095d14534bf7

and follow the build instructions https://github.com/wxWidgets/Phoenix/blob/master/README.rst , from which I only used the build command python build.py dox etg --nodoc sip build .

After building, you need to tell your python2 where to find the wx4 library. I ended up doing that by creating a virtualenv, and creating a symbolic link like so:

```<code>/home/user/venv/lib/python2.7/site-packages/wx -> /home/user/downloads/wxPython/wxPython-4.0.0b2/wx
</code>```

That latter directory cointaining the result of the build.

Body:
I am running Ubuntu 16 and have both python 2 and 3. I have downloaded wxpython and it works with the python2 interpreter but not 3. I get

Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>>

and

Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'wx'

What do I need to do to get installed for python 3?

Body:
A similar situation arises on Fedora 25, on which I was able to solve this. Your mileage may vary on Ubuntu.

First note that wxPython is available in two major versions, let's call them wx3 and wx4. You can identify your running version through import wx; print(wx.version()). The version string on Fedora 25 reads '3.0.2.0 gtk3 (classic)', i.e. a brand of wx3. On sourceforge these versions are known as 'wxPython' and 'wxPython4', and wxpython.org calls wx4 'phoenix'.

Inspecting the source code of wx3 you will note that wx3's syntax is incompatible with python3. Conversely, wx4 is compatible both with python2.7 and python3.

wx4 doesn't seem to be available on Fedora 25, therefore python3 can't run any wx out-of-the-box. Ubuntu may or may not have the same issue.

The following worked for me to install wx4 in a python3 virtual environment:

pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/fedora-26 wxPython

I presume the answer to your question would be

pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython

In case you need to port a (py2, wx3) application to python3, you would be wise creating an intermediate step: (py2, wx3) -> (py2, wx4) -> (py3, wx4), noting that (py3, wx3) is an impossibility.

To create the (py2, wx4) environment was more cumbersome for me, because the above pip install command fails to find header files when run using pip2.

What ended up working for me was to download the 4.0.0b2 source https://pypi.python.org/packages/bc/6f/f7bb525517557e1c596bf22ef3f242b87afaeab57c9ad460cb94b3b0714e/wxPython-4.0.0b2.tar.gz#md5=2e3716205da8f52d8039095d14534bf7

and follow the build instructions https://github.com/wxWidgets/Phoenix/blob/master/README.rst , from which I only used the build command python build.py dox etg --nodoc sip build .

After building, you need to tell your python2 where to find the wx4 library. I ended up doing that by creating a virtualenv, and creating a symbolic link like so:

/home/user/venv/lib/python2.7/site-packages/wx -> /home/user/downloads/wxPython/wxPython-4.0.0b2/wx

That latter directory cointaining the result of the build.


来源: stackexchange

问:
How to get line break within string interpolation in Angularjs
So I'm trying to do something very simple and I'm stuck. I have a String variable and within that variable I Wanna set line break so certain part of the text goes to new line.

What I have tried:

```<code>title: string = "My \n Title";
title: string = "My\ Title";
title: string = "My\
Title";
title: string = "My" + "\n" + "Title";
</code>```

I have tried many variations but its just not working. Am I being stupid and missing something very obvious?

Not a duplicate as I have tried the
 and it has not worked.

Update:

The variable is being printed in the browser HTML like so {{title}}

答:
You have done the right thing.
But if you are showing this in a browser, the \n means didley.

You have to do:

```<code>title: string = "My<br>Title"
</code>```

Now if you are using a fancy front end tool like React, you will have to deal with unsafe HTML in strings...

ContentLicense: CC BY-SA 3.0

Body:
So I'm trying to do something very simple and I'm stuck. I have a String variable and within that variable I Wanna set line break so certain part of the text goes to new line.

What I have tried:

title: string = "My \n Title";
title: string = "My\ Title";
title: string = "My\
Title";
title: string = "My" + "\n" + "Title";

I have tried many variations but its just not working. Am I being stupid and missing something very obvious?

Not a duplicate as I have tried the
 and it has not worked.

Update:

The variable is being printed in the browser HTML like so {{title}}

Body:
You have done the right thing.
But if you are showing this in a browser, the \n means didley.

You have to do:

title: string = "My<br>Title"

Now if you are using a fancy front end tool like React, you will have to deal with unsafe HTML in strings...


问:
Unable to connect to Teradata through VBA macro with mechanism as LDAP
Tried with the following code to connect to Teradata and it is working fine

```<code>  Worksheets("BO").range("A:C").Clearcontents
  conn.Open "Driver={Teradata};" & _
  "DBCName=" & TDServer & ";" & _
  "Database=" & TDDb & ";" & _
  "Uid=" & TDUname & ";" & _
  "Pwd=" & TDPword & ""
</code>```

Unable to connect to "LDAP" mechanism and it is throwing Userid/password is invalid even after including the "Authentication" as LDAP in the above code

答:
It's necessary when to specify your authentication mechanism when connecting through a non-default auth mech. You do that in your ODBC connection string using the Authentication setting.

In your case:

```<code>conn.Open "Driver={Teradata};" & _
  "DBCName=" & TDServer & ";" & _
  "Database=" & TDDb & ";" & _
  "Uid=" & TDUname & ";" & _
  "Pwd=" & TDPword & ";" & _
  "Authentication=LDAP"
</code>```

A few other very useful settings to consider in your connection string:

SessionMode. This should default to "Teradata", but I like to specify just in case since you have to be more explicit about your SQL if you find yourself in ANSI mode.

```<code>  "SessionMode=Teradata"
</code>```

CharSet which defaults to ASCII which may be fine for you needs, but if you have any data that is Unicode, then you will need to specify a Unicode character set in your connection string to avoid the Unicode characters being dumbed down to ASCII (Question marks and empty boxes are common replacements)

```<code>  "CharSet=UTF8"
</code>```

As an example, here is my connection function that I've been using for years to handle LDAP connections:

```<code>Public adoConn as ADODB.Connection
Private username as string
Private password as string

<other supporting functions here like getUsername and getPassword>

Function openConnection() As Boolean
    Dim ServerName As String, DatabaseName As String
    Set adoConn = New ADODB.Connection

    On Error GoTo ErrorHandler
startOver:
    If m_db.username = "" Or m_db.password = "" Then
        getUsername
        getPassword
    End If

    'ldap
    adoConn.Open "SessionMode=Teradata;Driver=Teradata;Authentication=LDAP;DBCName=mydb.somewhere.com;Database=mydb;CharSet=UTF8;Uid=" & username & ";Pwd=" & password

    Exit Function
ErrorHandler:
     If Err.Number = -2147217843 Then
        yesno = MsgBox("Your username or password was incorrect." & vbCrLf & vbCrLf & "Try Again?", vbYesNo)
        If yesno = vbYes Then
            m_db.password = ""
            GoTo startOver
        End If
    End If
    Debug.Print Err.Description, Err.Number
End Function
</code>```

Updating with a version that can work using a paramter to toggle ldap functionality:

```<code>Public adoConn as ADODB.Connection
Private username as string
Private password as string

<other supporting functions here like getUsername and getPassword>

Function openConnection(ldap as boolean) As Boolean
    Dim ServerName As String
    Dim DatabaseName As String
    Dim strConnection as string
    Set adoConn = New ADODB.Connection

    On Error GoTo ErrorHandler
startOver:
    If m_db.username = "" Or m_db.password = "" Then
        getUsername
        getPassword
    End If

    'ldap
    If ldap Then
        strConnection = "SessionMode=Teradata;Driver=Teradata;Authentication=LDAP;DBCName=mydb.somewhere.com;Database=mydb;CharSet=UTF8;Uid=" & username & ";Pwd=" & password
    Else 'not ldap
         strConnection = "SessionMode=Teradata;Driver=Teradata;DBCName=mydb.somewhere.com;Database=mydb;CharSet=UTF8;Uid=" & username & ";Pwd=" & password
    End If

    'open the connection
    adoConn.Open strConnection

    Exit Function
ErrorHandler:
     If Err.Number = -2147217843 Then
        yesno = MsgBox("Your username or password was incorrect." & vbCrLf & vbCrLf & "Try Again?", vbYesNo)
        If yesno = vbYes Then
            m_db.password = ""
            GoTo startOver
        End If
    End If
    Debug.Print Err.Description, Err.Number
End Function
</code>```

You can now call this like:

```<code>Set connTeradataProd = openConnection(True) 'for ldap
Set connTeradataStage = openConnection(False) 'for default auth
</code>```

Body:
Tried with the following code to connect to Teradata and it is working fine

  Worksheets("BO").range("A:C").Clearcontents
  conn.Open "Driver={Teradata};" & _
  "DBCName=" & TDServer & ";" & _
  "Database=" & TDDb & ";" & _
  "Uid=" & TDUname & ";" & _
  "Pwd=" & TDPword & ""

Unable to connect to "LDAP" mechanism and it is throwing Userid/password is invalid even after including the "Authentication" as LDAP in the above code

Body:
It's necessary when to specify your authentication mechanism when connecting through a non-default auth mech. You do that in your ODBC connection string using the Authentication setting.

In your case:

conn.Open "Driver={Teradata};" & _
  "DBCName=" & TDServer & ";" & _
  "Database=" & TDDb & ";" & _
  "Uid=" & TDUname & ";" & _
  "Pwd=" & TDPword & ";" & _
  "Authentication=LDAP"

A few other very useful settings to consider in your connection string:

SessionMode. This should default to "Teradata", but I like to specify just in case since you have to be more explicit about your SQL if you find yourself in ANSI mode.

  "SessionMode=Teradata"

CharSet which defaults to ASCII which may be fine for you needs, but if you have any data that is Unicode, then you will need to specify a Unicode character set in your connection string to avoid the Unicode characters being dumbed down to ASCII (Question marks and empty boxes are common replacements)

  "CharSet=UTF8"

As an example, here is my connection function that I've been using for years to handle LDAP connections:

Public adoConn as ADODB.Connection
Private username as string
Private password as string

<other supporting functions here like getUsername and getPassword>

Function openConnection() As Boolean
    Dim ServerName As String, DatabaseName As String
    Set adoConn = New ADODB.Connection

    On Error GoTo ErrorHandler
startOver:
    If m_db.username = "" Or m_db.password = "" Then
        getUsername
        getPassword
    End If

    'ldap
    adoConn.Open "SessionMode=Teradata;Driver=Teradata;Authentication=LDAP;DBCName=mydb.somewhere.com;Database=mydb;CharSet=UTF8;Uid=" & username & ";Pwd=" & password

    Exit Function
ErrorHandler:
     If Err.Number = -2147217843 Then
        yesno = MsgBox("Your username or password was incorrect." & vbCrLf & vbCrLf & "Try Again?", vbYesNo)
        If yesno = vbYes Then
            m_db.password = ""
            GoTo startOver
        End If
    End If
    Debug.Print Err.Description, Err.Number
End Function

Updating with a version that can work using a paramter to toggle ldap functionality:

Public adoConn as ADODB.Connection
Private username as string
Private password as string

<other supporting functions here like getUsername and getPassword>

Function openConnection(ldap as boolean) As Boolean
    Dim ServerName As String
    Dim DatabaseName As String
    Dim strConnection as string
    Set adoConn = New ADODB.Connection

    On Error GoTo ErrorHandler
startOver:
    If m_db.username = "" Or m_db.password = "" Then
        getUsername
        getPassword
    End If

    'ldap
    If ldap Then
        strConnection = "SessionMode=Teradata;Driver=Teradata;Authentication=LDAP;DBCName=mydb.somewhere.com;Database=mydb;CharSet=UTF8;Uid=" & username & ";Pwd=" & password
    Else 'not ldap
         strConnection = "SessionMode=Teradata;Driver=Teradata;DBCName=mydb.somewhere.com;Database=mydb;CharSet=UTF8;Uid=" & username & ";Pwd=" & password
    End If

    'open the connection
    adoConn.Open strConnection

    Exit Function
ErrorHandler:
     If Err.Number = -2147217843 Then
        yesno = MsgBox("Your username or password was incorrect." & vbCrLf & vbCrLf & "Try Again?", vbYesNo)
        If yesno = vbYes Then
            m_db.password = ""
            GoTo startOver
        End If
    End If
    Debug.Print Err.Description, Err.Number
End Function

You can now call this like:

Set connTeradataProd = openConnection(True) 'for ldap
Set connTeradataStage = openConnection(False) 'for default auth


问:
Spotify API: Can I retrieve users who have an artist / track in their playlists?
I'm using the Spotify API in R with the package Rspotify. Is there a way to retrieve a list of users who are interested in a specific artist / album / band? For example, getting a vector of ids that have track "6fQVr0vmoQRpOY3mRcoWIC" in their playlists.

All the commands seem to give information when you already have the user, but not the other way round. Does anyone have an idea how to get this?

答: This isn't possible, because, in order to get a users data, they have to grant you permission first. Once you've got the users permission to see their data, you'll be able to go through their playlists to find the artists and tracks that are included.</p>


问:
Writing IIS URL rewrite rules
I am using the IIS7 URL Rewrite module. I want to create a rule that matches this:

http://www.example.com/test123.

but not this:

http://www.example.com/test123/

答:
Is something like http://www.mydomain.com/test123/bla allowed?

If not:

```<code>^[^/]+$
</code>```

If yes:

```<code>^.*[^/]$
</code>```

ContentLicense: CC BY-SA 4.0

Title: Writing IIS URL rewrite rules

Body:
Is something like http://www.mydomain.com/test123/bla allowed?

If not:

^[^/]+$

If yes:

^.*[^/]$

ContentLicense: CC BY-SA 2.5


问:
Azure Data Factory invalid slices
I've come across this problem on multiple occasions so I've finally decided to ask about it... I have a pipeline with the following schedule:

```<code>    "start": "2016-10-04T00:00:00Z",
    "end": "2099-12-31T06:00:00Z",
    "isPaused": false,
    "hubName": "xerox_hub",
    "pipelineMode": "Scheduled"
</code>```

On the Monitor and Manage page I have the following setting:

And yet for some reason, every slice before 10-17-2017 is considered invalid.

There is data in my database from before this time, so I know the slices must have ran at some point, but for some reason, I cannot click them from the monitor and manage page... Anyone else experience something like this? (Note: I am not using ADF v2.0)

答:
The monitor and management in ADFv1 can only retain a small amount of log data. It struggles with anything long term or complex. Especially if you have lots of datasets.

This isn't an answer, but its not you. Its just a "feature" of v1.

In ADFv2 you have the full power of logging to the Azure Monitor so this will be replace the bits from your screen shot.

Hope this helps.

Paul

Title: Azure Data Factory invalid slices

Body:
I've come across this problem on multiple occasions so I've finally decided to ask about it... I have a pipeline with the following schedule:

    "start": "2016-10-04T00:00:00Z",
    "end": "2099-12-31T06:00:00Z",
    "isPaused": false,
    "hubName": "xerox_hub",
    "pipelineMode": "Scheduled"

On the Monitor and Manage page I have the following setting:

And yet for some reason, every slice before 10-17-2017 is considered invalid.

There is data in my database from before this time, so I know the slices must have ran at some point, but for some reason, I cannot click them from the monitor and manage page... Anyone else experience something like this? (Note: I am not using ADF v2.0)


Title: Group b Time and return Boolean value if group contain

Body:
I have df as below.

Index                                Receiver
1970-01-01 00:00:00.000000000         R1
1970-01-01 00:00:00.800000000         R1
1970-01-01 00:00:01.000287000         R2
1970-01-01 00:00:01.600896000         R2
1970-01-01 00:00:02.001388000         R1
1970-01-01 00:00:02.004698000         R1
1970-01-01 00:00:02.006706000         R2
1970-01-01 00:00:02.501351000         R2
1970-01-01 00:00:02.810382000         R2
1970-01-01 00:00:03.001981000         R1
1970-01-01 00:00:03.377116000         R1
1970-01-01 00:00:03.701811000         R2
1970-01-01 00:00:03.910326000         R2
1970-01-01 00:00:03.951355000         R2

How to get the following df from above?

Index                        R1   R2
1970-01-01 00:00:00          1    0
1970-01-01 00:00:01          0    1
1970-01-01 00:00:02          1    1
1970-01-01 00:00:03          1    1

Appreciate one liner code.
Regards,
Asif

Body:
df.set_index('Index').Receiver.resample('S').apply(lambda x : ','.join(set(x))).str.get_dummies(sep=',')
Out[909]:
                     R1  R2
Index
1970-01-01 00:00:00   1   0
1970-01-01 00:00:01   0   1
1970-01-01 00:00:02   1   1
1970-01-01 00:00:03   1   1


问:
ASP.NET MVC Routing to sub directories without area
I've reorganized my project into a more logical hierarchy:

```<code>-Controllers
  -Accounts
    -CustomersController
  -Setup
    -SystemDefaultsController
    -SettingsController
  -HomeController
</code>```

At the moment, I'm just trying to set up my URLs to match this structure. So valid example URLs would be:

```<code>localhost:1234/Home/Index
localhost:1234/Setup/SystemDefaults/Index
localhost:1234/Setup/Settings/Index
localhost:1234/CustomerAccounts/Index
</code>```

So I added a route on top of the default route in RouteConfig.cs:

```<code>public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapMvcAttributeRoutes();

    //AreaRegistration.RegisterAllAreas();

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        name: "Setup",
        url: "Setup/{controller}/{action}/{id}",
        defaults: new { controller = "Setup", action = "Index", id = UrlParameter.Optional },
        namespaces: new[] { "MVCWeb.Controllers.Setup" }
    );

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        namespaces: new[] { "MVCWeb.Controllers" }
    );
}
</code>```

This does make the above URLs work, but it has no constraints so these URLs work when I want them to be invalid:

localhost:1234/Setup/CustomerAccounts/Index
localhost:1234/SystemDefaults/Index

Additionally, since the Setup route matches everything, if I do either of these:

```<code>@Html.ActionLink("Customer Accounts", "Index", "CustomerAccounts")
@Url.Action("Index", "CustomerAccounts")
</code>```

It generates the URL as /Setup/CustomerAccounts/Index instead of /CustomerAccounts/Index.

Is there a way to do accomplish this without using an Area while still using {controller} in the route URL? Or would I have to add a route specifically for each controller under Setup?

答:
Have you ever evaluated Attribute Routing in MVC 5? It seems like you're starting a new project, so this could be a good new start. With the [RoutePrefix] attribute, you could probably enforce what you want to achieve easily:

```<code>[RoutePrefix("accounts")]
public class CustomersController : Controller
{
    // ...
}
</code>```

We don't use Attribute Routing yet so I can't speak from own experience but it looks very flexible and promising.

UPDATE

I created a GIST for you where I explain how you could validate your Attributes, not during compile time, but with Unit Tests. This is a simple code snipped designed for MS Test. The validation possibilities are very broad.

Custom Logic we might add to a custom RoutePrefixAttribute? For example, the RoutePrefixAttribute allows a string as a parameter. You could rewrite it to allow only a specific Enum as parameter, which lists only possible values, and internally set the Prefix string.

Body:
I've reorganized my project into a more logical hierarchy:

-Controllers
  -Accounts
    -CustomersController
  -Setup
    -SystemDefaultsController
    -SettingsController
  -HomeController

At the moment, I'm just trying to set up my URLs to match this structure. So valid example URLs would be:

localhost:1234/Home/Index
localhost:1234/Setup/SystemDefaults/Index
localhost:1234/Setup/Settings/Index
localhost:1234/CustomerAccounts/Index

So I added a route on top of the default route in RouteConfig.cs:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapMvcAttributeRoutes();

    //AreaRegistration.RegisterAllAreas();

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        name: "Setup",
        url: "Setup/{controller}/{action}/{id}",
        defaults: new { controller = "Setup", action = "Index", id = UrlParameter.Optional },
        namespaces: new[] { "MVCWeb.Controllers.Setup" }
    );

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        namespaces: new[] { "MVCWeb.Controllers" }
    );
}

This does make the above URLs work, but it has no constraints so these URLs work when I want them to be invalid:

localhost:1234/Setup/CustomerAccounts/Index
localhost:1234/SystemDefaults/Index

Additionally, since the Setup route matches everything, if I do either of these:

@Html.ActionLink("Customer Accounts", "Index", "CustomerAccounts")
@Url.Action("Index", "CustomerAccounts")

It generates the URL as /Setup/CustomerAccounts/Index instead of /CustomerAccounts/Index.

Is there a way to do accomplish this without using an Area while still using {controller} in the route URL? Or would I have to add a route specifically for each controller under Setup?

Body:
Have you ever evaluated Attribute Routing in MVC 5? It seems like you're starting a new project, so this could be a good new start. With the [RoutePrefix] attribute, you could probably enforce what you want to achieve easily:

[RoutePrefix("accounts")]
public class CustomersController : Controller
{
    // ...
}

We don't use Attribute Routing yet so I can't speak from own experience but it looks very flexible and promising.

UPDATE

I created a GIST for you where I explain how you could validate your Attributes, not during compile time, but with Unit Tests. This is a simple code snipped designed for MS Test. The validation possibilities are very broad.

Custom Logic we might add to a custom RoutePrefixAttribute? For example, the RoutePrefixAttribute allows a string as a parameter. You could rewrite it to allow only a specific Enum as parameter, which lists only possible values, and internally set the Prefix string.


问:
how to use scrollview in layout with toolbar and bottomnavigationview?
I have a screen in which there is a toolbar, a bottomNavigationView and some data between them including a textView and an imageView. I want to scroll the inner data that is between the toolbar and bottomNavigationView.

I want to scroll the design.xml inside of main.xml. Please suggest a way I can achieve this.

main.xml

```<code><?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar1"
        android:layout_width="match_parent"
        app:layout_scrollFlags="scroll|enterAlways"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    xmlns:app="http://schemas.android.com/apk/res-auto">
<include
    layout="@layout/design"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</ScrollView>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:itemBackground="@color/colorPrimary"
    app:itemIconTint="#FFFFFF"
    app:itemTextColor="#FFFFFF"
    app:menu="@menu/bottom_navigation_main" />
</code>```

design.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_marginTop="?android:attr/actionBarSize"
    tools:context="com.example.chaitanya.pg.Pgdata">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/relative">

        <Button
            android:id="@+id/btt1"
            android:background="@drawable/tprevoius"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="100dp" />

        <Button
            android:background="@drawable/tnext"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignTop="@+id/btt1"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:id="@+id/btt2" />
        <android.support.v4.view.ViewPager
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:id="@+id/viewPager"/>

        <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/tools"
            android:id="@+id/cardview1"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            card_view:cardElevation="5dp"
            android:layout_below="@id/viewPager"
            android:layout_margin="6dp"
            card_view:cardBackgroundColor="#FFF"
            card_view:cardCornerRadius="7dp"
            card_view:cardMaxElevation="5dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Facilities"
                android:textColor="@color/colorPrimary"
                android:textAllCaps="true"
                android:id="@+id/facilities"
                android:textSize="20dp"
                android:gravity="center"
                android:layout_below="@+id/viewPager"
                android:textColorHighlight="@color/colorPrimary"
                android:textStyle="bold|italic" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="50dp"
                android:orientation="horizontal"
                >
                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:paddingLeft="10dp"
                    android:textSize="15dp"
                    android:id="@+id/wifi"
                    />
                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:foregroundGravity="center"
                    android:textSize="15dp"
                    android:id="@+id/ac"
                    />
                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:foregroundGravity="right"
                    android:paddingLeft="20dp"
                    android:id="@+id/food"
                    android:textStyle="bold"
                    android:textSize="15dp"
                    />

            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/tools"
            android:id="@+id/cardview12"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            card_view:cardElevation="5dp"
            android:layout_below="@id/cardview1"
            android:layout_margin="6dp"
            card_view:cardBackgroundColor="#FFF"
            card_view:cardCornerRadius="7dp"
            card_view:cardMaxElevation="5dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Accomodation"
                    android:textColor="@color/colorPrimary"
                    android:textAllCaps="true"
                    android:textSize="20dp"
                    android:gravity="center"
                    android:textColorHighlight="@color/colorPrimary"
                    android:textStyle="bold|italic" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:layout_marginTop="2dp"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:foregroundGravity="center"
                    android:textSize="20dp"
                    android:id="@+id/accomodation"
                    />
            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/tools"
            android:id="@+id/cardview123"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            card_view:cardElevation="5dp"
            android:layout_below="@id/cardview12"
            android:layout_margin="6dp"
            card_view:cardBackgroundColor="#FFF"
            card_view:cardCornerRadius="7dp"
            card_view:cardMaxElevation="5dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Price"
                    android:textColor="@color/colorPrimary"
                    android:textAllCaps="true"
                    android:textSize="20dp"
                    android:gravity="center"
                    android:textColorHighlight="@color/colorPrimary"
                    android:textStyle="bold|italic" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:layout_marginTop="2dp"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:foregroundGravity="center"
                    android:textSize="20dp"
                    android:id="@+id/pricee"
                    />
            </LinearLayout>
        </android.support.v7.widget.CardView>
        <TextView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="200dp"
         android:id="@+id/name"
         android:textColor="#FFFFFF"
         android:textStyle="italic"
         android:textSize="20dp"
         android:layout_marginLeft="10dp"
         android:paddingLeft="20dp"

         />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/name"
            android:id="@+id/addr"
            android:textColor="#FFFFFF"
            android:textStyle="italic"
            android:layout_marginLeft="10dp"
            android:textSize="20dp"

           />
    </RelativeLayout>

</LinearLayout>
</code>```

答:
There needs to be only one layout inside ScrollView.

You do not need to put ScrollView inside ScrollView.
You have added the include tag inside the ScrollView and your
design.xml also has ScrollView.

I would not use android:fillViewport tag inside ScrollView, instead
use properties related to relative layout.

Rest of the things don't seem too difficult to figure out.

Body:
I have a screen in which there is a toolbar, a bottomNavigationView and some data between them including a textView and an imageView. I want to scroll the inner data that is between the toolbar and bottomNavigationView.

I want to scroll the design.xml inside of main.xml. Please suggest a way I can achieve this.

main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar1"
        android:layout_width="match_parent"
        app:layout_scrollFlags="scroll|enterAlways"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    xmlns:app="http://schemas.android.com/apk/res-auto">
<include
    layout="@layout/design"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</ScrollView>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:itemBackground="@color/colorPrimary"
    app:itemIconTint="#FFFFFF"
    app:itemTextColor="#FFFFFF"
    app:menu="@menu/bottom_navigation_main" />

design.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_marginTop="?android:attr/actionBarSize"
    tools:context="com.example.chaitanya.pg.Pgdata">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/relative">

        <Button
            android:id="@+id/btt1"
            android:background="@drawable/tprevoius"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="100dp" />

        <Button
            android:background="@drawable/tnext"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignTop="@+id/btt1"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:id="@+id/btt2" />
        <android.support.v4.view.ViewPager
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:id="@+id/viewPager"/>

        <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/tools"
            android:id="@+id/cardview1"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            card_view:cardElevation="5dp"
            android:layout_below="@id/viewPager"
            android:layout_margin="6dp"
            card_view:cardBackgroundColor="#FFF"
            card_view:cardCornerRadius="7dp"
            card_view:cardMaxElevation="5dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Facilities"
                android:textColor="@color/colorPrimary"
                android:textAllCaps="true"
                android:id="@+id/facilities"
                android:textSize="20dp"
                android:gravity="center"
                android:layout_below="@+id/viewPager"
                android:textColorHighlight="@color/colorPrimary"
                android:textStyle="bold|italic" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="50dp"
                android:orientation="horizontal"
                >
                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:paddingLeft="10dp"
                    android:textSize="15dp"
                    android:id="@+id/wifi"
                    />
                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:foregroundGravity="center"
                    android:textSize="15dp"
                    android:id="@+id/ac"
                    />
                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:foregroundGravity="right"
                    android:paddingLeft="20dp"
                    android:id="@+id/food"
                    android:textStyle="bold"
                    android:textSize="15dp"
                    />

            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/tools"
            android:id="@+id/cardview12"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            card_view:cardElevation="5dp"
            android:layout_below="@id/cardview1"
            android:layout_margin="6dp"
            card_view:cardBackgroundColor="#FFF"
            card_view:cardCornerRadius="7dp"
            card_view:cardMaxElevation="5dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Accomodation"
                    android:textColor="@color/colorPrimary"
                    android:textAllCaps="true"
                    android:textSize="20dp"
                    android:gravity="center"
                    android:textColorHighlight="@color/colorPrimary"
                    android:textStyle="bold|italic" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:layout_marginTop="2dp"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:foregroundGravity="center"
                    android:textSize="20dp"
                    android:id="@+id/accomodation"
                    />
            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/tools"
            android:id="@+id/cardview123"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            card_view:cardElevation="5dp"
            android:layout_below="@id/cardview12"
            android:layout_margin="6dp"
            card_view:cardBackgroundColor="#FFF"
            card_view:cardCornerRadius="7dp"
            card_view:cardMaxElevation="5dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Price"
                    android:textColor="@color/colorPrimary"
                    android:textAllCaps="true"
                    android:textSize="20dp"
                    android:gravity="center"
                    android:textColorHighlight="@color/colorPrimary"
                    android:textStyle="bold|italic" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:layout_marginTop="2dp"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:foregroundGravity="center"
                    android:textSize="20dp"
                    android:id="@+id/pricee"
                    />
            </LinearLayout>
        </android.support.v7.widget.CardView>
        <TextView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="200dp"
         android:id="@+id/name"
         android:textColor="#FFFFFF"
         android:textStyle="italic"
         android:textSize="20dp"
         android:layout_marginLeft="10dp"
         android:paddingLeft="20dp"

         />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/name"
            android:id="@+id/addr"
            android:textColor="#FFFFFF"
            android:textStyle="italic"
            android:layout_marginLeft="10dp"
            android:textSize="20dp"

           />
    </RelativeLayout>

</LinearLayout>


问:
Laravel session cookies with API token
We have a hybrid application for phone. Some pages are implemented in app and the other ones we show like web pages.
So i could say it's browser with several offline pages.

Login function are implemented in browser exactly. And at the same time user should be authorised in browser too.
So...The only logical solution for me it's to get token via API and then set session cookies in inner browser.

I think most secured way it's send post request inside browser with token. But is there any public function to "parse" this token?

Or other way - send api request to get cookies directly. There is also no function to get session cookies. Only for xsrf-token.

Or is there any way to use api token like session for regular routes?

答: You may give Laravel Passport a try. It's an official laravel package, you can see the details in their docs.

Title: Laravel session cookies with API token


问:
Laravel Eloquent events (attach, detach & sync)
I read about Eloquent events but didn't see any attach, detach or sync events there.

How to implement these Eloquent events?

答:
Taylor refuses to add this to laravel core, even many people need these events, see laravel PR about that https://github.com/laravel/framework/pull/14988

But here is a package which soles the problem :
https://github.com/fico7489/laravel-pivot

A package is well tested and well documented so many people started to use it.


问:
R: Fast multiply selected rows in data.frame (or other data structure)
I have an object of type data.frame like this, but much bigger:

```<code>> head(mydf)
   id1     id2   n
1    0 1032142   3
2    0 1072163   1
3    0  119323   2
</code>```

I need to print to a file columns a1 and a1, each of them n times. So that I could get a file like that:

```<code>0 1032142
0 1032142
0 1032142
0 1072163
0  119323
0  119323
</code>```

I tried the following solutions, but they make use of explicit for loops and are incredibly slow (it take few days to finish them with my data...):

```<code>for (j in 1:(nrow(mydf))) for (i in 1:(mydf[j,"n"])) write.table( mydf[j,c("id1","id2")], file="trials", append=T, row.names= F, col.names=F )
</code>```

The other tries to build a new data.frame with multiplied rows, but it is even slower to run.

```<code>towrite=data.frame(); for (j in 1:(nrow(mydf))) for (i in 1:(mydf[j,"n"])) towrite=rbind(towrite,mydf[j,c("id1","id2")])
</code>```

What is the simplest and fastest way of resolving this under R?

答:
Maybe you can try apply and sink. I am not sure if apply is actually faster than for-loops though (tapply and lapply definatly are).

```<code>mydat=data.frame(id1=0,id2=rnorm(5),n=sample(1:10,5))

mydat

sink("test.txt")
apply(mydat,1,function(x)cat(paste(rep(paste(x[1:2],collapse="\t"),x[3]),"\n" )))
sink()
</code>```

I know the code looks horrible

Body:
I have an object of type data.frame like this, but much bigger:

> head(mydf)
   id1     id2   n
1    0 1032142   3
2    0 1072163   1
3    0  119323   2

I need to print to a file columns a1 and a1, each of them n times. So that I could get a file like that:

0 1032142
0 1032142
0 1032142
0 1072163
0  119323
0  119323

I tried the following solutions, but they make use of explicit for loops and are incredibly slow (it take few days to finish them with my data...):

for (j in 1:(nrow(mydf))) for (i in 1:(mydf[j,"n"])) write.table( mydf[j,c("id1","id2")], file="trials", append=T, row.names= F, col.names=F )

The other tries to build a new data.frame with multiplied rows, but it is even slower to run.

towrite=data.frame(); for (j in 1:(nrow(mydf))) for (i in 1:(mydf[j,"n"])) towrite=rbind(towrite,mydf[j,c("id1","id2")])

What is the simplest and fastest way of resolving this under R?

Body:
Maybe you can try apply and sink. I am not sure if apply is actually faster than for-loops though (tapply and lapply definatly are).

mydat=data.frame(id1=0,id2=rnorm(5),n=sample(1:10,5))

mydat

sink("test.txt")
apply(mydat,1,function(x)cat(paste(rep(paste(x[1:2],collapse="\t"),x[3]),"\n" )))
sink()

I know the code looks horrible


问:
Passing an object to client in node/express + ejs?
I have a pretty large object that I need to pass to a function in a client script. I have tried using JSON.stringify, but have run into a few issues with this approach - mostly performance related. Is it possible to do something like this in ejs?

```<code>app.get('/load', function(req, res) {
    var data = {
        layout:'interview/load',
        locals: {
            interview: '',
            data: someLargeObj
        }
    };
    res.render('load', data);
});
</code>```

And in my client script, I would pass this object to a function like so

```<code><script type="text/javascript">
    load(<%- data %>); // load is a function in a client script
</script>
</code>```

When I try this I get either

```<code><script type="text/javascript">
    load();
</script>
</code>```

or

```<code><script type="text/javascript">
    load([Object object]);
</script>
</code>```

答:
If you are using templating, then it would be much better to get the values in the template, for example whether user is signed in or not. You can get the send local data using

```<code><script>
    window.user = <%- JSON.stringify(user || null) %>
</script>
</code>```

From the server side code, you are sending user data.

```<code>res.render('profile', {
    user: user.loggedin,
    title: "Title of page"
});
</code>```

Body:
I have a pretty large object that I need to pass to a function in a client script. I have tried using JSON.stringify, but have run into a few issues with this approach - mostly performance related. Is it possible to do something like this in ejs?

app.get('/load', function(req, res) {
    var data = {
        layout:'interview/load',
        locals: {
            interview: '',
            data: someLargeObj
        }
    };
    res.render('load', data);
});

And in my client script, I would pass this object to a function like so

When I try this I get either

or

Body:
If you are using templating, then it would be much better to get the values in the template, for example whether user is signed in or not. You can get the send local data using

<script>
    window.user = <%- JSON.stringify(user || null) %>
</script>

From the server side code, you are sending user data.

res.render('profile', {
    user: user.loggedin,
    title: "Title of page"
});


问:
Oracle Forms toolbar size
When creating a menu in Oracle Forms 6i, you can set a property for each menu option to be visible or not in the horizontal menu toolbar. You can also set the icon for the button on the toolbar and the text to display when hovering your mouse over it.

What I cannot find is the properties for the toolbar itself. It doesn´t seem to be possible to change the size, color or any other property for the toolbar.

I specifically want to change the size of the icons, since being an old tool, it was designed by default to work with 16x16 icons, but with current screen resolutions, the toolbar looks way to small.

Using larger icons doesn´t do the trick, since it just cuts the icon to 16 by 16.

Am I missing something? is it possible to adjust the toolbars properties?

答:
Adjusting the size of the toolbar is a new feature in Forms 12c. It is not available in earlier versions.

"do you have any source for this?"

I saw Michael Ferrante (the Forms Product Manager) talk at UKOUG on Monday. So straight from the horse's mouth :)  The Forms 12c New Features guide is here: page 12 is the page which will break your heart.

Title: Oracle Forms toolbar size


问:
Return value from overloaded operator Segmentation Fail
Got in header

```<code>DuzaLiczba operator>(const DuzaLiczba& right) const;
string& getData();
virtual ~DuzaLiczba();
private:
string& data;
</code>```

In my class overloaded operators return string in "\002\994\23923\"

```<code>return DuzaLiczba(wynik);
</code>```

In main

```<code>        cout << dl3.getData();
        cout.flush();
</code>```

cout.flush throws Segmentation fail.

Return in class is in ascii?
And heres problem. Got any advice?

答: You should not hold a reference in your class. You held a reference to a local variable, which was destructed and then accessed causing the segmentation fault. Also, operator> and operator< return bool normally.</p>

Body:
Got in header

DuzaLiczba operator>(const DuzaLiczba& right) const;
string& getData();
virtual ~DuzaLiczba();
private:
string& data;

In my class overloaded operators return string in "\002\994\23923\"

return DuzaLiczba(wynik);

In main

        cout << dl3.getData();
        cout.flush();

cout.flush throws Segmentation fail.

Return in class is in ascii?
And heres problem. Got any advice?


问:
Unwanted box shadow appearing on website and responsive break
I am currently updating/working on this web page "https://www.emergencydentalservice.com/emergency-dentist-by-city" and their is an unwanted box shadow appearing in the body that I can not determine from where or why. On top of the unwanted shadow the site also seems to break after 768px and I can't figure out why. Any help would be greatly appreciated, thank you all. Image of the site breaking after 768px</p>

答:
on

remove

```<code>background: url(/eds_siteIMGS/phoneBG_seperated.png) repeat-x;
</code>```

The image have shadow

Body:
on <div class="phone-wrap">

remove

background: url(/eds_siteIMGS/phoneBG_seperated.png) repeat-x;

The image have shadow


问:
apt-get remove not working ubuntu 16.04
I have a Ubuntu 16.04 install and need to remove cuda 9.0 so that I can install cuda 8.0. I have tried several commands like

sudo apt-get remove --purge cuda
sudo apt-get remove --purge cuda*
sudo apt-get remove --purge cuda-9-0

None of them work. Does anyone have any further suggestions?  Thank you in advance.

答:
Try this:

```<code>sudo apt-get remove "^cuda.*"
</code>```

This will remove cuda and all associated dependencies, and then you can install cuda version that you want.

Title: apt-get remove not working ubuntu 16.04

Body:
Try this:

sudo apt-get remove "^cuda.*"

This will remove cuda and all associated dependencies, and then you can install cuda version that you want.


问:
keras: Use one model output as another model input
I am adding a dense layer before InceptionResNetV2 model(pre-trained)
This is InceptionResNetV2 output

```<code>model_base = InceptionResNetV2(include_top=True, weights='imagenet')
x = model_base.get_layer('avg_pool').output
x = Dense(3, activation='softmax')(x)
</code>```

This is the layer will be added

```<code>input1 = Input(shape=input_shape1)
pre1 = Conv2D(filters=3, kernel_size=(5, 5), padding='SAME',
input_shape=input_shape1, name='first_dense')(input1)
pre = Model(inputs=input1, outputs=pre1)
</code>```

This is combining two models

```<code> after = Model(inputs=pre.output, outputs=x)

 model = Model(inputs=input1, outputs=after.output)

 model.compile(optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
</code>```

use

```<code>pre.output
</code>```

as

```<code>after.input
</code>```

But it doesn't works . How can I resolve it?

答:
First let's create a new model from model_base, because you want to get an earlier output.

Your code:

```<code>model_base = InceptionResNetV2(include_top=True, weights='imagenet')
x = model_base.get_layer('avg_pool').output
x = Dense(3, activation='softmax')(x)
</code>```

New model_base:

```<code>model_base = Model(model_base.input, x)
</code>```

Now, it's important to pass the output pre1 to this model:

```<code>base_out = model_base(pre1)
</code>```

That's it:

```<code>model = Model(input1, base_out)
</code>```

Body:
I am adding a dense layer before InceptionResNetV2 model(pre-trained)
This is InceptionResNetV2 output

model_base = InceptionResNetV2(include_top=True, weights='imagenet')
x = model_base.get_layer('avg_pool').output
x = Dense(3, activation='softmax')(x)

This is the layer will be added

input1 = Input(shape=input_shape1)
pre1 = Conv2D(filters=3, kernel_size=(5, 5), padding='SAME',
input_shape=input_shape1, name='first_dense')(input1)
pre = Model(inputs=input1, outputs=pre1)

This is combining two models

 after = Model(inputs=pre.output, outputs=x)

 model = Model(inputs=input1, outputs=after.output)

 model.compile(optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])

use

pre.output

as

after.input

But it doesn't works . How can I resolve it?

Body:
First let's create a new model from model_base, because you want to get an earlier output.

Your code:

model_base = InceptionResNetV2(include_top=True, weights='imagenet')
x = model_base.get_layer('avg_pool').output
x = Dense(3, activation='softmax')(x)

New model_base:

model_base = Model(model_base.input, x)

Now, it's important to pass the output pre1 to this model:

base_out = model_base(pre1)

That's it:

model = Model(input1, base_out)


问:
Phantomjs/CasperJs not rendering page so i can extract links
I am using casperjs with phantomjs on php to render webpage before extracting any links , in this way usually all links that are created by javascript are coming out and i can see them but not on this website:
centralcanadaclassics(.)com

here is JS for CasperJS that i am using:

```<code>var xpath = require('casper').selectXPath;
var casper = require('casper').create({
    pageSettings: {
    loadImages: false,
    webSecurityEnabled: false
    },
    verbose: true,
    logLevel: 'debug',
    colorizerType: 'Dummy'
});

casper.userAgent('casper');
casper.start().then(function() {
    this.open('http://www.centralcanadaclassics.com', {
        headers: {
            'Accept': 'text/html'
        }
     });
});
casper.then(function () {
    this.echo('[CURRENT_URL]' + this.getCurrentUrl());
    this.echo('[CURRENT_TITLE]' + this.getTitle());
    this.echo('[CURRENT_PAGE_CONTENT]' +
    this.getPageContent().replace(new RegExp('\r?\n','g'), ''));
    this.echo('[CURRENT_HTML]' + this.getHTML().replace(new RegExp('\r? \n','g'), ''));
    this.echo('[CURRENT_HEADERS]' +  JSON.stringify(this.currentResponse.headers));
    this.echo('[CURRENT_STATUS]' + this.currentResponse.status);
    this.echo('[CURRENT_STATUS_TEXT]' + this.currentResponse.statusText);
    this.echo('[CURRENT_COOKIES]' + JSON.stringify(phantom.cookies));
});
casper.run();
</code>```

So at the end all content stays the same , doesnt render that page.
Please explain why ?

答:
CasperJS is asynchronous.  You're dumping your data right as it's opening the page, so I'm going to go on a limb here and say that it's doing exactly what you are telling it do,  open a page, and while it's rendering that page (meaning before it completes) try to use the content.

If there is JS rendering (dynamic) of the page content, you'll need to implement a wait, either a hard-coded delay (very brittle) or identify a commonly rendered element and tell CapserJS to wait until it sees it, before doing any sort of link hunting.

Here is an example of what you might do using your own link parsing look which I'm going to call  'getLinks()';

```<code>// open the page
casper.thenOpen(url).then(function() {
    if (this.exists('#some-id')) {
        this.getLinks();   // this is your link hunting function
    }
});
</code>```

Or something like this

```<code>casper.wait(1000, function() {
    casper.then(function() {
        this.getLinks();   // this is your link hunting function
    });
});
</code>```

I think you're trying to use the content before it's rendered.

Body:
I am using casperjs with phantomjs on php to render webpage before extracting any links , in this way usually all links that are created by javascript are coming out and i can see them but not on this website:
centralcanadaclassics(.)com

here is JS for CasperJS that i am using:

var xpath = require('casper').selectXPath;
var casper = require('casper').create({
    pageSettings: {
    loadImages: false,
    webSecurityEnabled: false
    },
    verbose: true,
    logLevel: 'debug',
    colorizerType: 'Dummy'
});

casper.userAgent('casper');
casper.start().then(function() {
    this.open('http://www.centralcanadaclassics.com', {
        headers: {
            'Accept': 'text/html'
        }
     });
});
casper.then(function () {
    this.echo('[CURRENT_URL]' + this.getCurrentUrl());
    this.echo('[CURRENT_TITLE]' + this.getTitle());
    this.echo('[CURRENT_PAGE_CONTENT]' +
    this.getPageContent().replace(new RegExp('\r?\n','g'), ''));
    this.echo('[CURRENT_HTML]' + this.getHTML().replace(new RegExp('\r? \n','g'), ''));
    this.echo('[CURRENT_HEADERS]' +  JSON.stringify(this.currentResponse.headers));
    this.echo('[CURRENT_STATUS]' + this.currentResponse.status);
    this.echo('[CURRENT_STATUS_TEXT]' + this.currentResponse.statusText);
    this.echo('[CURRENT_COOKIES]' + JSON.stringify(phantom.cookies));
});
casper.run();

So at the end all content stays the same , doesnt render that page.
Please explain why ?

Body:
CasperJS is asynchronous.  You're dumping your data right as it's opening the page, so I'm going to go on a limb here and say that it's doing exactly what you are telling it do,  open a page, and while it's rendering that page (meaning before it completes) try to use the content.

If there is JS rendering (dynamic) of the page content, you'll need to implement a wait, either a hard-coded delay (very brittle) or identify a commonly rendered element and tell CapserJS to wait until it sees it, before doing any sort of link hunting.

Here is an example of what you might do using your own link parsing look which I'm going to call  'getLinks()';

// open the page
casper.thenOpen(url).then(function() {
    if (this.exists('#some-id')) {
        this.getLinks();   // this is your link hunting function
    }
});

Or something like this

casper.wait(1000, function() {
    casper.then(function() {
        this.getLinks();   // this is your link hunting function
    });
});

I think you're trying to use the content before it's rendered.


问:
How should I handle data files when testing with NUnit?
Say I have a file data.xml. I want to open this relative to my application, to start with just next to my exectuable using for example File.Open(data.xml). I added the file as an existing resource to my Visual Studio (2017) project and configured it to be copied to output directory on build. This works.

My issue is that I have a second project in my Solution containing my NUnit tests, referencing the main project. When this builds before I run my tests, this does not copy data.xml to the test binary directory and the test fails because it can't open the file (obviously).

How should I handle external files when doing unit tests? I would much prefer to not use absolute paths.

答:
I assume you mean that the data file is used by the app, not just by the tests.
When VS copies the app into your test output directory, it does not copy anything else, as you have seen.

There are several ways to go here...

Add a post-build step to your test project to copy the file from the app output directory to the test output directory. This will work but is messy to maintain. I don't recommend it.

Embed the resource in your app and change it to use the resource rather than an external file. Drawback is that it may require multiple changes in the app, depending on how you access the data. It won't work at all if the intent is that changing the file will immediately change the app's behavior without re-compiling it.

Change one or both apps to use a common output directory. That way, whenever the data changes it is copied and becomes available to all your tests. That's the way I generally like to handle the situation.


问:
If User sets Security setting in High mode from internet option. How to get Security mode in C# code?
In my web application I calling webmethods using javascript/Jquery in asp.net c# web application,
If User sets Security setting in High mode then no any javascript runs on client machine
it means Javascript goes disable.
All the web methods going stopped running & no action take place..

If User set in IE8.0 browser

```<code>Goto Tools,
-> internet option
-> security Tab
-> select Internet and set security mode to High
-> then It disabled Javascript.
</code>```

How we get security mode setting by user in C#?
If any alternate way to know that javascript is not enabled or change the mode!!
I want alert to if user set Internet security setting in high mode/Medium High mode..

-Thanks

Abhishek

答:
This is something you can only do at the client, typically by having a working site with script disabled, but enhancing the UI with script when available (perhaps replacing an anchor's click event with an AJAX call and cancel the default navigation).

You can also use  to remind the user that some features may be unavailable with their settings.

Body:
In my web application I calling webmethods using javascript/Jquery in asp.net c# web application,
If User sets Security setting in High mode then no any javascript runs on client machine
it means Javascript goes disable.
All the web methods going stopped running & no action take place..

If User set in IE8.0 browser

Goto Tools,
-> internet option
-> security Tab
-> select Internet and set security mode to High
-> then It disabled Javascript.

How we get security mode setting by user in C#?
If any alternate way to know that javascript is not enabled or change the mode!!
I want alert to if user set Internet security setting in high mode/Medium High mode..

-Thanks

Abhishek

Body:
This is something you can only do at the client, typically by having a working site with script disabled, but enhancing the UI with script when available (perhaps replacing an anchor's click event with an AJAX call and cancel the default navigation).

You can also use <noscript> to remind the user that some features may be unavailable with their settings.


问:
LEFT JOIN and WHERE with NULL values in the result
A simple query gives me user1's relationship with other users:

```<code>select u.id, u.name, ur.*
from users u
left join user_relationships ur
on ((ur.source_user_id = 1 and target_user_id = u.id) OR
    (ur.source_user_id = u.id and target_user_id = 1))
where u.id != 1
ORDER BY u.id;

+----+-------+----------+--------+------+
| id | name  | rel_from | rel_to | type |
+----+-------+----------+--------+------+
|  2 | beta  | 2        | 1      | 2    |
|  3 | gamma | 1        | 3      | 2    |
|  4 | delta | 4        | 1      | 1    |
|  5 | five  | NULL     | NULL   | NULL |
+----+-------+----------+--------+------+
</code>```

But I only want a list of users with whom the relationship type is not 2 ('delta' and 'five').

I tried some approaches.

```<code>-- Approach 1
-- -----------------------------
    where
    (u.id != 1) AND
    (ur.type != 2)
    -- gives 'delta', not 'five'

-- Approach 2
-- -----------------------------
left join user_relationships ur
on ((ur.source_user_id = 1 and target_user_id = u.id) OR
    (ur.source_user_id = u.id and target_user_id = 1)) AND
    (ur.type != 2)
where
    (u.id != 1)
ORDER BY u.id;
-- ur.* fields are NULL
-- (all rows, except for 'delta')

-- Approach 3
-- -----------------------------
where
    (u.id != 1) AND
    ((ur.type != 2) OR
    (ur.type IS NULL))
    -- this works, but why ?
</code>```

(A) Why Approaches 1,2 don't work, but 3 does ?

(B) Is there another (perhaps more elegant) way to achieve the same result ?

答:
Kaya,

When you work with possible null values should use the IS NULL comparative.

So your where could be:

```<code> where
    (u.id != 1) AND
    (ur.type != 2 OR ur.type IS NULL)
</code>```

Body:
A simple query gives me user1's relationship with other users:

select u.id, u.name, ur.*
from users u
left join user_relationships ur
on ((ur.source_user_id = 1 and target_user_id = u.id) OR
    (ur.source_user_id = u.id and target_user_id = 1))
where u.id != 1
ORDER BY u.id;

+----+-------+----------+--------+------+
| id | name  | rel_from | rel_to | type |
+----+-------+----------+--------+------+
|  2 | beta  | 2        | 1      | 2    |
|  3 | gamma | 1        | 3      | 2    |
|  4 | delta | 4        | 1      | 1    |
|  5 | five  | NULL     | NULL   | NULL |
+----+-------+----------+--------+------+

But I only want a list of users with whom the relationship type is not 2 ('delta' and 'five').

I tried some approaches.

-- Approach 1
-- -----------------------------
    where
    (u.id != 1) AND
    (ur.type != 2)
    -- gives 'delta', not 'five'

-- Approach 2
-- -----------------------------
left join user_relationships ur
on ((ur.source_user_id = 1 and target_user_id = u.id) OR
    (ur.source_user_id = u.id and target_user_id = 1)) AND
    (ur.type != 2)
where
    (u.id != 1)
ORDER BY u.id;
-- ur.* fields are NULL
-- (all rows, except for 'delta')

-- Approach 3
-- -----------------------------
where
    (u.id != 1) AND
    ((ur.type != 2) OR
    (ur.type IS NULL))
    -- this works, but why ?

(A) Why Approaches 1,2 don't work, but 3 does ?

(B) Is there another (perhaps more elegant) way to achieve the same result ?

Body:
Kaya,

When you work with possible null values should use the IS NULL comparative.

So your where could be:

 where
    (u.id != 1) AND
    (ur.type != 2 OR ur.type IS NULL)


问:
R, analyzing a data set with a large parameter space and replicates
I've run experiments whereby I use a parameter combination, collect the average forces and torques (in the x,y, and z directions). I do four replicates for each parameter combo, and I have 432 parameter combinations in total.

The actual dataset is a bit too big to include here, so I've made a subset for testing purposes and uploaded it to dropbox, along with the relevant R script.

Here is a heavily parsed version:

```<code>> data2[1:20,1:8]
# A tibble: 20 x 8
   `Foil Color` `Flow Speed (rpm)` `Frequency (Hz)` StepTime Maxpress Minpress `Minpress Percentage`      FxMean
         <fctr>             <fctr>           <fctr>   <fctr>   <fctr>    <int>            <fctr>       <dbl>
 1        Black                  0             0.25      250       50        0                 0 0.014537062
 2        Black                  0             0.25      250       50        0                 0 0.014870256
 3        Black                  0             0.25      250       50        0                 0 0.013180870
 4        Black                  0             0.25      250       50        0                 0 0.013448804
 5        Black                  0             0.25      250       50        3              0.05 0.012996979
 6        Black                  0             0.25      250       50        3              0.05 0.012115166
 7        Black                  0             0.25      250       50        3              0.05 0.012427347
 8        Black                  0             0.25      250       50        3              0.05 0.012561253
 9        Black                  0             0.25      250       50        5               0.1 0.012480644
10        Black                  0             0.25      250       50        5               0.1 0.011603403
11        Black                  0             0.25      250       50        5               0.1 0.011427116
12        Black                  0             0.25      250       50        5               0.1 0.011545803
13        Black                  0             0.25      250       50       13              0.25 0.009891865
14        Black                  0             0.25      250       50       13              0.25 0.008465604
15        Black                  0             0.25      250       50       13              0.25 0.009089619
16        Black                  0             0.25      250       50       13              0.25 0.008560160
17        Black                  0             0.25      250       75        0                 0 0.025101186
18        Black                  0             0.25      250       75        0                 0 0.023611920
19        Black                  0             0.25      250       75        0                 0 0.026276007
20        Black                  0             0.25      250       75        0                 0 0.026593895
</code>```

I am trying to group the data by the parameter combinations and calculate the average FxMean, sd, and se, for that group of 4 replicates.

I have tried to follow tutorials and other examples where people try to summarize the data (example), but it doesn't work for me. It normally spits out an array that looks nothing like what I need.

For example:

```<code>fx_data2 <- ddply(data_csv, c(data_csv$`Frequency (Hz)`,data_csv$`Flow Speed (rpm)`, data_csv$StepTime, data_csv$Maxpress, data_csv$`Minpress Percentage`), summarise,
N    = length(data_csv$FxMean),
mean = mean(data_csv$FxMean),
sd   = sd(data_csv$FxMean),
se   = sd / sqrt(N)
</code>```

)

```<code>fx_data3 <- summaryBy(FxMean ~freq + foilColor+maxP+minPP, data=data_csv, FUN=c(length, mean, sd))
</code>```

fx_data2 looks just...abyssmal.

```<code>head(fx_data2)
....
Foil Color.2530 Foil Color.2531 Foil Length.2512 Foil Length.2513 Foil
Length.2514 Foil Length.2515 Flow Speed (rpm).2544 Flow Speed (rpm).2545
Flow Speed (rpm).2546 Flow Speed (rpm).2547 Frequency (Hz).800 Frequency
(Hz).801 Frequency (Hz).802 Frequency (Hz).803 Foil Color.2532 Foil Color.2533
Foil Color.2534 Foil Color.2535 Foil Length.2516 Foil Length.2517 Foil
Length.2518 Foil Length.2519 Flow Speed (rpm).2548 Flow Speed (rpm).2549
Flow Speed (rpm).2550 Flow Speed (rpm).2551 Frequency (Hz).804 Frequency
(Hz).805 Frequency (Hz).806 Frequency (Hz).807 Foil Color.2536 Foil Color.2537
</code>```

I mean. I have no idea what's going on with that. The dimensions are 24x8724. Just...what.

and fx_data3 looks like this:

```<code>> fx_data3
  FxMean.length FxMean.mean  FxMean.sd
 1          1744  0.01379712 0.01423244
>
</code>```

Ideally, these would look like the original data set, but each parameter combination is compressed to a single line, and the values on the far right would be the mean, sd, and se for the FxMean, FxStDev, etc. for the four replicates.

I've been struggling with this for a few days. I'd greatly appreciate some help.

Thank you,
Zane

答:
Which parameters you want to group_by? Just insert them in the code snippet below in place of param1, param2 etc

You could use dplyr:

```<code>library(dplyr)

data %>%
  group_by(param1, param2, param3) %>%
  summarise(mean = mean(FxMean),
            sd = sd(FxMean),
            se = sd/n())
</code>```

Body:
I've run experiments whereby I use a parameter combination, collect the average forces and torques (in the x,y, and z directions). I do four replicates for each parameter combo, and I have 432 parameter combinations in total.

The actual dataset is a bit too big to include here, so I've made a subset for testing purposes and uploaded it to dropbox, along with the relevant R script.

Here is a heavily parsed version:

> data2[1:20,1:8]
# A tibble: 20 x 8
   `Foil Color` `Flow Speed (rpm)` `Frequency (Hz)` StepTime Maxpress Minpress `Minpress Percentage`      FxMean
         <fctr>             <fctr>           <fctr>   <fctr>   <fctr>    <int>            <fctr>       <dbl>
 1        Black                  0             0.25      250       50        0                 0 0.014537062
 2        Black                  0             0.25      250       50        0                 0 0.014870256
 3        Black                  0             0.25      250       50        0                 0 0.013180870
 4        Black                  0             0.25      250       50        0                 0 0.013448804
 5        Black                  0             0.25      250       50        3              0.05 0.012996979
 6        Black                  0             0.25      250       50        3              0.05 0.012115166
 7        Black                  0             0.25      250       50        3              0.05 0.012427347
 8        Black                  0             0.25      250       50        3              0.05 0.012561253
 9        Black                  0             0.25      250       50        5               0.1 0.012480644
10        Black                  0             0.25      250       50        5               0.1 0.011603403
11        Black                  0             0.25      250       50        5               0.1 0.011427116
12        Black                  0             0.25      250       50        5               0.1 0.011545803
13        Black                  0             0.25      250       50       13              0.25 0.009891865
14        Black                  0             0.25      250       50       13              0.25 0.008465604
15        Black                  0             0.25      250       50       13              0.25 0.009089619
16        Black                  0             0.25      250       50       13              0.25 0.008560160
17        Black                  0             0.25      250       75        0                 0 0.025101186
18        Black                  0             0.25      250       75        0                 0 0.023611920
19        Black                  0             0.25      250       75        0                 0 0.026276007
20        Black                  0             0.25      250       75        0                 0 0.026593895

I am trying to group the data by the parameter combinations and calculate the average FxMean, sd, and se, for that group of 4 replicates.

I have tried to follow tutorials and other examples where people try to summarize the data (example), but it doesn't work for me. It normally spits out an array that looks nothing like what I need.

For example:

fx_data2 <- ddply(data_csv, c(data_csv$`Frequency (Hz)`,data_csv$`Flow Speed (rpm)`, data_csv$StepTime, data_csv$Maxpress, data_csv$`Minpress Percentage`), summarise,
N    = length(data_csv$FxMean),
mean = mean(data_csv$FxMean),
sd   = sd(data_csv$FxMean),
se   = sd / sqrt(N)

)

fx_data3 <- summaryBy(FxMean ~freq + foilColor+maxP+minPP, data=data_csv, FUN=c(length, mean, sd))

fx_data2 looks just...abyssmal.

head(fx_data2)
....
Foil Color.2530 Foil Color.2531 Foil Length.2512 Foil Length.2513 Foil
Length.2514 Foil Length.2515 Flow Speed (rpm).2544 Flow Speed (rpm).2545
Flow Speed (rpm).2546 Flow Speed (rpm).2547 Frequency (Hz).800 Frequency
(Hz).801 Frequency (Hz).802 Frequency (Hz).803 Foil Color.2532 Foil Color.2533
Foil Color.2534 Foil Color.2535 Foil Length.2516 Foil Length.2517 Foil
Length.2518 Foil Length.2519 Flow Speed (rpm).2548 Flow Speed (rpm).2549
Flow Speed (rpm).2550 Flow Speed (rpm).2551 Frequency (Hz).804 Frequency
(Hz).805 Frequency (Hz).806 Frequency (Hz).807 Foil Color.2536 Foil Color.2537

I mean. I have no idea what's going on with that. The dimensions are 24x8724. Just...what.

and fx_data3 looks like this:

> fx_data3
  FxMean.length FxMean.mean  FxMean.sd
 1          1744  0.01379712 0.01423244
>

Ideally, these would look like the original data set, but each parameter combination is compressed to a single line, and the values on the far right would be the mean, sd, and se for the FxMean, FxStDev, etc. for the four replicates.

I've been struggling with this for a few days. I'd greatly appreciate some help.

Thank you,
Zane

Body:
Which parameters you want to group_by? Just insert them in the code snippet below in place of param1, param2 etc

You could use dplyr:

library(dplyr)

data %>%
  group_by(param1, param2, param3) %>%
  summarise(mean = mean(FxMean),
            sd = sd(FxMean),
            se = sd/n())


问:
boto3 add unix credentials, urllib2/3
Can we add the unix user credentials to SQS client?

Situation :
I have a user in Unix system (without 'sudo'/root privileges). And this Unix user's permissions does not allow me to connect to amazonaws.com.

Can I pass the username and password of this Unix user to boto3 client (SQS) ?

OR, can we pass boto3 client receive message object in urllib2/3?

What I already tried :

```<code>import boto3

# Create SQS client
sqs = boto3.client('sqs',region_name='eu-west-1')

queue_url='https://sqs.eu-west-1.amazonaws.com/XXXX'

# Receive message from SQS queue
response = sqs.receive_message(
    QueueUrl=queue_url,
    AttributeNames=[
        'SentTimestamp'
    ],
    MaxNumberOfMessages=10,
    MessageAttributeNames=[
        'All'
    ],
    VisibilityTimeout=0,
    WaitTimeSeconds=0
)
</code>```

I can access any URL using urllib2 to scrape it. And I am able to pass Unix credentials while doing it.

As a root user I am able to get messages from amazonSQS using boto3 as mentioned in the above code.

答:
No. Not possible. From your code, it looks like the credentials are stored under root user's directory which cannot be accessed by an user without sudo privileges. This is a Linux issue, nothing to do with Boto3.

Find a way to let the user access the aws credentials. Like a soft link with read permissions on the credentials file.

Title: boto3 add unix credentials, urllib2/3

Body:
Can we add the unix user credentials to SQS client?

Situation :
I have a user in Unix system (without 'sudo'/root privileges). And this Unix user's permissions does not allow me to connect to amazonaws.com.

Can I pass the username and password of this Unix user to boto3 client (SQS) ?

OR, can we pass boto3 client receive message object in urllib2/3?

What I already tried :

import boto3

# Create SQS client
sqs = boto3.client('sqs',region_name='eu-west-1')

queue_url='https://sqs.eu-west-1.amazonaws.com/XXXX'

# Receive message from SQS queue
response = sqs.receive_message(
    QueueUrl=queue_url,
    AttributeNames=[
        'SentTimestamp'
    ],
    MaxNumberOfMessages=10,
    MessageAttributeNames=[
        'All'
    ],
    VisibilityTimeout=0,
    WaitTimeSeconds=0
)

I can access any URL using urllib2 to scrape it. And I am able to pass Unix credentials while doing it.

As a root user I am able to get messages from amazonSQS using boto3 as mentioned in the above code.


问:
Ffmpeg gets aborted in an Electron sandboxed application
I have an Electron app, published on the Mac AppStore, and sandboxed.

I'm trying to add a new feature that will encode/decode videos on the fly so I can stream more video formats in an Electron context.

I'm using fluent-ffmpeg and a static exec of ffmpeg.

Everything works awesomely, I've uploaded the sandboxed app to Apple, and got rejected because ffmpeg is using by default a secure transport protocol which is using non-public API, this is what they've sent me with the rejection:

Your app uses or references the following non-public API(s):

'/System/Library/Frameworks/Security.framework/Versions/A/Security'

: SecIdentityCreate

Alright, after much investigation, it appears that I have to compile ffmpeg myself with a --disable-securetransport flag. Easy enough, I do it using the same config as the static build I've downloaded simply adding the new flag.

I manage to install every dependencies needed, except libxavs, no big deal I guess and simply remove its flag from the configure command:

```<code>./configure \
--cc=/usr/bin/clang \
--prefix=/opt/ffmpeg \
--extra-version=tessus \
--enable-avisynth \
--enable-fontconfig \
--enable-gpl \
--enable-libass \
--enable-libbluray \
--enable-libfreetype \
--enable-libgsm \
--enable-libmodplug \
--enable-libmp3lame \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopus \
--enable-libsnappy \
--enable-libsoxr \
--enable-libspeex \
--enable-libtheora \
--enable-libvidstab \
--enable-libvo-amrwbenc \
--enable-libvorbis \
--enable-libvpx \
--enable-libwavpack \
--enable-libx264 \
--enable-libx265 \
--enable-libxvid \
--enable-libzmq \
--enable-libzvbi \
--enable-version3 \
--pkg-config-flags=--static \
--disable-securetransport \
--disable-ffplay
</code>```

With the new ffmpeg exec, everything still works as expected. But once I'm packaging, signing and sandboxing the app, ffmpeg stops working as soon as I try to launch it throwing this error:

```<code>An error occurred ffmpeg was killed with signal SIGABRT Error: ffmpeg was killed with signal SIGABRT
    at ChildProcess.eval (webpack:///../node_modules/fluent-ffmpeg/lib/processor.js?:180:22)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
</code>```

I've tried to remove the --disable-securetransport flag, see if it could have messed with something, same result.

I've tried to compile on a Linux machine, just to see if it could help, same thing.

As soon as I'm using my custom compiled exec it doesn't work in the sandbox, but when using the static one, everything is ok (after I xattr it, because it's quarantined and blocked in sandbox).

The only thing I've noticed that seems odd is that my custom compilation is only 20mo or so, when the static install I've downloaded is 43mo.

I'm really stuck with this.

答:
So I finally was able to compile my static ffmpeg executable.

I've found my solution thanks to this answer.

Apparently, OSX has dynamic libraries located in /usr/local/bin which take precedence over everything else. So even if you try to compile your ffmpeg to be static, it won't work with these libraries on the way.

Once I've removed all those /usr/local/bin/*.dylib my build became fully static and worked perfectly in the sandbox.

Body:
I have an Electron app, published on the Mac AppStore, and sandboxed.

I'm trying to add a new feature that will encode/decode videos on the fly so I can stream more video formats in an Electron context.

I'm using fluent-ffmpeg and a static exec of ffmpeg.

Everything works awesomely, I've uploaded the sandboxed app to Apple, and got rejected because ffmpeg is using by default a secure transport protocol which is using non-public API, this is what they've sent me with the rejection:

Your app uses or references the following non-public API(s):

'/System/Library/Frameworks/Security.framework/Versions/A/Security'

: SecIdentityCreate

Alright, after much investigation, it appears that I have to compile ffmpeg myself with a --disable-securetransport flag. Easy enough, I do it using the same config as the static build I've downloaded simply adding the new flag.

I manage to install every dependencies needed, except libxavs, no big deal I guess and simply remove its flag from the configure command:

./configure \
--cc=/usr/bin/clang \
--prefix=/opt/ffmpeg \
--extra-version=tessus \
--enable-avisynth \
--enable-fontconfig \
--enable-gpl \
--enable-libass \
--enable-libbluray \
--enable-libfreetype \
--enable-libgsm \
--enable-libmodplug \
--enable-libmp3lame \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopus \
--enable-libsnappy \
--enable-libsoxr \
--enable-libspeex \
--enable-libtheora \
--enable-libvidstab \
--enable-libvo-amrwbenc \
--enable-libvorbis \
--enable-libvpx \
--enable-libwavpack \
--enable-libx264 \
--enable-libx265 \
--enable-libxvid \
--enable-libzmq \
--enable-libzvbi \
--enable-version3 \
--pkg-config-flags=--static \
--disable-securetransport \
--disable-ffplay

With the new ffmpeg exec, everything still works as expected. But once I'm packaging, signing and sandboxing the app, ffmpeg stops working as soon as I try to launch it throwing this error:

An error occurred ffmpeg was killed with signal SIGABRT Error: ffmpeg was killed with signal SIGABRT
    at ChildProcess.eval (webpack:///../node_modules/fluent-ffmpeg/lib/processor.js?:180:22)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

I've tried to remove the --disable-securetransport flag, see if it could have messed with something, same result.

I've tried to compile on a Linux machine, just to see if it could help, same thing.

As soon as I'm using my custom compiled exec it doesn't work in the sandbox, but when using the static one, everything is ok (after I xattr it, because it's quarantined and blocked in sandbox).

The only thing I've noticed that seems odd is that my custom compilation is only 20mo or so, when the static install I've downloaded is 43mo.

I'm really stuck with this.


问:
Automatically run a command or program when I'm away from keyboard?
Is there any way to run a program when I am away from keyboard after given timeout? For example, I want my torrent application to run automatically when I am away after 30 minutes. Was trying to find everywhere, but couldn't find any tool to do that.</p>

答:
On linux just use crontab. For Ubuntu it's explained here, but it will most likely apply to other linux distros too.

It's a bit more difficult under windows but this article describes it well.