text:
Q: Styling sibiling li items of list on hover Basically I have a list of items and when I hover over the last one, I want all others to change their background-color as well. So far, I tried few workarounds but without success.

 item 1

 item 2

 item 3

ul.profile > li:nth-child(3):hover {
  background-color: red;
}

A: Just try this:
ul.profile:hover > li:not(:hover) {
  background-color: yellow;
}
ul.profile > li:nth-child(3):hover {
  background-color: red;
}

A: If you just want to change the background of the whole ul when hovering over a certain li then you can use a little css trick with pointer-events.
You need to set the
 with pointer-events: none; , and the
 that you want to hover over with pointer-events: auto;.
Note: Because you disable pointer-events, links etc. won't work either.
A code snippet as example:

ul.profile {
    pointer-events: none;
}

ul.profile li:nth-child(3) {
    pointer-events: auto;
}

ul.profile:hover {
    background-color: red;
}

 item 1

 item 2

 item 3


text:
Q: Sitecore. Don't let the content Editor Save an item if some field is not filled In the Sitecore content editor, how I can make it possible so that the content editor wont be able to save an item until and unless he/she filled a field data for a field lets say field name is Email.
I check the Required field with validation rules but then still the Sitecore save the item if the field Email in it is null. It gives an error message but still save the item.

A: You need to set Result paramter to FatalError.
I don't think you want to edit the default Required validation rule. The easiest approach is to create a copy of Required validation rule and paste Result=FatalError inside the Parameters field. Then you can use it instead of the original Required rule and it will not allow to save the item:

redpajama_set_name: RedPajamaStackExchange


text:
Q: In React, why useState(foo()) call foo in every rerendering In React I know next code call foo one time in mount
(...)
function foo() {
 return {
      id: 1,
      text: 'hello',
    }
}

