问:
Recursively wrapping a regular expression with given text
For a given path, I wish to wrap a given regular expression in all files in that path or that path's sub-directories with some given text using standard Linux shell commands.

More specifically, wrap all my syslog commands with an assert command such as syslog(LOG_INFO,json_encode($obj)); becomes assert(syslog(LOG_INFO,json_encode($obj)));.

I thought the following might work, but received sed: -e expression #1, char 47: Invalid preceding regular expression error.

```<code>sed -i -E "s/(?<=syslog\()(.*)(?=\);)/assert(syslog(\1));/" /path/to/somewhere
</code>```

BACKUP INFO IN RESPONSE TO Wiktor Stribiżew's ANSWER

I've never used sed before.  Please confirm my understanding of your answer:

```<code>sed -i "s/syslog(\(.*\));/assert(syslog(\1));/g" /path/to/somewhere
</code>```

-i edit files in place.  One could first leave out to see on the screen what will be changed.

s   substitute text

The three /'s surrounding the pattern and replacement (i.e. /pattern/replacement/) are deliminator and can be any single character and not just /.

syslog(\(.*\));  The pattern with one placeholder.  Uses escaped parentheses.

assert(syslog(\1));  The replacement using escaped 1 (or 2, 3, etc) for replacement sub-strings.

g  Replace all and not just the first match.

Would sed -i "s/syslog(.*);/assert(&);/g" /path/to/somewhere work as well?

答:
sed patterns do not support lookarounds like (?<=...) and (?=...).

You may use a capturing group/replacement backreference:

```<code>sed -i "s/syslog(\(.*\));/assert(syslog(\1));/g" /path/to/somewhere
</code>```

The pattern is of BRE POSIX flavor (no -E option is passed), so to define a capturing group you need to use escaped parentheses, and unescaped ones will match literal parentheses.

Details

syslog( - syslog( substring

\(.*\) - Group 1: any 0+ chars as many as possible

); - a ); substring

The replacement is assert(syslog(\1));, that is, the match is replaced with assert(syslog(, the contents of Group 1, and then ));.

Body:
For a given path, I wish to wrap a given regular expression in all files in that path or that path's sub-directories with some given text using standard Linux shell commands.

More specifically, wrap all my syslog commands with an assert command such as syslog(LOG_INFO,json_encode($obj)); becomes assert(syslog(LOG_INFO,json_encode($obj)));.

I thought the following might work, but received sed: -e expression #1, char 47: Invalid preceding regular expression error.

sed -i -E "s/(?<=syslog\()(.*)(?=\);)/assert(syslog(\1));/" /path/to/somewhere

BACKUP INFO IN RESPONSE TO Wiktor Stribiżew's ANSWER

I've never used sed before.  Please confirm my understanding of your answer:

sed -i "s/syslog(\(.*\));/assert(syslog(\1));/g" /path/to/somewhere

-i edit files in place.  One could first leave out to see on the screen what will be changed.

s   substitute text

The three /'s surrounding the pattern and replacement (i.e. /pattern/replacement/) are deliminator and can be any single character and not just /.

syslog(\(.*\));  The pattern with one placeholder.  Uses escaped parentheses.

assert(syslog(\1));  The replacement using escaped 1 (or 2, 3, etc) for replacement sub-strings.

g  Replace all and not just the first match.

Would sed -i "s/syslog(.*);/assert(&);/g" /path/to/somewhere work as well?

Body:
sed patterns do not support lookarounds like (?<=...) and (?=...).

You may use a capturing group/replacement backreference:

sed -i "s/syslog(\(.*\));/assert(syslog(\1));/g" /path/to/somewhere

The pattern is of BRE POSIX flavor (no -E option is passed), so to define a capturing group you need to use escaped parentheses, and unescaped ones will match literal parentheses.

Details

syslog( - syslog( substring

\(.*\) - Group 1: any 0+ chars as many as possible

); - a ); substring

The replacement is assert(syslog(\1));, that is, the match is replaced with assert(syslog(, the contents of Group 1, and then ));.


来源: stackexchange

问:
What alternative do I have to a Left Join in this query?
I have this query that is used in a SSRS report that someone else created. The left join is the cause of the problem. If I change it to an inner join I get results (not the correct results) in about 15 seconds. With the Left Join I end up canceling the query after 20 minutes.  I added an index to both Budgets.Professionals and Transactions.Professionals with no change in performance. Is there a way to rewrite the query and not use the Left Join?</p>

```<code>SELECT
profs.ProfName as orig
,profs.Initials
,DATEPART(year, TransDate) as [Year]
,SUM(CASE WHEN IsFlatFee = 'Y'  OR COALESCE(MT.Admin, 'N') = 'Y'
    THEN 0.0
    ELSE Units * (aph.assignedpercent/100) * isnull(B.rate, 0.0)
    END) AS ctp
,SUM(CASE WHEN IsFlatFee = 'Y'  OR COALESCE(MT.Admin, 'N') = 'Y'
    THEN 0
    ELSE Units
    END * (aph.assignedpercent/100)) AS worked_hours
,SUM(Value * (aph.assignedpercent/100)) AS worked_value
, 0 AS billed_hours
,0 AS billed_value
,0 AS billed_netamt
, 0.0 as paid
, 0.0 as wo
FROM Transactions Trans
INNER JOIN Matters Matts ON Trans.matters  = Matts.matters
INNER JOIN MatterTypes MT ON Matts.mattertype  = MT.mattertypesdesc
and MT.Admin <> 'Y'
INNER JOIN Components Comps ON Comps.components  = Trans.components
and Comps.CompType = 'F'
INNER JOIN AssignedProfsHistory APH on APH.Matters = Trans.Matters
and APH.AssignedType = 'Originating'
and Trans.TransDate between APH.EffectiveDate and
ISNULL(EndDate,'12/31/2099')
INNER JOIN  Professionals profs on profs.Professionals  = APH.Professionals
    and profs.ProfType = 'Member'
    and profs.IsActive = 'Y'
    and profs.IsBillable = 'Y'
**LEFT join** (SELECT Budgets.Professionals as timekeeper, Budgets.Amount as
rate, Budgets.PeriodDate
FROM Matters Matts
INNER JOIN Budgets ON Matts.matters  = Budgets.matters
    and cast(Budgets.PeriodDate as Date) <= '2017-12-31'
    AND MONTH('2017-12-31') = MONTH(Budgets.PeriodDate)
WHERE Matts.MatterID  = '99999-99.003') as B
    *on B.timekeeper = Trans.Professionals*
    and YEAR(B.PeriodDate) = DATEPART(year, TransDate)
WHERE cast(transdate as DATE) between dateadd(day, 1, DATEADD(year, -3,
'2017-12-31')) and '2017-12-31'
GROUP BY profs.ProfName, profs.Initials, DATEPART(year, TransDate)
</code>```

答:
You can also try with the APPLY operator... remove left join & it's on condition, use  outer apply and include on conditions inside the outer apply script like

```<code>   AND budgets.timekeeper = trans.professionals
   AND year(budgets.perioddate) = datepart(year, transdate)
</code>```

Sample

```<code>OUTER APPLY
       (
                  SELECT     budgets.professionals AS timekeeper,
                             budgets.amount        AS rate,
                             budgets.perioddate
                  FROM       matters matts
                  INNER JOIN budgets
                  ON         matts.matters = budgets.matters
                  AND        cast(budgets.perioddate AS date) <= '2017-12-31'
                  AND        month('2017-12-31') = month(budgets.perioddate)
                  AND budgets.timekeeper = trans.professionals
                  AND year(budgets.perioddate) = datepart(year, transdate)
                  WHERE      matts.matterid = '99999-99.003'

                  ) AS b
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have this query that is used in a SSRS report that someone else created. The left join is the cause of the problem. If I change it to an inner join I get results (not the correct results) in about 15 seconds. With the Left Join I end up canceling the query after 20 minutes.  I added an index to both Budgets.Professionals and Transactions.Professionals with no change in performance. Is there a way to rewrite the query and not use the Left Join?

SELECT
profs.ProfName as orig
,profs.Initials
,DATEPART(year, TransDate) as [Year]
,SUM(CASE WHEN IsFlatFee = 'Y'  OR COALESCE(MT.Admin, 'N') = 'Y'
    THEN 0.0
    ELSE Units * (aph.assignedpercent/100) * isnull(B.rate, 0.0)
    END) AS ctp
,SUM(CASE WHEN IsFlatFee = 'Y'  OR COALESCE(MT.Admin, 'N') = 'Y'
    THEN 0
    ELSE Units
    END * (aph.assignedpercent/100)) AS worked_hours
,SUM(Value * (aph.assignedpercent/100)) AS worked_value
, 0 AS billed_hours
,0 AS billed_value
,0 AS billed_netamt
, 0.0 as paid
, 0.0 as wo
FROM Transactions Trans
INNER JOIN Matters Matts ON Trans.matters  = Matts.matters
INNER JOIN MatterTypes MT ON Matts.mattertype  = MT.mattertypesdesc
and MT.Admin <> 'Y'
INNER JOIN Components Comps ON Comps.components  = Trans.components
and Comps.CompType = 'F'
INNER JOIN AssignedProfsHistory APH on APH.Matters = Trans.Matters
and APH.AssignedType = 'Originating'
and Trans.TransDate between APH.EffectiveDate and
ISNULL(EndDate,'12/31/2099')
INNER JOIN  Professionals profs on profs.Professionals  = APH.Professionals
    and profs.ProfType = 'Member'
    and profs.IsActive = 'Y'
    and profs.IsBillable = 'Y'
**LEFT join** (SELECT Budgets.Professionals as timekeeper, Budgets.Amount as
rate, Budgets.PeriodDate
FROM Matters Matts
INNER JOIN Budgets ON Matts.matters  = Budgets.matters
    and cast(Budgets.PeriodDate as Date) <= '2017-12-31'
    AND MONTH('2017-12-31') = MONTH(Budgets.PeriodDate)
WHERE Matts.MatterID  = '99999-99.003') as B
    *on B.timekeeper = Trans.Professionals*
    and YEAR(B.PeriodDate) = DATEPART(year, TransDate)
WHERE cast(transdate as DATE) between dateadd(day, 1, DATEADD(year, -3,
'2017-12-31')) and '2017-12-31'
GROUP BY profs.ProfName, profs.Initials, DATEPART(year, TransDate)

Body:
You can also try with the APPLY operator... remove left join & it's on condition, use  outer apply and include on conditions inside the outer apply script like

   AND budgets.timekeeper = trans.professionals
   AND year(budgets.perioddate) = datepart(year, transdate)

Sample

OUTER APPLY
       (
                  SELECT     budgets.professionals AS timekeeper,
                             budgets.amount        AS rate,
                             budgets.perioddate
                  FROM       matters matts
                  INNER JOIN budgets
                  ON         matts.matters = budgets.matters
                  AND        cast(budgets.perioddate AS date) <= '2017-12-31'
                  AND        month('2017-12-31') = month(budgets.perioddate)
                  AND budgets.timekeeper = trans.professionals
                  AND year(budgets.perioddate) = datepart(year, transdate)
                  WHERE      matts.matterid = '99999-99.003'

                  ) AS b


问:
Declare array of lambdas in Java
I'd like to create an array of lambda. The problem is that the lambda could be different from each other. Example:

```<code>private interface I0 {
    int interface0(int a, int b);
}

