text:
Q: difference between API and framework what is the difference between these two terms, thanks in advance for any good simplifications and good examples.

A: An API is an interface to a (set of) component(s) encapsulating a functionality. For instance, the GoogleMaps API, the DirectX or OpenGL APIs.
A framework is more a set of tools, components aimed at helping the developer to develop his/her project in a given Frame. The framework usually sets some coding standards, provides useful components, ... For instance, Symfony/Cake are PHP web application frameworks. JUnit is a framework for unit tests in Java, ...
Frameworks can often bundle/provide a unified interface to some APIs.
Some APIs can be internally built using a framework.

A: A framework is a group of classes, interfaces and other pre-compiled code upon which or by the use of which applications can be built.
The API is the public face of a framework.  A well designed framework only exposes those classes, interfaces, etc that are needed to use the framework.  Code that supports the operation of the framework but that is not necessary to users of the framework is kept internal to the framework's assemblies/dlls.  This keeps the public face of the framework small and encourages a "pit of success," or the quality of a framework which makes it simple to do the right thing.
(I provide an example from the .NET world)
The SqlConnection class is used to connect to a Sql Server instance.  Its public API is pretty simple:
using (SqlConnection connection = new SqlConnection(connectionString))
{
    connection.Open();
    // Do work here; connection closed on following line.
}

However, this class depends on around 200 methods within the System.Data framework (in this case, an assembly), 3/4 of which are internal and not part of the public API of System.Data.  Because the framework's API is kept simple, it becomes easy to use SqlConnection properly.  If the user was required to deal with SqlConnectionFactory, SqlDebugContext, DbConnectionPoolGroup or any of the other internal classes required by the SqlConnection class, it would become exponentially more difficult to use SqlConnection properly.  Because the API only exposes a small percentage of the framework, it is easier to create and use a connection.

A: *

*API - application programming interface -> the contract you must obey when using a library's API

*library - a set of classes/modules that solve a specific problem -> has an API

*framework - a "bigger" set of libraries with a set of rules on how to use them

Since every library has an API, no point in giving examples.
A popular Java library for time is Joda time.
A popular Java framework is the Spring framework.
You must obey a lot of rules to use Spring well. You don't have to obey as many rules to use Joda time.

A: An API is something code has, not something it is. A framework has an API, but it is not itself an API.

A: *

*API "Application Programming Interface" is set of prewritten packages, classes and interfaces with their respective methods. You can use it without much concern about internal implementations. API is used an interface between two or more applications and like REST API.

*Framework is a skeleton that contains design patterns, classes, interfaces and libraries that can be used to build applications. Framework provides inversion of control which give the responsibility of program flow to the framework itself, also we can extend the framework without changing its predefined code. For example Spring is a framework that can be used to build web applications.

A: API's are pre-built-in from SDK (or from which you can include on to). Frameworks are loadable bundles wherein exposed functions of such bundles can be used. You can acquire expose functions of those frameworks by using pointer to functions.
Example:
API:
-stringWithString:

function from framework:
-myExposedMethod:

A: Framework is use to design an application, ie MVC, MEF.  Like a model that you build on, almost a base for a certain set of functionality that you might want in your application.
API is for interaction between applications, your app would use the Facebook API to interact with Facebook.
Hope this is a bit more clear.

A: *

*Java API simply means ...Application Programming Interface in which all the features describes of product or software.

*Java Framework means semi-completed project or code. It provides an architecture to make project . Framework have own classes and methods etc..

A: An API is simply a library built with a particular language that developers can use to build applications.
Frameworks are a set of libraries, just like APIs however the syntaxes may deffer of the original language. So the developer may be writing a different syntax of PHP for example when using Symphony.

A: The main or core difference beteen framework and API is that framework allows developer to hook into the life cycle of the objects through lifecycle callback methods mechanism whereas API doesn't do that, API is only intended to perform a functionality only.

A: Another way to visualize it is this: (true of any programming language)
Any(!) "piece of software that is intended to be used by another piece of software" by-definition must have some "application program interface (API)," which represents the "knobs, switches and dials" that the other piece of software is expected (and, permitted) to use.  All of the internal implementation details are not visible and cannot be reached.
"Frameworks" are tools that are designed to make it easier for humans to write a particular, common, type of application – such as a web-page.  The framework implements "the stuff that every such application is going to need to be able to do," and does it in one, well-tested way, "precisely so that you (the application author) don't have to." Instead of redundantly writing "the same old thing, one more time, and fretting over whether you did it correctly," you simply leverage what the framework has already done for you.
After all...

Actum Ne Agas: Do Not Do A Thing Already Done.


text:
Q: Error Could not find or load main class -jar I am working on a java UNO project, OS : Ubuntu 14. I am calling exec via passing command to run via a jar file with some set of sub commands of that jar file.
String finalOutputMSG = "";

  String[] cmd = {JAVA_LOCATION, " -jar ", JAR_LOCATION, " " + inputFile, " -dir ", ".isc", " -out xml"};//java location provides java location, jar location provides jar location, inputfile contains input file's location -dir provides output directory with name .isc, -out is output file with file format for output is xml

Similar command ran properly without showing any errors but in a case where I am trying to import a file and convert it into another format eg .xlsx to .xml, is giving error. In commands it worked, I have already generated outputs from an input file.
     finalOutputMSG = exec(cmd);

     /**
     * exec() is executed and outputs are displayed
     *
     * @param String[] command passed to jar
     * @return output message containing outputs or output message
     */
      private static String exec(String[] cmd) {

            String outputMSG = "";

        Process proc = null;
        try {
            ProcessBuilder pb = new ProcessBuilder(cmd);
            pb.redirectErrorStream(true);//any error output generated by subprocesses merged with the standard output,
            //read using the Process.getInputStream()
///* Start the process */
            proc = pb.start();
            if (debug) {
                System.out.println("Process started !");
            }

            outputMSG = getOutput(proc);
            if (debug) {
                System.out.println("outputMSG " + outputMSG);
            }
        } catch (IOException e) {
            if (debug) {
                System.out.println("Exception in exec " + e.getMessage());
                JOptionPane.showMessageDialog(null, "Exception in exec ");
            }
//            StringBuilder append = appendToFile.append("Exception in exec ").append(e.getMessage());

        } catch (Exception e) {
            if (debug) {
                System.out.println("Exception in exec " + e.getMessage());
                JOptionPane.showMessageDialog(null, "Exception in exec ");
            }
        } finally {
            ///* Clean-up */
            proc.destroy();
            if (debug) {
                System.out.println("Process ended !");
            }
        }
        return outputMSG;
    }
    /**
     * Reads output from current process
     *
     * @param current process
     * @return output read in current process
     */
    private static String getOutput(Process p) {
        StringBuilder outStream = new StringBuilder();
        if (debug) {
            System.out.println("StringBuilder initialized in getOutput");
        }
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
            if (debug) {
                System.out.println("BufferedReader initialized in getOutput");
            }
            String line = null;
            if (debug) {
                System.out.println("in.readLine() in getOutput abt to be read");
            }

            while ((line = in.readLine()) != null) {
                outStream.append(line);
                if (debug) {
                    System.out.println("line in getOutput " + line);
                    System.out.println("outStream in getOutput " + outStream);
                }
                outStream.append("\n");
            }
        } catch (IOException e) {
            if (debug1) {
                System.out.println("IOException in getOutputs " + e.getMessage());
            }

        } catch (Exception ex) {
            if (debug1) {
                System.out.println("Exception in getOutputs" + ex.getMessage());
            }
        }
        return outStream.toString();
    }

Error Message depicted by Netbeans
Error: Could not find or load main class  -jar
I have searched on the issue, but could not find any help that is useful, I could not understand, what is missing.

A: Solution:
String[] cmd = {JAVA_LOCATION, " -jar ", JAR_LOCATION, " " + inputFile, " -dir ", ".isc", " -out xml"};

I replaced the values that printed in console, and ran the command so got on terminal, it worked fine.
Solution: the command to be used must be without any spaces in the ends. Because terminal in linux interprets the commands like for "ls", but in java/ any programming language, it doesn't interprets for ls, so in case of the following parameter cmdarray
public Process exec(String[] cmdarray)
             throws IOException

takes the command as it is.
String[] cmd = {JAVA_LOCATION, "-jar", JAR_LOCATION, inputFile, "-dir",  ".isc", "-out", "xml"};

redpajama_set_name: RedPajamaStackExchange


text:
Q: need max, min, avg value for duplicate keys in tuple, as well as count of keys Using python, I am trying to figure out how to extract unique keys from a list of tuple pairs, with the highest, lowest and average values, as well as a count of how many keys, for example with this list:
[('a', 1), ('b', 3,), ('a', 9), ('b', 0), ('b', 9), ('a', 10), ('c', 2)]

I need to extract this information:
a: max = 10, min = 1, avg = 7 count = 3
b: max = 9, min = 0, avg = 4 count = 3
c: max = 2, min = 2, avg = 2, count = 1

A: You can use a defaultdict to gather the information.
from collections import defaultdict

data = [('a', 1), ('b', 3,), ('a', 9), ('b', 0), ('b', 9), ('a', 10), ('c', 2)]

pool = defaultdict(list)
for key, value in data:
    pool[key].append(value)

print(pool)

You should have no problem to implement the calculation of min, max and average (sum/len) for yourself.

A: Your target looks like a dictionary of dictionaries. So build dictionary taking the 1st element of each tuple as a key. Iterate through the tuples and build up the values for each.
You should end up with something like:
tally = {'a': {'count': 3, 'max': 10, 'avg': 7, 'min': 1}, ... etc.}


text:
Q: Django Template Render Included Variable My question is basically on rendering variables. For example, let's say I have an object block, where block.text='{{ "hello"|trans }}'
I want to include this into my base template. The following will obviously not work for what I intend.
{% include block.text %}

How might I render this into my template?

A: It does not seem a good idea generate dynamic templates from view side to render into a template.
But remember do you have other elegant approach like:

*

*Inclusion tags Is type of template tag that displays some data by rendering another template.

*Include "Loads a template and renders it with the current context."

Also, take in mind, that you can use IF statement into a template to include or not include some template and, also, you can pass additional context to the included template using keyword arguments (ex: {% include "name_snippet.html" with person="Jane" greeting="Hello" %} ).


text:
Q: Logs not coming for endpoint being created in sagemaker I am trying to create an endpoint via sagemaker. The status of the endpoint goes to failed with the message "The primary container for production variant variantName did not pass the ping health check. Please check CloudWatch logs for this endpoint".
But there are no logs created to check.
Blocked on this from quite some time, is anyone aware why this could be happening

A: You have missed defining the ping() method in your model_handler.py file.
The model_handler.py file must define two methods, like this -
custom_handler = CustomHandler()

# define your own health check for the model over here
def ping():
    return "healthy"

def handle(request, context): # context is necessary input otherwise Sagemaker will throw exception
    if request is None:
        return "SOME DEFAULT OUTPUT"
    try:
        response = custom_handler.predict_fn(request)
        return [response] # Response must be a list otherwise Sagemaker will throw exception

    except Exception as e:
        logger.error('Prediction failed for request: {}. \n'
                     .format(request) + 'Error trace :: {} \n'.format(str(e)))