const App = () => {
  const [value, setter] = useState(foo);
(...)

but if I change the foo(useState's argument) to foo() this code call foo if App is rerendering.
I know the difference Between foo and foo() but I know why the difference is occur

A: The code first(second()) means to call second, and pass its result into first. So every time a line like this runs, second will be called. Swap in the names in your code and we get useState(foo()), and it behaves the same. Every time this line runs, foo will be called.
As for why the other version only calls it once, that's because the useState hook is designed so that it if it receives a function, it will call that function on the first render only. On subsequent renders, you will still pass the function in, but react sees that this isn't the first render and so it does not call your function.

A: Function calls in a function body must be evaluated by the JS engine, it doesn't know that React is going to ignore the result on subsequent renders.
It's just like any other function call in the control flow. It has to be evaluated before JS can call useState.
If you send the function reference instead, the implementation of useState knows only to evaluate it on mount.


text:
Q: Lenovo Phab 2 Tango Error Extracting Image I was previously developing for the Tango Tablet Dev Kit and was able to extract and image from the image buffer with no problem. Now, however, with the same code, but on the Lenovo Phab 2, this is the image that is produced:
So, I am wondering, what has changed in the Tango API, or hardware native to cause this?

A: The specifics of the images are a bit different between the Yosemite tablet and that Phab2:
Fisheye:
Yosemite: (width: 640, height: 480, stride: 768)
Phab2 Pro: (width: 640, height: 480, stride: 640)
Color camera:
Yosemite: (width: 1080, height: 720, stride: 1080)
Phab2 Pro: (width: 1920, height: 1080, stride: 1920)
Make sure you are properly reading, and handling, these values from the TangoImageBuffer and you will be in good shape.


text:
Q: How can I change footer background color? Ive tried to change this footers background color, but to no avail. How can I change the background color on this footer? Please be specific because I am not a clever man. I included some CSS that isn't relevant but thought it was necessary.

Phone: 555-555-1800
hello

  Sample text

<?php bloginfo('name'); ?>
                 Copyright &copy All Rights Reserved.

<?php wp_footer(); ?>

A: You should use background-color property in your #footer.

A: Please try to use background-color property in the css or style. Mark it !important to avoid any type of confliction from another same property.

A: You should use background-color:color; in #footer in your CSS.
I have applied background-color:red; in your CSS.
Here is your code with background color : http://jsfiddle.net/992fK/
But, in this case, you have put all your contents inside
, that's why the background color is applied to all the contents. You can arrange your contents so that only footer contents will come inside footer div an then color will be applied as per your requirement.

A: You should correct your HTML code to the following

              Phone: 555-555-1800
hello

Sample text

        <?php bloginfo('name'); ?>

                 Copyright &copy All Rights Reserved.

        <?php wp_footer(); ?>

and to add background-color:color; in #footer in your CSS as @Beauflitz said


text:
Q: Merge Lists with same first index but other second index I am working on a search algorithm in python but there is something I don't get to work..
I have a list which looks like this [["A","1.txt"],["A","2.txt"],["A","3.txt"],["B","1.txt"],["B","3.txt"]]
Now I want to merge the sub-lists that have the same first index. So the result would be:
[["A",["1.txt","2.txt",3.txt"]],["B",["1.txt"],["3.txt"]]]
Anyone who knows how to do this...
Kinda got a sort (on mergesort basis) but this does not merge the tuples
def merge_pairs(data):
if len(data) <= 1 :
    return data[:]
else:
        mid = len(data) // 2
        fst = merge_pairs(data[:mid])
        snd = merge_pairs(data[mid:])
        res = []
        fi = 0
        si = 0
        while fi < len(fst) and si < len(snd):
            if fst[fi][0] < snd[si][0] or fst[fi][0] == snd[si][0] and fst[fi][1] < snd[si][1]:
                res.append(fst[fi])
                fi = fi + 1
            else:
                res.append(snd[si])
                si = si + 1
        if fi < len(fst) :
            res.extend(fst[fi:])
        elif si < len(snd) :
            res.extend(snd[si:])
return res

So i'd like not to use the dict() function of python
Thanks in advance

A: The easiest way (which may or may not be slower than the hard way) is to use a defaultdict:
>>> from collections import defaultdict
>>> result = defaultdict(list)
>>> mylist = [["A","1.txt"],["A","2.txt"],["A","3.txt"],["B","1.txt"],["B","3.txt"]]
>>> for key, value in mylist:
...     result[key].append(value)
...
>>> print(sorted(result.items()))
[('A', ['1.txt', '2.txt', '3.txt']), ('B', ['1.txt', '3.txt'])]

The hard way (if your data is truly already sorted):
>>> src = [["A","1.txt"],["A","2.txt"],["A","3.txt"],["B","1.txt"],["B","3.txt"]]
>>> prev = None
>>> dst = []
>>> for key, value in src:
...     if key != prev:
...         prev = key
...         dst.append((key, []))
...     dst[-1][-1].append(value)
...
>>> print(dst)
[('A', ['1.txt', '2.txt', '3.txt']), ('B', ['1.txt', '3.txt'])]

But note that Python sort is really, really fast, and Python loops like this... Not so much.
Edit  According to your comment below, you also want counts.  Again there is a dictionary way:
>>> from collections import defaultdict
>>> result = defaultdict(lambda: defaultdict(int))
>>> mylist = [["A","1.txt"],["A","2.txt"],["A", "2.txt"],["A","3.txt"],["B","1.txt"],["B","3.txt"]]
>>> for key, value in mylist:
...     result[key][value] += 1
...
>>> print(sorted((x, sorted(y.items())) for (x, y) in result.items()))
[('A', [('1.txt', 1), ('2.txt', 2), ('3.txt', 1)]), ('B', [('1.txt', 1), ('3.txt', 1)])]

and a loop way:
>>> src = [["A","1.txt"],["A","2.txt"],["A", "2.txt"],["A","3.txt"],["B","1.txt"],["B","3.txt"]]
>>> prevkey, prevvalue = None, None
>>> dst = []
>>> for key, value in src:
...     if key != prevkey:
...         prevkey = key
...         prevvalue = None
...         dst.append((key, []))
...     if value != prevvalue:
...         prevvalue = value
...         dst[-1][-1].append([value, 0])
...     dst[-1][-1][-1][-1] += 1
...
>>> dst
[('A', [['1.txt', 1], ['2.txt', 2], ['3.txt', 1]]), ('B', [['1.txt', 1], ['3.txt', 1]])]

You'd really want to run timeit to be sure, but in this instance, the loop way almost looks guaranteed to be slower (and of course, the dictionary way doesn't require you to do a pre-sort.)


text:
Q: Jump quickly to Output File from Visual Studio? From within Visual Studio, is there any way that I can launch Windows Explorer at the location of the binary that an individual project builds?
Xcode 3 lists the built binaries on the left hand side in its equivalent of Solution Explorer. If I right click on one, I have an option to "Reveal in Finder".
There are a number of simple workarounds like say keeping Windows Explorer always open at a particular location, but all of the workarounds I can think of are a bit slow and clunky when it comes to building multiple projects from multiple products and then copying to an install area.
I have 2005, 2008 and 2010 installed, all with Visual Assist.
Thanks.

A: Right click on the project and go to "Properties"
Under "Build Events" there is a spot for post-build commands to run.  You can set an option (at the bottom) to always run, or just when the project output is updated by the build.
If you click the "Edit Post-build ..." button, you'll have a way to find some of the variables for your project, such as the directory where the output goes.
To get Explorer to pop up at the location, you can use:
   explorer $(TargetDir)
However, you may be able to do more complex things, such as automating the copy of files to an installation area.
(Tested on Win 7, VS2010)


text:
Q: Frequencies associated with boson/fermion operators For a Hamiltonian like,
$$\hat{H}=\sum_{k}\hbar\omega_{k}b_{k}^{\dagger}b_{k}$$
What does it mean to say that the frequencies $\omega_{k}$ must be positive if $b_{k}$, $b_{k}^{\dagger}$ are boson operators for $\hat{H}$ to have a minimum? What would be different if these were fermion operators?

A: The point is that the operator $b^\dagger_k b_k$ has only positive eigenvalues, so if one of the $\omega_k$ were negative, you could find an eigenstate which has eigenvalues of $b^\dagger_k b_k$ as large as you want and the corresponding term in the Hamiltonian would become lower and lower. This implies that there is no ground state for such a theory.
If the operators were fermion operators, then $b^\dagger_k b_k$ could only take the eigenvalues $1$ or $0$, so that would not be a problem anymore.


text:
Q: How can I disable ActiveSupport::Notifications on Rails 7? I'm trying to upgrade my API from Rails 6 to Rails 7, and got this error after solving dependences and running my app:
Error:
ActiveSupport::Notifications::InstrumentationSubscriberError (Exception(s) occurred within instrumentation subscribers: NoMethodError, NoMethodError)

I never use this feature, searching all my files doesn't exist any mention to this Notifications.
Couldn't identify who and why is calling this notifications and neither find on Rails 7 Docs how can I disable this feature to solve my problem. Anyone know how can I do it?
Tried remove completely the ahoy_matey gem that appears in traceback and change de API mode to false on config/application.rb but both doesn't work.
I expect disabling this feature can fix my problem.

A: I was getting this exact same error, and the listed solution didn't work for me.
My specific error was an old version of the Airbrake notifier library (v10, updating the v13 fixed it), but to track it down I looked at the error page, which included the NoMethodError error traces below the main application trace.
So if this happens to you, hopefully you won't lose two days to it like I just have.

A: after spend few hours searching the docs of rails 7, I finally found it. Right here, where it says:

Controls behavior when parameters that are not explicitly permitted are found. The default value is :log in test and development environments.

:log to emit an ActiveSupport::Notifications.instrument event on the unpermitted_parameters.action_controller topic and log at the DEBUG level

The solution was add config.action_controller.action_on_unpermitted_parameters = false on my config/application.rb file.


text:
Q: How to shift data by a factor of two months in R? I would like to move down my entire data by a factor of two months. For example, if my data starts on Jan 01, i want to move the data in such a way that the data corresponds to March 01. Likewise, November data would become January data for the next year. Here is my sample code
DF <- data.frame(seq(as.Date("2001-01-01"), to= as.Date("2003-12-31"), by="day"),
                     A = runif(1095, 0,10),
                     D = runif(1095,5,15))
colnames(DF) <-  c("Date", "A", "B")

I tried DF$Date <- DF$Date + 61 but this moved the entire data.frame by a factor of two months including the dates- I just want the data to moved down.

A: I think a simple merge with itself will work here.
First, random data that you can reproduce,
headtail <- function(x, n = 4) { print(head(x, n=n)); print(tail(x, n=n)); }

set.seed(42)
DF <- data.frame(seq(as.Date("2001-01-01"), to= as.Date("2003-12-31"), by="day"),
                     A = runif(1095, 0,10),
                     D = runif(1095,5,15))
colnames(DF) <-  c("Date", "A", "B")
headtail(DF)
#         Date        A         B
# 1 2001-01-01 9.148060 10.049361
# 2 2001-01-02 9.370754 10.324953
# 3 2001-01-03 2.861395  5.868702
# 4 2001-01-04 8.304476 14.156014
#            Date         A         B
# 1092 2003-12-28 0.3284422  6.449250
# 1093 2003-12-29 7.7729724  7.270769
# 1094 2003-12-30 5.2614178 11.023033
# 1095 2003-12-31 2.6612188 13.923079

Now the merge. I use just the Date on the first frame so that the shifted Date will attached the data from the second frame.
out <- merge(DF["Date"], transform(DF, Date = Date + 61),
             by = "Date", all = TRUE)
headtail(out)
#         Date  A  B
# 1 2001-01-01 NA NA
# 2 2001-01-02 NA NA
# 3 2001-01-03 NA NA
# 4 2001-01-04 NA NA
#            Date         A         B
# 1153 2004-02-27 0.3284422  6.449250
# 1154 2004-02-28 7.7729724  7.270769
# 1155 2004-02-29 5.2614178 11.023033
# 1156 2004-03-01 2.6612188 13.923079

That is preserving all data. If you want just up until the last date of the original frame, then just change all= to all.x=:
out <- merge(DF["Date"], transform(DF, Date = Date + 61),
             by = "Date", all.x = TRUE)
headtail(out)
#         Date  A  B
# 1 2001-01-01 NA NA
# 2 2001-01-02 NA NA
# 3 2001-01-03 NA NA
# 4 2001-01-04 NA NA
#            Date         A         B
# 1092 2003-12-28 9.7939015 14.165207
# 1093 2003-12-29 1.7047221  8.269991
# 1094 2003-12-30 0.4273437  8.041551
# 1095 2003-12-31 1.4283236  5.053276

dplyr
library(dplyr)
as_tibble(DF) %>%
  mutate(Date = Date + 61) %>%
  full_join(., select(DF, Date), by = "Date") %>%
  arrange(Date)


text:
Q: Is there a way to end-to-end test a controller-runtime operator in conjunction with a client-go fake kubernetes clientset? I have an operator written in go using sigs.k8s.io/controller-runtime and I'm trying to write an end to end test for it. The test looks something like:
Feature: Operator deletes pods in a namespace when asked

  Scenario: Operator deletes pods on label updated to deletionRequested
    Given the target K8s cluster has got a namespace called "a525bb67-fda5-42cd-84e4-5d604e9f0156"
    And the namespace "a525bb67-fda5-42cd-84e4-5d604e9f0156" has got the following labels
      | state    | active |
    And the namespace "a525bb67-fda5-42cd-84e4-5d604e9f0156" has got the following releases installed with Helm
      | my-service    | 1.1.1 | https://example.com/artifactory/helm-test |
    And operator is running
    When the state label of "a525bb67-fda5-42cd-84e4-5d604e9f0156" is updated to "toBeDeleted"
    Then the namespace "a525bb67-fda5-42cd-84e4-5d604e9f0156" has the following labels
      | state    | deleted |
    And the namespace "a525bb67-fda5-42cd-84e4-5d604e9f0156" has no releases installed with Helm

What happens is that there is an event where the label is updated to "toBeDeleted" which the operator picks up based on a defined predicate. Then the operator will clear out the pods and update the label to "deleted". This is not expected to be instant so the "Then" steps poll until true with a timeout.
In other parts of the system I have k8s.io/client-go/kubernetes/fake working nicely to do things like setting and getting labels but I'm struggling to find a way to integrate it with the controller-runtime tests.
Is there a way of passing the fake clientset to the controller-runtime manager? (From my digging around in the source it seems to use a rest client and client object to communicate...) Or should I approach setting and updating the label differently for this test?
Thank you!

A: Unfortunately, as far as I know, the recommended way of testing the manager is via envtest.
I've tried using fake client via ClientBuilder, but this doesn't seem to work.
However, you should be able to structure your code in a way, that e2e tests only test that controller loops are running, leader election is happening etc. Controller loop logic itself can be tested with fake client, by passing whatever you normally pass using manager.GetClient().


text:
Q: Integrating MuPDF library in Android Project I downloaded "mupdf-1.3-source" and built using Cygwin.
Which files should I import in my Android project?

A: This is what i did to make MuPDF(currently using the 1.9 version) work with my project:
copy the jni folder in MuPDF-1.9-source into my project folder;
copy the thirdparty, generated, scripts, xps, fitz, cbz drawable folder into the jni folder that just copied over;
In res folder of my project, copy everything that the MuPDF needs, ie string values, colors, layouts, and drawables. For layout leaves the main layout alone copy the rest layouts over.
modify AndroidManifest.xml to include additional activities
I used cgywin to rebuild the libraries(?),but it gave me an error. Somehow without that step, MuPDF works for my project...


text:
Q: Show data after AJAX call, how to render in controller? I would like to use link_to to call a controller action named show. This happens, I get a 200 message. Now I want to update a div with the content that is being returned.
Code in controller:
respond_to do |format|
  format.html # show.html.erb
  format.js
 end

Code in view, link and JavaScript:
<%= link_to "Show analysis", company_comparison_path(3), :remote => true , :id => "thelink" %>

<div id="replaced"> will be replaced </div>

<script>
$('#thelink').bind('ajax:complete', function() {
        $('#replaced').html(data)
});
 </script>

I think I still don't understand how to return the HTML or JavaScript from the controller properly into the JavaScript. If I replace the word "data" in the JavaScript with some text in brackets, I get proper output. But how do I get the result from the controller action?

A: You were almost there, but you need to tell the bound function what the actual html content is you want to insert into your #results div. When you call .html() on $('#replaced') the variable you use (data) is still undefined.
Try the following:
$('#thelink').bind('ajax:complete', function(event, data) {
  $('#replaced').html(data.responseText);
});

edit: Oh, something to keep in mind is that this may render your view including the layout which is probably not what you want. You can add something like render layout: false if request.xhr? to your controller to prevent the layout from showing up on ajax requests.

A: If you want to return richer content from the AJAX response, you can render the view from the controller by the :render_to_string method.
See more: http://apidock.com/rails/ActionController/Base/render_to_string
respond_to do |format|
  format.html # show.html.erb
  format.js {
    @content = render_to_string(:partial => 'some_partial_view')
  }
 end


text:
Q: Java unique value map I need a map with unique keys and also storing duplicate values only once. The interface will be the Map but I don't want that the same value use memory multiple times. For example:
In a normal Map implementation like HashMap suposing value.equals(value') and value.equals(value'') but value!=value' and value!=value' and value!=value'' if we:
put(key1, value);
put(key2, value');
put(key3, value'');

Then the value will be stored three times.
I tried to make my own implementation which looks like:
class MyMap2<K, V> extends HashMap<K, V> {
    private Map<V, V> values;

    public MyMap2() {
        values = new HashMap<V, V>();
    }

    @Override
    public V put(final K key, final V value) {
        V v = values.get(value);
        if (v == null) {
            v = value;
            values.put(v, v);
        }
        return super.put(key, v);
    }
}

This implementation stores the value just one time (Please, note that I'm using the same value). But is there any Map which already implements this kind of data structure with get/put O(1)?
Please, note that BiMap is not useful because it will cause an error in case of duplicated values.

A: This implementation already promises constant time get/put operations. The worst case is when inserting a new value that has never been seen yet. In this case you will:

*

*Attempt to find the value in the values map - O(1), since it's a HashMap.

*Not find it, and put the value in the values map - O(1), since it's a HashMap.

*Put the key-value pair in super - O(1), since it's a HashMap.

You find a better way of implementing this logic, but not by an order of magnitude.
EDIT:
Note that the implementation may put in super twice, which is just redundant. It can be tweaked to be slightly cleaner:
@Override
public V put(final K key, final V value) {
    V v = values.get(value);
    if (v == null) {
        v = value
        values.put(v, v);
    }
    return super.put(key, v);
}

A: This was already asked before.
Check out BiMap.


text:
Q: Why is my regex string not matching as a whole while individual components of the whole do match? I'm trying to use a regular expression to match a string of the type 16 June 1997. The pattern isn't that complicated, and when I try and match individual components of the larger regex string, it matches just fine. But for some reason, I'm having trouble matching the entire regex string. I'm honestly at a loss here, so any tips are appreciated.
library(stringr)

## Good
str_detect("16 June 1997", "[0-9]{1,2}[\\s]{1,1}[January|February|March|April|May|June|July|August|September|October|November|December]")
#> [1] TRUE

## Good
str_detect("16 June 1997", "[\\s]{1,1}[0-9]{4,4}")
#> [1] TRUE

## Good
str_detect("16 June 1997", "[January|February|March|April|May|June|July|August|September|October|November|December]{1,1}[\\s]{1,1}[0-9]{4,4}")
#> [1] TRUE

## Bad
str_detect("16 June 1997", "[0-9]{1,2}[\\s]{1,1}[January|February|March|April|May|June|July|August|September|October|November|December]{1,1}[\\s]{1,1}[0-9]{4,4}")
#> [1] FALSE

Created on 2020-01-17 by the reprex package (v0.2.1)

A: Your regex format is a bit weird.
You don't have to specify quantifiers if you just want to match one character, and you can just put a single number to have a specific number of instances of a character.
Also, the months should be an OR, which would go in parentheses.
This works:
str_detect("1 June 1997", "[0-9]{1,2}\\s(January|February|March|April|May|June|July|August|September|October|November|December)\\s[0-9]{4}")

Also, be careful where you use this, if you're using this to parse user input, you might run into some trouble because you're assuming you're only gonna have a single space character surrounding the month.


text:
Q: Java SQL query execution, problems in reading the ResultSet rows I'm writing simple Java code and I have to execute an SQL query on my Postgresql database.
The result of this database (I've checked manually) is a simple table made by one column and two integer numbers, like this:

My problem is that I cannot find any way to read these two rows.
My reading code is:

_conn.setReadOnly(false);
_stmt = _conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
_stmt.setFetchSize(100);
List< Short > lista = new List< Short >();
_rs = _stmt.executeQuery(query);
while (_rs.next())  {
lista.add((short)_rs.getInt(1));
}

This code only reads the 1st row, but there's no way to make it read the 2nd row.
The Short list "lista" contains always 1 element.
It's like if the ResultSet does not proceed in reading the second row...
How to read both the rows?
EDIT: I've tried with ArrayList but it does not work. I've added the code part for the _conn connection and the _stmt statement.
Here's the query:
            SELECT COUNT(bffK.biological_function_feature_oid)
        FROM biological_function_feature AS bff
        INNER JOIN biological_function_feature_unfolded AS bffu
        ON bff.biological_function_feature_oid = bffu.term_oid
        INNER JOIN (    SELECT DISTINCT ON (g.gene_oid, bffu.ancestor_oid) g.gene_oid AS ance_gene, bffu.ancestor_oid AS ance_oid, mf.feature_name AS feature_name, mf.feature_id AS feature_id, ef.name AS evidence, qf.name AS qualifier
                FROM gene2biological_function_feature AS g2bff
                INNER JOIN biological_function_feature AS bff
                ON g2bff.biological_function_feature_oid = bff.biological_function_feature_oid
                INNER JOIN biological_function_feature_unfolded AS bffu
                ON bffu.term_oid = bff.biological_function_feature_oid
                INNER JOIN metadata.feature AS mf ON bff.feature_type = mf.feature_id
                INNER JOIN gene AS g ON g2bff.gene_oid = g.gene_oid
                LEFT JOIN flag.evidence_flags AS ef ON g2bff.evidence = ef.id
                LEFT JOIN flag.qualifier_flags AS qf ON g2bff.qualifier = qf.id
                LEFT JOIN flag.inferred_flags AS fif ON fif.id = g2bff.inferred
                WHERE g.gene_oid=(4060969)
                AND (bff.is_obsolete NOT IN ('t') OR bff.is_obsolete IS NULL)
                AND (g.is_obsolete NOT IN ('t') OR g.is_obsolete IS NULL)
                AND distance=1
                 UNION
                SELECT DISTINCT ON (g.gene_oid, bff.biological_function_feature_oid)
                g.gene_oid AS ance_gene, bff.biological_function_feature_oid AS ance_oid,
                mf.feature_name AS feature_name, mf.feature_id AS feature_id,
                ef.name AS evidence,
                qf.name AS qualifier
                FROM gene2biological_function_feature AS g2bff
                INNER JOIN biological_function_feature AS bff
                ON g2bff.biological_function_feature_oid = bff.biological_function_feature_oid
                INNER JOIN metadata.feature AS mf ON bff.feature_type = mf.feature_id
                INNER JOIN gene AS g ON g2bff.gene_oid = g.gene_oid
                LEFT JOIN flag.evidence_flags AS ef ON g2bff.evidence = ef.id
                LEFT JOIN flag.qualifier_flags AS qf ON g2bff.qualifier = qf.id
                LEFT JOIN flag.inferred_flags AS fif ON fif.id = g2bff.inferred
                WHERE g.gene_oid=(4060969)
                AND (bff.is_obsolete NOT IN ('t') OR bff.is_obsolete IS NULL)
                AND (g.is_obsolete NOT IN ('t') OR g.is_obsolete IS NULL)
                AND ef.name NOT IN ('IEA', 'ND')
            )
        AS unf ON unf.ance_oid = bffu.ancestor_oid
        INNER JOIN gene AS gK on gk.Gene_oid=ance_gene
        INNER JOIN biological_function_feature AS bffK
        ON bffK.biological_function_feature_oid = bffu.ancestor_oid
        LEFT JOIN flag.evidence_flags AS efK
        ON evidence = efK.name
        LEFT JOIN flag.qualifier_flags AS qfK
        ON qualifier = qfK.name
        WHERE bffu.distance=1 AND (bff.biological_function_feature_oid) IN (217538)
        AND evidence NOT IN ('IEA', 'ND')
        UNION
        SELECT COUNT(bffK.biological_function_feature_oid)
        FROM biological_function_feature AS bff
        INNER JOIN biological_function_feature_unfolded AS bffu
        ON bff.biological_function_feature_oid = bffu.term_oid
        INNER JOIN (    SELECT DISTINCT ON (g.gene_oid, bffu.ancestor_oid) g.gene_oid AS ance_gene, bffu.ancestor_oid AS ance_oid, mf.feature_name AS feature_name, mf.feature_id AS feature_id, ef.name AS evidence, qf.name AS qualifier
                FROM gene2biological_function_feature AS g2bff
                INNER JOIN biological_function_feature AS bff
                ON g2bff.biological_function_feature_oid = bff.biological_function_feature_oid
                INNER JOIN biological_function_feature_unfolded AS bffu
                ON bffu.term_oid = bff.biological_function_feature_oid
                INNER JOIN metadata.feature AS mf ON bff.feature_type = mf.feature_id
                INNER JOIN gene AS g ON g2bff.gene_oid = g.gene_oid
                LEFT JOIN flag.evidence_flags AS ef ON g2bff.evidence = ef.id
                LEFT JOIN flag.qualifier_flags AS qf ON g2bff.qualifier = qf.id
                LEFT JOIN flag.inferred_flags AS fif ON fif.id = g2bff.inferred
                WHERE g.gene_oid=(4060969)
                AND (bff.is_obsolete NOT IN ('t') OR bff.is_obsolete IS NULL)
                AND (g.is_obsolete NOT IN ('t') OR g.is_obsolete IS NULL)
                AND distance=1
                 UNION
                SELECT DISTINCT ON (g.gene_oid, bff.biological_function_feature_oid)
                g.gene_oid AS ance_gene, bff.biological_function_feature_oid AS ance_oid,
                mf.feature_name AS feature_name, mf.feature_id AS feature_id,
                ef.name AS evidence,
                qf.name AS qualifier
                FROM gene2biological_function_feature AS g2bff
                INNER JOIN biological_function_feature AS bff
                ON g2bff.biological_function_feature_oid = bff.biological_function_feature_oid
                INNER JOIN metadata.feature AS mf ON bff.feature_type = mf.feature_id
                INNER JOIN gene AS g ON g2bff.gene_oid = g.gene_oid
                LEFT JOIN flag.evidence_flags AS ef ON g2bff.evidence = ef.id
                LEFT JOIN flag.qualifier_flags AS qf ON g2bff.qualifier = qf.id
                LEFT JOIN flag.inferred_flags AS fif ON fif.id = g2bff.inferred
                WHERE g.gene_oid=(4060969)
                AND (bff.is_obsolete NOT IN ('t') OR bff.is_obsolete IS NULL)
                AND (g.is_obsolete NOT IN ('t') OR g.is_obsolete IS NULL)
                AND ef.name IN ('IEA', 'ND')
            )
        AS unf ON unf.ance_oid = bffu.ancestor_oid
        INNER JOIN gene AS gK on gk.Gene_oid=ance_gene
        INNER JOIN biological_function_feature AS bffK
        ON bffK.biological_function_feature_oid = bffu.ancestor_oid
        LEFT JOIN flag.evidence_flags AS efK
        ON evidence = efK.name
        LEFT JOIN flag.qualifier_flags AS qfK
        ON qualifier = qfK.name
        WHERE bffu.distance=1 AND (bff.biological_function_feature_oid) IN (217538)
        AND evidence IN ('IEA', 'ND')

A: List is an interface, try using something like ArrayList
List< Short > lista = new ArrayList< Short >();

_rs = _stmt.executeQuery(query);

     while (_rs.next()) {

lista.add((short)_rs.getShort(1));

}

A: List is an interface, therefore you cannot instantiate directly rather than using its one of implementation like ArrayList. Also note that count is a keyword in PG, so avoid using keyword as identifiers. Working solution:
pst = connection.prepareStatement("SELECT * FROM demo");
List<Short> lista = new ArrayList<Short>();
rs = pst.executeQuery();

while (rs.next()) {
   lista.add((short)rs.getInt(1));
}

A: It doesn't seem to be an issue with syntax. Do you also get one row when you run the query against the database? Perhaps you can post your SQL query too.


text:
Q: How to order multiple times while ordering by specified row between every other order clausule in MySQL? Table with products has (other than description) columns: availableNow, available1day, available3day, available7day, price.
Availability columns contain number of product in stock in that period and each period is including stock available in shorter-preceding period.
# Example row:
availableNow = 0
available1day = 4
available3day = 4
available7day = 10
price = 24.75

How do I ORDER these rows in way that first are items for shorter period + ORDERed by price and after that are items for later period and they again are ORDERed by price, etc?
This is what I came up, but I soon realised that result is not what I expect. This first orders things by availability and at end by price...
IF (availableNow > 0, 0, 1)
, IF (available1day > 0, 0, 1)
, IF (available3day > 0, 0, 1)
, IF (available7day > 0, 0, 1)
, price

Thing is, once item is (availableNow > 0, 0, 1), I want conforming rows order by price and not touch these rows anymore, then rest of rows order by IF (available1day > 0, 0, 1) and again order conforming rows by price and not touch it anymore...
# this kind of shows what I want, but result is not what I want
IF (availableNow > 0, 0, 1), price
, IF (available1day > 0, 0, 1), price
, IF (available3day > 0, 0, 1), price
, IF (available7day > 0, 0, 1), price

(feel free to edit Title, because I have NO idea how to name what do I want)

A: If I understand correctly, if availableNow is greater than 0 you want to order by it, but with those less than or equal to zero sorted afterwards. Same for available1day, etc.
If so:-
ORDER BY IF(availableNow > 0, 0, 1), availableNow,
        IF(available1day > 0, 0, 1),available1day,
        IF(available3day > 0, 0, 1),available3day,
        IF(available7day > 0, 0, 1),available7day

EDIT. Further to you explanation, possibly like this:-
ORDER BY IF(availableNow > 0, price, 999999999),
        IF(available1day > 0, price, 999999999),
        IF(available3day > 0, price, 999999999),
        IF(available7day > 0, price, 999999999)

Bit of a mess. Idea is that if available now it uses the price, if not 999999999 (so those not available now will come afterwards). Then the same for the other fields. 999999999 is just a number bigger than any of the prices (chose such a number with a bit of care!).


text:
Q: Different bare repo name cause different config My system is centos 7.4 with git 1.8.
I found a problem:create bare repo with name .git or name.git cause different config.
Test as below:
[root@localhost repo]# git init --bare site1.git
Initialized empty Git repository in /home/websites/site1/repo/site1.git/
[root@localhost repo]# git config --list

[root@localhost repo]# git init --bare .git
Initialized empty Git repository in /home/websites/site2/repo/.git/
[root@localhost repo]# git config --list
core.repositoryformatversion=0
core.filemode=true
core.bare=true

Notice different git config --list result with different bare repo name.
What's the problem?How to solve it?

A: Based on torek's comments,we should:
git init --bare site1.git
cd site1.git
git config --list


text:
Q: What tells us the speed of light is constant in another galaxy? I've read, and I hope to keep reading, so please send me all your links, and I apologize in advance if this is a duplicate, or non-mainstream physics question as the speed of light is widely accepted as a constant. While it's only a slight variation of numerous questions on this site - several of those listed below - I do believe it's unique. Or the specific answer is hidden, at least for a layman (that's me).

Why do we assume the speed of light is constant outside our solar system and/or galaxy and/or some other [relatively] local construct?
Or another way I might try to phrase this - why doesn't gravity affect light? I know it's not supposed to have mass, so it wouldn't - but it also seems like the general consensus is that it does have mass, we just can't measure it (like electrons), and it's considered so negligible in our equations we can ignore it.
To bring one example of my question not being answered in the below sources:
While you read the detailed and well-explained answer here, isn't every value used in the explanation derived from the assumption that the speed of light is constant throughout the universe? Couldn't every one of those calculations be performed and provide "satisfactory" answers even if light was varying based on some level? Why not?
Going to the derived from Maxwell's equation's response I've also seen a lot - Why wouldn't changes in gravity also affect these? Am I taking the statement "It's all relative" too literally here?
Further, I just thought back to the fact light can't escape a black hole, which means it is affected by gravity, right? So why is that effect ignored in all our modern equations? Is it really nothing/negligible when measuring the distance of something like another galaxy (or the particle horizon for that matter)?

From the reading I've done I'm guessing I have some fundamental misunderstanding... seems to always be the answer to these questions. I'm thinking maybe something regarding the way I'm thinking about time, or I'm somehow excluding it's relativity? Really don't know (obviously)
But if someone can help me out, I'd appreciate learning more about this.

EDIT:
I appreciate all the answers, I chose my accepted answer based on what helped me wrap my mind around this most easily. I'm also thinking of re-framing this as a new, more focused, question. I spent too long writing this and it got away from me/began to become multiple questions in one.

Previously read:
https://www.sciencenews.org/article/speed-light-not-so-constant-after-all
http://www.desy.de/user/projects/Physics/Relativity/SpeedOfLight/speed_of_light.html
http://www.desy.de/user/projects/Physics/ParticleAndNuclear/constants.html
http://www.desy.de/user/projects/Physics/ParticleAndNuclear/photon_mass.html
https://www.livescience.com/29111-speed-of-light-not-constant.html
https://en.wikipedia.org/wiki/List_of_electromagnetism_equations
Similar questions:
Why and how is the speed of light in vacuum constant, i.e., independent of reference frame?
Purported non-constant speed of light
Why does speed of light have to be constant?
Is the speed of light in a vacuum constant?
Why is the speed of light in vacuum constant?
The Speed of Light
How the speed of light is constant with the particle horizon moving toward us?

A: The most certain way is that we can observe the atomic transitions in distant galaxies. They are the same as what we observe here. This indicates the fine structure constant $\alpha=\frac{1}{4\pi\epsilon_0}\frac{e^2}{\hbar c}$ is the same everywhere. This then lends support for the speed of light being a universal constant.

A: Theoretically, you have seen the other answers.
Experimentally, really nothing tells us.
The speed of light is c in vacuum, when measured locally. It is very important to understand the difference between local and non-local measurements.
For non-local measurements, there is the Shapiro delay.
https://en.wikipedia.org/wiki/Shapiro_time_delay
But that does not say anything about the speed of light in a local measurement (in a very different gravitational field like in your case).
To prove what you are asking, we would need to make a local measurement somewhere far from Earth, where the gravitational potential is very different, like in your case in another galaxy, or at least near our Sun. This has not been done yet.
If we could travel somewhere like near the Sun, and measure the speed of light there locally, then that would be proof that the speed of light is c in vacuum, when measured locally in gravitational zones very different from the Earth's.
You are basically asking why doesn't gravity affect light? It does, but the speed of light is c in vacuum when measured locally. The speed of light varies only in non-local measurements (relative to a different gravitational zone).

A: One reason to accept the postulate that the speed of light does not vary from place to place (that is, the laws of physics have no spatial dependence) is if it did, then momentum would not be conserved. This in turn would mean that an object could suddenly and for no reason acquire or lose some arbitrary velocity in some random direction- something we do not observe in the universe we inhabit.

A: The short answer is the cosmological inflation theory.
The more analytical:
The speed of light $c$ in a vacuum is given by the equation:
$$
c=\frac{1}{\sqrt{\varepsilon_0 \mu_0}}
$$
where $\varepsilon_0$ and $\mu_0$ the permittivity and permeability of vacuum space.
It is not possible these parameters to had the same constant values at the first milliseconds of the Big Bang since there was no vacuum space and space was filled with energy therefore a much more condensed Universe.

image source: https://en.wikipedia.org/wiki/Big_Bang
Within one second after the BB the observable Universe expanded (including spacetime) more or less to its current size today. This means that the Universe expanded  with a much larger speed than c value at the first second of creation therefore the speed of light during this period must have been much larger than the current value c. After this 1 second the speed of light was more or less as its current value today $c$.
One may think that since the Universe is continuing expanding with an exponential rate the speed of light should become slower over the millennia? However, Dark energy phenomenon is keeping the volumetric energy density of vacuum space constant! Therefore the speed of light remains unchanged and a constant c everywhere in our observable Universe.
These two phenomena of inflation and dark energy result in only a minuscule error of  ~1 second in the calculation of the red shift of galaxies and their distance from our home planet which is negligible over a ~13.8 Byrs period.
As long as the vacuum energy density  remains the same everywhere in the observable Universe (including within galaxies) expect the speed of light at the vacuum to be at the constant value $c$.
Nevertheless, if in the far future the vacuum energy density will for whatever reason decrease it is possible the speed of light in a vacuum $c$ to actually drop:
$$
\Lambda=8 \pi \rho_{v a c} G / c^4=\kappa \rho_{\text {vac }}
$$
where $\rho_{v a c}$  is the vacuum energy density currently a constant.


text:
Q: howto to build nemo extension nemo-seahorse version 4.4.0 without libgnome-keyring-dev I use Ubuntu 20.04 desktop and install afterwards a Cinnamon deskstop.
Because Cinnamon Nemo filemanager did default not have nemo-seahorse support, I want to
build nemo-seahorse extension for Nemo filemanager. I already downloaded nemo-extensions version 4.4.0 from. How can I build nemo-seahorse extension from 4.4.0 source without Ubuntu package libgnome-keyring-dev because it is not provided anymore with ubuntu 20.04, but to build nemo-seahorse extension 4.4.0 from source needs libgnome-keyring-dev because of the build dependancy?

A: You can save time by using binary pre-compiled packages from
"Wasta-Linux" team's Cinnamon-Testing PPA:
sudo add-apt-repository ppa:wasta-linux/cinnamon-testing
sudo apt-get update
sudo apt-get install nemo-seahorse

Then restart Nemo by nemo -q.

Notes:

*

*the above PPA has many packages from/for Cinnamon as it shipped in Wasta Linux, so you can install fully-featured Cinnamon desktop on your Ubuntu 20.04 LTS system.

*to revert to default versions you have to remove the PPA use ppa-purge - sudo apt-get install ppa-purge; sudo ppa-purge ppa:wasta-linux/cinnamon-testing .


text:
Q: Remove extra value using XSL How to remove the extra value from being generated after the transformation.
Input:
<response status="200">
    <IDList>
        <IDLists>
            <IDSec>
                <IDField>
                    <IDFields>
                        <ID>123456</ID>
                        <IDState>done</IDState>
                    </IDFields>
                    <IDFields>
                        <ID>12345634</ID>
                        <IDState>failed</IDState>
                    </IDFields>
                </IDField>
            </IDSec>
        </IDLists>
        56
        <msg>yet</msg>
    </IDList>
</response>

XSL for transforming it:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="/">
        <xsl:if test="/response/IDList/IDLists/IDSec/IDField/IDFields/ID">
            <xsl:apply-templates/>
        </xsl:if>
    </xsl:template>
    <xsl:template match="IDFields">
        <cid>
            <id>
                <xsl:value-of select="ID"/>
            </id>
            <iDState>
                <xsl:value-of select="IDState"/>
            </iDState>
        </cid>
    </xsl:template>
</xsl:stylesheet>

Required output:
<cid>
  <id>123456</id>
  <iDState>done</iDState>
</cid>
<cid>
  <id>12345634</id>
  <iDState>failed</iDState>
</cid>

Generated output after using the above XSL:
<cid>
  <id>123456</id>
  <iDState>done</iDState>
</cid>
<cid>
  <id>12345634</id>
  <iDState>failed</iDState>
</cid>56yet

How to remove the extra 56yet from the output?

A: Change
<xsl:template match="/">
    <xsl:if test="/response/IDList/IDLists/IDSec/IDField/IDFields/ID">
        <xsl:apply-templates/>
    </xsl:if>
</xsl:template>

to
<xsl:template match="/">
        <xsl:apply-templates select="/response/IDList/IDLists/IDSec/IDField/IDFields[ID]"/>
</xsl:template>


text:
Q: Why can't electrostatically accelerated deuterium beams neutralized by electrons produce net energy fusion? I was looking through the various nuclear fusion approaches and it struck me that they all suffered from one of two problems. Either they wasted a lot of energy trying to accelerate fusion fuel to the needed speed by using heat, which produced a distribution of particle energies instead of a single energy, or they couldn't get the needed particle density for the reaction to progress fast enough to burn all the fuel before it flies apart.
The reactor that comes closest in terms of accelerating fusion fuel efficiently is the polywell, because it uses an electrostatic potential difference to get the fuel to the needed speed for fusion. However, since the nucleii are ions, it is very hard to get the densities (150 g/cm^3) for rapid fuel burn.
So a thought came to me. Why can't an electrostatic accelerator accelerate deuterium ions to fusion energies, and have the accelerators arranged to have the ion beams converge to a focal point. However, after accelerating the ions, and moving them towards the focus, neutralize the ions using an electron beam, so the particle beam is both at high speed, and neutral to allow compression without electrostatic repulsion.
I think this might, work and googled it and couldn't find anyone having attempted this. Am I missing something fundamental here? If so, what is it? Why wouldn't this work?


text:
Q: Are Icons (PNG) that display numbers or letters generated dynamically When there are notification icons to indicate a number for example, are those icons generated dynamically, or are they stored somewhere and the proper icon is fetched? It seems like the obvious answer is that there are icons stored labeled with the correct number and fetched locally or remotely. But if there is a way to generate it dynamically, that would be great. Any help would be appreciated!
Here are some examples:

A: You can use fontawesome to try making the layer counter.
Support for layer counters
Layering, Text, & Counters


text:
Q: How to add a custom Material UI DataGrid (Pro) custom type? I would like to add a custom type formatter to a DataGrid (Pro). DataGrid manual recommends to simply create a reusable partial column definition and then expand it (link).
But I see code in the DataGrid, and it looks like it supports custom types, but I can't find any documentations on it or find usages.
It looks like useDataGridProComponent method is intended for state management, specifically I can't just pass my columnTypes to it, I have to provide a few dozen different properties that I do not want to change from defaults.
Is it a supported feature? Is there an example of how I can use it?


text:
Q: <%=values%> are not updating inside an update panel I have tried almost all the suggested solutions which are posted here and are related to my issue with no luck. I am creating some graphs (using Dygraphs library). The following javascript code is just a small part of the whole function; in fact I create 5 graphs in such way.

In the code behind, I serialize (and serve as a String) both the sDataForROI1Graph and sLabelsForROI1Graph global variables which are filled in with the result of a database query in a specific format (the expected format for Dygraphs). This javascript code is located inside of an asp:UpdatePanel. When I fire a button (which is also inside of the same UpdatePanel) the query returns different results, so both the sDataForROI1Graph and sLabelsForROI1Graph are changed but the graphs are not redesigned (namely the values of the global variables are not passing from the code behind to client-side with the <%= => technique). I have also declared the Trigger option to the fired button as shown below...
   <Triggers>
        <asp:AsyncPostBackTrigger ControlID="RemoveAllbtn" />
   </Triggers>

... and my code is just simple as shown in the following snippet (actually I re-run a stored procedure which updates the 2 global variables sDataForROI1Graph and sLabelsForROI1Graph with new values)
Protected Sub RemoveAllbtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles RemoveAllbtn.Click
    RemoveAll()
End Sub

If I remove the UpdatePanel, everything works like a charm, because a full post-back occurs. I have tried to inject javascript code and perform other tricky suggestions but I haven't found a workaround yet.
My question is why these 2 global variables can't be accessed from client-side when are nested to the UpdatePanel? Which is the best approach to bypass this issue? I have also read about hidden Textboxes / HiddenFields / Labels / Literals controls, but even these approaches didn't help me to solve my issue.
EDIT
Admittedly, the suggested answer below is what I needed and it works fine, BUT after a lot of hours spending on my issue and banging my head against the wall, I realized that my problem persists and the reason is too weird. In client side, outside of the UpdatePanel I have created an <asp:HiddenField ID="hidfieldforROI1" runat="server"/> , that I am trying to get its value like this
var dataforROI1 = document.getElementById('<%= hidfieldforROI1.ClientID %>').value;

In the back-end I am setting the Value to the hidfieldforROI1 Control. And I am getting the following weird error:
error BC30451: 'dataforROI1' is not declared. It may be inaccessible due to its protection level.
I would appreciate any suggestion.

A: In the aspx file
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

<%= sDataForROI1Graph %>

        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"></asp:Button>

    </ContentTemplate>
</asp:UpdatePanel>

<asp:TextBox ID="hidfieldforROI1" runat="server" Text="textBoxje"></asp:TextBox>

And then in code behind
Dim sDataForROI1Graph As String = DateTime.Now.ToString

Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs)
    hidfieldforROI1.Text = "Page Load"
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    sDataForROI1Graph = DateTime.Now.ToString

    ScriptManager.RegisterStartupScript(Page, Page.GetType, "testScript", "testScript();", true)
End Sub

If I use this code, the sDataForROI1Graph is updated after a button click and displayed with the alert.
UPDATE
I altered my answer a bit to include a HiddenField (TextBox in my snippet to make visualisation easier). The HiddenField get a value in Page_load' and inButton1_Click. The one inButton1_Clickwill ofcourse not show up since theHiddenFieldis outside theUpdatePanel. But the properties are still available so you can still usehidfieldforROI1.ClientIDinside theUpdatePanel`


text:
Q: Gaining access to private members for testing in C++ I am developing code that solves about 100 equations. Most of theses equations are computed in private members, because in the end the user doesn't care about them. But, right now I do. So, as I develop the code I would like to have a quick way to test private members.
The code below gives the basic behavior that I want, but it does not work (privacy issue). If this behavior is possible, I would appreciate any help.
// Includes
#include <stdio.h>

// I want a general test class that can access private members
template <class Name> class TestClass{
    public:
        TestClass(Name& input) : the_class(input){}
        Name& operator()(){ return the_class; }
        Name& the_class;
};

// The class I want to test
class ClassA{
    public:
        friend class TestClass<ClassA>; // I hoped this would do it, but it doesn't
        ClassA(){}
    private:
        void priv(){ printf("a private function\n"); }
};

// Main function that preforms the testing
int main (){
    ClassA a;
    TestClass<ClassA> b(a);
    b().priv(); // I want to do this
}

A: You've granted friendship to TestClass<ClassA>, but you are asserting that friendship in main() instead.
Your choices are:

*

*Write a forwarding function in TestClass<> that invokes the_class.priv()

*Grant friendship to the function that actually requires it. (I imagine this isn't really main() in your actual program.)

A: There are different approaches to this. From a high level perspective, you can provide the same functions in the TestClass adapter that are present in the tested type and have it forward the requests. Another option is befriending a test class that will actually perform the tests in member functions.

The code below does not compile, it shows the approach to take, but the details are off. Read the article that Kerrek linked in the comment for more details

Finally, if you want to abuse your C++-fu, you can break access specifiers by using explicit template instantiations and member pointers (I am writing this off the top of my head, it might not compile, but the idea is there... just fight the compiler errors if they come):
template <typename T, void (T::*Ptr)() >
struct accessor {
   typedef void (T::*ptr_t)();
   static ptr_t ptr;
};
template <typename T, void (T::*Ptr)() >
accessor<T,Ptr>::ptr_t accessor<T,Ptr>::ptr = Ptr;

template accessor<ClassA, &ClassA::priv>;
typedef accessor<ClassA, &ClassA> priv_accessor;
int main() {
   ClassA a;
   (a.*priv_accessor::ptr)();
}

The approach here uses template instantiations to break access, as the arguments to the template explicit instantiation don't check access (it would be impossible to instantiate that template with a private member otherwise, as explicit template instantiations must happen at namespace level, and you cannot befriend a namespace)


text: Q: About exactness of $Hom$ functor? We know that a module $P$ is projective if and only if the functor $Hom(P,-):R-Mod \to Ab$ is exact, i.e it preserves epimorphisms: If $\alpha: M \to N$ is an epimorphism of modules then $Hom(P,\alpha):Hom(P,M)\to Hom(P,N)$ is an epimorphism of abelian groups. Now I'm trying to find some thing similar for a non-projective module $P$ but with finite projective dimension, say $pd(P)\leq d$. I know that in this case $Hom(P,-)$ is not exact, is there any condition for an epimorphism $\alpha: M \to N$ to have $Hom(P,\alpha):Hom(P,M)\to Hom(P,N)$ is an epimorphism of abelian groups?


text:
Q: How append string to string in PHP based on an array of items I am trying to make a script to extend the view of the SQL returned by Zend and format this SQL code, so I'd like to insert "\n" to the reserved words of mysql and "\n" and "\t" to tables names, fields names, etc...
E.g( in short, I use more reserved words to match ):
$sql = "SELECT * FROM `table` WHERE `field` = 'value';";

Output:

SELECT
    *
FROM
    table
WHERE
    field = 'value'
;

I could do a lot of calls to str_replace, but I need something like:
$sql = array('SELECT', 'FROM', 'WHERE', ... );

return "\nSELECT", "\nFROM", "\nWHERE" in the $sql variable.
The other characters I have already handled, the problems are the mysql reserved words
Any clue? I tried preg_replace but it still removes the matches.

A: You can try this
$keywords = array(
    "select",
    "update"
); //etc
$sql = SELECT * FROM`table`WHERE`field` = 'value';
$tokens = explode(" ", $sql);

foreach($tokens as $token)
    {

    // if token in $keywords print \n along with value else print as it is ..

    if (in_array($token, $keywords))
        {
        echo $token . "\n";
        }
      else
        {
        echo $token;
        }
    }

Hope this helps ..


text:
Q: How to force y position of one branch in d3 sankey plugin? I would like to force one branch of sankey diagram to be on top.
Instead of diagram like this:

would like to generate diagram where nodes 1, 2, 7, 15, 10 and 14 are always on top:

Link to fiddle with current code: http://jsfiddle.net/w5jfp9t0/1/
var margin = {top: 1, right: 1, bottom: 6, left: 1};
var width = 1052 - margin.left - margin.right;
var height = 500 - margin.top - margin.bottom;

var formatNumber = d3.format(",.0f"),
    format = function(d) { return formatNumber(d); },
    color = d3.scale.category20();

var svg = d3.select("#chart_sankey").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

var sankey = d3.sankey()
                         .nodeWidth(35)
                         .nodePadding(10)
                         .size([width, height]);

var path = sankey.link();

raw = '{"nodes":[{"name":"Node 1"},{"name":"Node 2"},{"name":"Node 3"},{"name":"Node 4"},{"name":"Node 5"},{"name":"Node 6"},{"name":"Node 7"},{"name":"Node 8"},{"name":"Node 9"},{"name":"Node 10"},{"name":"Node 11"},{"name":"Node 12"},{"name":"Node 13"},{"name":"Node 14"},{"name":"Node 15"}],"links":[{"source":9,"target":13,"value":25},{"source":14,"target":9,"value":37},{"source":14,"target":11,"value":16},{"source":14,"target":12,"value":8},{"source":14,"target":10,"value":68},{"source":6,"target":14,"value":154},{"source":6,"target":8,"value":40},{"source":1,"target":6,"value":345},{"source":1,"target":7,"value":66},{"source":1,"target":3,"value":17},{"source":1,"target":4,"value":25},{"source":1,"target":5,"value":117},{"source":0,"target":1,"value":692},{"source":0,"target":2,"value":19}]}';
data = JSON.parse(raw);

sankey.nodes(data.nodes)
    .links(data.links)
    .layout(32);

var link = svg.append("g")
            .selectAll(".link")
            .data(data.links)
            .enter().append("path")
            .attr("class", "link")
            .attr("d", path)
            .style("stroke-width", function(d) { return Math.max(1, d.dy); })
            .sort(function(a, b) { return b.dy - a.dy; });

var nodes = data.nodes;

var node = svg.append("g").selectAll(".node")
    .data(nodes)
  .enter().append("g")
    .attr("class", "node")
    .attr("transform", function(d) {
        return "translate(" + d.x + "," + d.y + ")"; })
  .call(d3.behavior.drag()
    .origin(function(d) { return d; })
    .on("dragstart", function() { this.parentNode.appendChild(this); })
    .on("drag", dragmove));

sankey.relayout();

node.filter(function(d) { return d.value != 0; }) // append text only if node value is not zero
    .append("rect")
    .attr("height", function(d) { return d.dy; })
    .attr("width", sankey.nodeWidth())
    .style("fill", function(d) { return d.color = color(d.name.replace(/ .*/, "")); })
    .style("stroke", function(d) { return d3.rgb(d.color).darker(2); })
  .append("title")
    .text(function(d) { return d.name + "\n" + format(d.value); });

node.filter(function(d) { return d.value != 0; }) // append text only if node value is not zero
    .append("text")
    .attr("x", -6)
    .attr("y", function(d) { return d.dy / 2; })
    .attr("dy", ".35em")
    .attr("text-anchor", "end")
    .attr("transform", null)
    .text(function(d) { return d.name; })
    .filter(function(d) { return d.x == 0; }) // at first column append text after column
    .attr("x", 6 + sankey.nodeWidth())
    .attr("text-anchor", "start");

function dragmove(d) {
  d3.select(this).attr("transform", "translate(" + d.x + "," + (d.y = Math.max(0, Math.min(height - d.dy, d3.event.y))) +  ")");
  sankey.relayout();
  link.attr("d", path);
}

What do I need to change to accomplish this?

A: Note
To be honest, I never used that plugin. I don't see an option to get the desired behaviour directly - thus I looked at the source of sankey.js to make the adjustments. Below I show how I'd modify - you might want to do it more thoroughly :)
Idea
Looking at the code of sankey.js, you see that the nodes are placed (y-direction) using the center function:
function center(node) {
  return node.y + node.dy / 2;
}

As I don't see a parameter to change that behaviour, you can change it to:
function center(node) {
  return 0;
}

If you then also revert the sorting order:
function ascendingDepth(a, b) {
  return b.y - a.y;
}

you get the following picture:


text:
Q: Refactor to smaller function, how? I have a function that loads a large selectlist for ASP.NET MVC.
This functions has a methodsize of 354 rows.
I want to refactor to more functions or to a local field so that each function will be less than 40 lines.
Here is the code snippet:
public static SelectList CreateShutterSpeedList()
        {
            var shutterSpeedList = new List<CameraSettingItem>();

            var secNotationPostfix = "\"";

            shutterSpeedList.Add(new CameraSettingItem
            {
                Id = ShutterSpeedDefaultValue,
                Description = string.Empty
            });

            shutterSpeedList.Add(new CameraSettingItem
            {
                Id = 1,
                Description = "30" + secNotationPostfix
            });

etc

Maybe a private list as a variable ? Or loading from file ? Or else...?

A: If IDs above ShutterSpeedDefaultValue are assigned sequentially, you could create an array of descriptions first, and then convert it to CameraSettingItem list with LINQ:
var descriptions = new[] {
    string.Empty
,   "30" + secNotationPostfix
,   ...
};
shutterSpeedList = descriptions
    .Select((d,i) => new CameraSettingItem {
        Id = i==0 ? ShutterSpeedDefaultValue : i
    ,   Description = d
    })
    .ToList();

You could also create a list of CameraSettingItems outside of your method's body, like this:
private const string secNotationPostfix = "\"";

private static IList<CameraSettingItem> shutterSpeedList = new List<CameraSettingItem> {
    new CameraSettingItem {
        Id = ShutterSpeedDefaultValue,
        Description = string.Empty
    },
    new CameraSettingItem {
        Id = 1,
        Description = "30" + secNotationPostfix
    },
    ...
};

public static SelectList CreateShutterSpeedList() {
    return new SelectList(shutterSpeedList, "Id", "Description");
}

A: You can store items that you need in JSON or XML files and deserialize them when you need using JavaScriptSerializer or Json.NET for example:
public static SelectList CreateShutterSpeedList(
{
    var json = File.ReadAllText(@"\ShutterSpeedList.json");
    var shutterSpeedList = JsonConvert.DeserializeObject<List<CameraSettingItem>>(json);
    // Convert shutterSpeedList to SelectList and return
}

Alternatively you can reduce number of lines by using collection initializer (as @dasblinkenlight pointed out) and constructors with optional parameters/object initializers if you have access to CameraSettingItem code:
public static SelectList CreateShutterSpeedList()
{
    var secNotationPostfix = "\"";
    var shutterSpeedList = new List<CameraSettingItem>
    {
        new CameraSettingItem(id: ShutterSpeedDefaultValue),
        new CameraSettingItem(id: 1, description: "30" + secNotationPostfix),
        ...
    };
    // Convert shutterSpeedList to SelectList and return
}


text:
Q: Yocto not (Skips) populating target openssl binaries in rootfs I am trying to add openssl_3.0.1 to my build. But when I bitbake openssl the binaries are build and installed in the tmp/**/image directory for eg: in the "/usr/bin". But when I build the whole system core image it doesn't get installed in the rootfs.
What might be the reason? I have tried install_append method to tell the build system to install this binaries specifically.
The following is my recipie
SUMMARY = "Secure Socket Layer"
DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools."
HOMEPAGE = "http://www.openssl.org/"
BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html"
SECTION = "libs/network"

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=c75985e733726beaba57bc5253e96d04"

SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
           file://run-ptest \
           file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \
           file://afalg.patch \
           file://0001-Configure-do-not-tweak-mips-cflags.patch \
           file://armv8-32bit.patch \
           file://0001-Fix-EVP_PKEY_CTX_get_rsa_pss_saltlen-no.patch \
           "

SRC_URI_append_class-nativesdk = " \
           file://environment.d-openssl.sh \
           "

SRC_URI[sha256sum] = "59eedfcb46c25214c9bd37ed6078297b4df01d012267fe9e9eee31f61bc70536"

inherit lib_package multilib_header multilib_script ptest perlnative
MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"

PACKAGECONFIG ?= ""
PACKAGECONFIG_class-native = ""
PACKAGECONFIG_class-nativesdk = ""

PACKAGECONFIG[cryptodev-linux] = "-DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS,-UHAVE_CRYPTODEV,cryptodev-linux"
PACKAGECONFIG[no-tls1] = "no-tls1"
PACKAGECONFIG[no-tls1_1] = "no-tls1_1"

B = "${WORKDIR}/build"
do_configure[cleandirs] = "${B}"

#| ./libcrypto.so: undefined reference to `getcontext'
#| ./libcrypto.so: undefined reference to `setcontext'
#| ./libcrypto.so: undefined reference to `makecontext'
EXTRA_OECONF_append_libc-musl = " no-async"
EXTRA_OECONF_append_libc-musl_powerpc64 = " no-asm"

# adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions
# (native versions can be built with newer glibc, but then relocated onto a system with older glibc)
EXTRA_OECONF_class-native = "--with-rand-seed=os,devrandom"
EXTRA_OECONF_class-nativesdk = "--with-rand-seed=os,devrandom"

# Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate.
CFLAGS_append_class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
CFLAGS_append_class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"

# This allows disabling deprecated or undesirable crypto algorithms.
# The default is to trust upstream choices.
DEPRECATED_CRYPTO_FLAGS ?= ""

do_configure () {
    os=${HOST_OS}
    case $os in
    linux-gnueabi |\
    linux-gnuspe |\
    linux-musleabi |\
    linux-muslspe |\
    linux-musl )
        os=linux
        ;;
    *)
        ;;
    esac
    target="$os-${HOST_ARCH}"
    case $target in
    linux-arc)
        target=linux-latomic
        ;;
    linux-arm*)
        target=linux-armv4
        ;;
    linux-aarch64*)
        target=linux-aarch64
        ;;
    linux-i?86 | linux-viac3)
        target=linux-x86
        ;;
    linux-gnux32-x86_64 | linux-muslx32-x86_64 )
        target=linux-x32
        ;;
    linux-gnu64-x86_64)
        target=linux-x86_64
        ;;
    linux-mips | linux-mipsel)
        # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags
        target="linux-mips32 ${TARGET_CC_ARCH}"
        ;;
    linux-gnun32-mips*)
        target=linux-mips64
        ;;
    linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el)
        target=linux64-mips64
        ;;
    linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*)
        target=linux-generic32
        ;;
    linux-powerpc)
        target=linux-ppc
        ;;
    linux-powerpc64)
        target=linux-ppc64
        ;;
    linux-powerpc64le)
        target=linux-ppc64le
        ;;
    linux-riscv32)
        target=linux-generic32
        ;;
    linux-riscv64)
        target=linux-generic64
        ;;
    linux-sparc | linux-supersparc)
        target=linux-sparcv9
        ;;
    mingw32-x86_64)
        target=mingw64
        ;;
    esac

    useprefix=${prefix}
    if [ "x$useprefix" = "x" ]; then
        useprefix=/
    fi
    # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the
    # environment variables set by bitbake. Adjust the environment variables instead.
    HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \
    perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} ${DEPRECATED_CRYPTO_FLAGS} --prefix=$useprefix --openssldir=${libdir}/ssl-3 --libdir=${libdir} $target
    perl ${B}/configdata.pm --dump
}