private interface I1 {
    int interface1(double d);
}
</code>```

Now, how can I declare a list which can contain both I0 and I1?

```<code>List<Object> test = Arrays.asList(
        (int a, int b) -> a + b,
        (double d) -> d * 2
);
</code>```

Obviously Object does not work.

答:
You must assign the lambda expressions to variables of the functional interface types first.

Otherwise the compiler cannot infer the types of these lambda expressions.

```<code>I0 i0 = (int a, int b) -> a + b;
I1 i1 = (double d) -> (int) (d * 2);
List<Object> test = Arrays.asList(
    i0,
    i1
);
</code>```

That said, I'm not sure what's the point of storing these lambda expressions in a List<Object>. You can't use them without casting them back to the individual functional interface types.

Title: Declare array of lambdas in Java

Body:
I'd like to create an array of lambda. The problem is that the lambda could be different from each other. Example:

private interface I0 {
    int interface0(int a, int b);
}

private interface I1 {
    int interface1(double d);
}

Now, how can I declare a list which can contain both I0 and I1?

List<Object> test = Arrays.asList(
        (int a, int b) -> a + b,
        (double d) -> d * 2
);

Obviously Object does not work.

Body:
You must assign the lambda expressions to variables of the functional interface types first.

Otherwise the compiler cannot infer the types of these lambda expressions.

I0 i0 = (int a, int b) -> a + b;
I1 i1 = (double d) -> (int) (d * 2);
List<Object> test = Arrays.asList(
    i0,
    i1
);

That said, I'm not sure what's the point of storing these lambda expressions in a List<Object>. You can't use them without casting them back to the individual functional interface types.


问:
Delete multiple sheets at once
I have multiple sheets with data on each sheet. I want to delete sheets from sheet number 4 to unlimited. I have tried below code:

```<code>Sub Delete_Sheets()
    Application.ScreenUpdating = False
    Dim j As Integer
    j = Worksheets.Count
    For k = 4 To j
        With Sheets(k).Delete
        End With
    Next k
    Application.ScreenUpdating = True
End Sub
</code>```

The problem is, every time the code ask my permission to delete sheet and finally saw deletes only few sheets. Someone help.

答:
If you delete sheets indexed 4 onward always then maybe this will work for you.

```<code>Dim idx, s As String

Application.DisplayAlerts = False '/* of course you need to turn this off */

If Sheets.Count > 3 Then
    s = "=TRANSPOSE(ROW(A4:A" & Sheets.Count & "))"
    idx = Evaluate(s)
    Sheets(idx).Delete
End If

Application.DisplayAlerts = True
</code>```

This will always delete sheets in excess of 4.

But make sure that your sheets are always correctly indexed, otherwise use loop.

Title: Delete multiple sheets at once

Body:
I have multiple sheets with data on each sheet. I want to delete sheets from sheet number 4 to unlimited. I have tried below code:

Sub Delete_Sheets()
    Application.ScreenUpdating = False
    Dim j As Integer
    j = Worksheets.Count
    For k = 4 To j
        With Sheets(k).Delete
        End With
    Next k
    Application.ScreenUpdating = True
End Sub

The problem is, every time the code ask my permission to delete sheet and finally saw deletes only few sheets. Someone help.

Body:
If you delete sheets indexed 4 onward always then maybe this will work for you.

Dim idx, s As String

Application.DisplayAlerts = False '/* of course you need to turn this off */

If Sheets.Count > 3 Then
    s = "=TRANSPOSE(ROW(A4:A" & Sheets.Count & "))"
    idx = Evaluate(s)
    Sheets(idx).Delete
End If

Application.DisplayAlerts = True

This will always delete sheets in excess of 4.

But make sure that your sheets are always correctly indexed, otherwise use loop.


问:
How to add the Cover image of your iOS App in the App store

As, shown in the picture the picture a cover image of instagram app has displayed but on most of the app we have not seen this. So how can i add this kind of cover image in my app for app store

答:
Apple selects popular apps and allows them to add the Cover Photo and Themes. It isn't upto the developers.

From official confirmation on this:

Applications that have custom background art on the App Store are selected editorially by Apple. If your application is selected to be receive custom art, you will be contacted by an Apple representative.

ContentLicense: CC BY-SA 4.0


问:
Installing SSL on Apache - Syntax Error in openssl.cnf
I'm trying to learn how to get ssl up and running on an apache 2.4 webserver (Windows Server 2012). I had the web server and PHP up and running perfectly fine without SSL.

I Generated my cert and key and placed them in C:\Apache24\conf

I Modified httpd.conf in the following way:

```<code>LoadModule ssl_module modules/mod_ssl.so
Include C:/Apache24/conf/openssl.cnf
</code>```

I modified c:/Apache24/conf/extra/httpd-ssl.conf in the following way:

SSLCertificateFile "c:/Apache24/conf/server.crt"
  SSLCertificateKeyFile "c:/Apache24/conf/server.key"
  DocumentRoot "c:/Apache24/htdocs"

Added the following System Environment Variable

Variable Name: OPENSSL_CONF
  Variable Value: C:\Apache24\conf\openssl.cnf

I've hit a point where apache will not start due to the following error.

running httpd -t in powershell gives the result:

```<code>: Syntax error on line 8 of C:/Apache24/conf/openssl.cnf:
Invalid command 'HOME', perhaps misspelled or defined by a module not included in the server configuration
</code>```

The following are lines 6 through 9 of openssl.cnf ( I have not modified this file. )

```<code># This definition stops the following lines choking if HOME isn't
# defined.
HOME            = .
RANDFILE        = $ENV::HOME/.rnd
</code>```

Any help is appreciated.
Thanks !

答:
You are basically trying to include a third party config file inside httpd configuration, which will never yield a good result because Apache httpd will never recognize what's in there. Remove that include.

If you want to add system variables you can use PassEnv directive from mod_env module.

To get SSL up and running all you need is a SSL virtualhost like this:

In your server config something like:

```<code>LoadModule ssl_module modules/mod_ssl.so
<IfModule mod_ssl.c>
        Listen 443
        LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
        SSLProtocol all -SSLv3
        SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
        SSLHonorCipherOrder     on
        SSLCompression          off
        SSLSessionTickets       off
        SSLRandomSeed startup file:/dev/urandom 2048 # perhaps this need to be adapted for windows
        SSLRandomSeed connect file:/dev/urandom 2048 # same with this
        SSLSessionCache shmcb:/path/to/logs/ssl_gcache_data(512000)
</IfModule>
</code>```

And the Virtualhost:

```<code><Virtualhost *:443>
ServerName myssllvh.example.com
DocumentRoot /filesystem/path/to/docroot
CustomLog /path/to/logs/mysslvh.log combined
ErrorLog /path/to/logs/mysslvh-error.log

SSLEngine on
SSLCertificateFile /path/to/certs/mysslvh.crt
SSLCertificateKeyFile /path/to/certs/mysslvh.key

