text:
Q: Tips for testing data intensive legacy application I'm working on a very large, data-intensive legacy application.  Both the code base & database are massive in scale.  A great deal of the business logic is spread across all of the tiers including in stored procedures.
Does anybody have any suggestions on how to begin applying "unit" tests (technically integration tests because they need to test across tiers for a single aspect of almost any given process) into the application in an efficient way?  The current architecture does not easily support any type of injection or mocking.  New code is being written to facilitate testing, but what about the legacy code?  Because of the strong dependency on the data itself and business logic in the database, I'm currently using inline sql to find data to use for testing but these are time consuming.  Creating views and/or stored procedures will not suffice.
What approaches have you taken (if applicable)?  What worked?  What didn't & why?  Any suggestions would be appreciated.  Thanks.

A: Get a copy of Working Effectively with Legacy Code by Michael Feathers.  It is full of useful advice for working with large, untested codebases.
Another good book is Object Oriented Reengineering Patterns. Most of the book is not specific to object-oriented software. The full text is available for free download in PDF format.
From my own experience: try to...

*

*Automate the build and deployment

*Get the database schema into version control, if it isn't yet.  Usually databases include reference data that the transactional code needs to exist before it can work.  Get this under version control too.  Tools like dbdeploy can help you easily rebuild a schema and reference data from a sequence of deltas.

*Install a version of the database (and any other infrastructure services) onto your development workstation.  This will let you work on the database without continually having to go through DBAs.  It's also faster than using a schema on a shared server in a remote datacentre. All major commercial database servers have free (as in beer) development versions that work on Windows (if you're stuck in the unenviable situation of developing on Windows and deploying on Unix).

*Before starting work on an area of the code, write end-to-end tests that roughly cover the behaviour of the area you're working on.  An end-to-end test should exercise the system from outside -- by controlling its user interface or interacting through network services -- so you won't need to change the code to put it into place.  It will act as an (imperfect) regression test and give you more confidence to refactor the internals of the system towards a structure that is easier to unit test.

*If there are manual test plans, read them and see what can be automated. Most manual test plans are almost entirely scripted and so are low-hanging fruit for automation

*Once you've got end-to-end tests coverage, refactor the code  into more loosely coupled units as you modify and/or extend it. Surround those units with unit tests.

Things to avoid:

*

*Copying data from the production database into the environment you use for automated testing.  This will make your tests unpredictable.  Sure, run the system against a copy of production data, but use that for exploratory testing, not regression testing.

*Rolling back transactions at the end of tests to isolate tests from one another.  This will not test behaviour that only happens when transactions are committed, and will throw away data that is valuable for diagnosing test failures.  Instead, tests should ensure the database is in a known initial state when they start.

*Creating a "tiny" data set for tests to run against.  This makes tests hard to understand because they cannot be read as a single unit.  The "tiny" data set soon grows very large as you add tests for different scenarios.  Instead, tests can insert data into the database to set up the test-fixture.

A: "Testing Legacy Application Modernization," highlights:

*

*High level overview of how tests are created in AscentialTest

*Ways to convert the legacy objects to the new platform Components of Object definition

*How to ensure that the modernized version of the application produces the same results
For more details on usage of testing legacy application, do check here:
http://application-management.cioreview.com/whitepaper/testing-legacy-application-modernization-wid-529.html

A: As mentioned before, there are some very good books out there. Highly recommended to take a look at Working Effectively with Legacy Code.
Something you could do is following a data driven approach, observe your application and introduce tests where you have more "pain". A semi-deterministic approach you might find useful: https://link.medium.com/zY9Tysfne9


text:
Q: Writing to a PHP Session Variable from Ajax Ok, this is starting to annoy me, as it's quite simply and works elsewhere, but on this current task it doesn't, so here I go!
There is a main page which relies on either a session variable being set or not to display certain information.
Let's say this page is located here: http://dev.example.com/some_page.php
e.g.
if (isset($_SESSION["some_var"])) { /* it's set so do whatever */ }
else { /* not set so do whatever else.. */ }

There is an ajax page triggered by jQuery $.ajax() to call and set this session variable to null to change the action of the main page, let's say it's located here: http://dev.example.com/ajax/some_ajax_page.php
It's code looks like so:
<?php
    if (!isset($_SESSION)) session_start();
    $_SESSION["some_var"] = null;

When the main page is reloaded after the ajax is triggered, the session var "some_var" is still intact, but if it's echoed after the "null" in the ajax page then it is set to "null".
Basically it doesn't seem to write to the global session, only to the local path.
Does this make sense?
Any help please? Also if you want more clarification with anything let me know!

A: Get rid of the check for session.  If this is the only file your calling just do this:
<?php
   session_start();
   $_SESSION["some_var"] = null;

Also, are you using framework that auto-regenerates session ID on each request?  If so, you'll might have problems.
If you have a dev machine to play with and permissions to do so, you can manually delete all sessions in the /var/lib/php/session/ directory.  As you use your site, only one session file should be created.  You can also inspect that file to see what is getting written and when.

A: The session_start() function will handle the attempt to create and persist a session for you, as defined by PHP's configuration, or optionally at runtime if you set your own save handler. Make sure you read the documentation here:
http://us2.php.net/manual/en/function.session-start.php
For your code, you want to make sure to call session_start() at the beginning of any page in which you'd like to save or access session variables. So your page above may look like:
 <?php

 session_start();

 $_SESSION['myvar'] = 'some value';

Then in a different page you can try to access that value:
 <?php

 session_start();

 if ($_SESSION['myvar'] == 'some value') {

   // do something

 }

That should work fine.

A: Seems that you are using different sessions vars. One for the AJAX call and another for the normal pages calls. This may occur when you do not init both call in the same way (or using the same starting code that initializes the sessions)
Be sure to session_start() both calls using the same session_id.
// try in both calls
session_start();
echo session_id(); // must return the same id in both calls

A: Why don't you use unset? It is the proper way to do it.

A: Turns out the application I was working on had it's own session_handler and if it was not included before requesting the session data, it was always invalid, eventhough it was the same session_id.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Const char to Array C++ I'm having a problem with a function to generate all sub sequences of a Word. Problem is:
cout << *(s + y) ;

This line print's a char and i want to add this "char" to a array
Like:
char str[100];
str+=(cout << *(s + y) );

I know this is wrong but there is any way to do this? To add char by char into a array? (this type *(s + y)  is also very weard, compiler is displaying a lot of problems)
Function:
void encontra(const char *s)
{
    string str;
    while(*s)
    {
        int x=0;
        while(*(s + x))
        {
            for(int y = 0; y <= x; y++)
                cout << *(s + y) ;
            cout << "\n";
            x++;
        }
        s++;
    }
}

A: There are two problems with the expression
str+=(cout << *(s + y) )

The first is that the output operator << returns a reference to the stream.
The second problem is that you can't append to arrays like that.
Instead use std::string, then you can easily append characters to the string:
std::string str;
std::cout << s[y];
str += s[y];


text:
Q: How to align the title of a pgfgantt on the left I would like align the titles of my gantt-chart on the left.
For the moment I have something like this:

but I  would like the numbers (0, 0.2, 0.4, etc.) to be place on the left, not in the middle.
Does someone know how to do it? Or is there a better way to do it than using pgfgantt?
My code lookes like that:
\begin{ganttchart}[
expand chart=\textwidth,
]{1}{20}
[vgrid={draw=none, dotted}]{1}{20}
\gantttitle{0} {2}
\gantttitle{0.2}{2}
\gantttitle{0.4}{2}
\gantttitle{0.6}{2}
\gantttitle{0.8}{2}
\gantttitle{1.0}{2}
\gantttitle{1.2}{2}
\gantttitle{1.4}{2}
\gantttitle{1.6}{2}
\gantttitle{1.8}{2} \\

\ganttbar{Process 1}{4}{7} \\
\ganttbar{Process 2}{3}{6} \\
\end{ganttchart}

Thanks in advance!

A: With 0 transformed into 0.0 as I am assuming that you want the same distance from the left.
\documentclass{article}
\usepackage{pgfgantt}

\begin{document}