You should look at the reference code in the accepted answer here.


text:
Q: Using Sphider search engine and robots.txt I've installed the Sphider 1.3.5 search engine on the site I'm developing. I'm working on a shared host (Dreamhost), and everything seemed to have installed fine and is working properly, save for one problem.
Sphider seems to be ignoring my robots.txt file. I've validated robots.txt syntax successfully, checked and rechecked my paths to ensure they were correct, reindexed the site in the admin area time and again, and no matter what I do Sphider won't stay out of my supposedly disallowed files.
Here is the text of the file:
# robots.txt for http://redesign.ladottransit.com/

User-agent: *
Disallow: /sphider-1.3.5/
Disallow: /whatsnew/
Disallow: /css/
Disallow: /js/
Disallow: /Library/
Disallow: /formtoemail/
Disallow: /Templates/
Disallow: /tmp/ # these will soon disappear
Disallow: /cc_thanks.html
Disallow: /index_static.html
Disallow: /comexp/routes/142/142_sked_all.php
Disallow: /comexp/routes/142/142_sked_ebwd.php
Disallow: /comexp/routes/142/142_sked_ebwe.php
Disallow: /comexp/routes/142/142_sked_wbwd.php
Disallow: /comexp/routes/142/142_sked_wbwe.php
Disallow: /comexp/routes/142/142_smap.php
Disallow: /comexp/routes/142/142_imap.php
Disallow: /comexp/routes/409/409_sked_all.php
Disallow: /comexp/routes/409/409_sked_downtown.php
Disallow: /comexp/routes/409/409_sked_glendale.php
Disallow: /comexp/routes/409/409_smap.php
Disallow: /comexp/routes/409/409_imap.php
Disallow: /comexp/routes/419/419_sked_all.php
Disallow: /comexp/routes/419/419_sked_chatsworth.php
Disallow: /comexp/routes/419/419_sked_downtown.php
Disallow: /comexp/routes/419/419_smap.php
Disallow: /comexp/routes/419/419_imap.php
Disallow: /comexp/routes/422/422_sked_all.php
Disallow: /comexp/routes/422/422_sked_hollywood.php
Disallow: /comexp/routes/422/422_sked_sanfernandovalley.php
Disallow: /comexp/routes/422/422_smap.php
Disallow: /comexp/routes/422/422_imap.php
Disallow: /comexp/routes/423/423_sked_all.php
Disallow: /comexp/routes/423/423_sked_encino.php
Disallow: /comexp/routes/423/423_sked_hollywood.php
Disallow: /comexp/routes/423/423_smap.php
Disallow: /comexp/routes/423/423_imap.php
Disallow: /comexp/routes/431/431_sked_all.php
Disallow: /comexp/routes/431/431_sked_downtown.php
Disallow: /comexp/routes/431/431_sked_westwood.php
Disallow: /comexp/routes/431/431_smap.php
Disallow: /comexp/routes/431/431_imap.php
Disallow: /comexp/routes/437/437_sked_all.php
Disallow: /comexp/routes/437/437_sked_culvercity.php
Disallow: /comexp/routes/437/437_sked_downtown.php
Disallow: /comexp/routes/437/437_smap.php
Disallow: /comexp/routes/437/437_imap.php
Disallow: /comexp/routes/438/438_sked_all.php
Disallow: /comexp/routes/438/438_sked_downtown.php
Disallow: /comexp/routes/438/438_sked_redondo.php
Disallow: /comexp/routes/438/438_smap.php
Disallow: /comexp/routes/438/438_imap.php
Disallow: /comexp/routes/448/448_sked_all.php
Disallow: /comexp/routes/448/448_sked_downtown.php
Disallow: /comexp/routes/448/448_sked_ranchopv.php
Disallow: /comexp/routes/448/448_smap.php
Disallow: /comexp/routes/448/448_imap.php
Disallow: /comexp/routes/534/534_sked_all.php
Disallow: /comexp/routes/534/534_sked_downtown.php
Disallow: /comexp/routes/534/534_sked_westla.php
Disallow: /comexp/routes/534/534_smap.php
Disallow: /comexp/routes/534/534_imap.php
Disallow: /comexp/routes/549/549_sked_all.php
Disallow: /comexp/routes/549/549_sked_burbank.php
Disallow: /comexp/routes/549/549_sked_glendale.php
Disallow: /comexp/routes/549/549_imap.php
Disallow: /comexp/routes/549/549_smap.php
Disallow: /comexp/routes/573/573_sked_all.php
Disallow: /comexp/routes/573/573_sked_encino.php
Disallow: /comexp/routes/573/573_sked_westwood.php
Disallow: /comexp/routes/573/573_smap.php
Disallow: /comexp/routes/573/573_imap.php
Disallow: /comexp/routes/574/574_sked_all.php
Disallow: /comexp/routes/574/574_sked_encino.php
Disallow: /comexp/routes/574/574_sked_lax.php
Disallow: /comexp/routes/574/574_smap.php
Disallow: /comexp/routes/574/574_imap.php
Disallow: /comexp/routes/UnionBunker/unionbunker_sked_all.php
Disallow: /comexp/routes/UnionBunker/unionbunker_sked_wdam.php
Disallow: /comexp/routes/UnionBunker/unionbunker_sked_wdpm.php
Disallow: /comexp/routes/UnionBunker/unionbunker_gmap.php
Disallow: /comexp/routes/UnionBunker/unionbunker_imap.php
Disallow: /comexp/routes/UnionBunker/unionbunker_smap.php
Disallow: /dash/routes/beachwood/beachwood_sked_all.php
Disallow: /dash/routes/beachwood/beachwood_sked_tohollywood.php
Disallow: /dash/routes/beachwood/beachwood_sked_tohollywood_sat.php
Disallow: /dash/routes/beachwood/beachwood_sked_tosunset.php
Disallow: /dash/routes/beachwood/beachwood_sked_tosunset_sat.php
Disallow: /dash/routes/beachwood/beachwood_imap.php
Disallow: /dash/routes/beachwood/beachwood_smap.php
Disallow: /dash/routes/beachwood/beachwood_gmap.php
Disallow: /dash/routes/boyleheights/boyleheights_sked_all.php
Disallow: /dash/routes/boyleheights/boyleheights_sked_north_sat.php
Disallow: /dash/routes/boyleheights/boyleheights_sked_north_weekday.php
Disallow: /dash/routes/boyleheights/boyleheights_sked_south_sat.php
Disallow: /dash/routes/boyleheights/boyleheights_sked_south_weekday.php
Disallow: /dash/routes/boyleheights/boyleheights_imap.php
Disallow: /dash/routes/boyleheights/boyleheights_gmap.php
Disallow: /dash/routes/boyleheights/boyleheights_smap.php
Disallow: /dash/routes/chesterfield/chesterfield_sked_all.php
Disallow: /dash/routes/chesterfield/chesterfield_sked_ebwd.php
Disallow: /dash/routes/chesterfield/chesterfield_sked_ebwe.php
Disallow: /dash/routes/chesterfield/chesterfield_sked_wbwd.php
Disallow: /dash/routes/chesterfield/chesterfield_sked_wbwe.php
Disallow: /dash/routes/chesterfield/chesterfield_imap.php
Disallow: /dash/routes/chesterfield/chesterfield_gmap.php
Disallow: /dash/routes/chesterfield/chesterfield_smap.phpchesterfield_sked_all.php
Disallow: /dash/routes/crenshaw/crenshaw_sked_all.php
Disallow: /dash/routes/crenshaw/crenshaw_sked_ccw.php
Disallow: /dash/routes/crenshaw/crenshaw_sked_ccwsat.php
Disallow: /dash/routes/crenshaw/crenshaw_sked_cw.php
Disallow: /dash/routes/crenshaw/crenshaw_sked_cwsat.php
Disallow: /dash/routes/crenshaw/crenshaw_imap.php
Disallow: /dash/routes/crenshaw/crenshaw_gmap.php
Disallow: /dash/routes/crenshaw/crenshaw_smap.php
Disallow: /dash/routes/downtown/downtown_sked_all.php
Disallow: /dash/routes/downtown/downtown_sked_a.php
Disallow: /dash/routes/downtown/downtown_sked_b.php
Disallow: /dash/routes/downtown/downtown_sked_d.php
Disallow: /dash/routes/downtown/downtown_sked_e.php
Disallow: /dash/routes/downtown/downtown_sked_f.php
Disallow: /dash/routes/downtown/downtown_we_sked_e.php
Disallow: /dash/routes/downtown/downtown_we_sked_f.php
Disallow: /dash/routes/downtown/downtown_imap.php
Disallow: /dash/routes/downtown/downtown_gmap.php
Disallow: /dash/routes/downtown/downtown_smap.php
Disallow: /dash/routes/elsereno/elsereno_sked_all.php
Disallow: /dash/routes/elsereno/elsereno_sked_nbsat.php
Disallow: /dash/routes/elsereno/elsereno_sked_nbsun.php
Disallow: /dash/routes/elsereno/elsereno_sked_nbwd.php
Disallow: /dash/routes/elsereno/elsereno_sked_sbsat.php
Disallow: /dash/routes/elsereno/elsereno_sked_sbsun.php
Disallow: /dash/routes/elsereno/elsereno_sked_sbwd.php
Disallow: /dash/routes/elsereno/elsereno_gmap.php
Disallow: /dash/routes/elsereno/elsereno_imap.php
Disallow: /dash/routes/elsereno/elsereno_smap.php
Disallow: /dash/routes/fairfax/fairfax_sked_all.php
Disallow: /dash/routes/fairfax/fairfax_sked_robertson.php
Disallow: /dash/routes/fairfax/fairfax_sked_robertson_sat.php
Disallow: /dash/routes/fairfax/fairfax_sked_wilshire.php
Disallow: /dash/routes/fairfax/fairfax_sked_wilshire_sat.php
Disallow: /dash/routes/fairfax/fairfax_gmap.php
Disallow: /dash/routes/fairfax/fairfax_imap.php
Disallow: /dash/routes/fairfax/fairfax_smap.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_sked_all.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_sked_ebwd.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_sked_ebwe.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_sked_wbwd.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_sked_wbwe.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_gmap.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_imap.php
Disallow: /dash/routes/HighlandPark_EagleRock/highland_smap.php
Disallow: /dash/routes/hollywood/hollywood_sked_all.php
Disallow: /dash/routes/hollywood/hollywood_sked_ccw.php
Disallow: /dash/routes/hollywood/hollywood_sked_ccw_ssh.php
Disallow: /dash/routes/hollywood/hollywood_sked_cw.php
Disallow: /dash/routes/hollywood/hollywood_sked_cw_ssh.php
Disallow: /dash/routes/hollywood/hollywood_gmap.php
Disallow: /dash/routes/hollywood/hollywood_imap.php
Disallow: /dash/routes/hollywood/hollywood_smap.php
Disallow: /dash/routes/hollywood_wilshire/hollywilshire_sked_all.php
Disallow: /dash/routes/hollywood_wilshire/hollywilshire_sked_larchmont.php
Disallow: /dash/routes/hollywood_wilshire/hollywilshire_sked_north.php
Disallow: /dash/routes/hollywood_wilshire/hollywilshire_sked_south.php
Disallow: /dash/routes/hollywood_wilshire/hollywilshire_gmap.php
Disallow: /dash/routes/hollywood_wilshire/hollywilshire_imap.php
Disallow: /dash/routes/hollywood_wilshire/hollywilshire_smap.php
Disallow: /dash/routes/KingEast/kingeast_sked_all.php
Disallow: /dash/routes/KingEast/kingeast_sked_ccw_sat.php
Disallow: /dash/routes/KingEast/kingeast_sked_ccwwd.php
Disallow: /dash/routes/KingEast/kingeast_sked_cw_sat.php
Disallow: /dash/routes/KingEast/kingeast_sked_cwwd.php
Disallow: /dash/routes/KingEast/kingeast_gmap.php
Disallow: /dash/routes/KingEast/kingeast_imap.php
Disallow: /dash/routes/KingEast/kingeast_smap.php
Disallow: /dash/routes/Leimert_Slauson/leimert_sked_all.php
Disallow: /dash/routes/Leimert_Slauson/leimert_sked_ccwsd.php
Disallow: /dash/routes/Leimert_Slauson/leimert_sked_ccwwd.php
Disallow: /dash/routes/Leimert_Slauson/leimert_sked_cwsd.php
Disallow: /dash/routes/Leimert_Slauson/leimert_sked_cwwd.php
Disallow: /dash/routes/Leimert_Slauson/leimert_gmap.php
Disallow: /dash/routes/Leimert_Slauson/leimert_imap.php
Disallow: /dash/routes/Leimert_Slauson/leimert_smap.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_sked_all.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_sked_ccwwd.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_sked_ccwwe.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_sked_cwwd.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_sked_cwwe.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_gmap.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_imap.php
Disallow: /dash/routes/LincolnHeights_Chinatown/lincolnheights_smap.php
Disallow: /dash/routes/LosFeliz/losfeliz_sked_all.php
Disallow: /dash/routes/LosFeliz/losfeliz_sked_nbwd.php
Disallow: /dash/routes/LosFeliz/losfeliz_sked_sbwd.php
Disallow: /dash/routes/LosFeliz/losfeliz_gmap.php
Disallow: /dash/routes/LosFeliz/losfeliz_imap.php
Disallow: /dash/routes/LosFeliz/losfeliz_smap.php
Disallow: /dash/routes/Midtown/midtown_sked_all.php
Disallow: /dash/routes/Midtown/midtown_sked_nbwd.php
Disallow: /dash/routes/Midtown/midtown_sked_nbwe.php
Disallow: /dash/routes/Midtown/midtown_sked_sbwd.php
Disallow: /dash/routes/Midtown/midtown_sked_sbwe.php
Disallow: /dash/routes/Midtown/midtown_gmap.php
Disallow: /dash/routes/Midtown/midtown_imap.php
Disallow: /dash/routes/Midtown/midtown_smap.php
Disallow: /dash/routes/Northridge/northridge_sked_all.php
Disallow: /dash/routes/Northridge/northridge_sked_sat.php
Disallow: /dash/routes/Northridge/northridge_sked_wd.php
Disallow: /dash/routes/Northridge/northridge_gmap.php
Disallow: /dash/routes/Northridge/northridge_imap.php
Disallow: /dash/routes/Northridge/northridge_smap.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_sked_all.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_sked_ccwwd.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_sked_ccwwe.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_sked_cwwd.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_sked_cwwe.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_gmap.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_imap.php
Disallow: /dash/routes/PanoramaCity_VanNuys/pcityvannuys_smap.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_sked_all.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_sked_northssh.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_sked_northweekday.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_sked_southssh.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_sked_southweekday.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_gmap.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_imap.php
Disallow: /dash/routes/PicoUnion_EchoPk/picounion_smap.php
Disallow: /dash/routes/SanPedro/sanpedro_sked_all.php
Disallow: /dash/routes/SanPedro/sanpedro_sked_nbsat.php
Disallow: /dash/routes/SanPedro/sanpedro_sked_nbsun.php
Disallow: /dash/routes/SanPedro/sanpedro_sked_nbwd.php
Disallow: /dash/routes/SanPedro/sanpedro_sked_sbsat.php
Disallow: /dash/routes/SanPedro/sanpedro_sked_sbsun.php
Disallow: /dash/routes/SanPedro/sanpedro_sked_sbwd.php
Disallow: /dash/routes/SanPedro/sanpedro_gmap.php
Disallow: /dash/routes/SanPedro/sanpedro_imap.php
Disallow: /dash/routes/SanPedro/sanpedro_smap.php
Disallow: /dash/routes/Southeast/southeast_sked_all.php
Disallow: /dash/routes/Southeast/southeast_sked_ccwwd.php
Disallow: /dash/routes/Southeast/southeast_sked_ccwwe.php
Disallow: /dash/routes/Southeast/southeast_sked_cwwd.php
Disallow: /dash/routes/Southeast/southeast_sked_cwwe.php
Disallow: /dash/routes/Southeast/southeast_sked_pdrnsat.php
Disallow: /dash/routes/Southeast/southeast_sked_pdrnwd.php
Disallow: /dash/routes/Southeast/southeast_sked_pdrssat.php
Disallow: /dash/routes/Southeast/southeast_sked_pdrswd.php
Disallow: /dash/routes/Southeast/southeast_gmap.php
Disallow: /dash/routes/Southeast/southeast_imap.php
Disallow: /dash/routes/Southeast/southeast_smap.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_sked_all.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_sked_ccwsat.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_sked_ccwwd.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_sked_cwsat.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_sked_cwwd.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_gmap.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_imap.php
Disallow: /dash/routes/VanNuys_StudioCty/vannuysstudiocity_smap.php
Disallow: /dash/routes/VermontMain/vermontmain_sked_all.php
Disallow: /dash/routes/VermontMain/vermontmain_sked_ccwsat.php
Disallow: /dash/routes/VermontMain/vermontmain_sked_ccwwd.php
Disallow: /dash/routes/VermontMain/vermontmain_sked_cwsat.php
Disallow: /dash/routes/VermontMain/vermontmain_sked_cwwd.php
Disallow: /dash/routes/VermontMain/vermontmain_gmap.php
Disallow: /dash/routes/VermontMain/vermontmain_imap.php
Disallow: /dash/routes/VermontMain/vermontmain_smap.php
Disallow: /dash/routes/Watts/watts_sked_all.php
Disallow: /dash/routes/Watts/watts_sked_ccwsat.php
Disallow: /dash/routes/Watts/watts_sked_ccwwd.php
Disallow: /dash/routes/Watts/watts_sked_cwsat.php
Disallow: /dash/routes/Watts/watts_sked_cwwd.php
Disallow: /dash/routes/Watts/watts_gmap.php
Disallow: /dash/routes/Watts/watts_imap.php
Disallow: /dash/routes/Watts/watts_smap.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_sked_all.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_sked_ccwsat.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_sked_ccwwd.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_sked_cwsat.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_sked_cwwd.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_gmap.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_imap.php
Disallow: /dash/routes/Wilmington_Bannings/wilmington_smap.php
Disallow: /dash/routes/Wilshire/wilshirekorea_sked_all.php
Disallow: /dash/routes/Wilshire/wilshirekorea_sked_ccwsat.php
Disallow: /dash/routes/Wilshire/wilshirekorea_sked_ccwwd.php
Disallow: /dash/routes/Wilshire/wilshirekorea_sked_cwsat.php
Disallow: /dash/routes/Wilshire/wilshirekorea_sked_cwwd.php
Disallow: /dash/routes/Wilshire/wilshirekorea_gmap.php
Disallow: /dash/routes/Wilshire/wilshirekorea_imap.php
Disallow: /dash/routes/Wilshire/wilshirekorea_smap.php
Disallow: /map/cemap_imap.php
Disallow: /map/cemap_smap.php
Disallow: /map/cemap_gmap.php
Disallow: /map/dashmap_smap.php
Disallow: /map/dashmap_gmap.php
Disallow: /map/dashmap_imap.php
Disallow: /other/observatoryshuttle/observatoryshuttle_smap.php
Disallow: /other/observatoryshuttle/observatoryshuttle_gmap.php
Disallow: /other/observatoryshuttle/observatoryshuttle_imap.php
Disallow: /other/observatoryshuttle/observatoryshuttle_all.php
Disallow: /other/observatoryshuttle/observatoryshuttle_nbwe.php
Disallow: /other/observatoryshuttle/observatoryshuttle_sbwe.php
Disallow: /KML/
Disallow: /store_template.html