# Other stuff here
</VirtualHost>
</code>```

Body:
I'm trying to learn how to get ssl up and running on an apache 2.4 webserver (Windows Server 2012). I had the web server and PHP up and running perfectly fine without SSL.

I Generated my cert and key and placed them in C:\Apache24\conf

I Modified httpd.conf in the following way:

LoadModule ssl_module modules/mod_ssl.so
Include C:/Apache24/conf/openssl.cnf

I modified c:/Apache24/conf/extra/httpd-ssl.conf in the following way:

SSLCertificateFile "c:/Apache24/conf/server.crt"
  SSLCertificateKeyFile "c:/Apache24/conf/server.key"
  DocumentRoot "c:/Apache24/htdocs"

Added the following System Environment Variable

Variable Name: OPENSSL_CONF
  Variable Value: C:\Apache24\conf\openssl.cnf

I've hit a point where apache will not start due to the following error.

running httpd -t in powershell gives the result:

: Syntax error on line 8 of C:/Apache24/conf/openssl.cnf:
Invalid command 'HOME', perhaps misspelled or defined by a module not included in the server configuration

The following are lines 6 through 9 of openssl.cnf ( I have not modified this file. )

# This definition stops the following lines choking if HOME isn't
# defined.
HOME            = .
RANDFILE        = $ENV::HOME/.rnd

Any help is appreciated.
Thanks !

Body:
You are basically trying to include a third party config file inside httpd configuration, which will never yield a good result because Apache httpd will never recognize what's in there. Remove that include.

If you want to add system variables you can use PassEnv directive from mod_env module.

To get SSL up and running all you need is a SSL virtualhost like this:

In your server config something like:

LoadModule ssl_module modules/mod_ssl.so
<IfModule mod_ssl.c>
        Listen 443
        LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
        SSLProtocol all -SSLv3
        SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
        SSLHonorCipherOrder     on
        SSLCompression          off
        SSLSessionTickets       off
        SSLRandomSeed startup file:/dev/urandom 2048 # perhaps this need to be adapted for windows
        SSLRandomSeed connect file:/dev/urandom 2048 # same with this
        SSLSessionCache shmcb:/path/to/logs/ssl_gcache_data(512000)
</IfModule>

And the Virtualhost:

<Virtualhost *:443>
ServerName myssllvh.example.com
DocumentRoot /filesystem/path/to/docroot
CustomLog /path/to/logs/mysslvh.log combined
ErrorLog /path/to/logs/mysslvh-error.log

SSLEngine on
SSLCertificateFile /path/to/certs/mysslvh.crt
SSLCertificateKeyFile /path/to/certs/mysslvh.key

# Other stuff here
</VirtualHost>


问:
Programmatically displaying HTML element titles
Is there a javascript way to display or hide element title (defined as an html attribute), as if the mouse was hovering above said dom element, without actually involving the mouse?

Thanks in advance.

答: Not with native tooltips/titles. But there are jQuery plugins like this which let you cutomize and control them. </p>

ContentLicense: CC BY-SA 2.5


问:
JSON schema conditional dependency on value
I know there is a similar question here, but it didn't really address my issue. In short, I want one my fields to be dependent on the other field's value. But for some values, I don't want any field to be required. Here is an example:

Schema

```<code>{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {

    "colour": {
      "type": "string",
      "enum": ["red", "black", "blue"]
    },

    "blackQuote": {
      "type": "string",
      "maxLength": 11
    },

    "redQuote": {
      "type": "string",
      "maxLength": 11
    }
  },

  "oneOf": [
      {
        "properties": {
          "colour": {"enum": ["red"]}
        },
        "required": ["redQuote"]
      },
      {
        "properties": {
          "colour": {"enum": ["black"]}
        },
        "required": ["blackQuote"]
      }
  ],

  "required": [
    "colour"
  ]
}
</code>```

This works like this:

IF the colour is "red" THEN "redQuote" (but not "blackQuote") is required: this is fine

IF the colour is "black" THEN "blackQuote" (but not "redQuote") is required: this is also fine

BUT if I put the colour "blue" in my JSON, then the validator says that the properties "redQuote" and "blackQuote" are missing... I don't want that, I only want dependecies for "red" and "black", but if the colour is "blue" I don't want anything required. How to achieve this?

答:
If you move the specifics of what you want into the OneOf's then you can keep it all pretty simple, especially if you end up with a load of other values for color.

```<code>{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "oneOf": [
        {
            "type": "object",
            "properties": {
                "colour": {
                    "type": "string",
                    "enum": [
                        "red"
                    ]
                },
                "redQuote": {
                    "type": "string",
                    "maxLength": 11
                }
            },
            "required": [
                "redQuote"
            ]
        },
        {
            "type": "object",
            "properties": {
                "colour": {
                    "type": "string",
                    "enum": [
                        "black"
                    ]
                },
                "blackQuote": {
                    "type": "string",
                    "maxLength": 11
                }
            },
            "required": [
                "blackQuote"
            ]
        },
        {
            "type": "object",
            "properties": {
                "colour": {
                    "type": "string",
                    "enum": [
                        "blue"
                    ]
                }
            }
        }
    ],
    "definitions": {}
}
</code>```

Body:
I know there is a similar question here, but it didn't really address my issue. In short, I want one my fields to be dependent on the other field's value. But for some values, I don't want any field to be required. Here is an example:

Schema

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {

    "colour": {
      "type": "string",
      "enum": ["red", "black", "blue"]
    },

    "blackQuote": {
      "type": "string",
      "maxLength": 11
    },

    "redQuote": {
      "type": "string",
      "maxLength": 11
    }
  },

  "oneOf": [
      {
        "properties": {
          "colour": {"enum": ["red"]}
        },
        "required": ["redQuote"]
      },
      {
        "properties": {
          "colour": {"enum": ["black"]}
        },
        "required": ["blackQuote"]
      }
  ],

  "required": [
    "colour"
  ]
}

This works like this:

IF the colour is "red" THEN "redQuote" (but not "blackQuote") is required: this is fine

IF the colour is "black" THEN "blackQuote" (but not "redQuote") is required: this is also fine

BUT if I put the colour "blue" in my JSON, then the validator says that the properties "redQuote" and "blackQuote" are missing... I don't want that, I only want dependecies for "red" and "black", but if the colour is "blue" I don't want anything required. How to achieve this?

Body:
If you move the specifics of what you want into the OneOf's then you can keep it all pretty simple, especially if you end up with a load of other values for color.

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "oneOf": [
        {
            "type": "object",
            "properties": {
                "colour": {
                    "type": "string",
                    "enum": [
                        "red"
                    ]
                },
                "redQuote": {
                    "type": "string",
                    "maxLength": 11
                }
            },
            "required": [
                "redQuote"
            ]
        },
        {
            "type": "object",
            "properties": {
                "colour": {
                    "type": "string",
                    "enum": [
                        "black"
                    ]
                },
                "blackQuote": {
                    "type": "string",
                    "maxLength": 11
                }
            },
            "required": [
                "blackQuote"
            ]
        },
        {
            "type": "object",
            "properties": {
                "colour": {
                    "type": "string",
                    "enum": [
                        "blue"
                    ]
                }
            }
        }
    ],
    "definitions": {}
}


问:
Python: Non diagonal elements of a matrix to 0
What is the quickest way to convert the non-diagonal elements of a square symmetrical numpy ndarray to 0?</p>

Body:
Here is a solution that also works on non-contiguous arrays:

a = np.arange(110).reshape(10, 11)[:, :10]

diag = np.einsum('ii->i', a)
# or if a is not guaranteed to be square
# mn = min(a.shape)
# diag = np.einsum('ii->i', a[:mn, :mn])
save = diag.copy()
a[...] = 0
diag[...] = save

a

# array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
#        [  0,  12,   0,   0,   0,   0,   0,   0,   0,   0],
#        [  0,   0,  24,   0,   0,   0,   0,   0,   0,   0],
#        [  0,   0,   0,  36,   0,   0,   0,   0,   0,   0],
#        [  0,   0,   0,   0,  48,   0,   0,   0,   0,   0],
#        [  0,   0,   0,   0,   0,  60,   0,   0,   0,   0],
#        [  0,   0,   0,   0,   0,   0,  72,   0,   0,   0],
#        [  0,   0,   0,   0,   0,   0,   0,  84,   0,   0],
#        [  0,   0,   0,   0,   0,   0,   0,   0,  96,   0],
#        [  0,   0,   0,   0,   0,   0,   0,   0,   0, 108]])


问:
How to find out which Features of SQL Server installed on my machine
I know it has installed SQL Server 2017 Developer edition, but I need to find if I have all needed features for SSAS installed.

Basically I need to have this:

答:
The 2 options you are looking for are not anymore in the sql server installer.
These are optional packages you have to download. This mainly done because management studio and sql data tools have a seperate release schedule then SQL server.

data tools

SQl server Management studio


问:
Run tab from android studio bottom toolbar has disappeared
There used to be a Run tab in bottom toolbar of Android Studio. But the tab is not showing anymore. How to bring it back? Please check the below image to see where it was before it disappeared.

The Run tab used to be in the red circle before the TODO tab.

答:
For the latest version of Android Studio (4.0+) go to:

View > Appearance > Tool Window Bars

make sure Tool Window Bars is checked.

For older versions:

The following shortcut key doesn't work in Android studio 3.0:

Alt+4.

For anyone who accidentally hides the bottom toolbar due to some configuration etc go to:

View > Tool Buttons (make sure its checked)

This worked for me, the accepted answer only reveals the required view not all of them.

Just putting this in case someone stumbles to this question


答:
I would use an absolutely positioned DIV that looks like the native tooltip and contains the same text as an alternative. It should be fairly trivial to loop through all elements and create a DIV for each one that has a title attribute.

Very little hassle and no JavaScript plugins required.

Title: Programmatically displaying HTML element titles

Body:
Is there a javascript way to display or hide element title (defined as an html attribute), as if the mouse was hovering above said dom element, without actually involving the mouse?

Thanks in advance.


问:
Get max score and the fields in the max score row in MySQL 5.7
```<code>| id | uid  | score   | date    |
————————————————————————————————
| 1  | aaa  | 10      | 2017.7.7|

| 2  | bbb  | 5       | 2017.7.7|

| 3  | aaa  | 15      | 2017.7.7|

| 4  | bbb  | 20      | 2017.7.8|
</code>```

I want to get everyone’s max score and every row should include all fields like id and date.

```<code>| id | uid | score | date    |
—————————————————————————————
| 4  | bbb | 20    | 2017.7.8|

| 3  | aaa | 15    | 2017.7.7|
</code>```

Select max(score) as score, id, date, uid from data group by uid order by score desc

I can use this sql to get what I want in MySQL before v5.7 but you know after MySQL 5.7 there is a sql_mode ONLY_FULL_GROUP_BY. So I can’t get the result as before. I see there are some answers tell me to disable the mode. But I want to know if there are any sql can do this as well as I don’t disable the mode.

答:
Another approach to rewrite the same query by using left join without use of aggregate function

```<code>select a.*
from data a
left join data b on a.uid = b.uid
and a.score < b.score
where b.uid is null
</code>```

Note it may return multiple rows for single uid if there are rows with same highest score you might need a CASE statement and another attribute to decide which row should be picked to handle this kind of situation

Demo using MySQL 5.7.12

Body:
| id | uid  | score   | date    |
————————————————————————————————
| 1  | aaa  | 10      | 2017.7.7|

| 2  | bbb  | 5       | 2017.7.7|

| 3  | aaa  | 15      | 2017.7.7|

| 4  | bbb  | 20      | 2017.7.8|

I want to get everyone’s max score and every row should include all fields like id and date.

| id | uid | score | date    |
—————————————————————————————
| 4  | bbb | 20    | 2017.7.8|

| 3  | aaa | 15    | 2017.7.7|

Select max(score) as score, id, date, uid from data group by uid order by score desc

I can use this sql to get what I want in MySQL before v5.7 but you know after MySQL 5.7 there is a sql_mode ONLY_FULL_GROUP_BY. So I can’t get the result as before. I see there are some answers tell me to disable the mode. But I want to know if there are any sql can do this as well as I don’t disable the mode.

Body:
Another approach to rewrite the same query by using left join without use of aggregate function

select a.*
from data a
left join data b on a.uid = b.uid
and a.score < b.score
where b.uid is null

Note it may return multiple rows for single uid if there are rows with same highest score you might need a CASE statement and another attribute to decide which row should be picked to handle this kind of situation

Demo using MySQL 5.7.12


问:
Excel VBA - delete range of cells based on criteria
I want to delete a "row-range" of cells and shift them up, if one cell (column K8:Kxxxx) isn't "6-Other miscellaneous Cluster".

```<code>With wb2.Sheets("CALC")
    .Range("L8:L" & LastRow3).Formula = "=IF(G8="""","""",CONCATENATE(G8,""/"",VALUE(TEXT(I8,""00#""))))" 'REF'