\begin{ganttchart}[
title label node/.append style={anchor=east,xshift=1mm},
expand chart=\textwidth,
]{1}{20}
[vgrid={draw=none, dotted}]{1}{20}
%\gantttitle{0} {2}
\gantttitle{0.0} {2}
\gantttitle{0.2}{2}
\gantttitle{0.4}{2}
\gantttitle{0.6}{2}
\gantttitle{0.8}{2}
\gantttitle{1.0}{2}
\gantttitle{1.2}{2}
\gantttitle{1.4}{2}
\gantttitle{1.6}{2}
\gantttitle{1.8}{2} \\

\ganttbar{Process 1}{4}{7} \\
\ganttbar{Process 2}{3}{6} \\
\end{ganttchart}

\end{document}


text:
Q: Rewrite variable in Erlang I am playing with records and list. Please, I want to know how to use one variable twice. When I assign any values into variable _list and after that I try rewrite this variable then raising error:

** exception error: no match of right hand side value

-module(hello).
-author("anx00040").

-record(car, {evc, type, color}).
-record(person, {name, phone, addresa, rc}).
-record(driver, {rc, evc}).

-record(list, {cars = [], persons = [], drivers = []} ).

%% API
-export([helloIF/1, helloCase/1, helloResult/1, helloList/0, map/2, filter/2, helloListCaA/0, createCar/3, createPerson/4, createDriver/2, helloRecords/0, empty_list/0, any_data/0, del_Person/1, get_persons/1, do_it_hard/0, add_person/2]).

createCar(P_evc, P_type, P_color) -> _car = #car{evc = P_evc, type = P_type, color = P_color}, _car
  .
createPerson(P_name, P_phone, P_addres, P_rc) -> _person= #person{name = P_name, phone = P_phone, addresa = P_addres, rc = P_rc}, _person
  .
createDriver(P_evc, P_rc) -> _driver = #driver{rc = P_rc, evc = P_evc}, _driver
  .

empty_list() ->
  #list{}.