I noticed Google Webmaster Tools is currently seeing the text of the file as:
# robots.txt for http://www.ladottransit.com/

User-agent: *
Disallow: /sphider-1.3.5/
Disallow: /whatsnew/
Disallow: /css/
Disallow: /js/
Disallow: /Library/
Disallow: /formtoemail/
Disallow: /Templates/
Disallow: /tmp/ # these will soon disappear
Disallow: /cc_thanks.html
Disallow: /index_static.html

This was the state of the file till this morning when I added the rest of the disallowed files. Linking directly to robots.txt brings up the full text. I presume Google hasn't reindexed so that's why it sees the old file. But I manually reindexed through the Sphider admin successfully, and it seems to be ignoring those rules.
Anyone see what the problem could be? I'm stumped.

A: Looks like this is a bug in Sphider 1.3.5. Some helpful soul named Matt, however, has provided a patch, which fixed the problem right up for me. Here's the patch:
http://www.sphider.eu/forum/read.php?2,5475,5478


text:
Q: How to allow user input of numbers and operators? how would I add a function that allows the user to input something like 2 + 2 or 10 / 5 then simply run the objects to calculate this as they would when they enter it manually using my "Enter first input" statements. So as part of the assignment I need to allow the user to input something like 10 / 5 + 1 / 2 in the console. I also need to be able to allow for operator overloading and I'm not sure if my program is currently allowing this. Any help would be appreciated. Thanks!
#include <iostream>
#include <conio.h>

using namespace std;

class Rational
{
    private:
        float numInput;

    public:
        Rational(): numInput(0)
        {}

        void getValues()
        {
            cout << "Enter number: ";
            cin >> numInput;
        }

        void showValues()
        {
            cout << numInput << endl;
        }

        Rational operator + (Rational) const;
        Rational operator - (Rational) const;
        Rational operator * (Rational) const;
        Rational operator / (Rational) const;
};

Rational Rational::operator + (Rational arg2) const
{
    Rational temp;
    temp.numInput = numInput + arg2.numInput;
    return temp;
}

Rational Rational::operator - (Rational arg2) const
{
    Rational temp;
    temp.numInput = numInput - arg2.numInput;
    return temp;
}

Rational Rational::operator * (Rational arg2) const
{
    Rational temp;
    temp.numInput = numInput * arg2.numInput;
    return temp;
}

Rational Rational::operator / (Rational arg2) const
{
    Rational temp;
    temp.numInput = numInput / arg2.numInput;
    return temp;
}