End With

deleteIds = Array("OTIF", "2-Stock Availability on Non Stock item", "1-Not in full or rejected", "3-Stock Availability on Stock item", "4-Credit Release after MAD", "5-Actual PGI after planned PGI") ' Put your employee ids in here
For Each employeeId In Range(ActiveSheet.Range("K8"), ActiveSheet.Range("K8").End(xlDown))
   If Not (IsError(Application.Match(employeeId.Value, deleteIds, 0))) Then
       ActiveSheet.Range("G" & employeeId.Row).Value = ""
       ActiveSheet.Range("H" & employeeId.Row).Value = ""
       ActiveSheet.Range("I" & employeeId.Row).Value = ""
       ActiveSheet.Range("J" & employeeId.Row).Value = ""
       ActiveSheet.Range("K" & employeeId.Row).Value = ""
       ActiveSheet.Range("L" & employeeId.Row).Value = ""
   End If
Next

lastrow4 = Range("D:D").End(xlDown).Row
For i = lastrow4 To 1 Step -1
    If IsEmpty(Cells(i, "D").Value2) Then
        Cells(i, "G8:L50000").Delete Shift:=xlShiftUp
    End If
Next i

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

MsgBox "DONE!"
</code>```

This is just the part of the macro, where i tried to delete the cells that don't match the criteria. At the moment the macro looks for every possible value except "06-Other..." and clears the content of the cells in range G8:Lxxx. But I can't get it to delete and shift up the blank cells. Hopefully someone can solve my Problem.

答:
This will delete and shift up the cells in the 6 columns after the matched criteria. </p>

```<code>    With wb2.Sheets("CALC")
             .Range("L8:L" & LastRow3).Formula = "=IF(G8="""","""",CONCATENATE(G8,""/"",VALUE(TEXT(I8,""00#""))))" 'REF'
        End With

Dim lStartRow As Long
Dim lEndRow As Long
Dim lSearchColumn As Integer
Dim lRow As Long

lStartRow = 8
lSearchColumn = 11
lEndRow = ActiveSheet.Range("K8").End(xlDown)

For lRow = lEndRow To lStartRow Step -1

    If Not (IsError(Application.Match(Cells(lRow, lSearchColumn), deleteIds, 0))) Then

        Cells(lRow, lSearchColumn + 1).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 2).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 3).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 4).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 5).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 6).Delete shift: xlShiftUp

    End If

Next

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

MsgBox "DONE!"
</code>```

Body:
I want to delete a "row-range" of cells and shift them up, if one cell (column K8:Kxxxx) isn't "6-Other miscellaneous Cluster".

With wb2.Sheets("CALC")
    .Range("L8:L" & LastRow3).Formula = "=IF(G8="""","""",CONCATENATE(G8,""/"",VALUE(TEXT(I8,""00#""))))" 'REF'
End With

deleteIds = Array("OTIF", "2-Stock Availability on Non Stock item", "1-Not in full or rejected", "3-Stock Availability on Stock item", "4-Credit Release after MAD", "5-Actual PGI after planned PGI") ' Put your employee ids in here
For Each employeeId In Range(ActiveSheet.Range("K8"), ActiveSheet.Range("K8").End(xlDown))
   If Not (IsError(Application.Match(employeeId.Value, deleteIds, 0))) Then
       ActiveSheet.Range("G" & employeeId.Row).Value = ""
       ActiveSheet.Range("H" & employeeId.Row).Value = ""
       ActiveSheet.Range("I" & employeeId.Row).Value = ""
       ActiveSheet.Range("J" & employeeId.Row).Value = ""
       ActiveSheet.Range("K" & employeeId.Row).Value = ""
       ActiveSheet.Range("L" & employeeId.Row).Value = ""
   End If
Next

lastrow4 = Range("D:D").End(xlDown).Row
For i = lastrow4 To 1 Step -1
    If IsEmpty(Cells(i, "D").Value2) Then
        Cells(i, "G8:L50000").Delete Shift:=xlShiftUp
    End If
Next i

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

MsgBox "DONE!"

This is just the part of the macro, where i tried to delete the cells that don't match the criteria. At the moment the macro looks for every possible value except "06-Other..." and clears the content of the cells in range G8:Lxxx. But I can't get it to delete and shift up the blank cells. Hopefully someone can solve my Problem.

Body:
This will delete and shift up the cells in the 6 columns after the matched criteria.

    With wb2.Sheets("CALC")
             .Range("L8:L" & LastRow3).Formula = "=IF(G8="""","""",CONCATENATE(G8,""/"",VALUE(TEXT(I8,""00#""))))" 'REF'
        End With

Dim lStartRow As Long
Dim lEndRow As Long
Dim lSearchColumn As Integer
Dim lRow As Long

lStartRow = 8
lSearchColumn = 11
lEndRow = ActiveSheet.Range("K8").End(xlDown)

For lRow = lEndRow To lStartRow Step -1

    If Not (IsError(Application.Match(Cells(lRow, lSearchColumn), deleteIds, 0))) Then

        Cells(lRow, lSearchColumn + 1).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 2).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 3).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 4).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 5).Delete shift: xlShiftUp
        Cells(lRow, lSearchColumn + 6).Delete shift: xlShiftUp

    End If

Next

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

MsgBox "DONE!"


问:
ORM JSON request handling for dataset insert
I am trying to view the JSON request which is sent from POSTMAN through a POST request to add a security group info to a table, and my request looks like one below

```<code>POST /securitygroup HTTP/1.1
Host: localhost:9292
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: c4bef1db-d544-c923-3b0b-e7004e2dd093

{
  "securitygroup":{
    "secgrp_id": 124,
    "secgrp_nm": "SECURITY ADMIN",
    "secgrp_profile_nme": "ADMIN"
  }
}
</code>```

Roda code looks like below

```<code># cat config.ru
require "roda"
require "sequel"
require "oci8"
require "json"

DB = Sequel.oracle(host: 'xyz.dev.com', port: '1525', database: 'devbox1', user: 'abc', password: 'pass')

class App < Roda
  plugin :json, classes: [Array, Hash, Sequel::Model, Sequel::Dataset]

  route do |r|
    # secgroup = DB[:security_groups]
    # secgroup.insert(r.params["securitygroup"])
    # secgroup
    # above insert threw the following error
    # OCIError: ORA-00947: not enough values,
    # because SQL generated as below
    # INSERT INTO "SECURITYGROUPS" VALUES (NULL)
    # so I am trying to access the request object 'r', I feel that I am doing
    # something which is not correct

    {"response": r.params.["securitygroup"]["secgrp_id"]}
    # throws undefined method `[]' for nil:NilClass
  end
end
</code>```

Can you please take a look at the request and point me, where am I going wrong, Request format not correct or is there a different way to handle the request on the ruby code.

I need help to parse the request that comes in as JSON similar to code presented in https://twin.github.io/introduction-to-roda/

```<code>  r.post "albums" do
    album = Album.create(r.params["album"])
    r.redirect album_path(album) # /albums/1
  end
</code>```

答:
You need just a little tweak: Add to the App the plugin :json_parser.

```<code>class App < Roda
  # use this plugin to convert response to json
  plugin :json

  # use this plugin to convert request from json
  plugin :json_parser

  ...

end
</code>```

See in the Roda documentation "Plugins that Ship with Roda" in the group "others" there is the json_parser plugin.

Body:
I am trying to view the JSON request which is sent from POSTMAN through a POST request to add a security group info to a table, and my request looks like one below

POST /securitygroup HTTP/1.1
Host: localhost:9292
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: c4bef1db-d544-c923-3b0b-e7004e2dd093

{
  "securitygroup":{
    "secgrp_id": 124,
    "secgrp_nm": "SECURITY ADMIN",
    "secgrp_profile_nme": "ADMIN"
  }
}

Roda code looks like below

# cat config.ru
require "roda"
require "sequel"
require "oci8"
require "json"

DB = Sequel.oracle(host: 'xyz.dev.com', port: '1525', database: 'devbox1', user: 'abc', password: 'pass')

class App < Roda
  plugin :json, classes: [Array, Hash, Sequel::Model, Sequel::Dataset]

  route do |r|
    # secgroup = DB[:security_groups]
    # secgroup.insert(r.params["securitygroup"])
    # secgroup
    # above insert threw the following error
    # OCIError: ORA-00947: not enough values,
    # because SQL generated as below
    # INSERT INTO "SECURITYGROUPS" VALUES (NULL)
    # so I am trying to access the request object 'r', I feel that I am doing
    # something which is not correct

    {"response": r.params.["securitygroup"]["secgrp_id"]}
    # throws undefined method `[]' for nil:NilClass
  end
end

Can you please take a look at the request and point me, where am I going wrong, Request format not correct or is there a different way to handle the request on the ruby code.

I need help to parse the request that comes in as JSON similar to code presented in https://twin.github.io/introduction-to-roda/

  r.post "albums" do
    album = Album.create(r.params["album"])
    r.redirect album_path(album) # /albums/1
  end

Body:
You need just a little tweak: Add to the App the plugin :json_parser.

class App < Roda
  # use this plugin to convert response to json
  plugin :json

  # use this plugin to convert request from json
  plugin :json_parser

  ...

end

See in the Roda documentation "Plugins that Ship with Roda" in the group "others" there is the json_parser plugin.


问:
UWP app with ADAL auth fails when ADFS WIASupportedUserAgents property includes "Mozilla/5.0"
We have a UWP Xamarin Application using ADAL for authentication.

ADFS WIASupportedUserAgents property has been configured to include "Mozilla/5.0"