any_data() ->
  _car1 = hello:createCar("BL 4", "Skoda octavia", "White"),
  _person1 = hello:createPerson("Eduard B.","+421 917 111 711","Kr, 81107 Bratislava1", "8811235"),
  _driver1 = hello:createDriver(_car1#car.evc, _person1#person.rc),

  _car2 = hello:createCar("BL 111 HK", "BMW M1", "Red"),
  _person2 = hello:createPerson("Lenka M","+421 917 111 111","Krizn0, 81107 Bratislava1", "8811167695"),
  _driver2 = hello:createDriver(_car2#car.evc, _person2#person.rc),

  _car3 = hello:createCar("BL 123 AB", "Audi A1 S", "Black"),
  _person3 = hello:createPerson("Stela Ba.","+421 918 111 711","Azna 20, 81107 Bratislava1", "8811167695"),
  _driver3 = hello:createDriver(_car3#car.evc, _person3#person.rc),

  _list = #list{
    cars = [_car1,_car2,_car3],
    persons = [_person1, _person2, _person3],
    drivers = [_driver1, _driver2, _driver3]},
  _list.

add_person(List, Person) ->
  List#list{persons = lists:append([Person], List#list.persons) }.

get_persons(#list{persons = P}) -> P.

do_it_hard()->
  empty_list(),
  _list = add_person(any_data(), #person{name = "Test",phone = "+421Test", addresa = "Testova 20 81101 Testovo", rc =88113545}),
  io:fwrite("\n"),
  get_persons(add_person(_list, #person{name = "Test2",phone = "+421Test2", addresa = "Testova 20 81101 Testovo2", rc =991135455}))
.

But it raising error when i use variable _list twice:
do_it_hard()->
  empty_list(),
  _list = add_person(any_data(), #person{name = "Test",phone = "+421Test", addresa = "Testova 20 81101 Testovo", rc =88113545}),
  _list =add_person(_list, #person{name = "Test2",phone = "+421Test2", addresa = "Testova 20 81101 Testovo2", rc =991135455}),
  get_persons(_list)
.

A: In the REPL, it can be convenient to experiment with things while re-using variable names. There, you can do f(A). to have Erlang "forget" the current assignment of A.
1> Result = connect("goooogle.com").
{error, "server not found"}
2> % oops! I misspelled the server name
2> f(Result).
ok
3> Result = connect("google.com").
{ok, <<"contents of the page">>}

Note that this is only a REPL convenience feature. You can't do this in actual code.
In actual code, variables can only be assigned once. In a procedural language (C, Java, Python, etc), the typical use-case for reassignment is loops:
for (int i = 0; i < max; i++) {
  conn = connect(servers[i]);
  reply = send_data(conn);
  print(reply);
}

In the above, the variables i, conn, and reply are reassigned in each iteration of the loop.
Functional languages use recursion to perform their loops:
send_all(Max, Servers) ->
 send_loop(1, Max, Servers).

send_loop(Current, Max, _Servers) when Current =:= Max->
 ok;
send_loop(Current, Max, Servers) ->
 Conn = connect(lists:nth(Current, Servers)),
 Reply = send_data(Conn),
 print(Reply).

This isn't very idiomatic Erlang; I'm trying to make it mirror the procedural code above.
As you can see, I'm getting the same effect, but my assignments within a function are fixed.
As a side note, you are using a lot of variable names beginning with underscore. In  Erlang this is a way of hinting that you will not be using the value of these variables. (Like in the above example, when I've reached the end of my list, I don't care about the list of servers.) Using a leading underscore as in your code turns off some useful compiler warnings and will confuse any other developers who look at your code.

A: In some situations it is convenient to use use SeqBind:

SeqBind is a parse transformation that auto-numbers all occurrences of these bindings following the suffix @ (creating L@0, L@1, Req@0, Req@1) and so on.

Simple example:
...
-compile({parse_transform,seqbind}).
...

List@ = lists:seq(0, 100),
List@ = lists:filter(fun (X) -> X rem 2 == 0 end, List@)
...

A: I used google...
Erlang is a single-assignment language. That is, once a variable has been given a value, it cannot be given a different value. In this sense it is like algebra rather than like most conventional programming languages.

http://www.cis.upenn.edu/~matuszek/General/ConciseGuides/concise-erlang.html


text:
Q: Get Dataset from a GridView? how can i get the dataset from a gridview i have populated?
i tried this:
Dim importedDS As DataSet = gwResults.DataSource

but it's coming out blank all the time. is there another way?

A: Find another way to store/retrieve/cache the dataset, or the specific values you need from it.
When you first retrieve a dataset and assign it to a Grid, you will be able to access it for the remainder of the page request. As soon as the page request is over, the HTTP context and page and any associated objects are purged, they will be set for garbage collection and destroyed. (As far as we're concerned, anyway)
On the next post back, the grid will reload it's values from the form, (and some properties from view state), but not the whole dataset, since that was never stored in the form/view state. Keeping a dataset in view state would be a incredibly inefficient. This is why the DataSource property will be blank on subsequent post backs.

A: As another person mentioned, once the request is over - the objects aren't in scope anymore.
How are you binding the Grid to the DataSet and are you doing an if (!IsPostBack)?


text:
Q: Deploying JAVA WEB APP (netbeans) to AWS or GOOGLE APP ENGINE Hey I am new to cloud computing.
I developed a java web app using netbeans. I now have been trying to deploy it onto google app engine and AWS for over a week.
In case of GAE it is showing the error of not supporting javax.servlet.annotation which I need to get the servlet context.
In case of AWS, it is successfully uploaded and deployed, however, on open link it gives a blank page.
Please somebody help me.
I have one more conceptual doubt which I couldn't find answer to.
In netbeans, I have a database. How is this database provided on GAE or AWS.

A: I think we need much more information for this. I can only speak for AWS.
Where is the page hosted? What sort of errors is your application spitting out. What's the source of the page look like? Are you sure it's actually empty?
If it's returning a 200 and it's blank, that mean the page DOES exist, it's just not populating the page with what you want.

A: Deploying an application at your local server setup and at the cloud is no different provided the cloud machine (AMI in case of amazon) has the server installed. Please share the exception or error log which you are getting. Also, have a look at amazon RDS where you can set up your database.


text:
Q: Proof that $N$ is an immersed submanifold. Consider the following set in $\mathbb{R}^3$:
$$N := \{(\cos(t),\sin(t),e^t) \rvert t \in \mathbb{R}\} \sqcup \{(\cos(t),\sin(t),0) \vert t \in \mathbb{R}\}.$$
This is the union of a 'spiral' and a circle. We have to show (or disprove) that this is an immersed submanifold.
Intuitively, I would guess this is indeed an immersed submanifold. We equip this with the topology whose opens are 'along' the spiral and the circle. Then, the inclusion is evidently smooth and furthermore the differential is injective. However, I'm not entirely sure if this is truly correct.

A: An immersed submanifold of a manifold $M$ is the image $N = f(S)$ of an immersion $f: S \to M$ defined on a smooth manifold $S$. Note that in general $N$ is not a submanifold of $M$, even if $f$ is injective (which is in general not true).
So let $S = \mathbb R \times \{0,1\} \subset \mathbb R^2$. This is a smooth manifold (in fact, a smooth submanifld of $\mathbb R^2$). Define $f : S \to \mathbb R^3, f(t,0) = (\cos t, \sin t, e^t), f(t,1) = (\cos t, \sin t, 0)$. This is clearly an immersion with image $N$ as in your question. However, it is not a submanifold of $\mathbb R^3$.
Alternatively you can define $S = \mathbb R \times \{(0,1)\} \cup S^1 \times \{0\} \subset \mathbb R^3$, where $S^1 = \{ (x,y) \mid x^2 + y^2 = 1 \}$, and $f(t,0,1) = (\cos t, \sin t, e^t), f(p,0) = (p,0)$. Then $f$ is an injective immersion and its restrictions to $\mathbb R \times \{(0,1)\}$ and to $S^1 \times \{0\}$ are embeddings.


text:
Q: JQuery compare value of input? I have the following hidden input:
<input id="PostId" type="hidden" value="1" name="PostId" >

I want to check the value using jquery so that I can redirect to another page but I'm getting error:
 TypeError: "#PostId".val is not a function

This is my Jquery code:
 if (("#PostId").val() == 7 || ("#PostId").val() == 8) {

    window.location = baseUrl + "Post/Details/" + ("#PostId").val();
 }

Whats the correct syntax?

A: Your code is missing the $
if ($("#PostId").val() == 7 || $("#PostId").val() == 8) {
   window.location = baseUrl + "Post/Details/" + $("#PostId").val();
}

A: (function ($)
    {
      if ($("#PostId").val() == 7 || $("#PostId").val() == 8) {
         window.location = baseUrl + "Post/Details/" + $("#PostId").val();
         }
}(jQuery));


text:
Q: Getting MySQL values into an array from two different tables? My tagging system uses two tables, tags and coupon_tags. The way it works is that each coupon and each tag is assigned a numerical value. So a coupon may have the id 13 and a tag may have the id 5, for example. coupon_tags makes a new row per coupon per tag, so it may look like so:
couponID | tagID
    5        3
    5        1
    5        9
    6        1

In the code I am working on, the couponID is known, and represented as the variable $coupID. I need help on the following: So what I would have to do is figure out all of the rows where couponID is, and pull all of those tagID's into an array, for example, $allTagIDs[], and then loop through that array and at each iteration, match the tagID to a tagName in the next table called tags (both tables have a tagID field, which is how I match them up). Those tags need to be put into an array as well.
Then for output, I'll just print_r($arrOfTagNames). I just don't know how to do what I wrote up there in PHP.

A: You don't actually want to do that. You want to write ONE query which retrieves the names of the tags associated with coupon $coupID.
If you're ever running a query in a loop, you're probably doing something wrong, and it'll come back to bite you by overloading your server as soon as you have some significant traffic.
$sql = "
    SELECT
      tags.tagID,
      tags.tagName
    FROM
      tags
    INNER JOIN
      coupon_tags
    ON
      coupon_tags.tagID = tags.tagID
    WHERE
      coupon_tags.couponID = $coupID
";

$result = mysql_query($sql);

$arrOfTagNames = array();
while ($row = mysql_fetch_array($result)) {
  $arrOfTagNames[] = $row['tagName'];
}

print_r($arrOfTagNames);


text:
Q: Run time of shellsort and insertionsort change depending on execution order        1/  DateTime before = DateTime.Now;
       2/  shellSort(List1);
       3/  DateTime after = DateTime.Now;
       4/  Console.WriteLine(after - before);
       5/
       6/  before = DateTime.Now;
       7/  insertionSort(List2);
       8/  after = DateTime.Now;
       9/  Console.WriteLine(after - before);

I am trying to compare the run time of two different sorting algorithms. List1 here is equal to List2. I was expecting shell sort to be faster than insertion sort but although first WriteLine differs, it usually prints something like this = 00:00:00.0035037. The second one however, either prints 00:00:00 or something smaller than the first print. I thought maybe the insertion sort was better suited for List's current state however even when i swap the line 7 and line 2 i still get the same result. What is causing this? Why is the second executed function runs faster? Or am i using the Dates completely wrong?
Edit : I used Stopwatch instead of DateTime Class as advised in another post. The result is pretty much the same. The second one usually runs faster but every now and then it's slower than the first one. I also used a pre-written shellsort code to see if my implementation was bad but that was also a dead end.
As requested, shellsort and insertionsort implementations
static void shellSort(List<int> numbers) // Implementation i found online
        {
            int i, j, increment, temp;
            increment = 3;
            while (increment > 0)
            {
                for (i = 0; i < numbers.Count ; i++)
                {
                    j = i;
                    temp = numbers[i];
                    while ((j >= increment) && (numbers[j - increment] > temp))
                    {
                        numbers[j] = numbers[j - increment];
                        j = j - increment;
                    }
                    numbers[j] = temp;
                }
                if (increment / 2 != 0)
                    increment = increment / 2;
                else if (increment == 1)
                    increment = 0;
                else
                    increment = 1;
            }
        }

public static void insertionSort(List<int> numbers)
        {
            int i = 0;
            while (i != numbers.Count)
            {
                int k = i;
                while (k != 0 && numbers[k] < numbers[k - 1])
                {
                    int temp = numbers[k - 1];
                    numbers[k - 1] = numbers[k];
                    numbers[k] = temp;
                    k--;
                }
                i++;
            }
        }

Also this was my implementation of shellsort
public static void shellSort(List<int> Liste)
        {
            int n = Liste.Count;
            int gap = (Liste.Count - 1) / 2;
            while (gap > 0)
            {
                int i = 0;
                for(int k = gap; k < n; k++) {

                    int p = i;
                    int m = k;
                    while (p >= 0)
                    {

                        if (Liste[p] > Liste[m])
                        {
                            int temp = Liste[p];
                            Liste[p] = Liste[m];
                            Liste[m] = temp;
                            m = p;
                        }
                        else
                            break;
                        p = p - gap;
                    }
                    i++;
                }
                gap = gap / 2;
            }
        }


text:
Q: Unable to customize authorisation callback URL for SAML provider after connecting custom domain I'm unable to customize the authorisation callback URL to my custom domain when adding a new SAML provider in Google Cloud Identity platform. I took the following steps:

*

*I successfully connected my domain via the firebase console: the status says 'Connected', and the SSL certificate has been provisioned.

*In Identity Platform, I added my custom domain to the authorized domains on the project level.

*I'm trying to add a SAML provider for a tenant.

I cannot edit the callback url in the cloud console. Also, when adding the provider with a custom url via a client SDK, the provider is created, but again with the default url.
Any pointers?
From the documentation:

A: This is expected.
The real issue is that the docs give the understanding of changing the callback URL in the console but you should change the authDomain in your code rather than in the GCP console and when making the request, you will see the callback URL using your custom domain.
For example, if in your code you have:
const config = {
  apiKey: "dsfdsDSSDDSFSDfsdf5ds14f5s",
  authDomain: "PROJECT_ID.firebaseapp.com",
};

You only have to change the authDomain for example to:
const config = {
  apiKey: "dsfdsDSSDDSFSDfsdf5ds14f5s",
  authDomain: "login.mydomain.com",
};

The only condition to make this work is that the domain you want to use is in the Authorized domains.


text:
Q: How do I generate sentences with Rita.js? I installed Rita through Node, following a RiTa.js egghead.io tutorial. After running the following code in my rita.js file on terminal, it shows a lot of data and says

Error: No valid sentence-starts remaining

var rita= require('rita');

var inputText= 'The blue bus drove by a crowded street. All the children were singing. It was a great bus ride.';

var markov= new rita.markov(5)

markov.addText(inputText)

var sentences= markov.generate(2);

console.log(sentences)

A: You just need to modify the markov input to '2' (limit) and it'll work.
Here's the example running:
https://notebook.xbdev.net/index.php?page=ritalanguage2&


text:
Q: Make a copy of an iteration I am creating a list of game objects. I'm attempting to take these basic Iterations from the objects_list and putting them into [[][][][][][]] lists within a list to correspond to the 6x6 game grid.
All.objects_list.extend([Inert("dirt","filthy, dirty, dirt"),
Inert("trees","tall spindly trees"),
Inert("rocks","scatterd rocks"),])

I just get an error
Inert' object does not support indexing
for i in range(0,37):
    for item in All.objects_list:
        All.objects.append(item[i])

Is there a way I can place into, remove and interact with a list iterated items for each of my 36 rooms?
> Traceback (most recent call last):   File
> "/private/var/mobile/Containers/Shared/AppGroup/EF18EB50-22D0-4A6B-A54C-1F9803851E30/Pythonista3/Documents/Text
> Adventures/ADVvX.py", line 603, in <module>
>     All.objects.append(item[i]) TypeError: 'Inert' object does not support indexing


text:
Q: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V WebLogic deployment When I'm trying to deploy my application to WebLogic server(firstly I'm building war archive with Maven and then deploying with IntelliJ Idea WebLogic plugin) I'm getting this error:
What have I done wrong?
weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:73)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:24)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:48)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:587)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
Caused By: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:764)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:495)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:824)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:678)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:243)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:200)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:185)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1838)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2876)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:823)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:73)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:24)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:48)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:587)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)