do_install () {
    oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install

    oe_libinstall -so libcrypto ${D}${libdir}
    oe_libinstall -so libssl ${D}${libdir}
    oe_libinstall -so libssl.so.3 ${D}${libdir}

    oe_multilib_header openssl/opensslconf.h
    oe_multilib_header openssl/configuration.h

    # Create SSL structure for packages such as ca-certificates which
    # contain hard-coded paths to /etc/ssl. Debian does the same.
    install -d ${D}${sysconfdir}/ssl
    mv ${D}${libdir}/ssl-3/certs \
       ${D}${libdir}/ssl-3/private \
       ${D}${libdir}/ssl-3/openssl.cnf \
       ${D}${sysconfdir}/ssl/

    # Although absolute symlinks would be OK for the target, they become
    # invalid if native or nativesdk are relocated from sstate.
    ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-3/certs
    ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-3/private
    ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-3/openssl.cnf
}

do_install_append_class-native () {
    create_wrapper ${D}${bindir}/openssl \
        OPENSSL_CONF=${libdir}/ssl-3/openssl.cnf \
        SSL_CERT_DIR=${libdir}/ssl-3/certs \
        SSL_CERT_FILE=${libdir}/ssl-3/cert.pem \
        OPENSSL_ENGINES=${libdir}/engines-3
}