When the PC is on an external network, authentication works as expected.

When the PC is joined to domain, the browser window never gets to the ADFS login page.

I also have the following capabilities set in the Package.appxmanifest

privateNetworkClientServer

internetClientServer

enterpriseAuthentication

答:
Please refer to the app configuration steps described in https://github.com/Azure-Samples/active-directory-dotnet-windows-store. In particular, please make sure that you configured your redirect URI following the guidance in section "
Find the TodoListClient app's redirect URI".</p>


问:
Group by List using inner list
Below is my List collection.

```<code>public class A
{
    public String id{ get; set; }
    public string name{ get; set; }
    public List<B> nestedList { get; set; }
}
public class B
{
    public String innerid{ get; set; }
    public string innername { get; set; }
}
</code>```

I want to use group by on nested collection properties
So I can have output as

```<code>  innerid="1",
  innername="Name1",
    {
      id= "1", name= "One"
      id= "2", name= "Two"
      id= "4", name= "Four"
    }
  innerid="2",
  innername="Name2",
    {
      id= "3", name= "Three"
      id= "6", name= "Six"
      id= "8", name= "Eight"
    }
</code>```

I tried
.GroupBy(a => a.nestedList.First().innerid).ToList()
But I am not getting required output.

答:
Assuming the items from the result must contain items of type A, you could use query syntax to solve this:

```<code> var grouping = from a in collectionOfA
                from b in a.nestedList
                group a by new { b.innerid, b.innername } into g
                select new
                {
                    innerid = g.Key.innerid,
                    innername = g.Key.innername,
                    items = g.ToList()
                };
</code>```

Title: Group by List using inner list

Body:
Below is my List collection.

public class A
{
    public String id{ get; set; }
    public string name{ get; set; }
    public List nestedList { get; set; }
}
public class B
{
    public String innerid{ get; set; }
    public string innername { get; set; }
}

I want to use group by on nested collection properties
So I can have output as

  innerid="1",
  innername="Name1",
    {
      id= "1", name= "One"
      id= "2", name= "Two"
      id= "4", name= "Four"
    }
  innerid="2",
  innername="Name2",
    {
      id= "3", name= "Three"
      id= "6", name= "Six"
      id= "8", name= "Eight"
    }

I tried
.GroupBy(a => a.nestedList.First().innerid).ToList()
But I am not getting required output.

Body:
Assuming the items from the result must contain items of type A, you could use query syntax to solve this:

 var grouping = from a in collectionOfA
                from b in a.nestedList
                group a by new { b.innerid, b.innername } into g
                select new
                {
                    innerid = g.Key.innerid,
                    innername = g.Key.innername,
                    items = g.ToList()
                };


问:
Rails - Globalize and Permanent_record dependent: :destroy callbacks
In a Rails 4.2 project I use gem 'permanent_records' to handle records soft-deletion and gem 'globalize' for translations.

Globalize sets the following relationships between the translated Model and the Translation Model (source):

```<code>has_many :translations, :class_name  => translation_class.name,
                                :foreign_key => options[:foreign_key],
                                :dependent   => :destroy,
                                :extend      => HasManyExtensions,
                                :autosave    => true,
                                :inverse_of  => :globalized_model
</code>```

The result is that calling :destroy on the translated Model, does not delete it (which is what permanent_records is used for), but I lose the related translations, which I'd like to keep alive.

Shall I override the dependent: :destroy callback only on some translated models (the translated models where I use permanent_records)? How to do it properly?

Is there any other way to get the desired result?

答:
There many ways to handle it. I wouldn't recommend to override dependent: :destroy.

best way to handle it by using paranoia gem which is a re-implementation of acts_as_paranoid. This gem takes care of soft delete with dependent destroy option.
Refer: https://github.com/rubysherpas/paranoia

Override callback like this

```<code>def destroy
  run_callbacks :destroy do
    # your code here for destroy
  end
end
</code>```

Body:
In a Rails 4.2 project I use gem 'permanent_records' to handle records soft-deletion and gem 'globalize' for translations.

Globalize sets the following relationships between the translated Model and the Translation Model (source):

has_many :translations, :class_name  => translation_class.name,
                                :foreign_key => options[:foreign_key],
                                :dependent   => :destroy,
                                :extend      => HasManyExtensions,
                                :autosave    => true,
                                :inverse_of  => :globalized_model

The result is that calling :destroy on the translated Model, does not delete it (which is what permanent_records is used for), but I lose the related translations, which I'd like to keep alive.

Shall I override the dependent: :destroy callback only on some translated models (the translated models where I use permanent_records)? How to do it properly?

Is there any other way to get the desired result?

Body:
There many ways to handle it. I wouldn't recommend to override dependent: :destroy.

best way to handle it by using paranoia gem which is a re-implementation of acts_as_paranoid. This gem takes care of soft delete with dependent destroy option.
Refer: https://github.com/rubysherpas/paranoia

Override callback like this

def destroy
  run_callbacks :destroy do
    # your code here for destroy
  end
end


问:
Java: How can I compile an entire directory structure of code ?
The use case is simple. I got the source files that were created using Eclipse. So, there is a deep directory structure, where any Java class could be referring to another Java class in the same, child, sibling or parent folder.

How do I compile this whole thing from the terminal using javac ?

答:
You have to know all the directories, or be able to use wildcard ..</p>

```<code>javac dir1/*.java dir2/*.java dir3/dir4/*.java dir3/dir5/*.java dir6/*src/*.java
</code>```

Body:
You have to know all the directories, or be able to use wildcard ..

javac dir1/*.java dir2/*.java dir3/dir4/*.java dir3/dir5/*.java dir6/*src/*.java


问:
hovering over a tag, but not showing the menu
im trying to make a very simple menu here
basically i want to hover over the link and a menu show up.
but its not showing up!
i nested 2 tags inside of each other and gave em ids.
u can see the rest in code.

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

#amenu:hover #headermenu {
  display: block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav class="navbar">
  <ul id="Header">
    <li>
      aaaa
        <div id="headermenu">
          <ul>
            <li><a>menue yek</li>
          </ul>
        </div>
      </a>
    </li>
  </ul>
</nav></code>```

答:
Check your rendered html.

The Issue:

The behaviour you are observing is a result of the html not being processed in the manner in which you are expecting.

Most likely because you are trying to open another anchor link within an existing one, e.g: containing link nested link

What's occurring in your use-case is most likely what's occurring in the embedded code snippet below:

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

#amenu:hover #headermenu {
  display: block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav class="navbar">
  <ul id="Header">
    <li>
      aaaa
        <div id="headermenu">
          <ul>
            <li><a>menue yek</li>
          </ul>
        </div>
      </a>
    </li>
  </ul>
</nav></code>```

Rendered Output:

Visible in DOM

```<code><nav class="navbar">
  <ul id="Header">
    <li>
      <a id="amenu">aaaa
        </a><div id="headermenu"><a id="amenu">
          </a><ul><a id="amenu">
            </a><li><a id="amenu"></a><a>menue yek</a></li>
          </ul>
        </div>

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

You may notice that #headermenu is no longer a child of #amenu, so the following selectors #amenu:hover #headermenu fail as a result.

The Solution:

To rectify the above processing and formatting issues, consider making the dropdown element a sibling to the anchor link - and not nested within it. Then move your id selector to the containing list item itself (parent li), e.g:

```<code><nav class="navbar">
  <ul id="Header">
    <li id="amenu"> <!-- add id attribute to containing element -->
      <a>aaaa</a> <!-- close your anchor tag -->
      <!-- make the dropdown a sibling of the anchor tag  -->
      <div id="headermenu">
        <ul>
          <li><a>menue yek</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav>
</code>```

Code Snippet Demonstration:

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

#amenu:hover #headermenu {
  display: block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav class="navbar">
  <ul id="Header">
    <li id="amenu"> <!-- add id attribute to containing element -->
      <a>aaaa</a> <!-- close your anchor tag -->
      <!-- make the dropdown a sibling of the anchor tag  -->
      <div id="headermenu">
        <ul>
          <li><a>menue yek</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav></code>```

Alternatively:

You could keep the id attribute on the nested anchor tag and use the adjacent sibling combinator (+) instead.

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

/* use the adjacent sibling combinator (+) */
#amenu:hover + #headermenu {
  display: block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav class="navbar">
  <ul id="Header">
    <li>
      aaaa <!-- close your anchor tag -->
      <!-- make the dropdown a sibling of the anchor tag  -->
      <div id="headermenu">
        <ul>
          <li><a>menue yek</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav></code>```

More on CSS combinators

Body:
im trying to make a very simple menu here
basically i want to hover over the link and a menu show up.
but its not showing up!
i nested 2 tags inside of each other and gave em ids.
u can see the rest in code.

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

#amenu:hover #headermenu {
  display: block;
}

      aaaa

menue yek

Body:
Check your rendered html.

The Issue:

The behaviour you are observing is a result of the html not being processed in the manner in which you are expecting.

Most likely because you are trying to open another anchor link within an existing one, e.g: <a href="#">containing link <a href="#">nested link</a></a>

What's occurring in your use-case is most likely what's occurring in the embedded code snippet below:

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

#amenu:hover #headermenu {
  display: block;
}

<nav class="navbar">
  <ul id="Header">
    <li>
      <a id="amenu">aaaa
        <div id="headermenu">
          <ul>
            <li><a>menue yek</a></li>
          </ul>
        </div>
      </a>
    </li>
  </ul>
</nav>

Rendered Output:

Visible in DOM

<nav class="navbar">
  <ul id="Header">
    <li>
      <a id="amenu">aaaa
        </a><div id="headermenu"><a id="amenu">
          </a><ul><a id="amenu">
            </a><li><a id="amenu"></a><a>menue yek</a></li>
          </ul>
        </div>

    </li>
  </ul>
</nav>

You may notice that #headermenu is no longer a child of #amenu, so the following selectors #amenu:hover #headermenu fail as a result.

The Solution:

To rectify the above processing and formatting issues, consider making the dropdown element a sibling to the anchor link - and not nested within it. Then move your id selector to the containing list item itself (parent li), e.g:

<nav class="navbar">
  <ul id="Header">
    <li id="amenu"> <!-- add id attribute to containing element -->
      <a>aaaa</a> <!-- close your anchor tag -->
      <!-- make the dropdown a sibling of the anchor tag  -->
      <div id="headermenu">
        <ul>
          <li><a>menue yek</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav>

Code Snippet Demonstration:

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

#amenu:hover #headermenu {
  display: block;
}

<nav class="navbar">
  <ul id="Header">
    <li id="amenu"> <!-- add id attribute to containing element -->
      <a>aaaa</a> <!-- close your anchor tag -->
      <!-- make the dropdown a sibling of the anchor tag  -->
      <div id="headermenu">
        <ul>
          <li><a>menue yek</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav>

Alternatively:

You could keep the id attribute on the nested anchor tag and use the adjacent sibling combinator (+) instead.

.navbar {
  width: 100%;
  height: 30px;
  overflow: no-display;
}

#headermenu {
  display: none;
}

/* use the adjacent sibling combinator (+) */
#amenu:hover + #headermenu {
  display: block;
}

<nav class="navbar">
  <ul id="Header">
    <li>
      <a id="amenu">aaaa</a> <!-- close your anchor tag -->
      <!-- make the dropdown a sibling of the anchor tag  -->
      <div id="headermenu">
        <ul>
          <li><a>menue yek</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav>

More on CSS combinators


问:
Any tips for making Hive run faster on Hadoop?
I'm new to Hive and Hadoop. I have Hadoop configured for pseudo-distributed operation with one data node and one name node, all on localhost.

I have a trivial employee table containing 4 records. I can select the records in a reasonable amount of time, but anything beyond that takes really long. For example:

```<code>0: jdbc:hive2://localhost:10000> select * from emp;
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (0.643 seconds)
0: jdbc:hive2://localhost:10000> select * from emp order by empno;
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (225.852 seconds)
</code>```

What's it doing that's taking so long? Are there polling periods that I could reduce? I know that Hive isn't optimized for small tasks but this seems ridiculous.

Here's the various files:
hive-site.xml

```<code><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>hive.mapred.mode</name>
    <value>nostrict</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>org.apache.derby.jdbc.EmbeddedDriver</value>
  </property>
  <property>
    <name>hive.exec.local.scratchdir</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.downloaded.resources.dir</name>
    <value>/home/hadoop/tmp/${hive.session.id}_resources</value>
  </property>
  <property>
    <name>hive.querylog.location</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/home/hadoop/tmp/operation_logs</value>
  </property>