my dependencies are
<properties>
    <spring.version>4.2.0.RELEASE</spring.version>
    <hibernate.version>5.0.0.CR4</hibernate.version>
</properties>
<dependencies>

    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.3.0.Final</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <version>2.20</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.ext</groupId>
        <artifactId>jersey-spring3</artifactId>
        <version>2.20</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
</dependencies>

A: I have just come across this issue when upgrading from Weblogic 12.1.3 to 12.2.1, using Hibernate 5.0.6.FINAL (The only thing I changed when I got this issue was the weblogic version - 12.1.3 was already configured for JPA 2.1)
I figured it's a classpath issue with different version of jboss-logging in the container - so I added an entry in my weblogic-application.xml file:
<wls:prefer-application-packages>
        <wls:package-name>org.jboss.logging.*</wls:package-name>
</wls:prefer-application-packages>

After doing so Weblogic takes the proper jboss-logging version that is bundled with Hibernate and deploys my application successfully.

A: It is very likely that you are using a version of a dependency that does not contain the method you are trying to use. Try to update your dependencies to a newer version.

A: I see that you have Jersey dependencies. If you still want to use Hibernate 5, see my answer here :https://stackoverflow.com/a/32278984/3525027

A: I had the same issue with Wildfly and the latest Hibernate version (5.0.3.Final). The solution was to remove jboss-logging completely from pom.xml since it obviously takes the logging from another library (weld-se).
I don't even know why I added jboss-logging. My projects works without it too.

A: note for myself: add this to your jvm args to find the root cause
-verbose:class

A: Add below param in webloic.xml file.
<wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>com.ctc.wstx.*</wls:package-name>
            <wls:package-name>org.springframework.context.*</wls:package-name>
            <!-- DO NOT REORDER slf4j and jboss -->
            <wls:package-name>org.slf4j.*</wls:package-name>
            <wls:package-name>org.jboss.*</wls:package-name>
                    </wls:prefer-application-packages>
    </wls:container-descriptor>

or like this:
<wls:container-descriptor>
        <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
    </wls:container-descriptor>


text:
Q: How to set icon next to text in tablayout I am working on Tablayout with text and icon from the following tutorial ..
My question is how to make the icon placed next to the text instead of above them?
I am new in Android Development, hopefully you guys can help me out. Thank you in advance, really appreciate the answer..

Here is my java file
public class AllProducts extends AppCompatActivity {

public ViewPager viewPager;
public TabLayout tabLayout;
    public int[] tabIcons = {
    R.drawable.ic_directions_car_white_24dp,
    R.drawable.ic_motorcycle_white_24dp,
    R.drawable.ic_build_white_24dp
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.all_products);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    viewPager = (ViewPager) findViewById(R.id.viewpager2);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);
    setupTabIcons();

}

private void setupTabIcons() {
    tabLayout.getTabAt(0).setIcon(tabIcons[0]);
    tabLayout.getTabAt(1).setIcon(tabIcons[1]);
    tabLayout.getTabAt(2).setIcon(tabIcons[2]);
}

private void setupViewPager(ViewPager viewPager) {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    adapter.addFragment(new Tab1(), "CAR");
    adapter.addFragment(new Tab2(), "MOTORCYCLE");
    adapter.addFragment(new Tab3(), "OTHERS");
    viewPager.setAdapter(adapter);
}

class ViewPagerAdapter extends FragmentPagerAdapter {
    private final List<Fragment> mFragmentList = new ArrayList<>();
    private final List<String> mFragmentTitleList = new ArrayList<>();

    public ViewPagerAdapter(FragmentManager manager) {
        super(manager);
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    public void addFragment(Fragment fragment, String title) {
        mFragmentList.add(fragment);
        mFragmentTitleList.add(title);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mFragmentTitleList.get(position);
    }
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

}

A: It's easy.
Tab tab = tabLayout.newTab();
tab.setCustomLayout( R.layout.whatever );
tabLayout.addTab(add);

Your layout would be a simple TextView with a drawableRight that specifies your icon.
For more: http://panavtec.me/playing-with-the-new-support-tablayout/

A: Another solution is setting the app:tabInlineLabel="true" in your activity .xml or call the TabLayout method setInlineLabel(true).
Source


text:
Q: Solr Multi Value Field - Boost values nearer to start As I understand it, for Multi Value fields Solr boosts scores based on a few things.
Specifically scoring shorter field lengths higher than longer ones (even if the search string is nearer the beginning).
The scoring factors I found in the above link:
termFreq: how often a term appears in the document
idf: how often the term appears across the index
fieldNorm: importance of the term, depending on index-time boosting and field length

However I would like to boost values in a multi value field where the value is nearer the start of the list. For example.
When searching for a document with herceptin PRODUCT 1 should rank higher than PRODUCT 2 - except PRODUCT 2 socres higher due to it's shorter field length.
PRODUCT 1
"herceptin",
"succinimidyl",
"radiolabeling",
"labeling",
"stability",
"discovery",
"potent",
"cb2 agonists",
"agonists",
"linkers",
"yield",
"esters",
"agent",
"syntheses",
"elimination",
"ligands",
"analogue",
"chemistry",
"functionality",
"formation",
"proteins",
"product",
"oxidizing",
"agonist",
"conjugated",
"receptor",
"activity",
"model".
PRODUCT 2
"trastuzumab",
"breast",
"cancer",
"patients",
"breast cancer",
"treatment",
"growth",
"antibody",
"receptor",
"human",
"clinical",
"chemotherapy",
"herceptin",
"combination",
"results".
Any ideas on how I could achieve this?
Thanks


text:
Q: $error.required message is not getting reset on reset button : AngularJs