do_install_append_class-nativesdk () {
    mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
    install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
    sed 's|/usr/lib/ssl/|/usr/lib/ssl-3/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
}

PTEST_BUILD_HOST_FILES += "configdata.pm"
PTEST_BUILD_HOST_PATTERN = "perl_version ="
do_install_ptest () {
    install -d ${D}${PTEST_PATH}/test
    install -m755 ${B}/test/p_test.so ${D}${PTEST_PATH}/test
    install -m755 ${B}/test/provider_internal_test.cnf ${D}${PTEST_PATH}/test

    # Prune the build tree
    rm -f ${B}/fuzz/*.* ${B}/test/*.*

    cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH}
    sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/configdata.pm
    cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH}

    # For test_shlibload
    ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/
    ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/

    install -d ${D}${PTEST_PATH}/apps
    ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps
    install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps
    install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps

    install -d ${D}${PTEST_PATH}/engines
    install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines
    install -m755 ${B}/engines/loader_attic.so ${D}${PTEST_PATH}/engines

    install -d ${D}${PTEST_PATH}/providers
    install -m755 ${B}/providers/legacy.so ${D}${PTEST_PATH}/providers

        install -d ${D}${PTEST_PATH}/Configurations
        cp -rf ${S}/Configurations/* ${D}${PTEST_PATH}/Configurations/

        # seems to be needed with perl 5.32.1
        install -d ${D}${PTEST_PATH}/util/perl/recipes
        cp ${D}${PTEST_PATH}/test/recipes/tconversion.pl ${D}${PTEST_PATH}/util/perl/recipes/

    sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/util/wrap.pl

}

# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto
# package RRECOMMENDS on this package. This will enable the configuration
# file to be installed for both the openssl-bin package and the libcrypto
# package since the openssl-bin package depends on the libcrypto package.

PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc"

FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}"
FILES_libssl = "${libdir}/libssl${SOLIBS}"
FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf \
                      ${libdir}/ssl-3/openssl.cnf* \
                      "
FILES_${PN}-engines = "${libdir}/engines-3"
# ${prefix} comes from what we pass into --prefix at configure time (which is used for INSTALLTOP)
FILES_${PN}-engines_append_mingw32_class-nativesdk = " ${prefix}${libdir}/engines-3"
FILES_${PN}-misc = "${libdir}/ssl-3/misc ${bindir}/c_rehash"
#FILES_${PN} =+ "${libdir}/ssl-3/* ${libdir}/ossl-modules/"
FILES_${PN} =+ "${libdir}/* ${bindir}/*"
FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"

CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf"

RRECOMMENDS_libcrypto += "openssl-conf"
RDEPENDS_${PN}-misc = "perl"
RDEPENDS_${PN}-ptest += "openssl-bin perl perl-modules bash"

RDEPENDS_${PN}-bin += "openssl-conf"

BBCLASSEXTEND = "native nativesdk"

CVE_PRODUCT = "openssl:openssl"

CVE_VERSION_SUFFIX = "alphabetical"

# Only affects OpenSSL >= 1.1.1 in combination with Apache < 2.4.37

I have also added the openssl in IMAGE_INSTALL


text:
Q: How to set the location of Figure of matplotlib I have some Figure objects of matplotlib (may be 6), and I want to show them at the same time. However, once I used plt.show(), they appeared at the same location in the screen(the center of the screen).
I want those Figures do not appear at the same place, it's better to arrange them like a 2*3 matrix. I don't want to solve this problem by showing the graphs in a figure which includes 6 axes.
How should I do?


text:
Q: Python Selenium Scrape with dropdown I am using python and selenium to scrape a website.  However I am having issues selecting an element from a dropdown list.  When I run this script on windows in the python IDE I can get my script to work:
listElement = driver.find_element_by_id('header-transactionTypeOptions')
transElement = driver.find_element_by_id('container-primary-4-transactionTypeOptions')
listElement.click()
time.sleep(2)
transElement.click()

<input id="header-transactionTypeOptions" class="jpui input header focus-on-header wrap right text-float-left   " type="button" aria-disabled="false" aria-expanded="false" aria-label=" SHOWING:: Activity since last statement" value="Activity since last statement">

However, when I run this on my ubuntu instance with pyvirtualdisplay it tells me it cannot locate the element.  In my research for using selenium with a drop down - the suggested answers are using "Select".  However there is no "Select ID" on the elements on this webpage.
I have include the elements below, as other options to reference in trying to find an answer:
<button id="iconButton-transactionTypeOptions" type="button" class="jpui input-icon icon text-overflow" aria-hidden="true" tabindex="-1"></button>

Jul 21, 2016 statement


text:
Q: Does attribute value "number" of "input" tag is critical for accessibility? The attribute number of input causes confusing during JavaScript validation and input filtration (discussed here). I am considering to use text attribute value (however with inputmode="numeric") when expect the numeric input from users. I see only one obstacle for now: accessibility. Does text value for numeric input fields impacts on accessibility?

A: I don't see any special accessibility problems with this approach - as long as the user is adequately informed about any 'bad' input (in line with the WCAG 3.3.x success criteria).
At a minimum, you should direct users to the specific field that has the erroneous input, and preferably give a clue what is wrong with it ("this field must contain only numbers"), rather than just reporting a blanket "this form is not filled out correctly".
Using inputmode="numeric" is a good ergonomic choice, and should prevent bad input from happening in those user agents that handle this attribute correctly.
You'll still have to convert the string to a numerical value later, of course.


text:
Q: Programmatically auto-connect to WiFi iOS I'm creating an app on Swift, and I need to know, if there's any way I can programatically auto connect an iPhone to a WiFi giving as paremeters the SSID and the Password from that WiFi Network.
Thanks in advance.

A: Below code will work on Xcode 9 and iOS 11
let WiFiConfig = NEHotspotConfiguration(ssid: "Mayur1",
                                                  passphrase: "123456789",
                                                  isWEP: false)

    WiFiConfig.joinOnce = false
    NEHotspotConfigurationManager.shared.apply(WiFiConfig) { error in
        // Handle error or success
        print(error?.localizedDescription)

A: Quotation from Apple Developer Documentation:

The NEHotspotHelper interface allows an app to participate in the process of joining Wi-Fi/hotspot networks. Such an app is referred to as a Hotspot Helper. A Hotspot Helper receives commands to be processed in the background that allow it to participate in the Hotspot Network state machine.

A: Not possible unfortunately! Too many issues that Apple would be not okay with. If you're working with a jailbroken device it may be possible (if it's not going on the app store, either)
Here's a question similar to yours you might want to look at


text:
Q: Using append in generic function inside Array extension I found this obscure problem when creating generic function inside Array extension. Let's say I have User class that I'll use to create array:
class User : NSObject {
    let name : String
    let surname : String

    init(name : String, surname : String) {
        self.name = name
        self.surname = surname
    }

    override var description : String {
        return self.name + " " + self.surname
    }
}

Note that I need it to be subclass of NSObject. Now let's create two users and add them to array of users.
var user1 = User(name: "Jimmy", surname: "Page")
var user2 = User(name: "David", surname: "Guilmour")

var users = Array<User>()
users.append(user1)
users.append(user2)

Now I need an Array extension with function specific to Array, or any other subclass of User, that will add some test users to any array of users. Reason I write it inside extension and not my own type is because i want to check it's type using if let something = something as [User]. If I build my own type I would not be able to do that.
extension Array {
    mutating func addTestUsers<T : User>() {
        var testUser1 = User(name: "King", surname: "Brown")
        var testUser2 = User(name: "Carlos", surname: "Santana")
        self.append(testUser1)
        self.append(testUser2)
    }
}

The problem comes when using append function or any other function that can somehow mutate the initial Array.
Error : Cannot invoke append with argument list of type (User)
I know it's because extension is never specified as extension of Array of User, but as I can see there is no way I can do this.

A: As suggested in @Martin R's comment, if you have a look at Array extension to remove object by value, the highest voted answer suggests writing a function that takes an array as an argument, in your case you could do something like:
func addTestUsers(inout array: [User]) {
    let user1 = User(name: "King", surname: "Brown")
    let user2 = User(name: "Carlos", surname: "Santana")
    array += [user1, user2]
}

You could then use this like so:
var array = [User(name: "Jimmy", surname: "Page")]
addTestUsers(&array) // [Jimmy Page, King Brown, Carlos Santana]

If you are intending to create subclasses of User, however, the previous method is unsuitable since you won't be able to pass an array of subclasses as the argument. In this situation you could override addTestUsers to accept your subclass, but a more elegant solution could be:
func addTestUsers<T: User>(inout array: [T]) {
    let user1 = T(name: "King", surname: "Brown")
    let user2 = T(name: "Carlos", surname: "Santana")
    array += [user1, user2]
}

For the previous function to work you need to mark init(name : String, surname : String) in User as required:
class User : NSObject {
    // ...
    required init(name : String, surname : String) {
        self.name = name
        self.surname = surname
    }
    // ...
}

Marking it as required means any subclasses of User must implement init(name : String, surname : String), therefore it's safe to use T(name: "...", surname: "...") in addTestUsers.


text:
Q: Python Concatenating Bytes Problems (2) So I am currently pulling information from a list to put into a bight array
for example:

street number 2894 ----> 2894 is built for a byte string b'\x28\x94

for some reason I am having a major problem trying to concatenate the b'\x' + 28 and 94 I tried:
RF_Pack = RF_Pack + b'\x' + Street_Num[i]

but got the error
PS C:\Users\kkelly\Desktop\AIM\b-AIM-1436> python reset_keys_proflex_08.12.2020_without_print.py ERM com12 proflex_config_file.txt
  File "reset_keys_proflex_08.12.2020_without_print.py", line 338
    RF_Pack = RF_Pack + b'\x' + PanArray[i]
                        ^
SyntaxError: (value error) invalid \x escape at position 0

it may be that what I am doing is illegal but I am unsure of another way around this.
***I also tried adding it to a starting byte string RF_Pack = b'\x36\67\x4R' and it prints out like b'\x01! any reason?
code used:
MyByte = b'\x01\x21\x2A'
streetnum= '2894'
streetnum = streetnum.encode('utf-8')
streetnumArray = [] #new list

for i in range(0,len(streetnum ),2): #separate string every two characters
   streetnumArray.append(streetnum [i:i+2]) #append into list
for i in range(0,len(streetnumArray)):
   MyByte= MyByte + b'\x' + streetnumArray[i]


text:
Q: XSL-FO : How do I repeat an xsl table for every page? I've done it previously by including the table in region-before AKA header section of xsl-fo. However, this introduces a problem of needing to dynamically set the margin-top of the region-body because the table's height is not fixed.
Hence, I would need to include it in region-body. I've found questions on this but they are only on how to repeat headers of a table. In my case, I need to repeat the whole table in each page. Is it possible? If so, how do I do that?
EDIT
Btw, I'm using FOP with Xalan

A: If you are using either Antenna House or FOP with either Saxon 9.5, Xalan, or DotNet 4.0 XSLT processors, then you can use the XSLT extensions from the Print and Page Layout Community Group @ W3C to run the FO processor in the middle of your XSLT transform.  See the examples at http://www.w3.org/community/ppl/wiki/XSLTExtensions
You can make a minimal FO document for rendering just the table, then run the extension functions on that to get an area tree containing the formatted table.  Lastly, you'd then adjust the margins for the fo:region-body based on the height of the formatted table.
If you don't have an XSLT processor that can run the extension functions but do have an FO processor that can produce area tree output, you could run the FO processor once to get the area tree for the table, then run it for real and have the XSLT transform use the previously generated area tree XML to work out the table height and the margins for fo:region-body.

A: Place the table you want to repeat in the header of another table. The table would be one cell wide and contain all the body content. Because the table is in the header it will repeat on each page tha the body table content flows to. This would work only if you have content for the body that is one column.


text:
Q: Toggle current class using jquery I want to toggle .title class when we click on .title .content class toggle.Here i written this classes inside .I want to be toggle .title in a current class. I tried but not getting. Can anyone suggest me what might be the issue here?

$(document).ready(function() {
  $('.title').click(function() {
    $(this).find('.content').slideToggle();
  });
});
.content {
  display: none;
}

The Establishment

Ascetur ridiculus mus. Suspendisse pellentesque convallis massa.

150 Employee

Pellentesque habitant morbi tristique senectus.

A: $(this).find will look for content inside of that element.
$(this).parent().find will look for the content inside of the elements parent
$(this).parent().find('.content').slideToggle();

A: Use parent to find class content.

$(document).ready(function() {
  $('.title').click(function() {
    $(this).parent().find('.content').slideToggle();
  });
});
.content {
  display: none;
}

The Establishment

Ascetur ridiculus mus. Suspendisse pellentesque convallis massa.

150 Employee

Pellentesque habitant morbi tristique senectus.

Alternative way using next:

$(document).ready(function() {
  $('.title').click(function() {
    $(this).next('div').slideToggle();
  });
});
.content {
  display: none;
}

The Establishment

Ascetur ridiculus mus. Suspendisse pellentesque convallis massa.

150 Employee

Pellentesque habitant morbi tristique senectus.

A: You were find in title tag but first you should select parent then you find which one you want to select.
I think you want like this:

$(document).ready(function() {
  $('body').on('click','.title', function() {
    $(this).parent('li').find('.content').slideToggle();
  });
});
.content {
 display:none;
}

The Establishment

Ascetur ridiculus mus. Suspendisse pellentesque convallis massa.

150 Employee

Pellentesque habitant morbi tristique senectus.

A: you can do this
if($('...').hasClass('content')) {
    $('...').addClass('title').removeClass('content');
}

if($('...').hasClass('title')) {
    $('...').addClass('content').removeClass('title');
}

A: You could also use the siblings as
$(document).ready(function() {
  $('.title').click(function(e) {
    $(this).siblings('.content').slideToggle();
  });
});

instead of going up the parent. next is also an option as mentioned already.


text:
Q: Zend Framework: How do I remove the decorators on a Zend Form Hidden Element? I'm trying to remove the default decorators on a hidden form element. By default, the hidden element is displayed like this:

Hidden Element Label (if I had set one)

<input type="hidden" name="foobar" value="1" id="foobar">

I don't want my hidden element to take up space on my page. I want to remove all the default decorators so all I'm left with is the input tag.
<input type="hidden" name="foobar" value="1" id="foobar">

How can I achieve this?

A: // based on above - a simple function to add a hidden element to $this form
/**
 * Add Hidden Element
 * @param $field
 * @param value
 * @return nothing - adds hidden element
 * */
public function addHid($field, $value){
    $hiddenIdField = new Zend_Form_Element_Hidden($field);
    $hiddenIdField->setValue($value)
          ->removeDecorator('label')
          ->removeDecorator('HtmlTag');
    $this->addElement($hiddenIdField);
}

A: When you have a lot of hidden inputs best answer is the following:
$elements = $this->getElements();
foreach ($elements as $elem)
    if ($elem instanceof Zend_Form_Element_Hidden)
        $elem->removeDecorator('label')->removeDecorator('HtmlTag');

A: For hidden field you need only one decorator - ViewHelper:
$field = new Zend_Form_Element_Hidden('id');
$field->setDecorators(array('ViewHelper'));

This will render only the input field, without Dt-Dd wrapper and label.

A: As mentioned in other posts setDisableLoadDefaultDecorators(true) doesn't work if they're already loaded... BUT clearDecorators() does!

A: From the Zend Element Decorators documentation:

Default Decorators Do Not Need to Be
  Loaded
By default, the default decorators are
  loaded during object initialization.
  You can disable this by passing the
  'disableLoadDefaultDecorators' option
  to the constructor:
$element = new Zend_Form_Element('foo',
    array('disableLoadDefaultDecorators' => true)
);

A: I couldn't get disableLoadDefaultDecorators to work quite right. Here's a solution I came up with.
$hiddenIdField = new Zend_Form_Element_Hidden('id');
$hiddenIdField->setValue($portalId)
              ->removeDecorator('label')
              ->removeDecorator('HtmlTag');

In the HTML, the hidden field appears without any extra tags around it.
...

Password

<input type="password" name="password" id="password" value="" />

<input type="hidden" name="id" value="1" id="id" />
...

A: I use this
$element->removeDecorator('DtDdWrapper');

to get rid of the dt dd tags around specific elements

A: here is what takeme2web from http://www.phpfreaks.com/forums/index.php?topic=225848.0
suggests
$yourhiddenzendformelement->setDecorators(array('ViewHelper'));

A: Using only a single "ViewHelper" decorator will generate invalid markup if you're still using the
 wrapper. Another approach is outlined in ZF-2718. This adds hidden fields to a subform that is wrapped in a
.

A: Well, 2012 and still the same issue. If you remove the decorators, the html won't validate. If you leave them, the hidden elements take up space. In all of my projects I have a CSS helper .hidden, so I just apply it to the
 and unset the label:
$element = new Zend_Form_Element_Hidden('foo', array('value' => 'bar'));
$element->removeDecorator('Label');
$element->getDecorator('HtmlTag')->setOption('class', 'hidden');

Valid html(5), nice looking forms. This can also go into a custom decorator for the hidden fields.
EDIT
This is how I put it into my own form element:
class Exanto_Form_Element_Hidden extends Zend_Form_Element_Hidden
{
    public function render(Zend_View_Interface $view = null)
    {
        $this->removeDecorator('Label');
        $this->getDecorator('HtmlTag')->setOption('class', 'hidden');
        return parent::render($view);
    }
}

A: Use this:
    foreach ($this->getElements() as $element) {

        $decorator = $element->getDecorator('label');
        if (!$decorator) {
            continue;
        }
        $decorator->removeOption('tag');
    }


text:
Q: How to prove in a concise way that $\{f(kz):k \in \mathbb{C}\}$ is a normal family? I am trying to prove the following statement:
If $f(z)$ is entire, show that the family formed by all the functions $f(kz)$ with constant k is normal in the annulus $r_1 < |z|<r_2$ If and only if $f$ Is a polynomial.
I have been trying to write, unsuccessfully, a concise proof of this fact just using Arzela-Ascoli, Montel's theorem, Marty's theorem or results in this line.
Thank you for your help.

A: This is not at all true. If $f(z)=z$ then  the given  family is not normal. Normailty demands that the functions are uniformly  bounded on any compact subset of the annulus. But $\{kz: k \in \mathbb C\}$ is not bounded even on one-point sets.
Actually the given family is normal iff $f$ is a constant.

A: Let's prove that if $f$ is entire and there is an annulus $r < |z| <R$ s.t the family $f(az), a \in \mathbb C$ is normal (in the extended sense where we allow compact divergence to infinity too), then $f$ is a polynomial. Let $A$ be the closed annulus $r+\delta \le |z| \le R-\delta$ for small enough $2\delta <R-r$.
We can assume wlog $f$ is not constant and we will prove that $f$ takes any value finitely many times only. This clearly implies $f$ polynomial.
Pick $w$ complex and assume $f(z)=w$ has infinitely many roots $z_n$. Clearly $z_n \to \infty$ since $f$ nonconstant, so there is $a_n \to \infty$, $\frac{z_n}{a_n}=y_n \in A$. But then $f(a_nz)-w$ has a zero at $y_n \in A$, so by normality if we take a subsequence of $f(a_nz)-w \to g$ uniformly on compact subsets of the original annulus, hence in particularly on $A$, $g(y)=0$ for any $y \in A$ limit point of $y_n$ with $n$ in the respective subsequence. On the other hand if $f(a_nz)-w$ hence $f(a_nz)$ is uniformly bounded by some $M$ on $A$, it follows by maximum modulus that $f$ is bounded in the plane as $a_n \to \infty$ and that implies $f$ constant which is not possible, so  any subsequence of $f(a_nz)-w$ must diverge compactly to infinity on $A$, so $g$ constructed above must be identically infinity, which contradicts the fact that $g(y)=0$. Done!


text:
Q: Can I use Javascript to mix multiple audio files into one audio? The Question:
Can I use Javascript to mix multiple audio files into one audio?
For example, I have a long people voice and a short background voice, and I need to get mixed audio which the background voice will play until people voice finish.
Is there any way that I achieve this with Javascript?
What I do:
I trying some audio third library like Tone.js and Howler.js, but still can't have any progress
If someone knows this, I will be very grateful, thinks.

A: ffmpeg.js meets your needs. This library provides FFmpeg builds ported to JavaScript

For browers:
Play two audios
Listen to the end event of previous audio, and play next audio.
Ensure audios are loaded in advance and check if there is a blank frame where the two audios are connected.
Another way, play the second audio a few millseconds early.
Concat two audios
Use AudioContext API to concat two audio buffers. Refer to Web Audio API append/concatenate different AudioBuffers and play them as one song


text:
Q: Cross-Origin Read Blocking for steam market api I'm trying to make an js app that gets the price of the Steam's "Sack of Gems" on their comunity market.
I need to download / parse the JSON in https://steamcommunity.com/market/priceoverview/?currency=0&appid=753&market_hash_name=753-Sack%20of%20Gems .
I tried jquery's $.getJSON, fully-js JSONP, and more.
full js JSONP:
<script>
function getJSONP(url, success) {
     var ud = '_' + +new Date,
          script = document.createElement('script'),
          head = document.getElementsByTagName('head')[0]
               || document.documentElement;

     window[ud] = function(data) {
          head.removeChild(script);
          success && success(data);
     };

     script.src = url.replace('callback=?', 'callback=' + ud);
     head.appendChild(script);
}

function button () {
     alert('Start!');
     getJSONP('https://steamcommunity.com/market/priceoverview/?currency=0&appid=753&market_hash_name=753-Sack%20of%20Gems&callback=?', function(data){
     console.log(data);
     });
}

</script>

I'm always getting this error:
steam_gem_calculator.html:100 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://steamcommunity.com/market/priceoverview/?currency=0&appid=753&market_hash_name=753-Sack%20of%20Gems&callback=_1569097351408 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
but i want the data to be logged in the console.
EDIT: Is it possible because i'm testing by viewing the file?

A: you have two solutions:

*

*use proxy

*install an extension to your browser that allow access origin; I suggest you cors everywhere extension (for short time solution)


text:
Q: How do I make the aside have the width of the remaining area? I have a simple page with content on the left and an aside on the right. I would like the div on the left to be 70% of the width of the container and then the aside take up the rest of the space, but I can't figure out how to give it a variable width.
I've tried setting the width of the aside to be 30%, but that doesn't leave any room for the 24px of space I'd like between the div and the aside. I also tried setting the width of the aside to be 28% and that gets it close, but I figured there's a more precise way of doing it.
Here's a simple example:

.container {
  width: 80%;
  margin: auto;
  background-color: #ccc;
  height: 500px;
  padding: 24px;
}
.left {
  background-color: white;
  width: 70%;
  height: 100%;
  float: left;
}
.right {
  background-color: white;
  width: 28%;
  height: 100%;
  float: right;
}

A: Without getting into Sass, you can use the CSS calc(); function.
Note that in the CSS below, I'm keeping your 28% value for graceful degradation on older browsers that do not support calc() (Old Android browsers, Opera Mini and IE8-).
Live example here.
.container {
  width: 80%;
  margin: auto;
  background-color: #ccc;
  height: 500px;
  padding: 24px;
}
.left {
  background-color: white;
  width: 70%;
  height: 100%;
  float: left;
}
.right {
  background-color: white;
  width: 28%;
  width: calc(30% - 24px);
  height: 100%;
  float: right;
}

A: Ok, how about this:
http://jsfiddle.net/9fy6txpa/
.left {
  background-color: white;
  width: 70%;
  height: 100%;
  float: left;
  border-right:24px solid #ccc;
  box-sizing:border-box;
}

Set the widths to 70% and 30% as desired.  Instead of having a margin/padding between the div and the aside, give the div a 24px wide right-border and then change it's box-sizing property to border-box.  That way, it's width will be 70% including the added border (a total width of 70%, not 70% plus the border as the default box model does).