</configuration>
</code>```

hdfs.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>dfs.replication</name>
      <value>1</value>
   </property>
   <property>
      <name>dfs.name.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/namenode</value>
   </property>
   <property>
      <name>dfs.data.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/datanode</value>
   </property>
</configuration>
</code>```

core-site.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>fs.default.name</name>
      <value>hdfs://localhost:9000</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.groups</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.groups</name>
      <value>*</value>
   </property>
</configuration>
</code>```

mapred-site.xml

```<code><?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>mapreduce.framework.name</name>
      <value>yarn</value>
   </property>
</configuration>
</code>```

yarn-site.xml

```<code><?xml version="1.0"?>
<configuration>
   <property>
      <name>yarn.nodemanager.aux-services</name>
      <value>mapreduce_shuffle</value>
   </property>
</configuration>
</code>```

答:
Your hive is using Map Reduce for processing the data which is deprecated in Hive2 and also giving slow response so you have to set Tez or Spark as your hive execution engine which gives you faster result.

As per my experience I suggest You have to used Tez as execution engine for best performance. For setup Hive-Tez please flow this document.
https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.6.2/bk_command-line-installation/content/ref-d677ca50-0a14-4d9e-9882-b764e689f6db.1.html

Body:
I'm new to Hive and Hadoop. I have Hadoop configured for pseudo-distributed operation with one data node and one name node, all on localhost.

I have a trivial employee table containing 4 records. I can select the records in a reasonable amount of time, but anything beyond that takes really long. For example:

0: jdbc:hive2://localhost:10000> select * from emp;
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (0.643 seconds)
0: jdbc:hive2://localhost:10000> select * from emp order by empno;
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (225.852 seconds)

What's it doing that's taking so long? Are there polling periods that I could reduce? I know that Hive isn't optimized for small tasks but this seems ridiculous.

Here's the various files:
hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>hive.mapred.mode</name>
    <value>nostrict</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>org.apache.derby.jdbc.EmbeddedDriver</value>
  </property>
  <property>
    <name>hive.exec.local.scratchdir</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.downloaded.resources.dir</name>
    <value>/home/hadoop/tmp/${hive.session.id}_resources</value>
  </property>
  <property>
    <name>hive.querylog.location</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/home/hadoop/tmp/operation_logs</value>
  </property>
</configuration>

hdfs.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>dfs.replication</name>
      <value>1</value>
   </property>
   <property>
      <name>dfs.name.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/namenode</value>
   </property>
   <property>
      <name>dfs.data.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/datanode</value>
   </property>
</configuration>

core-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>fs.default.name</name>
      <value>hdfs://localhost:9000</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.groups</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.groups</name>
      <value>*</value>
   </property>
</configuration>

mapred-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>mapreduce.framework.name</name>
      <value>yarn</value>
   </property>
</configuration>

yarn-site.xml

<?xml version="1.0"?>
<configuration>
   <property>
      <name>yarn.nodemanager.aux-services</name>
      <value>mapreduce_shuffle</value>
   </property>
</configuration>


问:
How do I connect a row with one another and order them alphabetically?
Please see the image first.

{image: https://i.hizliresim.com/8NRGrV.png}

I want to connect the rows TR and EN, so like yatırım >> invesment and I want them to go together wherever I put them and after that I want to list them alphabetically, just like dictionary. Is it possible? Thank you.

答: is this what you mean? What is it exactly what you want?</p>


问:
Angular Slider code not changing slides
I am using a bootstrap slider using the HTML code and CSS.
BUt the slides are not changing automatically or manually.
below is the code of slider.

(function( $ ) {

    //Function to animate slider captions
    function doAnimations( elems ) {
        //Cache the animationend event in a variable
        var animEndEv = 'webkitAnimationEnd animationend';

        elems.each(function () {
            var $this = $(this),
                $animationType = $this.data('animation');
            $this.addClass($animationType).one(animEndEv, function () {
                $this.removeClass($animationType);
            });
        });
    }

    //Variables on page load
    var $myCarousel = $('#carousel-example-generic'),
        $firstAnimatingElems = $myCarousel.find('.item:first').find("[data-animation ^= 'animated']");

    //Initialize carousel
    $myCarousel.carousel();

    //Animate captions in first slide on page load
    doAnimations($firstAnimatingElems);

    //Pause carousel
    $myCarousel.carousel('pause');

    //Other slides to be animated on carousel slide event
    $myCarousel.on('slide.bs.carousel', function (e) {
        var $animatingElems = $(e.relatedTarget).find("[data-animation ^= 'animated']");
        doAnimations($animatingElems);
    });
    $('#carousel-example-generic').carousel({
        interval:3000,
        pause: "false"
    });

})(jQuery);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/animate.css/3.5.1/animate.min.css">

<div id="first-slider">
  <div id="carousel-example-generic" class="carousel slide carousel-fade">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
      <li data-target="#carousel-example-generic" data-slide-to="1"></li>
      <li data-target="#carousel-example-generic" data-slide-to="2"></li>
      <li data-target="#carousel-example-generic" data-slide-to="3"></li>
    </ol>
    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
      <!-- Item 1 -->
      <div class="item active slide1">
        <div class="row">
          <div class="container">
            <div class="col-md-3 text-right">
              <img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/pfmmo6qj1/window_domain.png">
            </div>
            <div class="col-md-9 text-left">
              <h3 data-animation="animated bounceInDown">Add images, or even your logo!</h3>
              <h4 data-animation="animated bounceInUp">Easily use stunning effects</h4>
            </div>
          </div>
        </div>
      </div>
      <!-- Item 2 -->
      <div class="item slide2">
        <div class="row">
          <div class="container">
            <div class="col-md-7 text-left">
              <h3 data-animation="animated bounceInDown"> 50 animation options A beautiful</h3>
              <h4 data-animation="animated bounceInUp">Create beautiful slideshows </h4>
            </div>
            <div class="col-md-5 text-right">
              <img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/sp11uneml/rack_server_unlock.png">
            </div>
          </div>
        </div>
      </div>
      <!-- Item 3 -->
      <div class="item slide3">
        <div class="row">
          <div class="container">
            <div class="col-md-7 text-left">
              <h3 data-animation="animated bounceInDown">Simple Bootstrap Carousel</h3>
              <h4 data-animation="animated bounceInUp">Bootstrap Image Carousel Slider with Animate.css</h4>
            </div>
            <div class="col-md-5 text-right">
              <img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/eq8xvxeq5/globe_network.png">
            </div>
          </div>
        </div>
      </div>
      <!-- Item 4 -->
      <div class="item slide4">
        <div class="row">
          <div class="container">
            <div class="col-md-7 text-left">
              <h3 data-animation="animated bounceInDown">We are creative</h3>
              <h4 data-animation="animated bounceInUp">Get start your next awesome project</h4>
            </div>
            <div class="col-md-5 text-right">
              <img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/9vf8xngel/internet_speed.png">
            </div>
          </div>
        </div>
      </div>
      <!-- End Item 4 -->

    </div>
    <!-- End Wrapper for slides-->

      <i class="fa fa-angle-left"></i>
      <span class="sr-only">Previous</span>

      <i class="fa fa-angle-right"></i>
      <span class="sr-only">Next</span>

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

答:
```<code><!doctype html>
<html ng-app="plunker" >

 <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"> </script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"> </script>
    <script src="app.js"></script>

    <!-- adding  css files -->
    <link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">

  </head>
  <body>
           <div class="container" ng-controller="CarouselCtrl">
                <div class="offsetspan6">
                     <carousel interval="myInterval">
                          <slide ng-repeat="slide in slides" active="slide.active">
                                <img class="image-circle" ng-src="{{slide.image}}"    style="margin:auto;"/>
                         <div class="carousel-caption">
                             <h4>Slide {{$index}}</h4>
                             <p>{{slide.text}}</p>
                       </div>
                       </slide>
                </carousel>
          </div>
     </div>
  </div>
  </body>