 <input type="text" name="Name"
    data-ng-model="panNumber" required>

Kindly enter your valid 10 digit PAN Number

<button type="reset" data-ng-click="loginCtrl.reset()">RESET</button>

controller
this.reset = function(){
            $scope.loginForm.$setPristine();
            $scope.loginForm.$setValidity();
            $scope.loginForm.$setUntouched();
          };

I have several fields in a loginForm, the problem is when user clicks on submit button without entering any data in any of the fields , all the error messages (required) are getting displayed. But when I reset button , the error messages are still present, they are not getting cleared.
I tried to debug a lot but not able to find the solution.I do not know what mistake I am doing.
Any help is appreciated !!!
Thanks

A: I got the answer of this question by trying hard
just on click of reset button I need to call
$scope.submitted = false;


text:
Q: icCube connect to SQL Express file (.mdf) I read in this post that it is somehow possible to connect to SQL Express. This post is pretty old and I hope it is still possible somehow to make a connection to a .mdf file (SQL Express database).
How can you set-up a connection to this sort of file?


text:
Q: How to build Angular App having(only one page (SPA) and rest normal PHP pages? Q.Actually I want to know how to create an Angular PHP application.
Where I want the only page to be Angular(Single Page Application) and rest should be Normal loadable PHP pages.
-Actually I have built a complete application with PHP Codeigniter, and now i have planned to create only one module of application with Angular.
So I want to know, is it possible to create Angular and PHP applications where some pages are used in SPA application and rest would be normal PHP loadable pages?

A: After you finish building the angular app and invoke the ng build command, Just change the name of index.html to index.php, and upload the files to your server.
I suggest you put the angular page in a different subdomain or at least a different directory to make it easier for the linking.
Something like:

*

*app.example.com for the angular

*www.example.com for the PHP files


text:
Q: php rest webservice how can i get a xml file when i pass a parameterized url

A: If you are generating the XML file in PHP, try setting the header as the first line of the script.
header("Content-type: text/xml");


text:
Q: inline ng-template without script tags? Is it possible to create inline templates without a <script> tag?
My problem is that our widget framework removes <script> tags from content, before we can parse them as Angular. So when the app is bootstrapped, the inline templates are not found and ajax requests are made for them, returning 404.
I know most other directives can be used in tag or attribute form, but I have not had any luck trying <ng-template id="foo"> instead of <script type="text/ng-template" id="foo">


text:
Q: How is the matrix created using Isomorphic transform fucntion and Isomorphic inverse transform function? Trying to implementation AES Sbox and InSbox in combination circuit. Here for Sbox two operation is done i.e. Multiplicative Inverse and Affine Transform. For Affine Transform finite field is converted into a composite field using isomorphic transform, of which I have no idea how is that done. Need help in getting matrix delta shown in the image(attached with the question) from the irreducible polynomial mentioned p(x).

A: The matrices in the question are used for inversion (1/x) step. Affine transformation is a separate step and normally involves a matrix multiply followed by a column xor as specified by AES algorithm. Link to wiki article, note that the wiki article has least significant bits at the top, while the article you reference and other articles have the most significant bit at the top.
https://en.wikipedia.org/wiki/Rijndael_S-box
Getting back to how those matrices are created, I found a few articles, but they not only don't explain how those matrices are created, they were also missing key information, such as the primitive element chosen for GF(2^8) based on
polynomial x^8 + x^4 + x^3 + x + 1 (0x11b) with 1 bit coefficients, which is irreducible, but not primitive, since its primitive element is not x (0x02).
GF(2^8) is mapped to GF(((2^2)^2)^2). From the questions information, GF(2^2) uses x^2 + x + 1 (hex 7) with 1 bit coefficients to produce a 2 bit field with primitive element x = 0x2. GF((2^2)^2) uses x^2 + x + 2 (hex 16) with 2 bit coefficients from GF(2^2) to produce a 4 bit field with primitive element x = 0x4. GF(((2^2)^2)^2) uses x^2 + x + c (hex 11c) with 4 bit coefficients from GF((2^2)^2) to produce an 8 bit field with primitive x = 0x10.
For GF(2^8) there are 128 possible primitive elements: {0x03, 0x05, 0x06, ... , 0xff}. The matrix δ can be used to identify which primitive element was chosen for GF(2^8), in this case x^4 + x^3 + x^2 + x + 1 (hex 1f).
The columns of the matrix δ correspond to the mapping from GF(2^8) to GF(((2^2)^2)^2) by bit: 1st column maps 0x80, 2nd column maps 0x40, ..., 7th column maps 0x02, 8th column maps 0x01. The columns are powers of 0x10 in GF(((2^2)^2)^2). For example the 7th column is 0x5f, which is 0x10^0xa0 in GF(((2^2)^2)^2). Since the 7th column is used to map 0x02 in GF(2^8), this means GF(2^8)log??(0x02) = 0xa0, and that the chosen primitive element is 0x1f, since GF(2^8)log1f(0x02) = 0xa0. The 6th column is 0x7c, which is 0x10^0x41 in GF(((2^2)^2)^2), and GF(2^8)log1f(0x04) = 0x41.
The table below shows the data for all 8 colums.
GF(2^8) log1f(0x80) = 0x64, GF(((2^2)^2)^2) 0x10^0x64 = 0xfc (1st column of matrix)
GF(2^8) log1f(0x40) = 0xc3, GF(((2^2)^2)^2) 0x10^0xc3 = 0x4b (2nd column of matrix)
GF(2^8) log1f(0x20) = 0x23, GF(((2^2)^2)^2) 0x10^0x23 = 0xb0 (3rd column of matrix)
GF(2^8) log1f(0x10) = 0x82, GF(((2^2)^2)^2) 0x10^0x82 = 0x46 (4th column of matrix)
GF(2^8) log1f(0x08) = 0xe1, GF(((2^2)^2)^2) 0x10^0xe1 = 0x74 (5th column of matrix)
GF(2^8) log1f(0x04) = 0x41, GF(((2^2)^2)^2) 0x10^0x41 = 0x7c (6th column of matrix)
GF(2^8) log1f(0x02) = 0xa0, GF(((2^2)^2)^2) 0x10^0xa0 = 0x5f (7th column of matrix)
GF(2^8) log1f(0x01) = 0x00, GF(((2^2)^2)^2) 0x10^0x00 = 0x01 (8th column of matrix)

The inverse mapping matrix can use the same logic:
GF(((2^2)^2)^2) log10(0x80) = 0x67, GF(2^8) 0x1f^0x67 = 0x84 (1st column of matrix)
GF(((2^2)^2)^2) log10(0x40) = 0xbc, GF(2^8) 0x1f^0xbc = 0xf1 (2nd column of matrix)
GF(((2^2)^2)^2) log10(0x20) = 0xab, GF(2^8) 0x1f^0xab = 0xbb (3rd column of matrix)
GF(((2^2)^2)^2) log10(0x10) = 0x01, GF(2^8) 0x1f^0x01 = 0x1f (4th column of matrix)
GF(((2^2)^2)^2) log10(0x08) = 0x66, GF(2^8) 0x1f^0x66 = 0x0c (5th column of matrix)
GF(((2^2)^2)^2) log10(0x04) = 0xbb, GF(2^8) 0x1f^0xbb = 0x5d (6th column of matrix)
GF(((2^2)^2)^2) log10(0x02) = 0xaa, GF(2^8) 0x1f^0xaa = 0xbc (7th column of matrix)
GF(((2^2)^2)^2) log10(0x01) = 0x00, GF(2^8) 0x1f^0x00 = 0x01 (8th column of matrix)

Note that in the questions image, the inverse matrix 1st and 6th columns have the least significant bit flipped. The pdf file linked to below has the proper matrices.
https://github.com/bpdegnan/aes/blob/master/aes-sbox/documentation/aessbox.pdf
I created a small pdf file that explains how the mapping matrices seen on page 4, matrix (8) and page 5, matrix (10) are generated and the logic behind them.
https://github.com/jeffareid/finite-field/blob/master/Composite%20Field%20Mapping%20Example.pdf

In order for sub-field aka composite field math to work, there are two main requirements. Using map() to represent the mapping from GF(2^8) to GF(((2^2)^2)^2), then while operating in GF(((2^2)^2)^2)
map(a + b) = map(a) + map(b)               // addition (xor) is isomorphic
map(a · b) = map(a) · map(b)               // multiplication is isomorphic

This can also be restated as: using α to represent the primitive element for GF(2^8) and β to represent the primitive element for GF(((2^2)^2)^2).
if α^i + α^j = α^k, then β^i + β^j = β^k   // addition (xor) is isomporhic
if α^i · α^j = α^k, then β^i · β^j = β^k   // multiplication is isomorphic

Normally β = 100002, and a brute force search is done for 3 constants α, φ, δ, that result in compatible mapping and minimizing gate count, where α is the primitive element for GF(2^8), φ is the constant term for GF((2^2)^2) = x^2 + x + φ, and δ is the constant term for GF(((2^2)^2)^2) = x^2 + x + δ. In this case, α = 111112, φ = 102, δ = 11002.


text:
Q: how to add new row for every new login key word in object

<!DOCTYPE html>

Login Time
Ready Duration
Not_ready Duration
Logout Time

Here i have some array of object which contains two LOGINs(may have more than two logins in future) in object. For every login i need to add all READY durations and NOT_READY Durations and have to show it in one row irrespective of STATE:LOGOUT
i did for first login and i am getting any idea how to get new row for new login(Which Dont have STATE:LOGOUT yet)?
Any help would be appreciated.
Thanks in advance.

A: You can use a "state machine" to accumulate the data and reset it as you go.
Update: Support for case when didn't logout last.

$(document).ready(function() {

  localArray = [{
      "state": "LOGIN",
      "startTime": "10.25"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "615"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "874"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "222"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "111"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "333"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "888"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "444"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "999"
    },

    {
      "state": "LOGOUT",
      "startTime": "13.26"
    },
    {
      "state": "LOGIN",
      "startTime": "08.58"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "12"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "13"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "14"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "15"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "16"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "17"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "18"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "19"
    },

    {
      "state": "LOGOUT",
      "startTime": "09.45"
    },

    {
      "state": "LOGIN",
      "startTime": "09:58"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "12"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "13"
    },

    {
      "state": "READY",
      "startTime": "10.26",
      "endTime": "10.35",
      "duration": "14"
    },

    {
      "state": "NOT_READY",
      "startTime": "11:26",
      "endTime": "10.35",
      "duration": "15"
    }
  ];

  var state = null;
  var bucket = null;

  for (i = 0; i < localArray.length; i++) {
    tempOBJ = localArray[i];

    if (tempOBJ.state == "LOGIN") {
      state = "STATE_LOGIN";
      bucket = {
        login: tempOBJ.startTime,
        ready: 0,
        not_ready: 0,
      };
      continue;
    }

    if (state == "STATE_LOGIN") {

      if (tempOBJ.state == "READY") {
        bucket.ready += parseInt(tempOBJ.duration, 10);
      }
      if (tempOBJ.state == "NOT_READY") {
        bucket.not_ready += parseInt(tempOBJ.duration, 10);
      }
      if (tempOBJ.state == "LOGOUT") {
        row = "
" + bucket.login + "	" + bucket.ready + "	" + bucket.not_ready + "	" + tempOBJ.startTime + "
";
        $('#dataAdd').append(row);
        state = null;
      }

    }

  }

  if (state != null) {
    row = "
" + bucket.login + "	" + bucket.ready + "	" + bucket.not_ready + "	" + "..." + "
";
    $('#dataAdd').append(row);
    state = null;
  }

});

    Login Time
    Ready Duration
    Not_ready Duration
    Logout Time

A: Esentially what you want to do is aggregate up all of your data, forming an array of login events with the relevant info within. This can be done with reduce
const result = localArray.reduce( (acc,i) => {
   if(i.state == "LOGIN"){
      acc.push({loginTime:i.startTime,readyDuration:0,notReadyDuration:0,logOutTime:null });
   }
   if(i.state == "READY"){
      acc[acc.length-1].readyDuration += parseInt(i.duration,10);
   }
   if(i.state == "NOT_READY"){
      acc[acc.length-1].notReadyDuration += parseInt(i.duration,10);
   }
   if(i.state == "LOGOUT"){
      acc[acc.length-1].logOutTime = i.startTime;
   }
   return acc;
},[]);

This will produce an array, which you can then loop over to build your rows - demonstration below:

<!DOCTYPE html>

Login Time
Ready Duration
Not_ready Duration
Logout Time


text:
Q: Two different actions being performed I have in this code a method openItem(anuncio, operacao)" that runs when I click on the object that will perform the action. In this case I don't understand why when running (click) = 'checkFavorite (advert) he also performs the action. Clicking the verifyFavorite action should only run it and not openItem. Could anyone help me? thanks !!!

                <button *ngIf="operacao !== vis" class="ali-capa-livro-btn" (click)="openItem(anuncio, operacao)">

                </button>
                <button *ngIf="operacao === vis" class="ali-capa-livro-btn">

                </button>

{{anuncio.publicacao.titulo}}

{{anuncio.publicacao.autores}}

                {{anuncio.preco | currency:'R$':'code'}}
                ({{anuncio.tipoConservacao}})

por {{anuncio.usuario.nome}}

{{anuncio.statusAnuncio}}

                Anúncio: {{anuncio.tipoAnuncio.nome}} {{anuncio.tipoAnuncio.valor | currency:'R$':'code' }}

                <button mode="ios" class="botao-excluir-anuncio" (click)="excluir(tipo, anuncio._id, favorito)" ion-button
                    round text-center item-end>
                    <ion-icon name="trash" item-end></ion-icon>
                </button>

            <button mode="ios" class="botao-naoefavorito-anuncio" (click)='verificarFavorito(anuncio)' ion-button round
                text-center item-end>
                <ion-icon name="ios-heart-outline" item-end></ion-icon>
            </button>

            <button mode="ios" class="botao-favorito-anuncio" (click)='verificarFavorito(anuncio)' ion-button round
                text-center item-end>
                <ion-icon name="ios-heart" item-end></ion-icon>
            </button>

            <button mode="ios" class="botao-excluir-anuncio" (click)="excluir(tipo, anuncio._id, favorito)" ion-button round
                text-center item-end>
                <ion-icon name="trash" item-end></ion-icon>
            </button>

import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Anuncio } from '../../models/anuncio';
import { AppBasePage } from '../../pages/app-base-page/app-base-page';
import { AnuncioDetalhePage } from '../../pages/anuncio-detalhe/anuncio-detalhe';
import { NavController, NavParams } from 'ionic-angular';
import { AppGlobal } from '../../app/app.global';
import { AppRestService } from '../../services/app-rest.service';
import { RestNovoFavorito } from '../../services/app-rest.service';

@Component({
    selector: 'anuncio-list-item',
    templateUrl: 'anuncio-list-item.html'
})
export class AnuncioListItemComponent extends AppBasePage {