int main()
{
    Rational mathOb1, mathOb2, outputOb;
    int choice;
    mathOb1.getValues();
    cout << "First number entered: ";
    mathOb1.showValues();
    cout << endl;
    cout << "Enter operator: + = 1, - = 2, * = 3, / = 4  ";
    cin >> choice;
    cout << endl;
    mathOb2.getValues();
    cout << "Second number entered: ";
    mathOb2.showValues();    cout << endl;

    switch (choice)
    {
        case 1:
            outputOb = mathOb1 + mathOb2;
            break;
        case 2:
            outputOb = mathOb1 - mathOb2;
            break;
        case 3:
            outputOb = mathOb1 * mathOb2;
            break;
        case 4:
            outputOb = mathOb1 / mathOb2;
            break;
        default:
            cout << "Invalid choice! " << endl;
    }
    cout << "Answer: ";
    outputOb.showValues();
    cout << endl;

    return 0;
}

A: You can't use cin >> {int}, that will just fail if you provide a char and you'll be stuck from there on.
Just use std::getline and parse out the tokens from there:
std::string expression;
std::getline(std::cin, expression);

You can then use any of the many, many ways to split a string into tokens as expressed in this question, and loop through the tokens and interpret them based on whether they are operators or numbers.


text:
Q: mapping extra mouse buttons I have SteelSeries Sensei mouse with extra buttons: 8 9 10 11.
I want to map them as follows:
8: Shift_L, 9: CTRL_L, 10: PAGE_DOWN, 11: PAGE_UP
I spent hours looking for solutions.
problems with xbindkeys(best option):
Shift and Ctrl: no key down, key up. example:
typing, mouse 8 down, typing, mouse 8 up, typing. result:
test TEST TEST.
no hold repeat: mouse 10 down and hold, produces PageDown only once.
problems with imwheel:
could not make 10 and 11 work.
binds different actions to software - I don't need that mess.
I just want  mouse btn 10 === PageDown key, can I do that?

A: What you want to do will not work as:

*

*for the Shift and Ctrl: You cannot bind mouse-down and mouse-up events to key-press and key-up events only to keys...

*for the PgDn: Mouse buttons don't have a repeat function: only mouse-down and mouse-up (no "mouse-repeat")

Sorry to be the harbinger of bad news (but at least, you will not be losing any more time with it...)

A: I will suggest you try Input Remapper software. They provide a GUI and even several buttons in my mouse which didn't register any clicks xbindkeys showed up in this application.
https://linuxhint.com/input-remapper-linux/
Use the above link for downloading and reference.


text:
Q: Add Option Tag with value to empty Select Tag i have this element in my Code(added with jquery, works fine):
<select disabled><option value='no' selected>-No hidden contents-</option></select>
After that this option is removed and some other options were put into the select tag, which is now enabled.
Maybe later(Depends on user interaction), the other options were removed, the select is disabled and i am trying to put the old option-tag inside again.
This works, if it has no value Attribute(but i need it for some other code).
But if i add the value attribute (I tried jquery .val('theValue'), .attr('value','theValue') and add it with the option element) the option tag disappears on the screen and in the code(firefox inspector or google chrome dev tools). I don't know what happened.
Thank you for some help.

A: Could always try using full html when replacing the contents of the select. I personally haven't played much with values, but this appears to work:
$("selector").html("<option value='no' selected>-No hidden contents-</option>");

While I understand that this is probably not the best way to go about it, it can do in a pinch.


text:
Q: Two javascript slideshows with if condition? I'm trying to make a second slideshow on a floating layer. However, the main slideshow stopped working. I can't make both work at the same time.
This is the original code for the main slideshow:
var imgs = ["1.jpg", "2.jpg", "3.jpg"];

document.onkeydown = function(event) {
 var e = event || window.event;
 if (e.keyCode == '37') { // left
 changeImage(-1);![1]
 } else if (e.keyCode == '39') { // right
 changeImage(1);
 }
}

function changeImage(dir) {
var img = document.getElementById("imgClickAndChange");
img.src = imgs[imgs.indexOf(img.src) + dir] || imgs[(dir==1) ? 0 : imgs.length-1];
var index = imgs.indexOf(img.src);
};

I have tried an if condition for the second slideshow to work only when the floating layer in which it is contained is active, but I can't get it right.
Like this:
 if ($("#floatingLayer").is(":visible") == true) { ORIGINAL SLIDESHOW CODE ABOVE };

If it helps, this is the code to toggle the floating layer:
 function ToggleFloatingLayer(DivID){
  $('#' + DivID).fadeToggle(0);
 };

Can anyone help me? What should I change? I want the original layer to be working by default but to stop when I toggle the floating layer on. Then only the second slideshow should work.
Thank you


text:
Q: Getting all paths in tree traversal in c# Having a function like below to return all paths from a Node object.
private static IEnumerable<string> Paths(Node root)
{
    var queue = new Queue<Tuple<string, Node>>();
    queue.Enqueue(new Tuple<string, Node>(root.Account.ToString(), root));

    while (queue.Any())
    {
        var node = queue.Dequeue();
        if (node.Item2.Children.Any())
        {
            foreach (var child in node.Item2.Children)
            {
                queue.Enqueue(new Tuple<string, Node>(node.Item1 + "-" + child.Account, child));
            }
        }
        else
        {
            yield return node.Item1;
        }
    }
}

The Node object is defined as follows..(Its a Ledger account with a variable number of sum accounts as children)
public class Node
{
  public string Account { get; set; }
  public List<Node> Children { get; set; }
  public Node(string account)
  {
    Account = account;
    Children = new List<Node>();
  }
}

For testing below object is used
var root = new Node("1")
{
    Children = new List<Node>
    {
        new Node("2") { Children = new List<Node> {new Node("5"), new Node("6"), new Node("7") } },
        new Node("3"),
        new Node("4"){ Children = new List<Node> {new Node("7") } }
    }
};

and called like this
var allPaths = Paths(root);

The output is is correct but a text representation of all the paths
[0] "1-3"
[1] "1-2-5"
[2] "1-2-7"
[3] "1-2-"
[4] "1-4-7"

But instead of an string representation of the path i need a list with a list of node object List<List<Node>>
ex.
[0]
    [0] 1
    [1] 3
[1]
    [0] 1
    [1] 2
    [2] 5
[2]
    [0] 1
    [1] 2
    [2] 6
[3]
    [0] 1
    [1] 2
    [2] 7
[4]
    [0] 1
    [1] 4
    [2] 7

So what changes to the Paths function do i need in order to get the desired output..
Any help i more than welcome.


text:
Q: script# registerScript problems with Ext# I am trying to use extsharp (on codeplex) with the latest script# and am stalled
On the end of ExtJS.Scripts.debug.js (generated by script# from the extsharp library) is a line
ss.loader.registerScript('ExtJS.Scripts', [core], executeScript);

firstly there is nothing called 'core' in scope. Second looking at ssloader.debug.ls (which is the thing that has registrScript in it) there is nothing called 'loader' but there is a function on ss called registerScript. So I changed this line to
ss.registerScript('ExtJS.Scripts', [], executeScript);

Now I at least get my Ext.OnReady function called. But its clear that the meat of ExtJS.Scripts.debug.js has not been executed (all of the objects and functions set up there dont exist). I have reached my limit of how script# works, any ideas?
PS: nikhil - pls open source script#
EDIT: Multiple layers of confusion here
a) The extsharp project is setup as a s# library (which means app) as opposed to an import library - which is what v0.7 of s# seems to want (but in fact does not work - see another SO question on that topic)
b) ext# was written using an older version of s# that did usethe registerscript function
I am still stuck but have a better understanding of why I am stuck :-)

A: All of the sources relevant for digging deeper into this issue - the scripts, and the project templates, the import libraries, the msbuild tasks/target etc are all on github in source form at https://github.com/nikhilk/scriptsharp.
The lines of script above are coming from the script template (look inside the Properties folder of your project) and the script template can be customized to your need without modifying the script# compiler itself.
The latest versions of script# no longer use the constructs above. If you create a new project, you'll see a new script template that doesn't use registerScript etc.
ssloader.js is optional - it provides a script loader that does dependency checking etc. Core used to refer to mscorlib.js which is still needed.
Hope that gets you started.


text:
Q: Parent div's hover attribute doesn't affect child image? I have a parent div with two child divs inside of it, one with an image and one with just text. I've assigned a :hover style to my parent class so that when a user hovers the entire div gets an inset shadow... however when I test it, the child that contains the image either is not affected or is on top of the effect..
Is there a way to get the :hover style to affect the image as well?
updated fiddle
edit: updated the fiddle with empty div to illustrate desired effect...
css:

.main-box {
    border:2px solid #656565;
}
.main-box:hover {
    -webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
    -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
    box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
}

.image {
    display:inline-block;
}
.text {
    display:inline-block;
}

asdfasfda;lskjf

A: The solution to this is actually not too far from what you have, simply change your CSS to say
.main-box:hover img {
    -webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
    -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
    box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
}

and the effect should be what you are looking for.
Updated fiddle to show results
EDIT:
The best solution for this problem would be to add a :hover:before element in your CSS.  This will create new content above the div on the page for as long as the user's mouse is over the div in question, and by giving it an absolute position and z-index, all effects you add to the box will show above the contents of the hovered div.
The following CSS will give you what you want:
.main-box:hover:before {
    content: "";
    display: inline-block;
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
    -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
    box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.3) inset;
}

The problem with this method is that the :before content is now effectively covering everything in the div; any links, input fields or buttons you would want the user to be able to select are now rendered useless.
While pointer-events would be the easiest way of getting through this new overlay, it has terrible browser compatibility, so I would recommend the following:
.main-box a, .main-box input { position: relative; z-index: 3; }
// etc.

Doing this for all links, text or inputs you would want your users to be able to select should be clickable, and this solution should be compatible on all browsers.
Newer fiddle


text:
Q: Is it possible to make Vpn app using flutter and dart I tried using this package to make VPN connection app but it dose not support the connection type like (L2TP or PPTP)
https://pub.dev/packages/flutter_vpn

A: i found that code on source, seems like pptp connection
  /// Use given credentials to connect VPN (ikev2-eap).
  /// This will create a background VPN service.
  static Future<Null> simpleConnect(
      String address, String username, String password) async {
    await _channel.invokeMethod('connect',
        {'address': address, 'username': username, 'password': password});
  }

A: Yes It's Possible I have found this library on GitHub you should try it, https://github.com/X-dea/flutter_vpn


text:
Q: complex function bounded by $e^{\sqrt{|z|}}$ - complex analysis prelim practice Let $f$ be an entire function such that
$$|f(z)|\le e^{\sqrt{|z|}}$$
Let $n(r)$ be the number of zeros of $f$ with modulus less than $r$.
Prove that there exist $A,B\ge0$ such that
$n(r)\le A+B\sqrt{r}$ for all $r$.
I believe I am supposed to use the argument principle somewhere but how?