<script type="text/javascript">
  //angular.module('myApp', ['ui.bootstrap']);
var app = angular.module('plunker', ['ui.bootstrap']);

// Controller  for Carousel
function CarouselCtrl($scope) {

// initializing the time Interval
  $scope.myInterval = 1000;

 // Initializing  slide rray
$scope.slides = [
{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Platy%20PIX/Xiphophorus%20maculatusAQ%20Neon%20female.jpg',text:'Cute Fish'},

{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Platy%20PIX/Xiphophorus%20maculatusAQ%20Neon%20female.jpg',text:'Image2'},
{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Swordtail%20PIX/Xiphophorus%20helleriAQ%20Hifin%20Black%20males.jpg',text:'Image3'},
{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Platy%20PIX/Xiphophorus%20maculatusAQ%20Neon%20female.jpg',text:'Image4'}
                      ];

  var slides = $scope.slides;
  console.log(slides);

} // Controller Ends here
</script>
</html>
</code>```

Title: Angular Slider code not changing slides

Body:
I am using a bootstrap slider using the HTML code and CSS.
BUt the slides are not changing automatically or manually.
below is the code of slider.

(function( $ ) {

    //Function to animate slider captions
    function doAnimations( elems ) {
        //Cache the animationend event in a variable
        var animEndEv = 'webkitAnimationEnd animationend';

        elems.each(function () {
            var $this = $(this),
                $animationType = $this.data('animation');
            $this.addClass($animationType).one(animEndEv, function () {
                $this.removeClass($animationType);
            });
        });
    }

    //Variables on page load
    var $myCarousel = $('#carousel-example-generic'),
        $firstAnimatingElems = $myCarousel.find('.item:first').find("[data-animation ^= 'animated']");

    //Initialize carousel
    $myCarousel.carousel();

    //Animate captions in first slide on page load
    doAnimations($firstAnimatingElems);

    //Pause carousel
    $myCarousel.carousel('pause');

    //Other slides to be animated on carousel slide event
    $myCarousel.on('slide.bs.carousel', function (e) {
        var $animatingElems = $(e.relatedTarget).find("[data-animation ^= 'animated']");
        doAnimations($animatingElems);
    });
    $('#carousel-example-generic').carousel({
        interval:3000,
        pause: "false"
    });

})(jQuery);

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/animate.css/3.5.1/animate.min.css">

Add images, or even your logo!

Easily use stunning effects

 50 animation options A beautiful

Create beautiful slideshows

Simple Bootstrap Carousel

Bootstrap Image Carousel Slider with Animate.css

We are creative

Get start your next awesome project

      Previous

      Next


问:
ASP.Net JSON configuration file transforms with arrays
I have a base configuration file eg.

appsettings.json

```<code>{
    "Values": {
        "Test": ["one", "two"]
    }
}
</code>```

and

appsettings.dev.json

```<code>{
    "Values": {
        "Test": ["three"]
    }
}
</code>```

and after transforming, the array would be

```<code>["three", "two"]
</code>```

How do I make sure the transformed array is shrunk to a smaller number of elements rather than each element changing individually?

答:
I recommend use appsettings.Development.json and appsettings.Production.json to separate environments. And keep common settings in appsettings.json for both environments.

Just rename your appsettings.dev.json to appsettings.Development.json. Add Stage or Prodaction mode of appsettings.{#mode}.json. And modify ConfigurationBuilder in Startup.cs.

```<code>.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
</code>```

I think it's more common practice and could save your time from unnecessary logic of merging

Body:
I have a base configuration file eg.

appsettings.json

{
    "Values": {
        "Test": ["one", "two"]
    }
}

and

appsettings.dev.json

{
    "Values": {
        "Test": ["three"]
    }
}

and after transforming, the array would be

["three", "two"]

How do I make sure the transformed array is shrunk to a smaller number of elements rather than each element changing individually?

Body:
I recommend use appsettings.Development.json and appsettings.Production.json to separate environments. And keep common settings in appsettings.json for both environments.

Just rename your appsettings.dev.json to appsettings.Development.json. Add Stage or Prodaction mode of appsettings.{#mode}.json. And modify ConfigurationBuilder in Startup.cs.

.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)

I think it's more common practice and could save your time from unnecessary logic of merging


问:
JMeter extract link using regular expression pass into next request with blank values
This is how I have Test Plan set up:

HTTP Request -> Regular Expression Extractor to extract multiple links  - This is extracting correctly -- But some of the links are Blank
RegularExpressionExtractor ---

BeanShell Sampler - to filter blank or null values -- This works fine

BeanShell Sampler

```<code>log.info("Enter Beanshell Sampler");
matches = vars.get("url_matchNr");
log.info(matches);

for (Integer i=1; i < Integer.parseInt(matches); i++)
{
    String url = vars.get("url_"+i);
    //log.info(url1);
    if(url != null @and url.length() > 0)
    {
        log.info(i+"->" + url);
        //return url;
        //vars.put("url2", url);
        vars.put("url2", url);
        //props.put("url2", url);
        log.info("URL2:" + vars.get("url2"));
    }
}
</code>```

ForEach Controller
ForEach Controller

href="https://i.stack.imgur.com/Knomw.png" rel="nofollow noreferrer">Test Plan

The problem I am facing is ForEach Controller runs through all the values including Blank or NULL -- How can I run the loop only for the non null blank values

答:
ForEach controller doesn't work with JMeter Properties, you need to change the "Input Variable Prefix" to url_2 and your test should start working as expected.

Also be aware that since JMeter 3.1 it is recommended to use Groovy language for any form of scripting so consider migrating to JSR223 Sampler and Groovy language on next available opportunity.

Groovy has much better performance while Beanshell might become a bottleneck when it comes to immense loads.

Body:
This is how I have Test Plan set up:

HTTP Request -> Regular Expression Extractor to extract multiple links  - This is extracting correctly -- But some of the links are Blank
RegularExpressionExtractor ---

BeanShell Sampler - to filter blank or null values -- This works fine

BeanShell Sampler

log.info("Enter Beanshell Sampler");
matches = vars.get("url_matchNr");
log.info(matches);

for (Integer i=1; i < Integer.parseInt(matches); i++)
{
    String url = vars.get("url_"+i);
    //log.info(url1);
    if(url != null @and url.length() > 0)
    {
        log.info(i+"->" + url);
        //return url;
        //vars.put("url2", url);
        vars.put("url2", url);
        //props.put("url2", url);
        log.info("URL2:" + vars.get("url2"));
    }
}

ForEach Controller
ForEach Controller

Test Plan

The problem I am facing is ForEach Controller runs through all the values including Blank or NULL -- How can I run the loop only for the non null blank values


问:
Shuffling input files with tensorflow Datasets
With the old input-pipeline API I can do:

```<code>filename_queue = tf.train.string_input_producer(filenames, shuffle=True)
</code>```

and then pass the filenames to other queue, for example:

```<code>reader = tf.TFRecordReader()
_, serialized_example = reader.read_up_to(filename_queue, n)
</code>```

How can I achieve similar behaviour with the Dataset -API?

The tf.data.TFRecordDataset() expects tensor of file-names in fixed order.

答:
Start reading them in order, shuffle right after:

```<code>BUFFER_SIZE = 1000 # arbitrary number
# define filenames somewhere, e.g. via glob
dataset = tf.data.TFRecordDataset(filenames).shuffle(BUFFER_SIZE)
</code>```

EDIT:

The input pipeline of this question gave me an idea on how to implement filenames shuffling with the Dataset API:

```<code>dataset = tf.data.Dataset.from_tensor_slices(filenames)
dataset = dataset.shuffle(BUFFER_SIZE) # doesn't need to be big
dataset = dataset.flat_map(tf.data.TFRecordDataset)
dataset = dataset.map(decode_example, num_parallel_calls=5) # add your decoding logic here
# further processing of the dataset
</code>```

This will put all the data of one file before the one of the next and so on. Files are shuffled, but the data inside them will be produced in the same order.
You can alternatively replace dataset.flat_map with interleave to process multiple files at the same time and return samples from each:

```<code>dataset = dataset.interleave(tf.data.TFRecordDataset, cycle_length=4)
</code>```

Note: interleave does not actually run in multiple threads, it's a round-robin operation. For true parallel processing see parallel_interleave

Body:
With the old input-pipeline API I can do:

filename_queue = tf.train.string_input_producer(filenames, shuffle=True)

and then pass the filenames to other queue, for example:

reader = tf.TFRecordReader()
_, serialized_example = reader.read_up_to(filename_queue, n)

How can I achieve similar behaviour with the Dataset -API?

The tf.data.TFRecordDataset() expects tensor of file-names in fixed order.

Body:
Start reading them in order, shuffle right after:

BUFFER_SIZE = 1000 # arbitrary number
# define filenames somewhere, e.g. via glob
dataset = tf.data.TFRecordDataset(filenames).shuffle(BUFFER_SIZE)

EDIT:

The input pipeline of this question gave me an idea on how to implement filenames shuffling with the Dataset API:

dataset = tf.data.Dataset.from_tensor_slices(filenames)
dataset = dataset.shuffle(BUFFER_SIZE) # doesn't need to be big
dataset = dataset.flat_map(tf.data.TFRecordDataset)
dataset = dataset.map(decode_example, num_parallel_calls=5) # add your decoding logic here
# further processing of the dataset

This will put all the data of one file before the one of the next and so on. Files are shuffled, but the data inside them will be produced in the same order.
You can alternatively replace dataset.flat_map with interleave to process multiple files at the same time and return samples from each:

dataset = dataset.interleave(tf.data.TFRecordDataset, cycle_length=4)

Note: interleave does not actually run in multiple threads, it's a round-robin operation. For true parallel processing see parallel_interleave


问:
Need help determining if SQL*PLUS procedure call is correct (PHP)
my professor asked us to do a project using PHP and SQL (Oracle) and  I've never done PHP before in class or outside of it. I keep getting an error on the execute line that says my inputs are not correct. Is there something I'm doing wrong in the input area, or is there something else wrong. I'm trying to execute a stored procedure.(Error code is ORA-06550).</p>

```<code>function makeReservation($conn, $roomNo, $custID, $cardNo, $startDate, $startTime, $endDate, $endTime){
    $procedure = oci_parse($conn, 'BEGIN makeReservation(:roomNo, :custID, :cardNo, TO_DATE(:startDate, \'month dd YYYY\'), :startTime, TO_DATE(:endDate, \'month dd YYYY\'), :endTime);  END;');
    oci_bind_by_name($procedure, ':roomNo', $roomNo);
    oci_bind_by_name($procedure, ':custID', $custID);
    oci_bind_by_name($procedure, ':cardNo', $cardNo);
    oci_bind_by_name($procedure, ':startDate', $startDate);
    oci_bind_by_name($procedure, ':startTime', $startTime);
    oci_bind_by_name($procedure, ':endDate', $endDate);
    oci_bind_by_name($procedure, ':endTime', $endTime);
    oci_execute($procedure);
}
</code>```

答:
I don't see nothing about SQL*Plus

1/ You should add a return clause to your php function
2/ Maybe try  "'BEGIN makeReservation(:roomNo, :custID, :cardNo, TO_DATE(:startDate, 'month dd YYYY', :startTime, TO_DATE(:endDate, 'month dd YYYY'), :endTime);  END;")
3/ De sure than :startDate and :endDate are in a correct format
4/ May be add a fourth parameter $maxlength = -1 for each bind

Body:
my professor asked us to do a project using PHP and SQL (Oracle) and  I've never done PHP before in class or outside of it. I keep getting an error on the execute line that says my inputs are not correct. Is there something I'm doing wrong in the input area, or is there something else wrong. I'm trying to execute a stored procedure.(Error code is ORA-06550).

function makeReservation($conn, $roomNo, $custID, $cardNo, $startDate, $startTime, $endDate, $endTime){
    $procedure = oci_parse($conn, 'BEGIN makeReservation(:roomNo, :custID, :cardNo, TO_DATE(:startDate, \'month dd YYYY\'), :startTime, TO_DATE(:endDate, \'month dd YYYY\'), :endTime);  END;');
    oci_bind_by_name($procedure, ':roomNo', $roomNo);
    oci_bind_by_name($procedure, ':custID', $custID);
    oci_bind_by_name($procedure, ':cardNo', $cardNo);
    oci_bind_by_name($procedure, ':startDate', $startDate);
    oci_bind_by_name($procedure, ':startTime', $startTime);
    oci_bind_by_name($procedure, ':endDate', $endDate);
    oci_bind_by_name($procedure, ':endTime', $endTime);
    oci_execute($procedure);
}


问:
Woocommerce, get products by category with wp query
I tried many methods, but I can't show products with category name or id</p>

```<code>                  $args = array(
                       'post_type'             => 'product',
                       'post_status'           => 'publish',
                       'ignore_sticky_posts'   => 1,
                       'cat'                   => 40,
                       'posts_per_page'        => '12',
                   );

                  $loop = new WP_Query( $args );
</code>```

答:
Try this example,

So given a category with ID 26, the following code would return it's products (WooCommerce 3+):

 $args = array(
    'post_type'             => 'product',
    'post_status'           => 'publish',
    'ignore_sticky_posts'   => 1,
    'posts_per_page'        => '12',
    'tax_query'             => array(
        array(
            'taxonomy'      => 'product_cat',
            'field' => 'term_id', //This is optional, as it defaults to 'term_id'
            'terms'         => 26,
            'operator'      => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
        ),
        array(
            'taxonomy'      => 'product_visibility',
            'field'         => 'slug',
            'terms'         => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
            'operator'      => 'NOT IN'
        )
    )
);
$products = new WP_Query($args);
var_dump($products);```

Body:
I tried many methods, but I can't show products with category name or id

                  $args = array(
                       'post_type'             => 'product',
                       'post_status'           => 'publish',
                       'ignore_sticky_posts'   => 1,
                       'cat'                   => 40,
                       'posts_per_page'        => '12',
                   );

                  $loop = new WP_Query( $args );


问:
How to convert xsd datetime to localDateTime with default time zone
Valid xsd datetime values are:

```<code>2002-05-30T09:00:00
2002-05-30T09:30:10.5
2002-05-30T09:30:10Z
2002-05-30T09:30:10-06:00
</code>```

When I tried to parse this values with ZonedDateTime

```<code>public static void main(String[] args) {
    System.out.println(ZonedDateTime.parse(value, DateTimeFormatter.ISO_DATE_TIME).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
}
</code>```

in first two values if fails because there is no timezone:

```<code>Exception in thread "main" java.time.format.DateTimeParseException: Text '2017-12-05T10:05:19.296' could not be parsed: Unable to obtain ZonedDateTime from TemporalAccessor: {},ISO resolved to 2017-12-05T10:05:19.296 of type java.time.format.Parsed
</code>```

when I will use LocalDateTime it just ignore timezone in last two values.

```<code>public static void main(String[] args) {
    System.out.println(LocalDateTime.parse("2002-05-30T09:30:10-06:00", DateTimeFormatter.ISO_DATE_TIME)); // print 2002-05-30T09:30:10  and I am in +1 timezone
}
</code>```

So what is the correct way to convert this xsd datetime ?

UPDATE

so maybe the best solution to convert xsd:datime is to use old way to gregorianCalendar which also support zoneDateTime ?

```<code>public static LocalDateTime parseDateTime(String strVal) {
    try {
        if (strVal == null || strVal.isEmpty())
            return null;
        return ((GregorianCalendar) (DatatypeConverter.parseDateTime(strVal))).toZonedDateTime()
                .withZoneSameLocal(ZoneId.systemDefault()).toLocalDateTime();
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}
</code>```

答: The problem is that ZonedDateTime always require to have a timezone. The first two dates are missing it. What I would suggest is to encapsulate the logic in a separate class and if a zone is missing just add a 'Z' at the end as it's supposed to be a UTC date time. Your method will always return a ZonedDateTime and the client of the code will know nothing about how it's created.</p>

Body:
Valid xsd datetime values are:

2002-05-30T09:00:00
2002-05-30T09:30:10.5
2002-05-30T09:30:10Z
2002-05-30T09:30:10-06:00

When I tried to parse this values with ZonedDateTime

public static void main(String[] args) {
    System.out.println(ZonedDateTime.parse(value, DateTimeFormatter.ISO_DATE_TIME).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
}

in first two values if fails because there is no timezone:

Exception in thread "main" java.time.format.DateTimeParseException: Text '2017-12-05T10:05:19.296' could not be parsed: Unable to obtain ZonedDateTime from TemporalAccessor: {},ISO resolved to 2017-12-05T10:05:19.296 of type java.time.format.Parsed

when I will use LocalDateTime it just ignore timezone in last two values.

public static void main(String[] args) {
    System.out.println(LocalDateTime.parse("2002-05-30T09:30:10-06:00", DateTimeFormatter.ISO_DATE_TIME)); // print 2002-05-30T09:30:10  and I am in +1 timezone
}

So what is the correct way to convert this xsd datetime ?

UPDATE

so maybe the best solution to convert xsd:datime is to use old way to gregorianCalendar which also support zoneDateTime ?

public static LocalDateTime parseDateTime(String strVal) {
    try {
        if (strVal == null || strVal.isEmpty())
            return null;
        return ((GregorianCalendar) (DatatypeConverter.parseDateTime(strVal))).toZonedDateTime()
                .withZoneSameLocal(ZoneId.systemDefault()).toLocalDateTime();
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}


问:
Stack after pseudo Element behind headline (as box-shadow alternative)
I've the following problem: I want headlines with background and a box-shadow. Now, as firefox is not rendering transform rotate like a charm, I'm looking for an alternative.

```<code>h2 {
  padding: 1rem 2rem;
  display: inline-block;
  color: #FFF;
  background-color: #006AB3;
  transform: translateZ(1px) rotate(-3deg);
  transform-origin: 50% 50%;
  margin-bottom: rem-calc(50px);
  outline: 1px solid transparent;
  z-index:1;
  &:after{
            content: "";
            width: 100%;
            height: 100%;
            position: absolute;
            background: rgba(0,0,0,.3);
            right:-10px;
            bottom:-10px;
            outline: 1px solid transparent;
            z-index: -1;
        }
}
</code>```

https://jsfiddle.net/gw64ove4/

Why is the pseudo after Element not stacked behind the headline? Are there any other workarounds for anti aliasing when using box-shadow on a rotated element?

Thanks

答:
Try adding a span in H2 tag:

```<code><h2>
<span>TEXT</span>
</h2>
</code>```

and CSS for span like this:

```<code>span {display: block; position: relative; z-index: 10;}
</code>```

https://jsfiddle.net/zLna2xLa/

Also you can try using -moz- prefixes

EG::

```<code>-moz-transform: translateZ(1px) rotate(-3deg);
  -moz-transform-origin: 50% 50%;
</code>```

Body:
I've the following problem: I want headlines with background and a box-shadow. Now, as firefox is not rendering transform rotate like a charm, I'm looking for an alternative.

h2 {
  padding: 1rem 2rem;
  display: inline-block;
  color: #FFF;
  background-color: #006AB3;
  transform: translateZ(1px) rotate(-3deg);
  transform-origin: 50% 50%;
  margin-bottom: rem-calc(50px);
  outline: 1px solid transparent;
  z-index:1;
  &:after{
            content: "";
            width: 100%;
            height: 100%;
            position: absolute;
            background: rgba(0,0,0,.3);
            right:-10px;
            bottom:-10px;
            outline: 1px solid transparent;
            z-index: -1;
        }
}

https://jsfiddle.net/gw64ove4/

Why is the pseudo after Element not stacked behind the headline? Are there any other workarounds for anti aliasing when using box-shadow on a rotated element?

Thanks

Body:
Try adding a span in H2 tag:

<h2>
<span>TEXT</span>
</h2>

and CSS for span like this:

span {display: block; position: relative; z-index: 10;}

https://jsfiddle.net/zLna2xLa/

Also you can try using -moz- prefixes

EG::

-moz-transform: translateZ(1px) rotate(-3deg);
  -moz-transform-origin: 50% 50%;