    @Input('anuncio') anuncio: Anuncio;
    @Input('tipo') tipo: any;
    @Input('favorito') favorito: any;
    @Input('cesta') cesta: any;
    @Input('operacao') operacao: any;
    @Input('apenasexcluir') apenasexcluir: any;
    @Output() onExcluir: EventEmitter<any> = new EventEmitter();
    @Output() onDetail: EventEmitter<any> = new EventEmitter();

    constructor(private rest: AppRestService, private appGlobal: AppGlobal, public navCtrl: NavController, public navParams: NavParams) {

        super();

    }

    openItem(anuncio, operacao, apenasexcluir) {
        // quando origem cesta, chama com o parametro para atualizar a cesta de acordo com o anuncio alterado
        if (this.cesta) this.navCtrl.push(AnuncioDetalhePage, { anuncio: anuncio, operacao: operacao, apenasexcluir: apenasexcluir, cesta: this.cesta });
        else this.navCtrl.push(AnuncioDetalhePage, { anuncio: anuncio, operacao: operacao, apenasexcluir: apenasexcluir});
    }

    excluir(tipo, id, favorito) {
        if (tipo == 1) {
            this.onExcluir.emit(favorito);
        } else
            this.onExcluir.emit(id);

    }

    verificarFavorito(id) {
        if (id.favorito) {
            this.excluirFavorito(id.favorito._id)
        } else {
            this.incluirFavorito(id._id)
        }
    }

    async excluirFavorito(id) {
        await this.rest.excluirAnuncioFavorito(id);
    }