A: As already mentioned, you can use Jensen's formula. Assume that your function has a zero of order $\lambda$ at the origin, then since $f \in H(\mathrm{D}(0,R))$ (denotes the open disk of center zero and radius $R$), we have that
$$
\int_0^R \frac{n(r)}{r}dr = \frac{1}{2\pi}\int_0^{2\pi} \log |f(Re^{i \theta})| d\theta - \log \frac{|f^{(\lambda)}(0)|}{\lambda!} - \lambda \log R
$$
(this one you can obtain applying the formula which assumes $f(0)\neq 0$ to the function $f(z)z^{-\lambda}$).
Next observe that $|f(z)| \leq e^{|z|^{1/2}}$ implies that the growth scale of $f$,
$$
M(r) = \max_{|z|=r} |f(z)|,
$$
satisfies
$$
\log M(r) \leq \sqrt{r},\qquad r > 0
$$
Hence in the main formula the right hand side is bounded above: for $R=eR'>1$ ($e$ is Euler's constant):
$$
\frac{1}{2\pi}\int_0^{2\pi} \log |f(Re^{i \theta})| d\theta - \log \frac{|f^{(\lambda)}(0)|}{\lambda!} - \lambda \log R \leq  \sqrt{R} + A = B \sqrt{R'}+A
$$
Since $n(r)$ is non-decreasing, the left hand side of the main formula is bounded below:
$$
\int_0^R \frac{n(r)}{r}dr \geq \int_{R'}^{R} \frac{n(r)}{r}dr \geq n(R')\int_{R'}^R \frac{dr}{r} = n(R')
$$
Finally, set $R'=r$ to conclude:
$$
n(r) \leq B\sqrt{r} + A.
$$


text:
Q: How to reorganize array of objects with lodash? I've got the following response from my db:
[
  {
    "id": 1,
    "select": true,
    "insert": true,
    "update": true,
    "delete": false,
    "template": {
      "id": 1,
      "name": "Template 1"
    },
    "module": {
      "id": 1,
      "name": "Module 1"
    }
  }
  {
    "id": 2,
    "select": false,
    "insert": true,
    "update": true,
    "delete": false,
    "template": {
      "id": 1,
      "name": "Template 1"
    },
    "module": {
      "id": 2,
      "name": "Module 2"
    }
  }
  {
    "id": 3,
    "select": true,
    "insert": true,
    "update": false,
    "delete": false,
    "template": {
      "id": 2,
      "name": "Template 2"
    },
    "module": {
      "id": 1,
      "name": "Module 1"
    }
  }

]

So my root objects have two nested objects (template, module) + their own properties.
I want to convert my array in such a way that template should be root object, should have modules property with array of modules objects. Module object should have property permissions with  select, insert, update, delete props inside. As you can see template objects are duplicated. I want to avoid duplicates of template objects in my result array, they schould be merged.
So the result should look like this:
[
   {
      "id":1,
      "name":"Template 1",
      "modules":[
         {
            "id":1,
            "name":"Module 1",
            "permissions":{
               "select":true,
               "insert":true,
               "update":true,
               "delete":false
            }
         },
         {
            "id":2,
            "name":"Module 2",
            "permissions":{
               "select":false,
               "insert":true,
               "update":true,
               "delete":false
            }
         }
      ]
   },
   {
      "id":2,
      "name":"Template 2",
      "modules":[
         {
            "id":1,
            "name":"Module 1",
            "permissions":{
               "select":true,
               "insert":true,
               "update":false,
               "delete":false
            }
         }
      ]
   }
]

How to achieve that with lodash?

A: It isn't lodash, but I believe simple things like this should be done without external dependencies.

const data = [
  {
    "id": 1,
    "select": true,
    "insert": true,
    "update": true,
    "delete": false,
    "template": {
      "id": 1,
      "name": "Template 1"
    },
    "module": {
      "id": 1,
      "name": "Module 1"
    },
  },
  {
    "id": 2,
    "select": false,
    "insert": true,
    "update": true,
    "delete": false,
    "template": {
      "id": 1,
      "name": "Template 1"
    },
    "module": {
      "id": 2,
      "name": "Module 2"
    },
  },
  {
    "id": 3,
    "select": true,
    "insert": true,
    "update": false,
    "delete": false,
    "template": {
      "id": 2,
      "name": "Template 2"
    },
    "module": {
      "id": 1,
      "name": "Module 1"
    },
  },
];

const reorgData = data => {
  return Object.values(
    data.reduce((newObj, { id, module, template, ...permissions }) => {
      if (!newObj[template.name]) {
        newObj[template.name] = template;
        newObj[template.name].modules = [];
      }

      newObj[template.name].modules.push({
        ...module,
        permissions,
      });

      return newObj;
    }, {})
  );
};

console.log(reorgData(data));


text:
Q: A curious product formula Fiddling with Mathematica seems to suggest the following:
$$\frac{(2^2)(4^2)(6^2)\cdots(2N^2)}{(1^2)(3^2)(5^2)\cdots(2N-1)^2}=N\pi+\frac{\pi}{4}+\frac{\pi}{32N}-\frac{\pi}{128N^2}+o(1/N^2).$$
Does anyone have an explanation or reference for this, or know how the series continues? The next term appears to be around $-\frac{\pi}{411.5N^3}\approx-0.00763$.

A: Your first term is $r^2$, where $$r=\frac{2\cdot 4\cdots (2n)}{1\cdot 3\cdot 5\cdots (2n-1)}=\frac{(2\cdot 4\cdots (2n))^2}{(2n)!}=\frac{4^nn!n!}{(2n)!}=\frac{4^n}{{2n\choose n}}$$
Now, ${2n \choose n}$ is the central binomial coefficient, which is known to be approximately $\large \frac{4^n}{\sqrt{\pi n}}$ for large $n$.
Hence $r^2\approx \pi n$.  You are teasing out more terms of the approximation (then squaring).  You can get as many terms as you like by using terms of the Stirling series to approximate the  factorials.

A: This is similar to the famous Wallis product, discovered by John Wallis three or four centuries ago, and it can be seen as a special case of Euler's infinite product for the sine function. $$\frac{\sin\pi x}{\pi x}=\prod_{n=1}^\infty\left(1-\frac{x^2}{n^2}\right)$$ Take $x=\frac12$ , and Wallis' identity follows.


text:
Q: Linker Error using g++ with Qt 4.5.1 I'm trying to test out a new dev environment and I am having some problems referencing some of the required Qt libraries.
First I ran this:
$ g++ HelloWorld.C -o HelloWorld -I /usr/local/Trolltech/Qt-4.5.1/include/QtCore/ -I /usr/local/Trolltech/Qt-4.5.1/include/

and got this error:
    /tmp/ccmsm4kZ.o: In function `QString::QString(char const*)':
HelloWorld.C:(.text._ZN7QStringC2EPKc[_ZN7QStringC5EPKc]+0x1d): undefined reference to `QString::fromAscii_helper(char const*, int)'
/tmp/ccmsm4kZ.o: In function `QString::~QString()':
HelloWorld.C:(.text._ZN7QStringD2Ev[_ZN7QStringD5Ev]+0x2d): undefined reference to `QString::free(QString::Data*)'
collect2: ld returned 1 exit status

So then I  added reference to the QtCore library via:
$ g++ HelloWorld.C -o HelloWorld -I /usr/local/Trolltech/Qt-4.5.1/include/QtCore/ -I /usr/local/Trolltech/Qt-4.5.1/include/ -L /usr/local/Trolltech/Qt-4.5.1/lib -lQtCore

which removed the compile errors, however when I try to run the program I get this error:
./HelloWorld: error while loading shared libraries: libQtCore.so.4: cannot open shared object file: No such file or directory

I wasn't able to find a solution for this problem via google. Anyone have advice?

A: That error indicates that while the linker can find the library at compilation, it can't find it during runtime.
You should update your LD_LIBRARY_PATH to include that location like this:
In ~.bashrc probably somewhere near the bottom:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/Trolltech/Qt-4.5.1/lib
Alternatively, if you want to make this persistent throughout your system (and have root access), you can make an entry in /etc/ld.so.conf.d (on RedHat, I'm not sure about the other distributions)
touch /etc/ld.so.conf.d/qt.conf
Add the path to this file, and then update your runtime via /sbin/ldconfig


text:
Q: how to turn multiple URLs into domains with command line I have .csv files with multiple columns and ',' as separator. The url's are in the first column. I need to turn all url's into domains without removing the other columns
Example of the data I have:
https://www.example.com/dog/url/path/cat.php,column2,$3,4
http://www.unix.random.com/index.html,column2,$3,4
http://example.com/dog/cat.php,column2,$3,4
www.example.com/dog/,column2,$3,4
example.com/url/path/cat/dog,column2,$3,4
https://example.com/,column2,$3,4
https://www.unix.random.com,column2,$3,4
http://www.example.com,column2,$3,4
http://example.com,column2,$3,4
www.random.com,column2,$3,4
example.com/,column2,$3,4

I need to turn all urls in column 1 to a domain name without touching the other columns, the other columns contain no '/'. I need to keep subdomains expect for www.
The output need to be:
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
random.com,column2,$3,4
example.com,column2,$3,4

How to do this?

A: I believe this works:
sed -E 's#^(.*://)?(www\.)?##; s#^([^,/]+)[^,]*#\1#'

This first sed command (s#^(.*://)?(www\.)?##) matches the protocol and the 'www.' and replaces it with nothing. The second sed command (s#^([^,/]+)[^,]*#\1#) matches everything up to the first slash and then everything up to the first comma and replaces it with everything up to the first slash, so it essentially removes everything from the first slash until the first comma.

A: Using sed
$ sed -E 's~(^[^/]*//)?(w+\.)?([^/]*)[^,]*~\3~' input_file
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
random.com,column2,$3,4
example.com,column2,$3,4

A: Using any awk:
$ awk 'BEGIN{FS=OFS=","} {sub("^([^/:]+://)?(www[.])?","",$1); sub("/.*","",$1)} 1' file
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
random.com,column2,$3,4
example.com,column2,$3,4

A: This may not be the answer you are looking for, but sed can be inconsistent across OSs and its syntax hard to read.
This may be even worse, but one other option is to use Node.js on the command line with the -e flag which evaluates a string. The downside to this is that you will have to have Node.js installed on the system.
This code takes everything piped to it from standard input and prints the modified string to standard output:
cat infile.csv | node -e 'const stdin = process.openStdin();
let data = "";
stdin.on("data", chunk => data += chunk);
stdin.on("end", () => {
  console.log(
    data
      .trim()
      .split("\n")
      .filter(Boolean)
      .map((line) => {
        const parts = line.split(",");
        const url = new URL((!/^http(s)?\:\/\//.test(line) ? "https://" : "") + parts.shift());
        return `${url.host.replace(/^www\./,"")},${parts.join(",")}`
      })
      .join("\n"))
});' > outfile.csv

You may have trouble overwriting your input file if that's what you want to do. To solve that, you may pass the file name as an argument after the code instead of using a pipe:
node -e 'const fs = require("fs");
const infile = process.argv[1]; const data = fs.readFileSync(infile).toString();
const output = data
  .trim()
  .split("\n")
  .filter(Boolean)
  .map((line) => {
    const parts = line.split(",");
    const url = new URL((!/^http(s)?\:\/\//.test(line) ? "https://" : "") + parts.shift());
    return `${url.host.replace(/^www\./,"")},${parts.join(",")}`
  })
  .join("\n");
fs.writeFileSync(infile, output)' file.csv

A: Using Raku (formerly known as Perl_6)
raku -pe 's{ (^ <-[/]>* \/\/ )? (w**3 \.)? (<-[/]>*) <-[,]>* } = "$2";'

[Above is a translation of sed code from @HatLess].
raku -pe 's{ ^ (.* "://" )? (www\.)? } = ""; s{ ^ (<-[,/]>+) <-[,]>* } = "$0";'

[Above is a translation of sed code from @D_Bear].
Sample Output (both cases):
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
unix.random.com,column2,$3,4
example.com,column2,$3,4
example.com,column2,$3,4
random.com,column2,$3,4
example.com,column2,$3,4

https://raku.org


text:
Q: How to append records with enforced referential integrity? I have a OCDB table that I use to extract data. I currently use it to append the data to a new table and then manipulate it. The problem is I have just added a relationship to that table and when I use the enforced referential integrity the query won't run.
How do I get the append query to automatically update a foreign key?


text:
Q: Get text from element using Selenium/WebDriver with PHP Is it possible to somehow get a value from an input that does not display the value in the source page?
Check screen: https://prnt.sc/1t2pnm8
Unfortunately, in this case the getText function does not work
$driver->findElement(WebDriverBy::xpath('//*[@id="list-overlay-form-wrapper"]/div/div[2]/div[1]/div[1]/div/div[1]/div/input'))->getText('');

A: You need to read value attribute of the element, not its text.
$inputElement = $driver->findElement(WebDriverBy::id('ember171'));
$value = $inputElement->getAttribute('value');

For more examples have a look at php-webdriver documentation.


text:
Q: Why does System.Data.SqlClient complain about my statement? What I am trying to achieve is the generation and insertion of a unique identifier into each entry I make to the table.

I have added the default value (newsequentialid()) to the UserID column, therfore when I execute an INSERT query directly to the database then the result is as expected (the UserID is automaticaly generated and increments each time a new value is added).
However this is not the case when I execute a query through my ASP.NET WebService which provides the following error:

System.Data.SqlClient.SqlException: Operand type clash: int is
  incompatible with uniqueidentifier

I understand that the error is indicating a data type clash, but I am not intending to populate that coloumn from within my C# code rather it should be added automaticaly?! (no?)
DataClassesDataContext dbContext = new DataClassesDataContext();
AddingNewUsers.UserName = UserName;
AddingNewUsers.UserPass = UserPass;
AddingNewUsers.DOB = Convert.ToDateTime(DOB);
AddingNewUsers.EmailAddress = Email;
AddingNewUsers.JoiningDate = DateTime.Today;
AddingNewUsers.Status = "Active";
AddingNewUsers.WalletAmount = 0;
dbContext.UserTables.InsertOnSubmit(AddingNewUsers);
dbContext.SubmitChanges();

A: uniqueidentifier expects a GUID you should alter the UserId to be a Int change the Datatype to Int also if you plan to populate that field via C# code then that column should not be an auto increment column


text:
Q: C++ - Why is conv2 so slow in Armadillo? I am using conv2 function in armadillo with image size of 224x224 and mask size of 10x10. For a 3 channel image, I am doing something like:
arma::mat temp(215, 215, fill::zeros);
for (int i = 0; i < 3; i++)
   temp += arma::mat(arma::conv2(image_channel, channel_mask)).submat(9, 9, 222, 222);

I want only valid convolution and hence I am using submat. This code is executed in a loop 32 times with different masks. For 32 iterations it takes 2.37 seconds which is way much slower than octave. Octave can execute the same code in 0.25 seconds.
Both octave and armadillo are set up to use OpenBLAS and I have defined appropriate flags in c++ file. (Eg. ARMA_USE_BLAS etc.). Can anybody please tell me what is the problem here.


text:
Q: What is the probability of an outcome in general, if you know its respective probabilities in a bunch of other situations? Say there are choices A, B, C, D, and E, and I want to know the probability of A being selected, but I only know the probability of A when compared to only 2 other choices.
For example,
I know for a fact that given the choice between A, B, C : I have a P(A) = .2
A, B, D : P(A) = .3
A, B, E : P(A) = .8
A, C, D : P(A) = .6
A, C, E : P(A) = .43
A, D, E : P(A) = .61
Is there a way for me to find out the probability that A will chosen? In the example I listed all the possible combinations, but what if I was missing one, let's say I didn't have the (A,D,E) variant? How would that effect the probabilities? What if I had the probabilities for all the other 3 choice combinations that don't include A like (B,C,D), (B,C,E)... etc? Would those help me?
For the record, all the numbers I gave are made up, and so is this problem. I'm simply very curious.

A: What you know in the first case is the probability of $A$ given $ A \cup B \cup D $. From Bayes' theorem you have
$$ P(A | A\cup B\cup C) = \frac{P(A)P(A\cup B\cup C | A)}{P(A\cup B\cup C)} $$
Since your choices are distinct this can be written as
$$  P(A | A\cup B\cup C) = \frac{P(A)}{P(A)+P(B)+P(C)} $$
or using the actual numbers
$$ 0.3 = \frac{P(A)}{P(A)+P(B)+P(C)} \Rightarrow $$
$$ P(A) = 0.3P(A) + 0.3P(B) + 0.3P(C) \Rightarrow $$
$$ 0.7P(A) - 0.3P(B) - 0.3P(C) = 0. $$
If you have four of these kind of relations, together with $ P(A) + \dots + P(E) = 1$, you have a 5x5 linear system of equations, if the numbers are good, you can solve it and find the probabilities.


text:
Q: Understanding dequeue_rt_stack() for RT scheduling class linux enqueue_task_rt function in ./kernel/sched/rt.c is responsible for queuing the task to the run queue. enqueue_task_rt contains call to enqueue_rt_entity which calls dequeue_rt_stack. Most part of the code seems logical but I am a bit lost because of the function dequeue_rt_stack unable to understand what it does. Can somebody tell what is the logic that I am missing or suggest some good read.
Edit: The following is the code for dequeue_rt_stack function
     struct sched_rt_entity *back = NULL;
     /* macro for_each_sched_rt_entity defined as
     for(; rt_se; rt_se = rt_se->parent)*/
     for_each_sched_rt_entity(rt_se) {
             rt_se->back = back;
             back = rt_se;
     }

     for (rt_se = back; rt_se; rt_se = rt_se->back) {
             if (on_rt_rq(rt_se))
                     __dequeue_rt_entity(rt_se);
     }

More specifically, I do not understand why there is a need for this code:
     for_each_sched_rt_entity(rt_se) {
             rt_se->back = back;
             back = rt_se;
     }

What is its relevance.

A: When a task is to be added to some queue, it must first be removed from the queue that it currently is on, if any.
With the group scheduler, a task is always at the lowest level of the tree, and might have multiple ancestors:
       NULL
         ^
         |
+-----parent------+
|                 |
| top-level group |
|                 |
+-----------------+
         ^      ^_____________
         |                    \
+-----parent------+   +-----parent------+
|                 |   |                 |
| mid-level group |   |   other group   |  ...
|                 |   |                 |
+-----------------+   +-----------------+
         ^      ^_____________
         |                    \
+-----parent------+   +-----------------+
|                 |   |                 |
|      task       |   |   other task    |  ...
|                 |   |                 |
+-----------------+   +-----------------+

To remove the task from the tree, it must be removed from all groups' queues, and this must be done first at the top-level group (otherwise, the scheduler might try to run an already partially-removed task). Therefore, dequeue_rt_stack uses the back pointers to constructs a list in the opposite direction:
   NULL    back
     ^      |
     |      V
+-parent----------+
|                 |
| top-level group |
|                 |
+----------back---+
     ^      |   ^_____________
     |      V                 \
+-parent----------+   +-----parent------+
|                 |   |                 |
| mid-level group |   |   other group   |  ...
|                 |   |                 |
+----------back---+   +-----------------+
     ^      |   ^_____________
     |      V                 \
+-parent----------+   +-----------------+
|                 |   |                 |
|      task       |   |   other task    |  ...
|                 |   |                 |
+----------back---+   +-----------------+
            |
            V
           NULL

That back list can then be used to walk down the tree to remove the entities in the correct order.

A: I am a fresh man in kernel hacking. This is my first time to answer linux kernel question.
Maybe this help to you.
I read the source code. I think it maybe relates to group scheduling.
When kernel have these codes:
#ifdef CONFIG_RT_GROUP_SCHED

It represents that we can collect some schedule entities in to one schduling group.
static void enqueue_rt_entity(struct sched_rt_entity *rt_se, bool head)

{
    dequeue_rt_stack(rt_se);
    for_each_sched_rt_entity(rt_se)
          __enqueue_rt_entity(rt_se, head);

}
Function dequeue_rt_stack(rt_se) extracts all the scheduling entities belong to the group, then add them to run queue.
Hierarchical group I/O scheduling
CFS group scheduling


text:
Q: How can I display a meaningful login error messages to user within python-social-auth? I am using python-social-auth with Django 1.6 and things are working well.
I defined SOCIAL_AUTH_LOGIN_ERROR_URL to point to a view I have within my app to show an error to the user when the login does not go as planned.
My system does not allow creation of new users. You must first log into your account using the regular credentials, associate your account with a social account, and only then can you log in using a social auth mechanism.
If a user attempts to log into my system using a social account which is not registered to a user within my system, I want to display a custom message. The problem is, the view located at SOCIAL_AUTH_LOGIN_ERROR_URL does not receive any info about what the error could be. The best I can do is say "An error occurred while trying to log in."
How would I trap such errors and display a custom message to my users when that particular error happens?

A: Take a look at the middleware from the django_app:
https://github.com/omab/python-social-auth/blob/526439ac66b00ce801e4fc5df89633a66eb8ffb2/social/apps/django_app/middleware.py
and either create your own based on this or extended by overriding. As mentioned there, probably the get_message method.

A: to handle this, I do the following:
settings.py
...
SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
    # the custom pipeline step
    'accounts.views.user_details_after',
)
...

views.py
def user_details_after(strategy, details, user=None, *args, **kwargs):
    if not user:
        messages.info(strategy.request, "You have to sign up first.")

in the loging template I render the message to display it to the user.

A: A simpler way is to just render the error page with the info you want, like
return render(
        request,
        "error.html",
        {
        "error_title":"Custom Error",
        "error_message":"This is an error"
        }
    )

and your templates/error.html template

{{ error_title }}

{{ error_message }}


text:
Q: C# Unit Testing In A Single Project Alright, so I'm doing my first "real" C# project.  I'm chugging along, enjoying myself, nice little language I've got here, fairly easy to use, la ti da.  Then I get to the point that I realize there's no simple way of setting up friend classes for unit testing.
Well.  This is unfortunate.
I dig around and find that I can jump through some burning hoops and expose everything to another assembly with:

[assembly: InternalsVisibleTo("AssemblyName")]

But...  this is a fairly minor in-house app that I've just going to a single binary and doesn't really warrant multiple assemblies.  What other options - if any - does C# offer?

A: None.  There is no way to run unit tests without first building the tests into an assembly.  That means one of two things:

*

*Ship all your test code with your product.  Not recommended--particularly if your tests do anything with a database.

*Package the test code in a separate DLL that is used in house.  Recommended.

Even Microsoft's unit test framework has this limitation.

A: You could add an additional build configuration to Debug and Release called Test or UnitTest and define a compiler directive TEST or UNITTEST or whatever.
Then build your tests into the same assembly, even into the same classes if you really want to test privates.  Then wrap the test class or test methods with #if TEST.  That way if you build as Test the tests are included and your assembly is testable including privates.  Build as Debug or Release and they're not included.
Maybe a little messy to include tests with your assembly and not perfect, but we've used it and it does work.

A: What's the trouble with using public methods and classes? Your methods should be encapsulated appropriately and you should be writing tests against public and occasionally internal (which can be exposed to your testing assembly through InternalsVisibleTo) methods.
You shouldn't have to test private methods. Doing that means you're testing implementation details instead of a behaviour contract. Your tests shouldn't care how something gets done, just that it does get done. Doing it otherwise increases the chances of your tests being brittle and requiring extra maintenance when production code is modified.
A typical solution setup for C# is to have an assembly (or several) for your production code and an assembly (or several) for your tests. The assembly split for production code is generally decided based on functionality. For a small in-house app you'd be fine with just one. For tests, assemblies are sometimes split based on the kind of testing performed -- unit or integration.
I recommend following that pattern and placing your tests into a separate assembly that references your production code assembly. Make your classes/methods public as needed and test those features without worrying about the minutiae of their implementation in your tests.

A: [assembly: InternalsVisibleTo("AssemblyName")]

This does not expose everything to another assembly. This exposes members marked as internal.
public members are obviously exposed by default, however private and protected members are not.
Microsoft's recommendation for unit testing private methods it to use reflection or their automatically generated Private Accessors: How to: Test a Private Method
To get at a private method using reflection:
using System.Reflection

MyClass instance = new MyClass();
MethodInfo privateMethod = instance.GetType().GetMethod("PrivateMethod", BindingFlags.NonPublic | BindingFlags.Instance);

Then to run the method:
object returnvalue = privateMehtod.Invoke(instance, new object[] {any, parameters, the, method, needs});

I would only ever use this for testing. I would not use this to call a private method in normal code, because it's private for a reason.

A: Your other options are putting the tests in the same assembly or making your classes more public.
Personally, I generally go with InternalsVisibleTo (I've just written a small project of Powershell Cmdlets with 20-odd tests and I've still done it that way). It does feel like a dubious thing to do when you first do it, but it becomes perfectly natural after a while. Fact is that you're being very specific about what the Internals will be Visible To.

A: There is a better way than using friend classes. If you are using MSTest, right-click on a class name in the editor window.
On the contextual menu that appears select : Create Private Accessor. Then select your test project.
What this will do is create a class in your test project that will allow you to test the private members and methods of a class without making it public.
Here is how you use this accessor:
Foo foo = new Foo();

var shadowFoo = Foo_Accessor.AttachShadow(Foo);
shadowFoo._private ...

EDIT: Here is a link on how to use accessors: http://michaelflanakin.com/Weblog/tabid/142/articleType/ArticleView/articleId/1030/MSTest-Helper-Create-Private-Accessor.aspx.
Also see my comment for more information.


text:
Q: Why is Kullback–Leibler divergence a divergence. How is it related to divergence of a vector field? Why is Kullback–Leibler divergence a divergence. How is it related to divergence of a vector field

A: Considering that the vector calculus concept's Wikipedia article opens

This article is about divergence in vector calculus. For divergence of
  infinite series, see Divergent
  series. For
  divergence in statistics, see Divergence
  (statistics).
  For other uses, see Divergence
  (disambiguation).

and KL is an example of a divergence in statistics and its own article opens

Not to be confused with
  divergence in vector
  calculus.

I think the names are unrelated. There are just too many times in the history of mathematics terminology someone has needed a name that conveys a difference between things.


text:
Q: a bytes-like object is required, not 'str' while parsing XML files I am trying to parse an xml that looks like this. I want to extract information regarding the katagorie i.e ID, parent ID etc:
<?xml version="1.0" encoding="UTF-8"?>
<test timestamp="20210113">
<kategorien>
    <kategorie id="1" parent_id="0">
        Sprache
    </kategorie>
</kategorien>
</test>

I am trying this
fields = ['id', 'parent_id']

with open('output.csv', 'wb') as fp:
    writer = csv.writer(fp)
    writer.writerow(fields)
    tree = ET.parse('./file.xml')
    # from your example Locations is the root and Location is the first level
    for elem in tree.getroot():
        writer.writerow([(elem.get(name) or '').encode('utf-8')
            for name in fields])

but I get this error:
in <module>
    writer.writerow(fields)
TypeError: a bytes-like object is required, not 'str'

even though I am already using encode('utf-8')  in my code. How can I get rid of this error?

A: EDIT 2
If want to find regarding nested attributes or sub-classes, there are two ways:

*

*You can use a nested loop:

for elem in root:
    for child in elem:
        print([(child.attrib.get(name) or 'c') for name in fields])

Output:

['1', '0']

Here, it can also return for classes which have id and parent_id but not the name kategorie.

*If you want to perform the task with a bit more performance and less memory:

for elem in root.iter('kategorie'):
    print([(elem.attrib.get(name) or 'c') for name in fields])

Output:

['1', '0']

For this method, it will return for every class and sub-class named kategorie.
EDIT 1: For the issue in comments:
<?xml version="1.0"?>
<kategorien>
    <kategorie id="1" parent_id="0">
        Sprache
    </kategorie>
</kategorien>

For the above xml file, the code seems to work perfectly:
fields = ['id', 'parent_id']

for elem in tree.getroot():
    print([(elem.attrib.get(name) or 'c') for name in fields])

Output:

['1', '0']

Original Answer:
Looks like you are looking at the wrong location for the error. The error is actually occurring at
writer.writerow(fields)

fields is a list containing str and not byte, that is why it is giving you the error. I would have recommended you to change the write type from wb to w, but looking at the rest of the code, it looks like you want to write in byte.
writer.writerow([x.encode('utf-8') for x in fields])

encode() just converts your data to byte form.

A: I see two problems. First, you don't need to do the encoding yourself. Open the file without the "b" binary flag and skip .encode. The file object will do the encoding for you. The error you see comes from the ['id', 'parent_id'] list holding unencoded strings. But if you don't open in binary in the first place, its not a problem.
Second, you are iterating the wrong element. Add a print(elem) in your loop and you'll see. instead, you can use findall with a pseudo-xpath to get the elements you want.
import csv
import xml.etree.ElementTree as ET

fields = ['id', 'parent_id']

with open('output.csv', 'w') as fp:
    writer = csv.writer(fp)
    writer.writerow(fields)
    tree = ET.parse('./file.xml')
    # from your example Locations is the root and Location is the first level
    for elem in tree.getroot().findall('kategorien/kategorie'):
        writer.writerow([(elem.get(name) or '')
            for name in fields])


text:
Q: Two docker's container see each others in the same machine I create an Docker's image with name is sample, then I installed nginx on both of them that listen to port 80 and it shows simple index.html.
then I use below commands to run contianers:
 docker run -it -p 80:80 --name sample1 sample
 docker run -it -p 81:80 --name sample2 sample

and I successfully see the index.html from main OS  from two containers, but when I go inside container sample1 I couldn't see the index.html of sample2 and It does not work conversely either.

A: The -p option is the shortform for ports. When you do -p you are binding the container's port 80 to its host's port 80.
So container sample1 and sample2 are just merely binding their respective port 80 to the host's port 80 and 81, hence there is no direct linkage between them.
To make the containers visible to each other, first you will have to use the --link option and then do an --expose to allow the containers to see each other through the exposed port.
Example:
docker run -it -p 80:80 --name sample1 sample
docker run -it -p 81:80 --link=sample1 --expose="80" --name sample2 sample

Essentially --link means to allow the container to see the link value's container
--expose means the linked containers are able to communicate through that expose port.
Note: linking the containers is not sufficient, you need to expose ports for them to communicate.
You might want refer to the docker-compose documentation for more details;
https://docs.docker.com/compose/compose-file/
While the documentation is for docker-compose but the options are pretty much the same as the raw docker binary, and everything is nicely put on 1 page. That's why I prefer looking at there.

A: In Docker you can bind container's port to docker machine (Machine installed with docker) port using
docker run -it -p 80:80 image
Then you can use docker machine Ip and port inside the another container.


text:
Q: Adding a gesture recognizer to both custom tableview cell and subviews on cell is not working I have added  gesture recognisers to subviews on my tableview custom cell .
Enabled isUserInteractionEnabled for UIElements
let imageView: UIImageView = {
        let imageView = UIImageView()
        imageView.translatesAutoresizingMaskIntoConstraints = false
        imageView.isUserInteractionEnabled = true
        return imageView
    }()

let firstLabel: UILabel = {
    let label = UILabel()
    label.translatesAutoresizingMaskIntoConstraints = false
    label.isUserInteractionEnabled = true
    return label
}()

let someStackView: UIStackView = {
    let stackView = UIStackView()
    stackView.translatesAutoresizingMaskIntoConstraints = false
    stackView.axis = .vertical
    stackView.alignment = .leading
    return stackView
}()

let secondButton: UIButton = {
    let button = UIButton(type: .custom)
    button.isUserInteractionEnabled = true
    button.translatesAutoresizingMaskIntoConstraints = false
    return button
}()

 func setupcustomcellView() {
    addSubview(imageView)
    addSubview(someStackView)
    someStackView.addArrangedSubviews([
        firstLabel,
        secondButton
    ]) }

I have added gestures using below function :
 private func setupUserInteraction() {
        let iMageTapRecognizer = UITapGestureRecognizer(target: self,
                                                              action: #selector(didTappediMage))
        imageView.addGestureRecognizer(iMageTapRecognizer)

        secondButton.addTarget(self,
                                             action: #selector(didTappedtButton),
                                             for: .touchUpInside)
        let firstLabelTapRecognizer = UITapGestureRecognizer(target: self,
                                                              action: #selector(didTappedfirstLabel))
        firstLabel.addGestureRecognizer(firstLabelTapRecognizer)
    }

These gestures are recognised only when I disable user interaction for custom cell content view.
contentView.isUserInteractionEnabled = false

But I want to add gesture to my content view itself. When user clicks on cell I need to perform certain action. But when I make contentView.isUserInteractionEnabled = true, My subviews gesturerecognizers are not recognised. Please guide me why is gesture of UI elements are not recognised when custom cell user interaction is set to true.

A: Content view is blocking in between . I made below changes and it worked
 func setupcustomcellView() {
    self.contentView.addSubview(imageView)
    self.contentView.addSubview(someStackView)
    someStackView.addArrangedSubviews([
        firstLabel,
        secondButton
    ]) }


text:
Q: GitHub - Remove pushed commits without affecting local repository What is the best way to remove commits from GitHub without affecting my local repositories since i made some commits that i wish to keep?
Github repository has two wrong commits that i desire to remove while keeping the commits on my local repository.

A: Assuming the current repository state is this:
server:         A---B---C---D
                            ^master

workstation:    A---B---C---D
                            ^HEAD
                            ^master
                            ^origin/master

And the desired state is this:
server:         A---B
                    ^master

workstation:    A---B---C---D
                            ^HEAD
                            ^master
                    ^origin/master

Then what you can do to get there is this:
$ git push --force origin bbbbbbbb:master

where bbbbbbbb is the commit hash of B.
Notes:

*

*As with all --force, be careful. You can get yourself into a place that's difficult to come out of.

*Make sure all your team members know what you're doing. They may inadvertently push C and D right back into the repository if they don't update their own repository correctly after you push.

*If any other tags/branches point to commits C and D, they'll remain accessible through there.

*Commits C and D and all changes in them may not be instantly deleted. They will be removed in a garbage collection pass at an undefined moment in time.


text:
Q: How to increase Pagesize of REST API call response using SSJS in Cloudpage I am using REST API call to get history data. For this I am writing SSJS in Cloud page and am trying to store the data in a data extension. The result of REST API call is more than 100 records. But by default it is giving me page 1 , page size = 100. How to set page size to maximum? I am using a for loop, if condition in the body to get specific activity details for all Id's

A: In general,but not always the case, you can use the $page and $pageSize parameters to control this.
For example:
/fake/myendPoint?$page=1&$pageSize=500 would return a payload of the first 500 items in the return.
Do be careful though as not every endpoint will do this. Also, sometimes in order for $pageSize to work, you need to indicate the page first (like my sample) or it will not affect the return.
EDIT: for anything being retrieved in bulk, I would look to either have multiple calls that are looped through and concatenated (will likely be a high resource draw and risk of timeout issues) or I would look to do a data extract of the full load, push this to an FTP and then utilize your service to grab this data and properly ingest it.


text:
Q: How to use addEventListener to element rendered by javascript instead of inline js I don't want to see the inline js when I inspect the page.
const data = [
    {name: "A", desc: "Lorem ipsum dolor"},
    {name: "B", desc: "sit amet consectetur adipisicing elit"},
]

const container = document.querySelector(".container");
data.forEach(item => {
    container.innerHTML += `<div class="card" onclick="showDetail('${item.desc}')">${item.name}</div>`
})

function showDetail(desc) {
    console.log(desc);
}

Therefore, I want to use addEventListener, but I don't know how to access desc without render in HTML
const cards = document.querySelectorAll(".card");
cards.forEach(card => {
    card.addEventListener("click", () => {
        stuck here...
    })
})

edit:
I watched a video on youtube. I can use document.createElement in forEach. Then I can use addEventListener on it.
data.forEach(item => {
   const newDiv = document.createElement("div");
   newDiv.innerHTML = `...`;

   newDiv.addEventListener("click", () => console.log(item.desc))

   container.append(newDiv)
})

A: You can use data-attribute for example:
data.forEach(item => {
    container.innerHTML += `<div class="card" data-desc="${item.desc}">${item.name}</div>`
})

Then into addEventListener:
const cards = document.querySelectorAll(".card");
cards.forEach(card => {
    card.addEventListener("click", () => {
        showDetail(card.dataset.desc);
    })
})

A: First, I'd like to commend you on wisely ridding your code of attribute event handlers, the next step in imptoving your code is to use event delegation.
Event delegation is the best way to listen and handle events under circumstances of a changing environment such as:

*

*listen for events for an unknown amount of elements

*listen for events on dynamically created elements
Event delegation leverages event bubbling and the very versitile Event Object. Basically, add an event listener to a parent element (".container") of the tags (".card") that the user will actually click. Then in the event handler, determine what happens to certian tags and exclude the rest.
Details are commented in example below

const box = document.querySelector(".container");

const data = [{
    name: "A",
    desc: "Lorem ipsum dolor"
  },
  {
    name: "B",
    desc: "sit amet consectetur adipisicing elit"
  }
];

/* Pass the event object */
const clickHandler = event => {
  /* This is .container -- parent element that
     listens for the click event for it's child
     tags '.card'
  */
  const base = event.currentTarget;
  // This an array of '.card' within '.caontainer'
  const deck = [...base.querySelectorAll('.card')];
  // This is the actual '.card' that was clicked
  const item = event.target;
  // This is the index of the clicked '.card'
  const index = deck.indexOf(item);
  /*
  This condition ensures that only '.card' tags
  are clickable -- any other tag is ignored
  */
  if (item.matches('.card')) {
    console.log(data[index]['desc']);
  }
};

data.forEach(item => {
  box.insertAdjacentHTML('beforeEnd', `<div class="card">${item.name}</div>`);
});

box.addEventListener('click', clickHandler);


text:
Q: Using a SELECT statement within a WHERE clause SELECT * FROM ScoresTable WHERE Score =
  (SELECT MAX(Score) FROM ScoresTable AS st WHERE st.Date = ScoresTable.Date)

Is there a name to describe using a SELECT statement within a WHERE clause? Is this good/bad practice?
Would this be a better alternative?
SELECT ScoresTable.*
FROM ScoresTable INNER JOIN
  (SELECT Date, MAX(Score) AS MaxScore
  FROM ScoresTable GROUP BY Date) SubQuery
  ON ScoresTable.Date = SubQuery.Date
  AND ScoresTable.Score = SubQuery.MaxScore

It is far less elegant, but appears to run more quickly than my previous version. I dislike it because it is not displayed very clearly in the GUI (and it needs to be understood by SQL beginners). I could split it into two separate queries, but then things begin to get cluttered...
N.B. I need more than just Date and Score (e.g. name)

A: It's not bad practice at all. They are usually referred as SUBQUERY, SUBSELECT or NESTED QUERY.
It's a relatively expensive operation, but it's quite common to encounter a lot of subqueries when dealing with databases since it's the only way to perform certain kind of operations on data.

A: It's called correlated subquery. It has it's uses.

A: There's a much better way to achieve your desired result, using SQL Server's analytic (or windowing) functions.
SELECT DISTINCT Date, MAX(Score) OVER(PARTITION BY Date) FROM ScoresTable

If you need more than just the date and max score combinations, you can use ranking functions, eg:
SELECT  *
FROM    ScoresTable t
JOIN (
    SELECT
        ScoreId,
        ROW_NUMBER() OVER (PARTITION BY Date ORDER BY Score DESC) AS [Rank]
        FROM ScoresTable
) window ON window.ScoreId = p.ScoreId AND window.[Rank] = 1

You may want to use RANK() instead of ROW_NUMBER() if you want multiple records to be returned if they both share the same MAX(Score).

A: The principle of subqueries is not at all bad, but I don't think that you should use it in your example. If I understand correctly you want to get the maximum score for each date. In this case you should use a GROUP BY.

A:
This is a correlated sub-query.

(It is a "nested" query - this is very non-technical term though)
The inner query takes values from the outer-query (WHERE st.Date = ScoresTable.Date) thus it is evaluated once for each row in the outer query.
There is also a non-correlated form in which the inner query is independent as as such is only executed once.
e.g.
 SELECT * FROM ScoresTable WHERE Score =
   (SELECT MAX(Score) FROM Scores)

There is nothing wrong with using subqueries, except where they are not needed :)
Your statement may be rewritable as an aggregate function depending on what columns you require in your select statement.
SELECT Max(score), Date FROM ScoresTable
Group By Date

A: In your case scenario, Why not use GROUP BY and HAVING clause instead of JOINING table to itself. You may also use other useful function. see this link

A: Subquery is the name.
At times it's required, but good/bad depends on how it's applied.


text:
Q: create a view with map / reduce functions that return values I would like to create a view with map / reduce functions that return the latest values from several documents with same id, seems I can return the latest document giving with the xyz id based on the update_datetime, not sure how to get the latest value like field1 and field2, thank you
doc1: id='xyz', field1='v1.0', field2='v2.0', field3='v3.0', status='NEW', update_datetime='2015-04-28'
doc2: id='xyz', field2='v2.1', field3='v3.0', status='CHANGED', update_datetime='2015-05-01'
doc3: id='xyz', field3='v3.1', status='CLOSED', update_datetime='2015-05-10'

define a view with map / reduce that, given a key value 'xyz', returns the following document:
id='xyz', field1='v1.0', field2='v2.1', field3='v3.1', status='CLOSED', update_datetime='2015-05-10'.

A: I have a feeling that the data model you have could be improved but I do not know enough about your use case to comment on that really. Therefore I would suggest a reduce function that will perform a merge of the documents using newer as an override for existing properties unless a property does not exist.
Here is the content of map and reduce functions (btw, I have changed the name of one of the fields from update_datetime to updated. Also please bear in mind that id and _id are different - might be worth renaming your own id field to something more distinguishable from couchdb's doc id field):
// MAP
function(doc) {
  emit(doc.id, doc);
}
// REDUCE
function(keys, values, rereduce) {
    if (values.length > 1) {
        var mergedDoc = values[0];
        for (var i = 1; i < values.length; i++) {
            var newDoc = values[i];
            var updatingWithNewer = newDoc.updated >= mergedDoc.updated;
            for (key in newDoc) {
                if (key != "_id" && key != "id") {
                    if (updatingWithNewer || mergedDoc[key] == undefined) {
                        mergedDoc[key] = newDoc[key];
                    }
                }
            }
        }
        return mergedDoc;
    } else {
        return values[0];
    }
}

Performing level 1 reduce will give you expected result. Hope it helps.


text:
Q: How to make python 3.7 default in Ubuntu 20.04? I would like to install tensorrt binding for python3 on Ubuntu 20.04 ( https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-700/tensorrt-install-guide/index.html#installing-debian ) . This Ubuntu has python 3.8 as a default, but those tensorrt bindings needs python 3.7 or lower.
The package is installed via sudo apt-get install python3-libnvinfer-dev  . But this crash because of python 3.8 . So I have installed also python 3.7 via sudo apt-get install python3.7 so I can access 3.7 running command python3.7 . I have also made a ln -s /usr/bin/python3.7 /usr/bin/python3 to make a python3 command opennning the 3.7 version. But aptget still has a problem and python3.7 is not visible for it. What can I do to make python 3.7 native in Ubuntu 20.04 or how to tell apt-get to look in /usr/bin/python3.7 location? Thanks

A: Check if http://web.mit.edu/6.00/www/handouts/pybuntu.html helps.
unbuntu seems to ahvve update-alternative
Didn't try it myself.

A: This should solve your problem. But i don't know how to make python3.7 the default in Ubuntu 20.04.
Download the tar file install package of your desired TensorRT version. Extract it. Navigate to the extracted folder and then to the python folder. You will find the .whl files for the TensorRT python API. Try installing with pip.
In your case it should be like this(if you are trying to install TensorRT 7.1):
python3.7 -m pip install tensorrt-7.1.3.4-cp37-none-linux_x86_64.whl

I found this procedure from the official TensorRT github repository