    async incluirFavorito(id) {
        let restNovoFavorito = new RestNovoFavorito();
        restNovoFavorito.anuncio = id;
        await this.rest.incluirFavorito(restNovoFavorito);

    }

}


text:
Q: Telerik RadAjaxManager and ASP.net Validators I'm trying to use a required field validator along with Telerik's RadAjaxManager.
If I'm using a button then there is no problem and a postback does not occur while the field is empty.
However, there are some cases where I'm invoking an ajax request manually, and then a validation does not occur and the postback takes place regardless of whether the field is empty or not.
Here is an example with both a button and a manual request:

<asp:TextBox ID="tb1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="req1" runat="server" ControlToValidate="tb1" Text="!!!"></asp:RequiredFieldValidator>

<asp:Button ID="button1" runat="server" onclick="button1_Click" Text="Submit" />
Ajax Request
<asp:Label ID="Label1" runat="server"></asp:Label>

<telerik:RadScriptManager ID="ScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="button1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Label1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Label1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

When clicking button1 while the textbox is empty - no postback occurs.
When clicking the span while the textbox is empty - the postback occurs, and in the server side req1.IsValid is true, unless I manually call Page.Validate().
Is there a simple way to activate the validator when performing an ajax request like that?
(I realize there are ways to call a validator using javascript, like in this example, but since I may have several validators coming from different custom controls, I was hoping for a simpler way)

A: A few weeks ago I searched for the same thing and came across this forum post. It was proposed to use Page_ClientValidate() call and then block the page submission explicitly. Have not given it a try yet as my project tasks are put on hold, but appears to be working for the guy who started the thread, hence you may try it out.


text:
Q: In/at the end of a sentence/file I just realized that I don't really understand such a basic thing as whether to use "in" or "at" in contexts like:

*

*Don't forget to put a period in/at the end of a sentence.

*Don't forget to put an empty line in/at the end of a file.

"In" or "at"? And why?

A: "...at the end of..." is always correct. The expression "in the end" is valid, but it never has "of" after it.
The preposition "at" has the meaning of the location of a specific point, where "in" is less specific. The end of something is a specific place, so it only makes sense to use "at". The expression "in the end" doesn't refer to a specific place, but to the outcome, or end result, generally.
This Google Ngram shows there's a few "in the end of", but they're either non-idiomatic writing styles (like the Bible) or they're about media with titles that start, "The End of...", such as:

In "The End of Policing",..."

Where "The End of Policing" is a book title.


text:
Q: Bulma - force navbar vertical on desktop With bulma I want to create a site that follows sports (baseball, basketball ... tennis, wrestling) but by the time I get to the end (alphabetically it's wrestling) there are too many items (horizontally left to right) for a navbar to show properly on a desktop. So I thought I could use a menu (vertical navigation) but it doesn't give me a hamburger icon or anything similar on a mobile device. I used the menu example found here. I thought to use navbar on mobile and menu for desktops via media queries with something along the lines of
/** mobile **/
@media (max-width: 768px) {

      .menu {
       display: none;
      }
}

/** desktop **/
@media (min-width: 1024px) and (max-width: 1215px) {

    .navbar {
     display: none;
    }
}

but that still leaves me with two separate components & lists of links, icons, etc.. Is there a way to force the bulma navbar to remain vertical all the time? That way I can use just one component instead of two...

A: I had the same issue as you. I wanted a sidebar that I could use as my main menu, with a hamburger when displaying in responsive mode.
So I overrode the  component from Bulma (which is the side menu):

*

*I use the SASS version of Bulma

*I added an extensions folder within the Bulma build

*I added my improved_sidebar.sass file in it

Here's my code, which might be helpful to you:
// ––––––––––––––––––––––––––––––––––––––––––––––––––
// Aside improvements
// ––––––––––––––––––––––––––––––––––––––––––––––––––
$aside-width: 250px
$aside-right-padding: 30px
$aside-delta: $aside-width - $aside-right-padding
aside
    display: block
    box-sizing: border-box
    position: fixed
    top: 0
    left: 0
    max-width: $aside-width
    height: 100%
    padding:
        top: 10px
        bottom: 10px
        left: 10px
        right: $aside-right-padding
    overflow-y: auto

    // Initially hidden in mobile mode. Needs to be flagged as "is-active" to be shown
    // It will appear OVER the page content
    +touch
        left: -$aside-delta

        &.is-active
            left: 0
            z-index: 900

// ––––––––––––––––––––––––––––––––––––––––––––––––––
// Clickable burger in mobile mode
// ––––––––––––––––––––––––––––––––––––––––––––––––––
$burger-dimensions: 25px
#aside-burger
    display: none

    +touch
        position: absolute
        display: block
        top: calc(50% - calc(#{$burger-dimensions} / 2))
        right: calc(calc(#{$aside-right-padding} - #{$burger-dimensions}) / 2)
        width: $burger-dimensions
        height: $burger-dimensions
        color: white

    i
        position: relative
        z-index: 1000
        font-size: 40px !important
        cursor: pointer

        &:hover
            color: $info

        &:active
            color: $danger

// Rotate the icon when the sidebar is toggled
aside.is-active
    i
        transform: rotate(180deg)

// ––––––––––––––––––––––––––––––––––––––––––––––––––
// Utilities
// ––––––––––––––––––––––––––––––––––––––––––––––––––
// The sidebar is natively visible only in desktop
// Therefore we move tagged items to the right, of the same amount
.adjust-with-sidebar
    +touch
        margin-left: $aside-right-padding

    +desktop
        margin-left: $aside-width

And here is my HTML template for the  (I'm using jinja2 and vuejs for templating):
{% load static %}

Exemples

API Exemple

Mon Compte

Mes informations

Déconnexion

A: I think you could force the navbar to be vertical instead of using a menu bar because menu bars in Bulma are vertical and don't actually expand or compress with burgers (navbars use burgers). So, check out this post by W3Schools where they talk about forcing the navbar vertically with CSS. Also, Bulma's navbars fit across the whole screen when you open them up with the navbar burger. This is a characteristic of Bulma so I'm not sure if you want it that way - you may have to tweak some CSS here and there.


text:
Q: C# snake game problem with body extension monogame So I have this problem where my sprites draw to close to the head of my snake and therefore only takes very long time to complete the map. I have tried to increase the speed and lower the frame rate but it is very laggy.
//Comments are in Swedish
{
    public class Game1 : Game
    {
        private GraphicsDeviceManager _graphics;
        private SpriteBatch _spriteBatch;

        SpriteFont xcord;
        SpriteFont ycord;

        //Map settings
        int mapX;
        int mapY;

        //Movement Variabels

        //Snake Movement
        bool snakemoveup;
        bool snakemovedown;
        bool snakemoveright;
        bool snakemoveleft;
        int speedx;
        int speedy;
        int score;
        int timer;
        int i;

        List<Rectangle> snakelength = new List<Rectangle>();
        List<int> positiony = new List<int>() { 300, 300 };

        bool snakemoveup2;
        bool snakemovedown2;
        bool snakemoveright2;
        bool snakemoveleft2;
        bool snakemoveupMemory;
        bool snakemovedownMemory;
        bool snakemoverightMemory;
        bool snakemoveleftMemory;

        //Sprite Variables
        //Textures
        Texture2D snakehead;
        Texture2D gamemap;
        Texture2D gamemapborder;
        Texture2D Leader_Right;
        Texture2D Leader_Left;
        Texture2D Leader_Up;
        Texture2D Leader_Down;
        Texture2D Follower;
        Texture2D Candy;

        //Sprite Rectangles
        Rectangle snakerec;
        Rectangle followerrec;
        Rectangle candyrec;

        //Position Variables

        public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible = true;
        }enter code here

        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            //MapSize

            mapX = 900 + 100;
            mapY = 800 + 100;

            _graphics.PreferredBackBufferWidth = mapX;
            _graphics.PreferredBackBufferHeight = mapY;
            _graphics.ApplyChanges();

            //Movement
            speedx = 0;
            speedy = 0;

            base.Initialize();
        }

        protected override void LoadContent()
        {
            //läger till en svans i listan
            snakelength.Add(new Rectangle(snakerec.X, snakerec.Y, 50, 50));

            //sänker fps:n (nämnaren = önskade fps:n)
            IsFixedTimeStep = true;
            TargetElapsedTime = System.TimeSpan.FromSeconds(1d / 60);

            xcord = Content.Load<SpriteFont>("File");
            ycord = Content.Load<SpriteFont>("File");
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            Leader_Right = Content.Load<Texture2D>("Leader_Right");
            Leader_Left = Content.Load<Texture2D>("Leader_Left");
            Leader_Up = Content.Load<Texture2D>("Leader_Up");
            Leader_Down = Content.Load<Texture2D>("Leader_Down");

            Candy = Content.Load<Texture2D>("Candy");
            Follower = Content.Load<Texture2D>("Follower");
            gamemap = Content.Load<Texture2D>("Snake_map");
            gamemapborder = Content.Load<Texture2D>("Snakemapborder");

            snakerec = new Rectangle(500, 450, Leader_Right.Width, Leader_Right.Height);
            candyrec = new Rectangle(200,150, Candy.Width, Candy.Height);

            // TODO: use this.Content to load your game content here
        }

        protected override void Update(GameTime gameTime)

        {

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            //gameTime.ElapsedGameTime.Milliseconds

            //sätt en if innan ditt ökande

            snakerec.X += speedx;
            snakerec.Y += speedy;
            if (Keyboard.GetState().IsKeyDown(Keys.W) && snakemovedown == false)
            {
                snakemoveup2 = true;
                snakemoveupMemory = true;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D) && snakemoveleft == false)
            {
                snakemoveright2 = true;
                snakemoverightMemory = true;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.A) && snakemoveright == false)
            {
                snakemoveleft2 = true;
                snakemoveleftMemory = true;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.S) && snakemoveup == false)
            {
                snakemovedown2 = true;
                snakemovedownMemory = true;
            }

            if (snakerec.X % 50 == 0 && snakemoveupMemory == true)
            {
                speedy = -5;
                speedx = 0;
                snakemoveup = true;
                snakemovedown = false;
                snakemoveright = false;
                snakemoveleft = false;

                snakemoveupMemory = false;
            }

            if (snakerec.Y % 50 == 0 && snakemoveleftMemory == true)
            {
                speedy = 0;
                speedx = -5;
                snakemoveleft = true;
                snakemovedown = false;
                snakemoveright = false;
                snakemoveup = false;

                snakemoveleftMemory = false;
            }

            if (snakerec.X % 50 == 0 && snakemovedownMemory == true )
            {
                speedy = 5;
                speedx = 0;
                snakemovedown = true;
                snakemoveup = false;
                snakemoveright = false;
                snakemoveleft = false;

                snakemovedownMemory = false;
            }

            if (snakerec.Y % 50 == 0 && snakemoverightMemory == true)
            {
                speedy = 0;
                speedx = 5;
                snakemoveright = true;
                snakemovedown = false;
                snakemoveup = false;
                snakemoveleft = false;

                snakemoverightMemory = false;
            }

            if (Keyboard.GetState().IsKeyUp(Keys.W))
            {
                snakemoveup2 = false;
            }
            if (Keyboard.GetState().IsKeyUp(Keys.S))
            {
                snakemovedown2 = false;
            }
            if (Keyboard.GetState().IsKeyUp(Keys.A))
            {
                snakemoveleft2 = false;
            }
            if (Keyboard.GetState().IsKeyUp(Keys.D))
            {
                snakemoveright2 = false;
            }

            //Godis

            Random randomx = new Random();
            Random randomy = new Random();
            List<int> godtalx = new List<int>() { 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900 };
            List<int> godtaly = new List<int>() { 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800 };

            if (snakerec.Intersects(candyrec))
            {
                candyrec.X = godtalx[randomx.Next(1, 18)];
                candyrec.Y = godtaly[randomx.Next(1, 16)];

                score++;

                snakelength.Add(new Rectangle(snakerec.X, snakerec.Y, 50, 50));

            }
            //Follower

            if (snakelength.Count != score)
            {
                for (int i = snakelength.Count - 1; i > 0; i--)
                {
                    snakelength[i] = new Rectangle(snakelength[i - 1].X, snakelength[i - 1].Y, 50, 50);
                }
            }
            snakelength[0] = new Rectangle(snakerec.X, snakerec.Y, 50, 50);

            //Infite borders

            //X
            if (snakerec.X <= 50 || snakerec.X >= 900)
            {
                if (snakerec.X <= 0)
                {
                    snakerec.X = 995;
                }
                if (snakerec.X >= 1000)
                {
                    snakerec.X = 5;
                }
            }
            //Y
            if (snakerec.Y <= 50 || snakerec.Y >= 800)
            {
                if (snakerec.Y <= 0)
                {
                    snakerec.Y = 895;
                }
                if (snakerec.Y >= 900)
                {
                    snakerec.Y = 5;
                }
            }

            // TODO: Add your update logic here

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here

            base.Draw(gameTime);
            _spriteBatch.Begin();

            _spriteBatch.Draw(gamemap, new Vector2(0, 0), Color.White);

            for (int i = 0; i < snakelength.Count; i++)
            {

                _spriteBatch.Draw(Follower, new Rectangle(snakelength[i].X, snakelength[i].Y, 50, 50), Color.White);
            }

            //Vilket håll huvudet kollar mot

            if (true)
            {

                if (snakemoveup == true)
                {
                    _spriteBatch.Draw(Leader_Up, snakerec, Color.White);
                }

                if (snakemoveright == true)
                {
                    _spriteBatch.Draw(Leader_Right, snakerec, Color.White);
                }

                if (snakemoveleft == true)
                {
                    _spriteBatch.Draw(Leader_Left, snakerec, Color.White);
                }

                if (snakemovedown == true)
                {
                    _spriteBatch.Draw(Leader_Down, snakerec, Color.White);
                }
            }

            _spriteBatch.Draw(Candy, candyrec, Color.White);
            _spriteBatch.Draw(gamemapborder, new Vector2(0, 0), Color.White);
            _spriteBatch.DrawString(xcord, (snakelength.Count).ToString(), new Vector2(0, 60), Color.Black);
            _spriteBatch.DrawString(xcord, (snakerec.X).ToString(), new Vector2(0, 0), Color.Black);
            _spriteBatch.DrawString(ycord, (snakerec.Y).ToString(), new Vector2(0, 30), Color.Black);

            _spriteBatch.End();
        }
    }
}


text:
Q: При скачивания видео из Youtube с помощью pytube и tkinter произойдёт ошибка. Почему? Я создал графическую программу которая должен скачать видео из ютуб. Программа откроется но при нажатии на кнопку скачать выйдет такая ошибка:
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "C:\Users\User\Desktop\Savetube\Savetube.py", line 28, in download
    yt = pytube.YouTube(link)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 71, in __init__
    self.video_id = extract.video_id(url)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py", line 162, in video_id
    return regex_search(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", url, group=1)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\helpers.py", line 127, in regex_search
    results = regex.search(string)
TypeError: expected string or bytes-like object

Не знаю почему.
Вот код программа:
from tkinter import
import pytube

root=Tk()
root.geometry('700x500')
root.resizable(width=False, height=False)
root.title("Save video from Youtube")

def func():
    root=Toplevel()
    root.title('Hello')
    root.geometry('300x200')

try:
    def main():
        global link, place
        lab=Label(root, text='Добавьте адрес для скачивания: ', font='Times 24')
        lab.grid(row=1, column=3)
        link=Entry(root, width=50, bd=3)
        link.grid(row=2, column=3)

        labe=Label(root, text='Выберите место для сохранения: ', font='Times 24')
        labe.grid(row=3, column=3)
        place=Entry(root, width=50, bd=3)
        place.grid(row=4, column=3)

        def download():
            yt = pytube.YouTube(link)
            stream = yt.streams.first()
            stream.download(place)

        download=Button(root, text="Скачать", width=10, height=3, command=download,
        bg='green', fg='black')
        download.grid(row=4, column=4)
except:
    exlab=Label(root, text='Извините произошла ошибка', font='Times 24')
    exlab.grid(row=6, column=3)

main()
root.mainloop()

A: Entry не может быть строкой, по этому нужно использовать Entry.get() в твоем случае это: link.get(), place.get() то есть:
def download():
        yt = pytube.YouTube(link.get())
        stream = yt.streams.first()
        stream.download(place.get())