text:
Q: How to connect to a L2TP VPN given some info from a sysadmin I have been given some details of a VPN I am meant to connect to, and can't for the life of me get it to work under Kubuntu.
The info I have been given is (fake values substituted where appropriate of course):

I have configured a new VPN account for you on our server.
Your login details are as follows:
IP address: 1.2.3.4
username: myfullname
password: wordpass
shared secret: XXXXXXXXXX

The connection type is L2TP.
Ensure that you select the option to send all traffic over the VPN.

I have tried 2 routes:
1) Using the KDE widget to configure this
2) Using config files to configure this
Using the widget:
I add the https://launchpad.net/~seriy-pr/+archive/network-manager-l2tp PPA, and install network-manager-l2tp.
Then, I add an L2TP connection and I come across the following fields (which I fill in):
Gateway (1.2.3.4)
User name: (myfullname)
Password: (wordpass)
Then I go into IPsec Settings, and (after checking "Enable IPSec tunnel to L2TP host):
Group Name
Gateway ID
Pre-shared Key
I fill in Pre-shared Key with XXXXXXXXXX, and click OK.
Then I try to connect, and get the following error:
"Necessary secrets for the VPN connection were not provided."
Using config files, and using https://www.elastichosts.com/support/tutorials/linux-l2tpipsec-vpn-client/ as a guide, I do the following:
I add the following to /etc/ipsec.conf:
config setup
....
    protostack=netkey
    plutoopts="--interface=wlan0"
....
conn tab-vpn
    authby=secret
    pfs=no
    auto=add
    keyingtries=3
    dpddelay=30
    dpdtimeout=120
    dpdaction=clear
    rekey=yes
    ikelifetime=8h
    keylife=1h
    type=transport
    left=%defaultroute
    leftnexthop=%defaultroute
    leftprotoport=17/1701
    right=1.2.3.4

I add the following to /etc/ipsec.secrets:
%any 1.2.3.4: PSK "XXXXXXXXXX"

Then when I restart ipsec with:
sudo ipsec auto --up tab-vpn

I get:
104 "tab-vpn" #1: STATE_MAIN_I1: initiate
003 "tab-vpn" #1: ignoring Vendor ID payload [MS NT5 ISAKMPOAKLEY 00000009]
003 "tab-vpn" #1: received Vendor ID payload [RFC 3947] method set to=115
003 "tab-vpn" #1: received Vendor ID payload [draft-ietf-ipsec-nat-t-ike-02_n] meth=106, but already using method 115
003 "tab-vpn" #1: ignoring Vendor ID payload [FRAGMENTATION]
003 "tab-vpn" #1: ignoring Vendor ID payload [MS-Negotiation Discovery Capable]
003 "tab-vpn" #1: ignoring Vendor ID payload [IKE CGA version 1]
106 "tab-vpn" #1: STATE_MAIN_I2: sent MI2, expecting MR2
003 "tab-vpn" #1: NAT-Traversal: Result using draft-ietf-ipsec-nat-t-ike (MacOS X): both are NATed
108 "tab-vpn" #1: STATE_MAIN_I3: sent MI3, expecting MR3
003 "tab-vpn" #1: we require peer to have ID '1.2.3.4', but peer declares '192.168.122.2'
218 "tab-vpn" #1: STATE_MAIN_I3: INVALID_ID_INFORMATION

I and the server in question are behind the same firewall.
It SHOULD allow me to connect so I can move onto setting up the xl2tpd.conf options, but I don't get that far.
Help?

A: Try:
conn tab-vpn
    ...
    rightid=192.168.122.2

in /etc/ipsec.conf
The rightid parameter can be used to specify the IP address that the server identifies itself as (ie. it's LAN IP address rather than the public IP address of the router).
If the expected IP address and the IP address that the server identifies as don't match then ipsec abandons the connection attempt.


text:
Q: how to sort array date wise in cakephp I have 2 table booking and message , now I want to show booking request and message in inbox at a time.
$this->paginate = array(
            'conditions' => $conditions,'limit' =>10,
        'order'=>array('Booking.created'=>'DESC'));
    $bookings = $this->paginate('Booking');

    $this->paginate = array(
            'conditions' => $conditions,'limit' =>10,
        'order'=>array('MessageDetail.created'=>'DESC'));
    $messages = $this->paginate('MessageDetail');

i have merge both table data (  array_merge($bookings, $messages);  )
now i want to it sort date wise (or any conditions)
Array
(
[0] => Array
    (
        [Booking] => Array
            (
                [id] => 4
                [host_id] => 21
                [place_id] => 10
                [room_id] => 13
                [user_id] => 12
                [message_detail_id] => 16
                [created] => 2013-04-23 14:44:03
                [accept_date] =>
                [cancel_date] =>
            )

    )

[1] => Array
    (
        [Booking] => Array
            (
                [id] => 3
                [host_id] => 21
                [place_id] => 10
                [room_id] => 13
                [user_id] => 12
                [message_detail_id] => 13
                [created] => 2013-04-15 14:10:59
                [accept_date] => 2013-04-15 14:40:47
                [cancel_date] =>
            )

    )

[2] => Array
    (
        [MessageDetail] => Array
            (
                [id] => 17
                [message_id] => 2
                [user_id] => 12
                [sender_id] => 21
                [unread] => 0
                [created] => 2013-04-24 12:11:47
            )

    )

[3] => Array
    (
        [MessageDetail] => Array
            (
                [id] => 15
                [message_id] => 2
                [user_id] => 12
                [sender_id] => 21
                [booking_id] => 3
                [unread] => 0
                [created] => 2013-04-15 15:01:12
            )

    )

  )

Thanks in advance.

A: Option #1:
Create a third Model named "BookingAndMessage". You could use the Model's afterSave method (on both Booking and Message) to create a duplicate record in your new model. You could then query the BookingAndMessage in the proper sort order.
Option #2: To solve the problem, as it stands, you will want to use PHP's usort function (also explained here PHP Sort a multidimensional array by element containing date).
<?php

$BookingsAndMessages = array_merge($bookings, $messages);

function date_compare($a, $b)
{
   $modelKeyA = array_key_exists('Booking',$a) ? 'Booking' : 'MessageDetail';
   $modelKeyB = array_key_exists('Booking',$b) ? 'Booking' : 'MessageDetail';
   $t1 = strtotime($a[$modelKeyA]['created']);
   $t2 = strtotime($b[$modelKeyB]['created']);
   return $t1 - $t2;
}

usort($BookingsAndMessages, 'date_compare');
// Would sort the merged records by `created` date
?>

The downside to option 2 is, you are going to have to create rules for each field (and sort direction).

A: Perhaps you should Union your queries first, the Order.
$bookings = $this->Bookings->find('all', [
        'conditions' => $conditions,'limit' =>10,
]);

$messages = $this->find('all', [
        'conditions' => $conditions,'limit' =>10
]);

$data = $bookings->union($messages);
// This works if your first selected field is the one you want to sort.
$data->epilog('ORDER BY 1 ASC');

reference:
How do you modify a UNION query in CakePHP 3?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Never terminating when solving linear Diophantine systems Say I have:
$(1):$ Set of Diophantine systems where each defines a  (possibly unbounded) polyhedron.
This is solvable with existing algorithms:
$(*):$ The $(1)$ can be solved in SageMath with integral_points_generators() function, using the PyNormaliz backend. - This was mentioned on MathOverflow in the following post mentioning a problem that falls into the $(1)$ category.
This should be solvable with Mathematica since it implements such algorithms:

$(M):$ According to Mathematics's manual, the algorithms and procedures for solving $(1)$ should be implemented and working, where the Reduce[] function is given as an example that uses this.
If $(1)$ is bounded, then $(M_1):$ the linked manual section "Bounded Systems of Linear Equations and Inequalities" is the case. Otherwise, the we should be in the case $(M_2):$ "Arbitrary Systems of Linear Equations and Inequalities" as titled in the linked manual. Either way, the $(1)$ should be always solvable.
As far as I understood the manual.

But, for certain cases of $(1)$, when we have the unbounded case of $(1)$, then Reduce[] sometimes works well and finds all solutions, and sometimes it never finishes and hence fails to solve the case.
And sometimes, those failed cases (solved cases), can actually be solved (become failed), if the input to the Reduce[] is given differently, which is a weird inconsistency to me.
Can we circumvent this issue, or am I missing something?
I will be demonstrating this with a concrete example:

Example of a problem that falls into $(1)$ category
I have a concrete example of a system that falls into $(1)$ category, which is equivalent to "$d=7$ case" mentioned in the linked post $(*)$, where it was solved using SageMath for all $K$ cases that have solutions.
It is given as:

$(S):$ The $K=(k_1,k_2,k_3,k_4,k_5,k_6)$ represents fixed constants. We have:
$$
\begin{equation*}
\begin{cases}
 0-a_{1} + 2 c_{1} + 2 c_{2} + 2 c_{3} + c_{4} = b k_{1} \\
 k_{1}-a_{2} + 6 c_{1} + 6 c_{2} + 6 c_{3} + 3 c_{4}  = b k_{2} \\
 k_{2}-a_{3} + 15 c_{1} + 10 c_{2} + 7 c_{3} + 3 c_{4} = b k_{3}\\
 k_{3}-a_{4} + 20 c_{1} + 10 c_{2} + 4 c_{3} + c_{4}  = b k_{4}\\
 k_{4}-a_{3} + 15 c_{1} + 5 c_{2} + c_{3}  = b k_{5}\\
 k_{5}-a_{2} + 6 c_{1} + c_{2} = b k_{6}  \\
 k_{6}-a_{1} + c_{1} = 0
\end{cases}
\end{equation*}
$$
Where $a_1\in[1,b-1],a_2,a_3,a_4\in[0,b-1],c_1\in[1,b],c_2,c_3,c_4\in[0,b],b\ge2$.

According to $(M)$, this should be solvable in Mathematica, with Reduce[]? But, sometimes it fails to resolve a $K$ case (keeps running forever).
Firstly, Reduce[] always works when there are no solutions to find (This is for a majority of $K$ cases, since only finitely many $K$ cases actually have solutions), and outputs False as expected.
Secondly, it also seems to always work as expected when we have a $K$ case that leads to the the bounded case of $(1)$, and finds all of the finitely many solutions as expected $(M_1)$.
And finally, when $K$ given falls into the category of unbounded case of $(1)$, then sometimes Reduce[] finds all solutions with paremeterization output like expected and described in the wolfram manual $(M_2)$; But some other times, it fails to terminate in such a case, and does not produce solutions (any output at all), and keeps running forever.
And there are inconsistencies in these failures.
To give an example, first here is the system $(S)$ implementation as sys[3, K]:
ClearAll[a, c, b, l, x, eq, bUp, bLow, sys];
x[a_, b_, l_] :=
  Sum[a[i + 1] (b^i + b^(2 l - i)), {i, 0, l - 1}] + a[l + 1] b^l;
eq[l_] :=
  Fold[And,
   MapIndexed[#1 == k[First[#2]] b &,
     CoefficientList[
      x[c, b + 1, l] - x[a, b, l] + Sum[k[i] b^i, {i, 0, 2 l}],
      b]] /. {k[0] -> 0, k[2 l + 1] -> 0}];
bUp[l_] :=
  Fold[And,
   Join[Table[a[i + 1] < b, {i, 0, l}],
    Table[c[i + 1] < b + 1, {i, 0, l}]]];
bLow[l_] :=
  Fold[And,
   Join[Table[If[i == 0, a[i + 1] >= 1, a[i + 1] >= 0], {i, 0, l}],
    Table[If[i == 0, c[i + 1] >= 1, c[i + 1] >= 0], {i, 0, l}]]];
sys[l_, K_] :=
  eq[l] && bUp[l] && bLow[l] && b >= 2 &&
   Fold[And, Table[k[i] == K[[i]], {i, 1, 2 l}]];

ClearAll[k1, k2, k3, k4, k5, k6];
sys[3, {k1, k2, k3, k4, k5, k6}] /. And -> List // Column

Inconsistency examples
$A)$ The example $K=(1,3,7,7,5,1)$ is not a failed case by default, the following code will terminate and output expected solutions:
(* r1 *) TimeConstrained[Reduce[sys[3, {1, 3, 7, 7, 5, 1}], {}, Integers], 60]

But for example, if either of the following two modifications are made, then it can't solve this case.
$A.1)$ If we specify variables variables {b, a[1], a[2], a[3], a[4], c[1], c[2], c[3], c[4]} instead of leaving {} blank, then it appears to keep running forever (aborts after 60 seconds), and hence fails to solve the case.
$A.2)$ It also fails if $K$ variables are not given as variables, but substituted directly into the expression. That is, the following modification is made:
sys[l_, K_] := (eq[l] && bUp[l] && bLow[l] && b >= 2) /. Table[k[i] -> K[[i]], {i, 1, 2 l}];

Where now (* r1 *) would appear to fail to ever terminate, and remain running forever (aborts after 60 seconds).

Failed Examples
$B)$ But the main issue is, that some cases of $K$ never can be solved, where as they should be solvable according to $(M),(M_2)$?
If $K$ is picked as any case from the following set:
Kfail = {{1, 4, 7, 8, 5, 2}, {1, 4, 11, 13, 10, 3}, {1, 5, 11, 14, 10, 4}, {2,7, 10, 10, 5, 2}, {2, 7, 14, 15, 10, 3}, {2, 8, 14, 16, 10, 4}, {2,8, 18, 21, 15, 5}, {3, 9, 14, 12, 6, 1}, {3, 10, 17, 17, 10, 3}, {3, 10, 18, 18, 11, 3}, {3, 11, 21, 23, 15, 5}, {3, 11, 22, 24, 16, 5}, {3, 12, 21, 24, 15, 6}, {4, 13, 20, 19, 10, 3}, {4, 13, 21, 20, 11, 3}, {4, 14, 24, 25, 15, 5}, {4, 14, 25, 26, 16, 5}, {5, 16, 23, 21, 10, 3}, {5, 17, 27, 27, 15, 5}}

Then the (* r1 *) line equivalent input fails to terminate. For example:
(* r2 *)TimeConstrained[Reduce[sys[3, {1, 4, 7, 8, 5, 2}], {}, Integers], 60]

Never terminates (aborts after 60 seconds).
But if we fix a value of b in this failed example (by adding && b==100 for example), we can get partial solutions.
And looking at consecutive values of b, we see that this (* r2 *)  can be written in a closed form similarly to the output of (* r1 *).

But the Reduce[] never finds this expected closed form for case (* r2 *). I do not understand why it can solve (* r1 *) but not (* r2 *) (Or any other case from the Kfail cases) ?
What am I missing?

For comparison to Kfail cases, the following cases can be solved:
Ksolved = {{0, 2, 6, 9, 7, 3}, {1, 3, 7, 7, 5, 1}, {1, 4, 8, 9, 6, 2}, {1, 5, 9, 11, 7, 3}, {1, 5, 10, 12, 8, 3}, {1, 5, 12, 15, 11, 4}, {2, 6, 10, 9, 5, 1}, {2, 6, 11, 10, 6, 1}, {2, 7, 11, 11, 6, 2}, {2, 7, 12, 12, 7, 2}, {2, 7, 15, 16, 11, 3}, {2, 8, 13, 14, 8, 3}, {2, 8, 14, 15, 9, 3}, {2, 8, 15, 17, 11, 4}, {2, 8, 16, 18, 12, 4}, {2, 8, 17, 19, 13, 4}, {3, 9, 13, 11, 5, 1}, {3, 10, 14, 13, 6, 2}, {3, 10, 15, 14, 7, 2}, {3, 10, 16, 15, 8, 2}, {3, 11, 17, 17, 9, 3}, {3, 11, 18, 18, 10, 3}, {3, 11, 18, 19, 11, 4}, {3, 11, 19, 20, 12, 4}, {3, 11, 20, 21, 13, 4}, {3, 12, 22, 25, 16, 6}, {3, 12, 23, 26, 17, 6}, {4, 12, 16, 13, 5, 1}, {4, 12, 17, 14, 6, 1}, {4, 12, 18, 15, 7, 1}, {4, 13, 18, 16, 7, 2}, {4, 13, 19, 17, 8, 2}, {4, 13, 22, 21, 12, 3}, {4, 14, 22, 22, 12, 4}, {4, 14, 23, 23, 13, 4}, {4, 14, 24, 24, 14, 4}, {4, 14, 26, 27, 17, 5}, {4, 15, 26, 28, 17, 6}, {5, 16, 24, 22, 11, 3}, {5, 16, 25, 23, 12, 3}, {5, 17, 28, 28, 16, 5}, {5, 17, 29, 29, 17, 5}}

Questions

$Q_1:$ Can we avoid the inconsistencies observed? (Is there "a proper way to feed expressions to Reduce[]", that these inconsistencies are violating?)
$Q_2:$ Why is Reduce[] failing to solve cases from Kfail? Is it possible to solve these cases with Mathematica?

What am I missing?


text:
Q: Mocking dependencies inside of an AOP object using Testbox and AOP/1 I am curious if there is an easier way to mock the dependencies inside a component that uses AOP.
For example I have a component that uses CRUD methods to persist changes to the database. For audit logging I figured I could use AOP so I didn't have to put my logging calls inside of the methods. The issue that I am running into is during unit testing when I want to mock the database and session storage used inside the object that provides the AOP. The only way I have been able to figure out how to fake the database and session is to create a new mock component file that extends the original and then overrides the init method. Using this method is not very flexible as I have to create several extra files for a simple unit test. Below is some of the test code:
This is the bean that gets created with the di/1 bean factory:
//customerBean.cfc
component accessors="true" extends="models.abstracts.AbstractModel" displayname="Customer" {
    property name="ID"  type="numeric" default="0";
    property name="Name" type="string" length="100" default="<Unknown>" logEvents="update";
    property name="Type" type="string" default="Homeowner" logEvents="update";
    property name="Status" type="string" default="Active" logEvents="update";

    public any function init(customerDAO) {
        variables.DAO = arguments.customerDAO;
    }

}

Here is the component that the customerBean extends:
//abstractModel.cfc
component accessors="true" {

    public any function doCreate(required struct data) {
        setID(save());
        return getID();
    }
}

This is the AOP component that has two dependencies that need to be mocked:
//customerLogger.cfc
component accessors="true" {
    property name="tableToLogTo" default="CustomerLogs" setter="false";

    public any function init(LoggerServiceDAO, scopeStorage) {
        variables.loggerServiceDAO = arguments.loggerServiceDAO;
        variables.scopeStorage = arguments.scopeStorage;
    }

    public any function after(targetBean, methodName, args, result) {
        variables.loggerServiceDAO.insertLog(method=arguments.methodName, user=variables.scopeStorage.get('session.user.id'));
    }
}

Here is the code I use to get the CustomerBean:
bf = new framework.aop(
    folders="/models,/system,/tests/Mocks", config={transients=["entity", "process", "transients", "report", "forms"],transientPattern="Bean$"}
);
bf.intercept('CustomerBean', 'CustomerLoggerMock', 'doCreate');
customerBean = bf.getBean('CustomerBean', {customerDAO: customerDAOMock});

Ideally what I would like to do is use Testbox to mock the two objects and use the nice built in verification methods. Is this possible or am I stuck creating all of these mock files?


text:
Q: calling function with pandas column as argument I wrote a function that takes a pandas data frame and two of its columns. Inside the function, I want to group the elements of the first column by the elements of the second column. The goal of the function is to generate a bar chart using matplotlib that plots the grouped counts. I do not know how to refer to the column arguments so they can be recognized by the group-by call inside the function.
I tried using df['col'] and 'col' but none of these worked. When I use df['col'], I get this error:
AttributeError: 'DataFrameGroupBy' object has no attribute 'x'

When I use 'col', I get this error:
AttributeError: 'DataFrameGroupBy' object has no attribute 'x'

Here is an example implementation, first without the function, to generate the expected result, and then with the function.
import pandas as pd

# generate dataframe
df = pd.DataFrame()
df['col_A'] = [1, 4, 3, 2, 2, 1, 1, 4, 3, 2]
df['col_B'] = ['a', 'a', 'b', 'b', 'b', 'c', 'c', 'c', 'c', 'c']

# plot counts
import matplotlib.pyplot as plt

counts = df.groupby('col_B').col_A.count()
counts = counts.sort_values(ascending=False)

fig = plt.figure(figsize=(10,8))
counts.plot.barh(ylim=0).invert_yaxis()

# plot count with function
def count_barplot(data, x, y):

    counts = data.groupby(y).x.count()
    counts = counts.sort_values(ascending=False)

    fig = plt.figure(figsize=(10,8))
    counts.plot.barh(ylim=0).invert_yaxis()

# function call
count_barplot(df, df['col_A'], df['col_B'])

How do I specify the data frame column arguments inside the function and in the function call, so that the group-by function can recognize them?

A: This way it works for me:
def count_barplot(data, x, y):

    counts = data.groupby(y)[x].count()
    counts = counts.sort_values(ascending=False)

    fig = plt.figure(figsize=(10,8))
    counts.plot.barh(ylim=0).invert_yaxis()

# function call
count_barplot(df, 'col_A', 'col_B')

A: The problem is that your function call is providing a a dataframe and two series as its arguments, while what you want to pass is a dataframe and column names. Note that you also want to use the [] syntax for referring to the column in your groupby, and you can simplify your count method using the built-in value_counts() method.
Thus, using your syntax:
# plot count with function
def count_barplot(data, x, y):

    counts = data.groupby(y)[x].count()
    counts = counts.sort_values(ascending=False)

    fig = plt.figure(figsize=(10,8))
    counts.plot.barh(ylim=0).invert_yaxis()

count_barplot(df, 'col_A', 'col_B')

or more simply:
# plot count with function
def count_barplot(data, y):

    counts = df[y].value_counts()

    fig = plt.figure(figsize=(10,8))
    counts.plot.barh(ylim=0).invert_yaxis()

# function call
count_barplot(df, 'col_B')

or even
def count_barplot(data, x, y):
    fig = plt.figure(figsize=(10,8))
    df[y].value_counts(ascending=True).plot.barh(ylim=0)


text:
Q: how to remove the a composable from the back stack in Compose-Navigation I there is a a screen in my application that allows the user to Edit an Item in the database and after the user finishes editing the item they click on "Done" Button that will take them to the previous Screen.
But when the user click on the back button they will go to the edit Screen again.
What I want is when the user Clicks on the back button is to go to another Screen Like they never went to the Edit Screen.
here is my navigation graph:
@Composable
fun AppNavigator(
    textFieldsViewModel: TextFieldsViewModel,
    shoppingListsViewModel: ShoppingListsViewModel,
    addNewShoppingListViewModel: AddNewShoppingListViewModel
) {

    val navController = rememberNavController()

    NavHost(navController, startDestination = "SplashScreen") {
        composable("SplashScreen") {
            SplashScreen(navController = navController)
        }
        composable("shoppingLists") {
            ShoppingListsScreen(
                navController = navController,
                shoppingListsViewModel = shoppingListsViewModel,
                textFieldsViewModel = textFieldsViewModel
            )
        }
        composable(
            "ItemsList/{listID}",
            arguments = listOf(navArgument("listID") { type = NavType.IntType })
        ) {
            ShoppingListItemsScreen(
                it.arguments?.getInt("listID")!!,
                shoppingListsViewModel = shoppingListsViewModel,
                textFieldsViewModel = textFieldsViewModel,
                navController = navController
            )
        }
        composable(
            "EditItem/{itemId},{itemName},{itemQuantity},{itemParentListId}",
            arguments = listOf(
                navArgument("itemId") { type = NavType.IntType },
                navArgument("itemName") { type = NavType.StringType },
                navArgument("itemQuantity") { type = NavType.IntType },
                navArgument("itemParentListId") { type = NavType.IntType })
        ) {
            EditItemScreen(
                navController = navController,
                textFieldsViewModel = textFieldsViewModel,
                shoppingListsViewModel = shoppingListsViewModel,
                itemId = it.arguments?.getInt("itemId")!!,
                itemName = it.arguments?.getString("itemName")!!,
                itemQuantity = it.arguments?.getInt("itemQuantity")!!,
                itemParentListId = it.arguments?.getInt("itemParentListId")!!
            )
        }
        composable("AddNewShoppingList") {
            AddNewShoppingListScreen(
                navController = navController,
                textFieldsViewModel = textFieldsViewModel,
                addNewShoppingListViewModel = addNewShoppingListViewModel,
                shoppingListsViewModel = shoppingListsViewModel
            )
        }

    }
}

And here is the code of the button that is responsible of navigat to the previous composable:
 IconButton(
                onClick = {
                    shoppingListsViewModel.addNewItemToShoppingList(item)
                    navController.navigate("ItemsList/${changeableParentListId.value}")
                }) {
                Icon(Icons.Rounded.Done, "Save or Edit the Shopping Item")
            }

here is a Screenshot of the Edit screen:
enter image description here

A: From the edit/details screen you should call navController.popBackStack().


text:
Q: Не отображается содержимое HTML
Код:
Startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Shop.Data.interfaces;
using Shop.Data.mocks;

namespace Shop
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {

            services.AddTransient<IAllCars, MockCars>();
            services.AddTransient<ICarsCategory, MockCategory>();
            services.AddMvc(); //
            services.AddRazorPages();
            services.AddMvc(options => options.EnableEndpointRouting = false);

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {

            app.UseMvcWithDefaultRoute();
            app.UseDeveloperExceptionPage();
            app.UseStatusCodePages();
            app.UseStaticFiles();

        }
    }
}

СarsController.cs
using Microsoft.AspNetCore.Mvc;
using Shop.Data.interfaces;
using Shop.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Shop.Controllers
{
    public class CarsController : Controller { // унаследовали от Класса Контролер

        private readonly IAllCars _allCars; // переменная на интерфей ( интерфейс+ класс с реализацией)
        private readonly ICarsCategory _allCategories;

        public CarsController(IAllCars iAllCars , ICarsCategory iCarsCat)
        {
            _allCars = iAllCars;
            _allCategories = iCarsCat;
        }
        public ViewResult List() { // обращаемся к ф-ции List и получаем html страничку
            ViewBag.Title = "Страница с автомобилями";
            CarsListViewModel obj = new CarsListViewModel();
            obj.allCars = _allCars.Cars;
            obj.currCategory = "Автомобили";

           return View(obj); // получение htlm

List.cshtml

Все автомобили

@Model.currCategory

    @{
        foreach (var car in Model.allCars)
        {

Модель: @car.name

Цена:@car.price.ToString("c")

            }
        }

A: Ты отключил маршрутизацию по конечным точкам, ну так самой маршрутизации у тебя нет. Либо добавляй обработчик маршрута в методе configure, через метод расширения UseMvc, либо в самом контроллере через атрибуты пропиши путь, по типу
[Route("List")]
public IActionResult List()...


text:
Q: Android Studio Gradle is not building third party libraries I am using Android Studio 1.3.1 in Windows and same in Ubuntu.
In Ubuntu, everything is perfect.
But in Windows, when I compile third party libraries, the build fails and says:

Can not find resource

The build.gradle of my module is :
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "app.android.parking"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'cn.pedant.sweetalert:library:1.3'
}

the error is coming in the last line. And it is coming for every third party library,not only for this one.
When I open same project in Ubuntu, the build is successful.
The build.gradle of my project is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
     repositories {
       jcenter()
   }
dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
   }
}

The exact error is:
Error:A problem occurred configuring project ':parking'.

Could not resolve all dependencies for configuration ':parking:_debugCompile'.
  Could not resolve cn.pedant.sweetalert:library:1.3.
       Required by:
           parking:parking:unspecified
  Could not resolve cn.pedant.sweetalert:library:1.3.
  Could not get resource 'https://jcenter.bintray.com/cn/pedant/sweetalert/library/1.3/library-1.3.pom'.
  Could not GET 'https://jcenter.bintray.com/cn/pedant/sweetalert/library/1.3/library-1.3.pom'.
  jcenter.bintray.com

I tried invalidating cache and restart, It did not work. It is compiling everything except those third party libraries.


text:
Q: Jfree chart - Include pan functionality in browser Hi I am trying to make a dynamic stacked area and time series chart using jfreechart. I want to display it on a browser. Also, I want the pan and zoom using mouse wheel functionality. Any idea, how this can be done? Is it even possible ?
Or is there any other library by which I can make the chart?

A: *

*In order to zoom in your chart, you need to implement Zoomable interface.

*In order to pan your chart, you need to implement Pannable interface.

Rather than using JFreeChart, you can use the new Java way to draw charts JavaFX. Check this tutorials Using JavaFX Charts.


text:
Q: Implementing find function for key value pair map on top of a generic set I have the following code (removing not relevant parts) trying to implement key value pair map on top of generic set class (Setlike)
class Setlike f where
....
getElem :: Ord a => a -> f a -> Maybe a
.....

newtype KV k v = KV { kv :: (k,v) }
type Map f k v = f (KV k v)
type ListMap k v = Map [] k v
type TreeMap k v = Map BST k v

find :: (Setlike f, Ord k) => k -> Map f k v -> Maybe v
find k m  = Nothing  where res=(getElem k m) -- this is the  problem, for some reason  I  this dummy line of code does not work

I get this error when calling (getElem k m) from the find function  :
** error:
    * Occurs check: cannot construct the infinite type: k ~ KV k v
      Expected type: f k
        Actual type: f (KV k v)
    * In the second argument of `getElem', namely `m'
      In the expression: (getElem k1 m)
      In an equation for `res': res = (getElem k1 m)
    * Relevant bindings include
        res :: Maybe k (bound at hw02.hs:206:30)
        m :: f (KV k v) (bound at hw02.hs:206:10)
        k1 :: k (bound at hw02.hs:206:7)
        find :: k -> f (KV k v) -> Maybe v (bound at hw02.hs:206:2)
    |
206 |  find k1 m  = Nothing  where res=(getElem k1 m)**

I thought it should work because m :: f (KV k v) and find has a Setlike f constraint.

A: The definition of getElem takes a key (of type a) and returns a value of type Maybe a. In your usage, you pass in a key of type k and expect a value of type Maybe v where v is distinct from type k.
In other words, your Map type is not set-like, since the input key results in a different type v.
Perhaps if you explained what you are trying to do, rather than how you are trying to do it, we might be able to help.

A: When you write
getElem k m

you have
getElem :: a -> f a        -> Maybe a
m       ::      f (KV k v)
k       :: k

The first two lines suggest that we should choose a to be KV k v, but the first and third suggest we should choose a to be just plain old k. These are in conflict.
One way to fix this would be to invent an arbitrary v to use for the lookup, as in
getElem (KV (k, undefined)) m

and cross your fingers that the implementation of getElem will ignore the undefined and return the correct associated value instead.


text:
Q: Display Backbone model nested attributes in itemview Initially my Backbone model
 [
   {
        "id" : 1,
    "author" : "CA",
    "city": "LA",
        "Num_of_books": "5"
   },

   {
        "id": 2,
    "author":"John",
    "city": "AM",
    "Num_of_books": "10"
   }
 ]

I am passing collection to a layoutout view which has composite view and itemview in composite view is like
 var View = Backbone.Marionette.ItemView.extend({
    tagName: 'option',
    constructor: function(options) {
        this.attributes = {
            value: options.model.id
        };
        console.log(options);
        Backbone.Marionette.ItemView.prototype.constructor.apply(this, arguments);
    },
    template: _.template("<%= author %>")
 });

This gives me a
   <option value="idValue"> Author Name </option>

Now I need to change my json format to a nested (object instead of array) so id is key. For example
  {
       "1": {
        "author" : "CA",
    "city": "LA",
        "Num_of_books": "5"
       },

       "2": {
        "author":"John",
    "city": "AM",
    "Num_of_books": "10"
      }
  }

Now how can I access my model attributes in item view so I can achieve thing like
  <option value="idValue"> Author Name </option>

A: Ideally this data should be a collection, not a model. To use it in this way goes against the patterns in place for Backbone & Marionette and will cause all kinds of maintainability headaches later.
Consider something like this:
var Book = Backbone.Model.extend({
    // .. book model config
});

var BookShelf = Backbone.Collection.extend({
    model: Book
});

var BookOption = Marionette.ItemView.extend({
    tagName: 'option',
    template: _.template('<%= author %>'),
    attributes: function() {
       return {
         value: this.model.id
       }
    }
});

var BookList = Marionette.CollectionView.extend({
    tagName: 'select',
    itemView: BookOption
});

// ------

var bookshelf = new BookShelf();

bookshelf.add([{
    "id": 1,
        "author": "CA",
        "city": "LA",
        "Num_of_books": "5"
},{
    "id": 2,
        "author": "John",
        "city": "AM",
        "Num_of_books": "10"
}]);

var bookList = new BookList();


text:
Q: Showing hundreds of tiny images in HTML5 Canvas only after load I have a canvas and 100 tiny images that I want to add to my canvas in a grid-like formation.
I have already achieved this, but the images are being draw on the canvas one by one and sometimes the image at the 40th position might be drawn before the image at the 10th position.
It takes a couple of seconds and then I get my desired result, but I was wondering how I could show images only after they're loaded?
I know there are other questions with a similar problem but I have read all of them and tried their solutions but have not succeeded yet.
I have this piece of code that draws the images one by one on the canvas at the right position using nested for loops:
for(...) {
  for(..) {
    add_image(source, row, column, width, height);
  }
}

Now add_image actually creates an image object and draws it onload
function add_image(...) {
  let image = new Image();
  image.src = source;

  image.onload = function() {
    context.drawImage(img, row, col, width, height);
  }
}

In this exact situation, what is the best way to load all the images first and the "draw" them? I tried creating an array and populating it with all the image objects, then when all the images were loaded I would run the for loop to draw the images, but it wouldn't work and I didn't see a console error so I was left clueless.
Thank you in advance!

A: Or use Promise.all...
function preloadImage(source) {
  return new Promise((resolve, reject) => {
    const image = new Image();

    image.addEventListener('load', resolve.bind(null, image));
    image.src = source;
  });
}

const images = []; // Array of image sources

Promise.all(images.map(preloadImage)).then((imgs) => {
  // Draw them :)
});

Here's a demo on jsfiddle.

A: Add the images to an array and count each image as you do. In the image onload event decrease the counter. When the count is zero all the images have been loaded and can be drawn.
Example:
var images = [];
var loading = 0;
function add_image(url,xpos,ypos) {
  var image = new Image();
  image.src = url;
  images.push({
     image : image,
     xpos : xpos,
     ypos : ypos,
  });
  loading += 1;
  image.onload = function() {
      loading -= 1;
      if(loading === 0){
         drawImages(); // call function to draw all the images.
      }
  }
}
function drawImages(){
   for(var i = 0; i < images.length; i ++){
       // draw the image
       ctx.drawImage(images[i].image,images[i].xpos,images[i].ypos);
   }
}


text:
Q: MemoryError from BioPython's Align.PairwiseAligner() I'm trying to write a Python3 script that performs a global alignment of two sequences, of ~ 10 kb and 11 kb length. Both are very similar to each other. (I'm trying to find the few points where they do not match, one of which I know is close to the end of the query sequence, which is why a local alignment is not sufficient (BLASTN just crops the last 2 bases to get a better alignment score).)
I had hoped to be able to use BioPython for this, specifically the Align.PairwiseAligner. However, I'm getting a MemoryError.
Is there a way to configure or use BioPython to use less memory (more runtime is completely fine - within reason, of course)? Or any other way to perform a global alignment of 2 sequences that I can use without having to resort to external software like Emboss Needle?
(This is part of a larger software. I already have to ship BLAST and BioPython along. I would prefer not to have to ship yet another software, if it can be avoided.)
Here's an MVCE:
from Bio import Align

ref_seq = "GAAAGACCTGAAAGATCACGGTGCCTTCATTTCAACTGTGAGACATGAAGTAATTTTCCCAAATCTACAACATTAAGATATGGTGCAATAAGGACCAGATTAAAGGTCTCCTGATTTGCGGCCATGTTCCCTCCATCTCCTTTACTCCTAAACACACTCACACTCACTACTGCAAATAGTTGTCTTGTCAAGTGGGAAATGAATGCTCTTACAAGGCTCAAACTTGTGAACACATCACTGACCAGCACAGAGCTGGCTACAATAGCTCCCCAATTAAGGTGTTTTACATGCAACTGGTTCAAACCTTCCAAGTGCTAAATTAAAACAATCCTTTAAAGAAGGAAATTCTGTTTCAGAAGAGGACCTTCATACAGCATCTCTGACCAGCAACTGATGATGCTATTGAACTCAGATGCTGATTGGTTCTCCAACACGAGATTACCCAACCCAGGAGCAAGGAAATCAGTAACTTCCTCCCTATAACTTGGAATGTGGGTGGAGGGGTTCATAGTTCTCCCTGAGTGAGACTTGCCTGCTAAGCTGGCCCCTGGTCCTGTCCTGTTCTCCAGCATGGTGTGTCTGAAGCTCCCTGGAGGCTCCTGCATCCTAGCGCTGACAGTGACACTGATGGTGCTGAGCTCCCCACTGGCTTTGGCTGGGGACACCCGACGTAAGTGCACATTGCGGGTGCTGAGCTACTATGGGGTGGGGAAAATAGGGAGTTTTGTTAACATTGTGCCCAGGCCATGTCCCTTAAGAAATTGTGACGTTTTCTTCAGAGATTGCCCATCTTTATCATTGGATCCCAAATTATTTCCTCCATAAAAGGAGCTTGGGTACTTGCCCTCTTCATGAGACTTGTGTAAGGGGCCTTTGCACAAGTCATTTCTTTTCAAATCTCCACCAATAAAACCTTTGCATCACATGTCCTCAGGGTCTTTAGAGGATTTAGAAATAAGGATTCTAAAATAAATTCCCCATACAGCACTTCCCTTTATTATGTTGACTTATGTCAGACAAAAGGAGGTTCTTACTGAAAATTTTGTGGGAGTCAAGGGAATTCAAAGGGTCTCTCCTAGACGATCCAGTGTTAGGTTCCCCACAGGACCTTTGGTGTTGGCCATAGTCCTCATATGTGAGGATGGACCCAGTGGCCTCCCCATTATCTCCTTTCTTTTCTTGCTGAACTCCAATGTTTATAAGGCCTGTATCCCTGTAGCGTATGTAGGTTCTCTGACAGAAGTTATACTTAGTGCTCTTCCTTTCTTGTGGGGAAAAGTCCCTGGAACTGAAGCTGAGATTGTTAGTACTTGGAGTCACCTTACAGATACAGAGCATTTATGAGGTATTCTTTGGTGCCTAAAGAACTTAAGGCATCCTCTGAAAAACTAGCCCAGGTTCGTGTTCATTATGAATCTTTTTTAACCTTTCTGTACTTGTTTCTCTTGCATCTCCTATGTGCTCTAACTAGACATGACAGAAGAGATTTAACTAATGTATAAATTATATGAAATTCTATTTTTTAAGTCAAAAATAATCAACTATCAGAAATTTAATAATGTTCAAACTATATACTCTGTGTGGGGTTACCGAGATGATGTGAACATTGTTCACGTCTCATAGGGCTGAAAGTCAATGGGCAAGTCTTGGGAACTCATTGTCTTACTGGGGTCTTGTCCTAAATTTCCTAGGTTCACCCATCATGCCCTCAGCTTTCCTTAACTAGCCATGTCTGCTTACCTCTTCCTCCAGTTTCTATTTTTCCCCAGCTATGTTGTCATCATTTCCAGAAATCTCTAAAGCTTGCACAGAACCTTAGCACTATGCGATTCATTGAAAGAGACTTTTTTTCTCTTTTTGAGGTAGGGCCTGGCTCTGTCACCCAGTCTATAGCTCAGTGGTGTGATCGAGGCTCACTGCAACCTCTGCCACCCATGCTCAAGTGATCCTCCCTCCTCAGGCTCCAGAGTAGCTGGGAATACAGGCAGGCAACCACGCCCAGCTAATTTTTGTAATTTTGGTAGACATGAGATTTTGCCATGTTGCCCAGGCTGGTCTTAAACTGCTGGTTTCAAGCAATCCTCCTGCCTTGGCCTCCCAACATGCTAGGATTATAGATGTGAGCCACTGTGCCCAGGCAAAAAGAAATGACTCTTAATAAAAAAATTTCCTTTTTCTTAAATCACTGTTTCTTTATCTGTGAATTCTTCTTCCAACTAGAAGGAGGAGAAAAAAGAAGTTTGCCTGTATTTCTCACCAGGAGGAGAAGGGGTCTAGTGTGACATTAAAATGAAAGGGTGCTGGAGCTTGAGCCCCTTCTTGCTTTCCAGGATCCCTACAGTGATCAGTTCCCATACCCTGGTTTATTCATGTAAACCACACTTATTTTTCTCAGCAGCTACTCTTTACTGGGCTCCATTCTAGGTTCAAATCATTCTATTTGATTAAGTTAGAGAGCGTCCCTACTCTCATGGAAGTTACACAAGAGTAGAGGAGACAGACACTAACCCAATAAGCATTTAACAAAGAAGATAATGTTAGAGAGTCATAGTGCACTGAAGAAAAGACATCAGGTTTGTGAAAAAGAGAGACATGGATTCACCTACTTTAGTTCATATGTTAGGGAGCTCCACCTGAGAAAGTGACATTCAGCTGAGACAACAAAATAAGTAGACAGTCGTGAAGATCTAAGGGATGAAAGTTCCAGGGAGACCAAATGGCGGGAAAGCCCTGGTGTGGGAAACTATGTGGAGGGAGAGAAAGAAAGCTAGAGGGGCTGAAGTATAGAAAGCAACGAAATGGAGAGGCAGAAGATGAGGTAGGACACAGAGAGGAAGTCAGGAGCCTCATCATTATAGGCTCTGATGTCCACGGTAAAAAAAATTTGAATTTTATTATTTATTTACCTATTTATTTGTTTATTTATTTTATTTTATTTTGTGATGGAGTCTCTCTCTGTTGCCCAGGCTAGATGGCAGTGGCACAATCTCGGCTCACTGCAACCTCCGCCTCCTGGGTTCAAGCAATTCTCCTGCCTCAGCCTCCCAATTAGCTGGGGCCACAGGTGCATGCCACCACACCTGGCTAATTTTTTGTATTTTTAGTAGGGATAGGATTTCACCGTGTTAGCCAGGATGGTCTCGATCTCCTGACCTCGTGATCCGCCCGCCTTGGCCTCCCAAAGTGCTGGGATTATAGGCGTGAGCCACTGCACCCGGCCTATATTCAATTTTTAAAACTAATTCTAGCTACTCTGTGGGGATTGGATTGTTGGGGTTCACCAGTGGTTAGGAAGACTATTTAGGAGCACAGCAGGGAATTCTCCAGGGAAAACAAGCTTGTGGCTTCATGGAGTGCATTAGTGATAAAGACGGTGAAGAAGATAAAGTGGACAGACTCGGCATGTATTTTTGCTTAGCTTGTTAATGAATTACTGTAAAGGGGGTAGAGCTTATTCCTAAGGATTTTCTTTTGACAAATAAGTGGGTGGTAGTGTTGTTTATTGAGATAGGAAAAACTATGGGAGGAAATGATTTGAAGTGGGTGGTTTGAAATAAAAGTTTTGTTTAAATATGAGATGATTGACTGACATTTATGTGGAGCAATCAGAAGGTCAATGGCATTTAAGAGACTCATGGTGAGGCTAGGGCTTCAGGTATTTATGTTGGAGGCATCAATACGTGTAGTGTGTTAAATTCCAGGGAGTGGAAGAGGATACATAGGGAGATGGATTGTGTGGAGAAACAAGAAGAGGGCACAGGCCAGCAAAGGGGGCTGAGAAAGAGCCCAGGGATGTTGGAGAAAAACCAAGAGAACATCATGTATGTAAGTCAAGGAAAACAGATTTTTTTCAAGGAGAAGGGAGAGGCCAATTGTGGTGAGTACCACTAAGAGGAGGGGGAAGTGAGAATATGACAGAGAAGCAAGTGCTGGGATTGGTGGAGTTGATATTTGCAGTCAATGGAGTATCCAGGGAGGAAACTGGATTGGACCATTTGGAGAGCAAATAAAAGTGAGGACGAGGTTAAGGTTGACTGTTCTGTGTAGAGAGCTTCAGGGAAGGATTGTTCTCTGGGTTCAGGGAGCCAGCTGAACCTAAAGGAAAAGGCTAAAGAAGCTGAAGAGAAGGAGGAGGACCTGTGAACCAGAGATGCTCAGCCATTATTAGCAAGGAAATACAAGAGAGCCCCTGTGTGCAGTGGTGACTACTCATGCAAAATGTCACACAGCCAATATTTAACACAGCCAGGATTTCACACAGCCAATATTTATTAGTGACATAGAATATATTTGTTATTGCTCTAGGTCATGAGAATGGAGTGACAAAATGAATCCGGTCGCCATCAGTATATGCCACATAACATTTTGCAGTGACTGTGTGCCAGGCCTATGAATTTCAGTATTCAATTTCAATAATGATCCTGTTGTATCTGTGGTATTTAAAAACATATACATCTCTGTAATCTAAAATTGAGAGGTTATAAGTAAAACCCAGTATTACAAATTTAGTGCTGGAAATTGATTGCAGTTTAAATCTGAGCATATAGAAAGTCCCTTTCTTCTATGTCAGCAGATGCCTTTTGTGTGAGGTTTAGGTATACTGCATTATTAGACATAAACCAGTGTTTCTGCCCTATGTTTTCAGAATGACAATTCTTTATGAAACTAATAGAAGAACAGAAGACAATTGCAAAATCATGATGAAGATACTAATTGCTTTAGAATTAAGGAATACAAATAATGTGAGCTGCAGTTATAGGGATCAAAAAAGTTACAATGGGAATGTATTTGAGTGTTTATTATGTGATCAGTGCTAAGAAGTGTCATCATTTAATTTTACACTTAACAGTAATCCTGTGAGGATTATGCTATTATTAAATGCACTTGATACATTACAAAAAGGCTTATGGTTGATATAAATTGACCCAAGTAGAAGAGATCATGTTTTTATTCAGGTTTTCTGATTCTAGAGTTTGAGAGTTTGACCATCATTAGTGAGTAGTGACTATATTGTGTCTGAATTATTGACAGAATTTCTGATATTCATATGTACCAGGTTGTTTCTTAGAGTGGGAGCAGAGATGCAAGGGCTGCTAGTTCCGATGTGTAGGAGAAACTATCATTCATTTTGCATTTATCATTTTAAACGTTCTATATGTCTATCCTGGGCATGTGTTGAAGAACACAAGGAAGTATTAAATCACTCCTTCTTCTGAAGTTTGACTGGCAAAATTGGGCTAGAGTTACGAAATAAAATACAGGTTCCTAGTGAAATCTGAATTTCAGATACACAACCATAATTTATTGGAAATCCAAATTTAACTGGATATCTTCTATTATTCTCTGTTCTAGAACTCCACACTTCTAACATTTCTCATTCCTGTCTAAGCTCTTGTGTGTTTGGTTTTTGGCCATCGCTTTCACTGCTCTTTAAGCTCCCCCAGTAGAGTGGAGAGGTCTGTTTTCCCTCGTTTGGATTCCTACAGGCAGCGCAGGCCTGGCACAAGGTCATCACTAAGGAAGTGTTCACAGGGTGAAGGCGGTGGGTGCTGTTGAAGGAACCGGTAAAGCCTGTGGGATGAGAGAAGGAGCAGAGAGTGTTTTTGGGGTGGAGGCTCCCAGGAGGAGGCGGGACGGGCTGCGGTGCTGGGCGGATCCTCCTCCAGCTCCTGCTTGGAGGTCTCCAGAACAGGCTGGAGGCAGGGAGGGGGTCCCAAAAGCCTGGGGATGAGAAGGGGTTTTCCCGCATGGTCCCCCAGGCCCCCGTTCGCCTCAGGAAGACGGAGGATGAGCTCCTGGGCTGCTGGTGGTGGGCGTTGCGGGTGGGGCCGGTTAAGGTTCCCAGTGCCCGCACCCTGCCCAGGGAGCCCCGGATGGTGGCGTCGCTGTCAGTGTCTTCTCAGGAGGCTGCCCGTGTGACCGGATCCTTCGTGTCCCCACAGCACGTTTCTTGTGGCAGCTTAAGTTTGAATGTCATTTCTTCAATGGGACGGAGCGGGTGCGGTTGCTGGAAAGATGCATCTATAACCAAGAGGAGTCCGTGCGCTTCGACAGCGACGTGGGGGAGTACCGGGCGGTGACGGAGCTGGGGCGGCCTGATGCCGAGTACTGGAACAGCCAGAAGGACCTCCTGGAGCAGAGGCGGGCCGCGGTGGACACCTACTGCAGACACAACTACGGGGTTGGTGAGAGCTTCACAGTGCAGCGGCGAGGTGAGCGCGGCGCGGGGCGGGGCCTGAGTCCCTGTAAGCGGAGAATCTGAGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTAAGAAAGAGAGAGAGCGCGCCATCTGTGAGCATTTAGAATCCTCTCAATCCCCAGCAAGCAGTTCTGAGAGCACAGGTGTGTGTGTAGAGTGTGGATTTGTCTGGGTATGTCTGTTGTGGGAGGGGAGGCAGGAGGGGGCTGATTCTTATCCTTGGAGACCTCTGTGGGGAGGTGACAAGGGAGGTGGGTGCTGGGGGCTGGAGAGAGAGGAGACCTTGATTGTCTCGGGTCCTTAGAGATGCGGGGAAGGGAAATGTAAGGGGTGTGTGATTGGGGTGAAGGTTTAGGGGAGGACTGCTGAGGGGTAAGGAAGGTTTGGGATAATGTGAGGAGGCCGGTTCCAGACTCTCCCTGGCATACACCCTTCGTGTAATCTCTGAAATAAAAGTGTGTGCTGTTTGTTTGTAAAAGCATTAGATTAATTTCTAGAGGAACTGAGTAGACCTCTGAGGCACTCCTGAAGCTTCTTTATATCTAAATTTCTTGCTAGTTTTTTGGGTTTTTTTAGTGTGTATATTTTTACATAGTAGAAATGACTGTGAAACTAACTTTTTGAATTAAAGTTTTAACACAGTTACTATTTTATTATAATGCTAGTTTTCTAGTAGTTACATATTATTCTTTTATATATAATAGTTATGACACAACTCACCTCACTTTCCCCTTTGTTGACCTTTATTATGACATTCACCAAAAGTTGAAAATGTATGTTTCTGGTTAATTTTTAATTTATATTTTTTATTTGTAATTGCTTTGAATTATTTTGACCTATTTATTGGCGGATTATAATTATTGCTCTAAGAATTCCCTATTGTATTTGGTAGGCAATGGACAATGATCTATGGTCTGATATCTTGAGGGCTTAGTATTTTTCTCAGTGACTTTGTGGGTTCTTTGTGCTATAAGATTATTAACACTTTATTGATATTTGATCCAGCATTTGCTTCAGTTTGTGGTTTGTATGTGGATTTTGAAAGTTCTTTTCCATGTTAAGAATTTGAACTTTTTATTTAATAAAATATATTGCAAAATTTTTATTAATGATTTACAATCCATCTTAAATCTGCCATTTTGTGGCATTGTTGTCTCCAGGTTCCTCCTTACTTCTAAAAAAAATAGTTGTATTTATTGAGAGTATGCTAGTGTTGGGGATTTTCCTGGGCATAAGCACCCCAAGTAACAAGTCCCAGACACTGCCTTAATCCAAATGTGACTCTGGAAAGAAAAATCATTTTACAATGATAGGCCTAATAATAATTATGCTTGTGTTACACGGGAGATGCATTGATCAGCTAAATGTAAATATAAGAACTTTCAAAACTAAAATGACATTCCCTAATCCTTTTCTCTGCTTCGGGACTCATGCTTTTCTAGGAACGTAAAAATTTGGAGAATCATTTCTGTCTGTCCCACATTCCCAGGGGCAGAACAATTTCTGTTTTGTTCTAAGGTGTGAGTGCATGGCAGTAGTATTCCTAAAATTCATACTCGGTTTCCTCATGTACCCAATTCTGTCCCTTTATCTATGCATATTTCTTTAAATCATATTTTTCTGTCATGGGGTACAAGGATGATAAATAGGTGCCAAGTGGAGCACCCAAGTGTGATGAGCGCCCTCACAGTGGAATGGAGTGAGAAGCTTTCTGACCTTATAAACTGAAGGCTATCTTCAGTCATTGTTTTATATATTTTACATGCATTAATCCTCATATAACCCCAAGAGGTAAATTAGTATAATTATCCTTCATTGTAGGTGACAAAGTTGAGACACAGAAGAATCAAAAAACTCTTCCAGGATCAACCAGTAAAAGGCAGACCTTGGATTCGAACCAAGCAACCTGGCTCAAATATCAGTTTTAATTACTACACTCTATACTTTCCAAGATTTGTAAACAGTTTGACAATGCATGCCAATTTAAAGCTATGAAGAAACAAACACAATTTTTCACAACACCTCTCAAATCTAATGGGTCCTCACTGTCAAGATTAAATTCCAGGCTGATGACACTGTAAGGTCACATGGCCAGCTGTGCTATAGGCCTGGTCAAGGTCAGAGCCTGGGTTTGCAGAGAAGCAGACACACAGCCAAACCAGGAGACTTACTCTGTCTTCCTGACTCATTCTCTCTACATTTGTTTTCTCCTAGTTGAGCCTAAGGTGACTGTGTATCCTTCAAAGACCCAGCCCCTGCAGCACCACAACCTCCTGGTCTGCTCTGTGAGTGGTTTCTATCCAGGCAGCATTGAAGTCAGGTGGTTCCGGAACGGCCAGGAAGAGAAGGCTGGGGTGGTGTCCACAGGCCTGATCCAGAATGGAGATTGGACCTTCCAGACCCTGGTGATGCTGGAAACAGTTCCTCGGAGTGGAGAGGTTTACACCTGCCAAGTGGAGCACCCAAGTGTGACGAGCCCTCTCACAGTGGAATGGAGTGAGCAGCTTTCTGACTTCATAAATTTCTCACCCACCAAGAAGGGGACTGTGCTAATCCCTGAGTGTCAGGTTTCTCCTCTCCCACACCCTATTTTCATTTGCTCCATGTTCTCATCTCCATCAGCACAGGTCACTGGGGGTAGCCCTGTAGGTGTTTCTAGAAACACCTGTACCTCCTGGAGAAGCAGTCTCACCTGCCAGGCAGGAGAGACTGTCCCTCTTTTGAACCTCCCCATGATTTCGCAGGTCAGGGTCACCCACTCTCCCCAGGCTCCAGGCCCTGCTTCTGGGTCTGAGACTGAGTTTCTGGTGCTGTTGCTCTGAGTTATTTTTTGTGATCTGGGAAGAGGAGAAGTGTAGGGGCCTACCTGACATGAGGGGAATCCAATCTCAGCCCTGCCTTTTATTAGCTCTGTCACTCTAGACAAACTACTTAGCTTCATTGAGTCTCAGGCTTTCTGTTGATCAGATGTTGAACGCTTGCCTTACATCAAGGCTGTAATATTTGAATGAGTTTGATGTCTGAACATCGTAACTGTTCAGCGTGATTTGAAATCCTTTTTTTCTCCTGAAATGGCTAGTTATTTTAATTCTTGTGGGGCAGGCTTCTGCCCCATTTTCAAAGCTCTGAATCTTAGAGTCTCAATTAAAGAGGTTCAATTTGGAATAAGCATCACTAAACCTGGATTCCTCTCTCAGGAGCACGGTCTGAATCTGCACAGAGCAAGATGCTGAGTGGAGTCGGGGGCTTCGTGCTGGGCCTGCTCTTCCTTGGGGCCGGGCTGTTCATCTACTTCAGGAATCAGAAAGGTGAGGAGCCTTTGGGAGCTGACTCTCTCCATAGGCTTTTCTGGAGGAGGAACCATGGTTTTGCTGAGAGGTTAGTTCTCAGTATACGAGTGGCCCTGAATAAAGCCTTTCTTTCCCCAAACGGCTCTAATGTCCTGCTAATCCAGAAATCATCAGTGCATGGTTACTATGTCAAAGCATAATAGCTTGTGGCCTGCAGAGACAAGAGGAAGGTTAACAAGTAGGGGTCCTTTTGTTTGAGATCCTGGAGCAAATTAAGGAAGAGCCACTAAGGCTAATGGAATTACACTGGATCCTGTGACAGACACTTCAGGCTTCATGGGTCACATGGTCTGTCTCTGCTCCTTTCTGCCCCTTTCTGCCCTGGTTGGTGCGGGTTGTGGTGTTAGAGAAATCTCAGGTGGGAGATCTGCGGCTGGGACATTGTGTTGGAGGACAGATTTGCTTCAATAACTTTTAAGTGTATTTCTTTTCCTCTTTTTCCCAGGACACTCTGGACTTCAGCCAACAGGTAATACCTTTTAATCCTCTTTTAGAAACAGACACAGTTTCCCTAGTGAGAGGTGAAGCCAGCTGGACTTCTGGGTGGGGTGGGGACTTGGAGAACTTTTCTTACAAGAGGTTTCTAAATGCCCCAATCAGTGCTTTGTAAAAACACACCAATAGGTTCTCTGTGGCTAGCTGGATGTTTGTAAAATGGACCAATTTGCACTCTGTAAAATGGACCAATCAGCATTCTTTAAAATGGACCAATCAGCACTTTTAAAATGGGCCAATCAGCACTCTTTAAAATGGACCAATCAGCACTCTTTAAAATGGACCAATCTGCAGGACATGGGCAGGGACAAATACAGGAATAAAAGCTGGCCACCCCAACCAGCAGTGGCAACCCACTCAGGTCCTCTTCCCTGCTGTGGAAGTTTTGTTCTTTTGATCTTCACAATAAATCTTGCTGCTGCCTACTCTTTGGGTCCCTGCCGCCTTTAAGAGCTGTAACACTCACTGTGAAGGTCTGCTTGAAGTCAGCGAGACCACAAACCCACTGGAAGGAACAAACTGCGGACACACTAGAATGATGGTAGAGGTGATAAGGCATGAGACAGAAATAATAGGAAAGACTTTGGATCCAAATTTCTGATCAGGCAATTTACACCAAAATTCCTCCTCTCCACTTAGAAAAGGGCTGTGCTCTGCGGGACTATTGGCTCAGGGGAGACTCAGGAACTTGTTTTTCTGCTTCCTGCAGTGCTCTCATCTGAGCCCTTGAAAGAGGAGAAAAGAAACTGTTAGTAGAGCCAGGTTGAAAACAACACTCTCCTCTGTCTTTTGCAGGATTCCTGAGCTGAAATGCAGATGACCACATTCAAGGAAGAACCTTCTGTCCCAGCTTTGCAGAATGAAAAGCTTTCCTGCTTGGCAGTTATTCTTCCACAAGAGAGGGCTTTCTCAGGACCTGGTTGCTACTGGTTCGGCAACTGCAGAAAATGTCCTCCCTTGTGGCTTCCTCAGCTCCTGCCCTTGGCCTGAAGTCCCAGCATTGATGACAGCGCCTCATCTTCAACTTTT"
query_seq = "GAGTGAGACTTGCCTGCTAAGCTGGCCCCTGCTCCTGTCCTGTTCTCCAGCATGGTGTGTCTGAAGCTCCCTGGAGGCTCCTGCATCCTAGCGCTGACAGTGACACTGATGGTGCTGAGCTCCCCACTGGCTTTGGCTGGGGACACCCGACGTAAGTGCACATTGCGGGTGCTGAGCTACTATGGGGTGGGGAAAATAGGGAGTTTTGTTAACATTGTGCCCAGGCCATGTCCCTTAAGAAATTGTGACGTTTTCTTCAGAGATTGCCCATCTTTATCATTGGATCCCAAATTATTTCCTCCATAAAAGGAGCTTGGGTACTTGCCCTCTTCATGAGACTTGTGTAAGGGGCCTTTGCACAAGTCATTTCTTTTCAAATCTCCACCAATAAAACCTTTGCATCACATGTCCTCAGGGTCTTTAGAGGATTTAGAAATAAGGATTCTAAAATAAATTCCCCATACAGCACTTCCCTTTATTATGTTGACTTATGTCAGACAAAAGGAGGTTCTTACTGAAAATTTTGTGGGAGTCAAGGGAATTCAAAGGGTCTCTCCTAGACGATCCAGTGTTAGGTTCCCCACAGGACCTTTGGTGTTGGCCATAGTCCTCATATGTGAGGATGGACCCAGTGGCCTCCCCATTATCTCCTTTCTTTTCTTGCTGAACTCCAATGTTTATAAGGCCTGTATCCCTGTAGCGTATGTAGGTTCTCTGACAGAAGTTATACTTAGTGCTCTTCCTTTCTTGTGGGGAAAAGTCCCTGGAACTGAAGCTGAGATTGTTAGTACTTGGAGTCACCTTACAGATACAGAGCATTTATGAGGTATTCTTTGGTGCCTAAAGAACTTAAGGCATCCTCTGAAAAACTAGCCCAGGTTCGTGTTCATTATGAATCTTTTTTAACCTTTCTGTACTTGTTTCTCTTGCATCTCCTATGTGCTCTAACTAGACATGACAGAAGAGATTTAACTAATGTATAAATTATATGAAATTCTATTTTTTAAGTCAAAAATAATCAACTATCAGAAATTTAATAATGTTCAAACTATATACTCTGTGTGGGGTTACCGAGATGATGTGAACATTGTTCACGTCTCATAGGGCTGAAAGTCAATGGGCAAGTCTTGGGAACTCATTGTCTTACTGGGGTCTTGTCCTAAATTTCCTAGGTTCACCCATCATGCCCTCAGCTTTCCTTAACTAGCCATGTCTGCTTACCTCTTCCTCCAGTTTCTATTTTTCCCCAGCTATGTTGTCATCATTTCCAGAAATCTCTAAAGCTTGCACAGAACCTTAGCACTATGCGATTCATTGAAAGAGACTTTTTTTCTCTTTTTGAGGTAGGGCCTGGCTCTGTCACCCAGTCTATAGCTCAGTGGTGTGATCGAGGCTCACTGCAACCTCTGCCACCCATGCTCAAGTGATCCTCCCTCCTCAGGCTCCAGAGTAGCTGGGAATACAGGCAGGCAACCACGCCCAGCTAATTTTTGTAATTTTGGTAGACATGAGATTTTGCCATGTTGCCCAGGCTGGTCTTAAACTGCTGGTTTCAAGCAATCCTCCTGCCTTGGCCTCCCAACATGCTAGGATTATAGATGTGAGCCACTGTGCCCAGGCAAAAAGAAATGACTCTTAATAAAAAAATTTCCTTTTTCTTAAATCACTGTTTCTTTATCTGTGAATTCTTCTTCCAACTAGAAGGAGGAGAAAAAAGAAGTTTGCCTGTATTTCTCACCAGGAGGAGAAGGGGTCTAGTGTGACATTAAAATGAAAGGGTGCTGGAGCTTGAGCCCCTTCTTGCTTTCCAGGATCCCTACAGTGATCAGTTCCCATACCCTGGTTTATTCATGTAAACCACACTTATTTTTCTCAGCAGCTACTCTTTACTGGGCTCCATTCTAGGTTCAAATCATTCTATTTGATTAAGTTAGAGAGCGTCCCTACTCTCATGGAAGTTACACAAGAGTAGAGGAGACAGACACTAACCCAATAAGCATTTAACAAAGAAGATAATGTTAGAGAGTCATAGTGCACTGAAGAAAAGACATCAGGTTTGTGAAAAAGAGAGACATGGATTCACCTACTTTAGTTCATATGTTAGGGAGCTCCACCTGAGAAAGTGACATTCAGCTGAGACAACAAAATAAGTAGACAGTCGTGAAGATCTAAGGGATGAAAGTTCCAGGGAGACCAAATGGCGGGAAAGCCCTGGTGTGGGAAACTATGTGGAGGGAGAGAAAGAAAGCTAGAGGGGCTGAAGTATAGAAAGCAACGAAATGGAGAGGCAGAAGATGAGGTAGGACACAGAGAGGAAGTCAGGAGCCTCATCATTATAGGCTCTGATGTCCACGGTAAAAAAAATTTGAATTTTATTATTTATTTACCTATTTATTTGTTTATTTATTTTATTTTATTTTGTGATGGAGTCTCTCTCTGTTGCCCAGGCTAGATGGCAGTGGCACAATCTCGGCTCACTGCAACCTCCGCCTCCTGGGTTCAAGCAATTCTCCTGCCTCAGCCTCCCAATTAGCTGGGGCCACAGGTGCATGCCACCACACCTGGCTAATTTTTTGTATTTTTAGTAGGGATAGGATTTCACCGTGTTAGCCAGGATGGTCTCGATCTCCTGACCTCGTGATCCGCCCGCCTTGGCCTCCCAAAGTGCTGGGATTATAGGCGTGAGCCACTGCACCCGGCCTATATTCAATTTTTAAAACTAATTCTAGCTACTCTGTGGGGATTGGATTGTTGGGGTTCACCAGTGGTTAGGAAGACTATTTAGGAGCACAGCAGGGAATTCTCCAGGGAAAACAAGCTTGTGGCTTCATGGAGTGCATTAGTGATAAAGACGGTGAAGAAGATAAAGTGGACAGACTCGGCATGTATTTTTGCTTAGCTTGTTAATGAATTACTGTAAAGGGGGTAGAGCTTATTCCTAAGGATTTTCTTTTGACAAATAAGTGGGTGGTAGTGTTGTTTATTGAGATAGGAAAAACTATGGGAGGAAATGATTTGAAGTGGGTGGTTTGAAATAAAAGTTTTGTTTAAATATGAGATGATTGACTGACATTTATGTGGAGCAATCAGAAGGTCAATGGCATTTAAGAGACTCATGGTGAGGCTAGGGCTTCAGGTATTTATGTTGGAGGCATCAATACGTGTAGTGTGTTAAATTCCAGGGAGTGGAAGAGGATACATAGGGAGATGGATTGTGTGGAGAAACAAGAAGAGGGCACAGGCCAGCAAAGGGGGCTGAGAAAGAGCCCAGGGATGTTGGAGAAAAACCAAGAGAACATCATGTATGTAAGTCAAGGAAAACAGATTTTTTTCAAGGAGAAGGGAGAGGCCAATTGTGGTGAGTACCACTAAGAGGAGGGGGAAGTGAGAATATGACAGAGAAGCAAGTGCTGGGATTGGTGGAGTTGATATTTGCAGTCAATGGAGTATCCAGGGAGGAAACTGGATTGGACCATTTGGAGAGCAAATAAAAGTGAGGACGAGGTTAAGGTTGACTGTTCTGTGTAGAGAGCTTCAGGGAAGGATTGTTCTCTGGGTTCAGGGAGCCAGCTGAACCTAAAGGAAAAGGCTAAAGAAGCTGAAGAGAAGGAGGAGGACCTGTGAACCAGAGATGCTCAGCCATTATTAGCAAGGAAATACAAGAGAGCCCCTGTGTGCAGTGGTGACTACTCATGCAAAATGTCACACAGCCAATATTTAACACAGCCAGGATTTCACACAGCCAATATTTATTAGTGACATAGAATATATTTGTTATTGCTCTAGGTCATGAGAATGGAGTGACAAAATGAATCCGGTCGCCATCAGTATATGCCACATAACATTTTGCAGTGACTGTGTGCCAGGCCTATGAATTTCAGTATTCAATTTCAATAATGATCCTGTTGTATCTGTGGTATTTAAAAACATATACATCTCTGTAATCTAAAATTGAGAGGTTATAAGTAAAACCCAGTATTACAAATTTAGTGCTGGAAATTGATTGCAGTTTAAATCTGAGCATATAGAAAGTCCCTTTCTTCTATGTCAGCAGATGCCTTTTGTGTGAGGTTTAGGTATACTGCATTATTAGACATAAACCAGTGTTTCTGCCCTATGTTTTCAGAATGACAATTCTTTATGAAACTAATAGAAGAACAGAAGACAATTGCAAAATCATGATGAAGATACTAATTGCTTTAGAATTAAGGAATACAAATAATGTGAGCTGCAGTTATAGGGATCAAAAAAGTTACAATGGGAATGTATTTGAGTGTTTATTATGTGATCAGTGCTAAGAAGTGTCATCATTTAATTTTACACTTAACAGTAATCCTGTGAGGATTATGCTATTATTAAATGCACTTGATACATTACAAAAAGGCTTATGGTTGATATAAATTGACCCAAGTAGAAGAGATCATGTTTTTATTCAGGTTTTCTGATTCTAGAGTTTGAGAGTTTGACCATCATTAGTGAGTAGTGACTATATTGTGTCTGAATTATTGACAGAATTTCTGATATTCATATGTACCAGGTTGTTTCTTAGAGTGGGAGCAGAGATGCAAGGGCTGCTAGTTCCGATGTGTAGGAGAAACTATCATTCATTTTGCATTTATCATTTTAAACGTTCTATATGTCTATCCTGGGCATGTGTTGAAGAACACAAGGAAGTATTAAATCACTCCTTCTTCTGAAGTTTGACTGGCAAAATTGGGCTAGAGTTACGAAATAAAATACAGGTTCCTAGTGAAATCTGAATTTCAGATACACAACCATAATTTATTGGAAATCCAAATTTAACTGGATATCTTCTATTATTCTCTGTTCTAGAACTCCACACTTCTAACATTTCTCATTCCTGTCTAAGCTCTTGTGTGTTTGGTTTTTGGCCATCGCTTTCACTGCTCTTTAAGCTCCCCCAGTAGAGTGGAGAGGTCTGTTTTCCCTCGTTTGGATTCCTACAGGCAGCGCAGGCCTGGCACAAGGTCATCACTAAGGAAGTGTTCACAGGGTGAAGGCGGTGGGTGCTGTTGAAGGAACCGGTAAAGCCTGTGGGATGAGAGAAGGAGCAGAGAGTGTTTTTGGGGTGGAGGCTCCCAGGAGGAGGCGGGACGGGCTGCGGTGCTGGGCGGATCCTCCTCCAGCTCCTGCTTGGAGGTCTCCAGAACAGGCTGGAGGCAGGGAGGGGGTCCCAAAAGCCTGGGGATGAGAAGGGGTTTTCCCGCATGGTCCCCCAGGCCCCCGTTCGCCTCAGGAAGACGGAGGATGAGCTCCTGGGCTGCTGGTGGTGGGCGTTGCGGGTGGGGCCGGTTAAGGTTCCCAGTGCCCGCACCCTGCCCAGGGAGCCCCGGATGGTGGCGTCGCTGTCAGTGTCTTCTCAGGAGGCTGCCCGTGTGACCGGATCCTTCGTGTCCCCACAGCACGTTTCTTGTGGCAGCTTAAGTTTGAATGTCATTTCTTCAATGGGACGGAGCGGGTGCGGTTGCTGGAAAGATGCATCTATAACCAAGAGGAGTCCGTGCGCTTCGACAGCGACGTGGGGGAGTACCGGGCGGTGACGGAGCTGGGGCGGCCTGATGCCGAGTACTGGAACAGCCAGAAGGACCTCCTGGAGCAGAGGCGGGCCGCGGTGGACACCTACTGCAGACACAACTACGGGGTTGGTGAGAGCTTCACAGTGCAGCGGCGAGGTGAGCGCGGCGCGGGGCGGGGCCTGAGTCCCTGTAAGCGGAGAATCTGAGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTAAGAAAGAGAGAGAGCGCGCCATCTGTGAGCATTTAGAATCCTCTCAATCCCCAGCAAGCAGTTCTGAGAGCACAGGTGTGTGTGTAGAGTGTGGATTTGTCTGGGTATGTCTGTTGTGGGAGGGGAGGCAGGAGGGGGCTGATTCTTATCCTTGGAGACCTCTGTGGGGAGGTGACAAGGGAGGTGGGTGCTGGGGGCTGGAGAGAGAGGAGACCTTGATTGTCTCGGGTCCTTAGAGATGCGGGGAAGGGAAATGTAAGGGGTGTGTGATTGGGGTGAAGGTTTAGGGGAGGACTGCTGAGGGGTAAGGAAGGTTTGGGATAATGTGAGGAGGCCGGTTCCAGACTCTCCCTGGCATACACCCTTCGTGTAATCTCTGAAATAAAAGTGTGTGCTGTTTGTTTGTAAAAGCATTAGATTAATTTCTAGAGGAACTGAGTAGACCTCTGAGGCACTCCTGAAGCTTCTTTATATCTAAATTTCTTGCTAGTTTTTTGGGTTTTTTTAGTGTGTATATTTTTACATAGTAGAAATGACTGTGAAACTAACTTTTTGAATTAAAGTTTTAACACAGTTACTATTTTATTATAATGCTAGTTTTCTAGTAGTTACATATTATTCTTTTATATATAATAGTTATGACACAACTCACCTCACTTTCCCCTTTGTTGACCTTTATTATGACATTCACCAAAAGTTGAAAATGTATGTTTCTGGTTAATTTTTAATTTATATTTTTTATTTGTAATTGCTTTGAATTATTTTGACCTATTTATTGGCGGATTATAATTATTGCTCTAAGAATTCCCTATTGTATTTGGTAGGCAATGGACAATGATCTATGGTCTGATATCTTGAGGGCTTAGTATTTTTCTCAGTGACTTTGTGGGTTCTTTGTGCTATAAGATTATTAACACTTTATTGATATTTGATCCAGCATTTGCTTCAGTTTGTGGTTTGTATGTGGATTTTGAAAGTTCTTTTCCATGTTAAGAATTTGAACTTTTTATTTAATAAAATATATTGCAAAATTTTTATTAATGATTTACAATCCATCTTAAATCTGCCATTTTGTGGCATTGTTGTCTCCAGGTTCCTCCTTACTTCTAAAAAAAATAGTTGTATTTATTGAGAGTATGCTAGTGTTGGGGATTTTCCTGGGCATAAGCACCCCAAGTAACAAGTCCCAGACACTGCCTTAATCCAAATGTGACTCTGGAAAGAAAAATCATTTTACAATGATAGGCCTAATAATAATTATGCTTGTGTTACACGGGAGATGCATTGATCAGCTAAATGTAAATATAAGAACTTTCAAAACTAAAATGACATTCCCTAATCCTTTTCTCTGCTTCGGGACTCATGCTTTTCTAGGAACGTAAAAATTTGGAGAATCATTTCTGTCTGTCCCACATTCCCAGGGGCAGAACAATTTCTGTTTTGTTCTAAGGTGTGAGTGCATGGCAGTAGTATTCCTAAAATTCATACTCGGTTTCCTCATGTACCCAATTCTGTCCCTTTATCTATGCATATTTCTTTAAATCATATTTTTCTGTCATGGGGTACAAGGATGATAAATAGGTGCCAAGTGGAGCACCCAAGTGTGATGAGCGCCCTCACAGTGGAATGGAGTGAGAAGCTTTCTGACCTTATAAACTGAAGGCTATCTTCAGTCATTGTTTTATATATTTTACATGCATTAATCCTCATATAACCCCAAGAGGTAAATTAGTATAATTATCCTTCATTGTAGGTGACAAAGTTGAGACACAGAAGAATCAAAAAACTCTTCCAGGATCAACCAGTAAAAGGCAGACCTTGGATTCGAACCAAGCAACCTGGCTCAAATATCAGTTTTAATTACTACACTCTATACTTTCCAAGATTTGTAAACAGTTTGACAATGCATGCCAATTTAAAGCTATGAAGAAACAAACACAATTTTTCACAACACCTCTCAAATCTAATGGGTCCTCACTGTCAAGATTAAATTCCAGGCTGATGACACTGTAAGGTCACATGGCCAGCTGTGCTATAGGCCTGGTCAAGGTCAGAGCCTGGGTTTGCAGAGAAGCAGACACACAGCCAAACCAGGAGACTTACTCTGTCTTCCTGACTCATTCTCTCTACATTTGTTTTCTCCTAGTTGAGCCTAAGGTGACTGTGTATCCTTCAAAGACCCAGCCCCTGCAGCACCACAACCTCCTGGTCTGCTCTGTGAGTGGTTTCTATCCAGGCAGCATTGAAGTCAGGTGGTTCCGGAACGGCCAGGAAGAGAAGGCTGGGGTGGTGTCCACAGGCCTGATCCAGAATGGAGATTGGACCTTCCAGACCCTGGTGATGCTGGAAACAGTTCCTCGGAGTGGAGAGGTTTACACCTGCCAAGTGGAGCACCCAAGTGTGACGAGCCCTCTCACAGTGGAATGGAGTGAGCAGCTTTCTGACTTCATAAATTTCTCACCCACCAAGAAGGGGACTGTGCTAATCCCTGAGTGTCAGGTTTCTCCTCTCCCACACCCTATTTTCATTTGCTCCATGTTCTCATCTCCATCAGCACAGGTCACTGGGGGTAGCCCTGTAGGTGTTTCTAGAAACACCTGTACCTCCTGGAGAAGCAGTCTCACCTGCCAGGCAGGAGAGACTGTCCCTCTTTTGAACCTCCCCATGATTTCGCAGGTCAGGGTCACCCACTCTCCCCAGGCTCCAGGCCCTGCTTCTGGGTCTGAGACTGAGTTTCTGGTGCTGTTGCTCTGAGTTATTTTTTGTGATCTGGGAAGAGGAGAAGTGTAGGGGCCTACCTGACATGAGGGGAATCCAATCTCAGCCCTGCCTTTTATTAGCTCTGTCACTCTAGACAAACTACTTAGCTTCATTGAGTCTCAGGCTTTCTGTTGATCAGATGTTGAACGCTTGCCTTACATCAAGGCTGTAATATTTGAATGAGTTTGATGTCTGAACATCGTAACTGTTCAGCGTGATTTGAAATCCTTTTTTTCTCCTGAAATGGCTAGTTATTTTAATTCTTGTGGGGCAGGCTTCTGCCCCATTTTCAAAGCTCTGAATCTTAGAGTCTCAATTAAAGAGGTTCAATTTGGAATAAGCATCACTAAACCTGGATTCCTCTCTCAGGAGCACGGTCTGAATCTGCACAGAGCAAGATGCTGAGTGGAGTCGGGGGCTTCGTGCTGGGCCTGCTCTTCCTTGGGGCCGGGCTGTTCATCTACTTCAGGAATCAGAAAGGTGAGGAGCCTTTGGGAGCTGACTCTCTCCATAGGCTTTTCTGGAGGAGGAACCATGGTTTTGCTGAGAGGTTAGTTCTCAGTATACGAGTGGCCCTGAATAAAGCCTTTCTTTCCCCAAACGGCTCTAATGTCCTGCTAATCCAGAAATCATCAGTGCATGGTTACTATGTCAAAGCATAATAGCTTGTGGCCTGCAGAGACAAGAGGAAGGTTAACAAGTAGGGGTCCTTTTGTTTGAGATCCTGGAGCAAATTAAGGAAGAGCCACTAAGGCTAATGGAATTACACTGGATCCTGTGACAGACACTTCAGGCTTCATGGGTCACATGGTCTGTCTCTGCTCCTTTCTGCCCCTTTCTGCCCTGGTTGGTGCGGGTTGTGGTGTTAGAGAAATCTCAGGTGGGAGATCTGCGGCTGGGACATTGTGTTGGAGGACAGATTTGCTTCAATAACTTTTAAGTGTATTTCTTTTCCTCTTTTTCCCAGGACACTCTGGACTTCAGCCAACAGGTAATACCTTTTAATCCTCTTTTAGAAACAGACACAGTTTCCCTAGTGAGAGGTGAAGCCAGCTGGACTTCTGGGTGGGGTGGGGACTTGGAGAACTTTTCTTACAAGAGGTTTCTAAATGCCCCAATCAGTGCTTTGTAAAAACACACCAATAGGTTCTCTGTGGCTAGCTGGATGTTTGTAAAATGGACCAATTTGCACTCTGTAAAATGGACCAATCAGCATTCTTTAAAATGGACCAATCAGCACTTTTAAAATGGGCCAATCAGCACTCTTTAAAATGGACCAATCAGCACTCTTTAAAATGGACCAATCTGCAGGACATGGGCAGGGACAAATACAGGAATAAAAGCTGGCCACCCCAACCAGCAGTGGCAACCCACTCAGGTCCTCTTCCCTGCTGTGGAAGTTTTGTTCTTTTGATCTTCACAATAAATCTTGCTGCTGCCTACTCTTTGGGTCCCTGCCGCCTTTAAGAGCTGTAACACTCACTGTGAAGGTCTGCTTGAAGTCAGCGAGACCACAAACCCACTGGAAGGAACAAACTGCGGACACACTAGAATGATGGTAGAGGTGATAAGGCATGAGACAGAAATAATAGGAAAGACTTTGGATCCAAATTTCTGATCAGGCAATTTACACCAAAATTCCTCCTCTCCACTTAGAAAAGGGCTGTGCTCTGCGGGACTATTGGCTCAGGGGAGACTCAGGAACTTGTTTTTCTGCTTCCTGCAGTGCTCTCATCTGAGCCCTTGAAAGAGGAGAAAAGAAACTGTTAGTAGAGCCAGGTTGAAAACAACACTCTCCTCTGTCTTTTGCAGGATTCCTGAGCTGAAATGCAGATGACCACATTCAAGGAAGAACCTTCTGTCCCAGCTTTGCAGGA"

aligner = Align.PairwiseAligner()
aligner.match_score = 2
aligner.mismatch_score = -3
aligner.open_gap_score = -5
aligner.extend_gap_score = -2
aligner.query_right_open_gap_score = 0
aligner.query_left_open_gap_score = 0
aligner.query_right_extend_gap_score = 0
aligner.query_left_extend_gap_score = 0
alignments = aligner.align(ref_seq, query_seq)  # <= this is where the MemoryError occurs

for a in sorted(alignments):
    print(a)

This is Python 3 on Windows 10. The Biopython version is 1.72.
Edit: and here's the Traceback:
Traceback (most recent call last):
  File "C:/foo/temp.py", line 15, in <module>
    alignments = aligner.align(ref_seq, query_seq)  # <= this is where the MemoryError occurs
  File "C:\Program Files (x86)\Python36\lib\site-packages\Bio\Align\__init__.py", line 1352, in align
    score, paths = _aligners.PairwiseAligner.align(self, seqA, seqB)
MemoryError: Out of memory

A: In your case, where the aligner.align() call led to the MemoryError, it was likely due to a memory leak in an earlier Biopython version (since the core code is written in C, not python). This has been fixed in the later Biopython versions, so the solution is to upgrade Biopython to the latest version (now 1.77).

In other cases, sorted(alignments) could be the cause. You create, in memory, a list of all the alignments, which can be massive. You can check the size of this potential list in advance by calling print(len(alignments)).
Since alignments is a lazy iterator, you just iterate over the alignments 1 by 1 for a in alignments:, solving your memory issue, but I would still not recommend printing them all. Maybe you just want the first alignment first_alignment = next(alignments) or the first say 10 alignments:
import itertools

for a in itertools.islice(alignments, 10):
    print(a)


text:
Q: Highlight Row in Red up to certain column if cell contains certain value I have a small macro that highlights an entire row in red if the cell value in J column contains the value 427.See below...
Dim lr As Long
lr = Worksheets("owssvr").Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row

         Dim cell As Range
            For Each cell In Range("J2:J" & lr)
               If cell.Value = 427 Then
               cell.EntireRow.Interior.Color = 255
    End If

What I would like to do is to amend the macro so that it only highlights in red the section of the row that contains data, rather than the entire row (in this tables case, up to column AF). Thank you.

A: If you only want to highlight row between columns A & F then try-
Sub Highlight()
Dim lr As Long
lr = Worksheets("owssvr").Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row

    Dim cel As Range
    For Each cel In Range("J2:J" & lr)
        If cel.Value = 427 Then
           Range("A" & lr & ":F" & lr).Interior.Color = 255
        End If
    Next

End Sub


text:
Q: lftp catch output for progress bar how I can use unbuffer to capture each output line for lftp? I would like to use this information to update a zenity/yad progress bar. Only after upload I get the full file... With wget works like a charm.
Thanks,
Michael
Here my code:
unbuffer -p lftp -e 'put /home/bld/xx12.deb; bye' -u ftp,11111 san.rrr.com | sed -u 's/\([0-9]\)%//' > file2

the output:
open `san.rrr.com' [Löse Hostadresse auf...]

»/home/bld/xx12.deb« bei 0 (ffff) [FEAT Verbindungsaufbau...]
»/home/bld/xx12.deb« bei 0 (0%) [Warte auf Antwort...]
»/home/bld/xx12.deb« bei 655376 (8%) [Sende Daten]
»/home/bld/xx12.deb« bei 1160536 (14%) 533.0K/s ca. fertig:13s [Sende Daten]
»/home/bld/xx12.deb« bei 1700736 (20%) 547.1K/s ca. fertig:11s [Sende Daten]
»/home/bld/xx12.deb« bei 2173776 (26%) 589.9K/s ca. fertig:10s [Sende Daten]
»/home/bld/xx12.deb« bei 2626376 (32%) 580.3K/s ca. fertig:9s [Sende Daten]
»/home/bld/xx12.deb« bei 3236656 (39%) 604.9K/s ca. fertig:8s [Sende Daten]
»/home/bld/xx12.deb« bei 3797296 (46%) 617.8K/s ca. fertig:7s [Sende Daten]
»/home/bld/xx12.deb« bei 4425096 (54%) 632.8K/s ca. fertig:6s [Sende Daten]
»/home/bld/xx12.deb« bei 5045596 (62%) 652.0K/s ca. fertig:5s [Sende Daten]
»/home/bld/xx12.deb« bei 5667556 (69%) 660.5K/s ca. fertig:4s [Sende Daten]
»/home/bld/xx12.deb« bei 6283676 (77%) 665.7K/s ca. fertig:3s [Sende Daten]
»/home/bld/xx12.deb« bei 6746496 (83%) 658.2K/s ca. fertig:2s [Sende Daten]
»/home/bld/xx12.deb« bei 7244356 (89%) 658.9K/s ca. fertig:1s [Sende Daten]
»/home/bld/xx12.deb« bei 8099411 (100%) 684.1K/s ca. fertig:0s [Warte auf Übertragun

8099411 Bytes übertragen in 13 Sekunden (627.2K/s)

Wget code:
wget http://download.virtualbox.org/virtualbox/5.0.4/virtualbox-5.0_5.0.4-102546~Ubuntu~trusty_amd64.deb 2>&1 | sed -u 's/.*//' > file1


text:
Q: Deal with same method body in different handlers I have a method fired on mouse down:
private function setGender(e:MouseEvent):void
        {
            check.visible = true;
            check.x = e.target.x;
            check.y = e.target.y;
        }

The same method body is shared by another method fired on a keyboard Event (so, it takes a keyboard Event for argument). Which is the best way to deal with situations like this one? I would like to have only one method!
One way could be to create a new method called by the two event handlers (even if, if I need to use e.target, it can change according to the type of event and other variables, so I should eventually create a method that takes e.target as a parameter). This creates three methods...
Would it be possible to change for example e:MouseEvent with a parent of MouseEvent and KeyboardEvent? Would it work? Any drawbacks? Is this totally wrong?

A: You could just use the same event handler for both, but specify the argument type as Event (which is the base class for both event types that you target.) Note that this will of course not work if you are using anything that is specific to KeyboardEvent in the other handler (that you are not showing) but if they are really identical it will work.
private function setGender(e : Event) : void
{
    check.visible = true;
    check.x = e.target.x;
    check.y = e.target.y
}

This event listener can be used for any event that is dispatched by a display object (or any object with x and y properties).

A: Your last sentence is on the right track, but not quite correct. What you actually want is an Event type that is higher in the hierarchical structure than both MouseEvent and KeyboardEvent. This means an Event is actually what you'd like to use.
private function setGender(e:Event):void
        {
            check.visible = true;
            check.x = e.target.x;
            check.y = e.target.y;
        }

As a base Event has the only property you're looking for in both events, this should work. If, however, you want to use a different property, even one shared by MouseEvent and KeyboardEvent, you can only use it if it exists in the base Event class. However, you can also try casting the event if you end up wanting to use other properties of the events.
private function setGender(e:Event):void
        {
            if (e is MouseEvent)
            {
                //handle mouse
            }
            else
            {
                //handle keyboard
            }
            check.visible = true;
            check.x = e.target.x;
            check.y = e.target.y;
        }

A: Personally, I think you code would be cleaner and better express your intent if you were to make use of the extract method refactoring pattern as you originally suggested:
private function onMouseEvent(event : MouseEvent) : void {
    updateGender(event.target);
}

private function onKeyboardEvent(event : KeyboardEvent) : void {
    updateGender(event.target); // are you sure event.target is the intended
                                // DisplayObject on a KeyboardEvent?
}

private function updateGender(target : DisplayObject) : void {
    // update the DisplayList here.
}
This way you are providing a decoupling between the trigger (either a MouseEvent or a KeyboardEvent) and the reaction (the code in updateGender()).


text:
Q: Are these subrings of $\Bbb Q$? Are the following subrings of $\Bbb Q$?

1) The set of non-negative rational numbers.
No since we don't have any additive inverses, and the subring should be armed with an Abelian group for addition.

2) The set of squares of rational numbers.
No since the squares of rational numbers are also all positive, and hence we don't have additive inverses.

3) The set of all rational numbers with odd numerators(when the fraction is completely reduced)
No since $\frac{3}{2} -\frac{1}{2}=\frac22$

Are these all correct reasonings. I would hate to misunderstand something seemingly so simple.

A: $1$ & $2$ are fine, but $\frac {2}{ 2} = \frac {1} {1}$ has odd numerator, when the fraction is completely reduced - so this isn't a counterexample. But $3-1$ is.


text:
Q: Inserting values into 2D Python list using indexing I am trying to insert values, one at at time, from several python lists of lists (i.e. 2D lists) into another 2D list. (I know numpy is better at this, but I am trying to compare the performance of lists to numpy, so please don't just suggest numpy.) I want to insert the values at specific locations, hence the indexing on the left hand side.
resampled_pix_spot_list is a 240 by 240 list of lists, and pix_spot_list is a 225 by 225 list of lists.
The error I am getting, from the final four lines in the example, is "TypeError: 'float' object is not subscriptable". I get that pix_prod_bl[0][0], for example, is a float, but I don't understand why I can't insert it into a particular set of indices in resampled_pix_spot_list.
Edit 1- added minimal working example.
Edit 2- in adding the working example, I found that I accidentally had the line commented where I convert the lists back to numpy, and somehow I misinterpreted the Spyder console about where the error was originating. Anyway it works now, thank you very much for the quick feedback. I guess I'll leave this here in case it's helpful to anyone else.
Edit 3- pix_spot_values is an array of data, so just a random array of floats between 0 and 1 will suffice.
xc=57
yc=189
rebin=15

# fraction pixel offset requiring interpolation
dx=xc*rebin-int(np.floor(xc*rebin)) # positive value between 0 and 1
dy=yc*rebin-int(np.floor(yc*rebin)) # positive value between 0 and 1

# weights for interpolation
w00=(1-dy)*(1-dx)
w10=dy*(1-dx)
w01=(1-dy)*dx
w11=dy*dx

# now the rest of the offset is an integer shift
dx=int(np.floor(xc*rebin))-int(np.floor(xc))*rebin # positive integer between 0 and 14
dy=int(np.floor(yc*rebin))-int(np.floor(yc))*rebin # positive integer between 0 and 14

def new_pix_spot(w00, w10, w01, w11, pix_spot_list, ny_spot, nx_spot, rebin, dy, dx):
    #first change numpy array to list
    pix_spot_list=pix_spot_values.tolist()

    #preallocate array of zeros
    resampled_pix_spot_list=[[0 for x in range (ny_spot + rebin)] for y in range(nx_spot+rebin)]

    #create 2D lists
    pix_prod_bl = [[x*w00 for x in y] for y in pix_spot_list]#bottom left
    pix_prod_br = [[x*w10 for x in y] for y in pix_spot_list]#bottom right
    pix_prod_tl = [[x*w01 for x in y] for y in pix_spot_list]#top left
    pix_prod_tr = [[x*w11 for x in y] for y in pix_spot_list]#top right

    for i in range (len(pix_spot_list)):
        for j in range (len(pix_spot_list)):

            k=dy + i
            m=dx + j
            n=dy + 1 + i
            p=dx + 1 + i

            resampled_pix_spot_list[k][m] += pix_prod_bl[i][j] #bottom left
            resampled_pix_spot_list[n][m] += pix_prod_br[i][j] #bottom right
            resampled_pix_spot_list[k][p] += pix_prod_tl[i][j] #top left
            resampled_pix_spot_list[n][p] += pix_prod_tr[i][j] #top right

    resampled_pix_spot_values = np.array(resampled_pix_spot_list)

    return resampled_pix_spot_values

A: Inserting and Replacing
To insert values into a list in Python, you must work with the list object (for example, resampled_pix_spot_list[0]) rather than the elements within it (resampled_pix_spot_list[0][0], as you tried).
In both Python 2 and 3, you can insert into a list with your_list.insert(<index>, <element>) (list insertion docs here).
So to insert a number to the left of your chosen coordinate, the code would be:
resampled_pix_spot_list[k].insert(m, pix_prod_bl[i][j])

If you wanted to replace the pixel at that position, you would write:
resampled_pix_spot_list[k][m] = pix_prod_bl[i][j]

(Notice the [k] vs [k][m].) In short:  To insert, talk to the list; to replace, talk to the element.

Pitfalls of Repeated Inserts
Just a tip:  if you're planning on repeatedly inserting values into specific places in a list, try to iterate from the end of the list, backwards.  If you don't, you'll have to adjust your indices, since each .insert() call will shift part of your list to the right.
To see what I mean, let's imagine I have the list [1, 2, 3] and want to end up with [1, 88, 2, 99, 3] via insertions.  The order we insert matters.  Compare the wrong order (iterating forwards):
data = [1, 2, 3]
>>> data.insert(1, 88)
>>> print(data)
[1, 88, 2, 3]  # so far so good
>>> data.insert(2, 99)
>>> print(data)
[1, 88, 99, 2, 3]  # oops!  the first insert changed my indices, so index "2" was wrong!

with the right order (iterating backwards):
data = [1, 2, 3]
>>> data.insert(2, 99)
>>> print(data)
[1, 2, 99, 3]  # so far so good
>>> data.insert(1, 88)
>>> print(data)
[1, 88, 2, 99, 3]  # same insertions + different order = different results!

Slices
Some food for thought:  Python 2.7 and 3 both allow you to replace whole "slices" of lists with a very clean syntax, which would also help you avoid "off-by-one" errors (slice notation docs here).  For example:
>>> data = [1, 2, 3]
>>> data[1:2] = [88, data[1], 99]  # safer, shorter, faster, and clearer
>>> print(data)
[1, 88, 2, 99, 3]

Working with slices might be a bit more declarative and clear.  Hope this helps!


text:
Q: Is it possible to get a symbolic or numeric relation when solving a transcendental equation? Here is the code.
Solve[(1 - E^x + (3 x^2)/2)/(2 x) == a, x, Reals]

Unfortunately, Mathematica told me that  this system cannot be solved with the methods available to Solve.
If not a symbolic relation, can a numeric relation be found?
What's the numeric relation of x expressed in terms of a?
Let's make up a numeric relation between $x$ and $a$.
$x \rightarrow 0.812a+\frac{1}{2}a^2 $
Anyone who have a better idea?

A: Not an answer, just a long comment.
By making small Manipulate, it shows that no real solution exist when $a$ gets over value of around $-1/10$.   Hard to determine the exact value of $a$ but using the slider you can get very close to finding it. i.e when $a$ is larger than that limit, it never crosses the x-axis, so no real solution exist.
ClearAll[a,x];
eq = (1 - Exp[x] + (3 x^2)/2)/(2 x) - a;
Manipulate[Plot[eq /. a -> a0, {x, -3, 3}],
 {{a0, 0, "a"}, -1, 1, .001, Appearance -> "Labeled"},
 TrackedSymbols :> {a0}
 ]

I think this might explain why Solve could not do it in addition to the other comments above.

A: Well if you insist on having some relation you can always use FindFormula note that from an analytic perspective this is not the "correct" answer.
sols = Table[
   Flatten@{a,
     x /. Solve[(1 - E^x + (3 x^2)/2)/(2 x) == -a, x, Reals]}, {a, 1,
    100}];
branch1 = sols[[All, {1, 2}]];
branch2 = sols[[All, {1, 3}]];
formula1 = FindFormula[branch1, a];
formula2 = FindFormula[branch2, a];

Now you have some formulas formula1 and formula2 which might be helpful or not.

A: $Version

(* "12.1.1 for Mac OS X x86 (64-bit) (June 19, 2020)" *)

Clear["Global`*"]

eqn = (1 - E^x + (3 x^2)/2)/(2 x) == a;

The numeric solution for a given value of a and an initial estimate is given by FindRoot
f[a_?NumericQ, init_?NumericQ] :=
 FindRoot[(1 - E^x + (3 x^2)/2)/(2 x) == a, {x, init}]

pt1 = ({x, a} /. f[a, -10]) /. a -> -6 // Quiet

(* {-7.91581, -6} *)

pt2 = ({x, a} /. f[a, 3]) /. a -> -6 // Quiet

(* {4.42428, -6} *)

To find the max value of a
xa = Solve[D[eqn[[1]], x] == 0, x, Reals][[1]]

(* {x -> Root[{-2 + E^#1*(2 - 2*#1) +
             3*#1^2 & ,
    1.554653058468533267935\
     17428741457642172`20.286009576768794}]} *)

The exact value is a Root expression.
The maximum value of a is then
amax = a /. Solve[eqn /. xa, a, Reals][[1]]

(* (1 - E^Root[{-2 + E^#1*(2 - 2*#1) +
                3*#1^2 & ,
      1.55465305846853326793\
       517428741457642172`20.286009576768794}] +
      (3/2)*Root[{-2 + E^#1*(2 - 2*#1) +
                  3*#1^2 & ,
       1.5546530584685332679\
        3517428741457642172`20.286009576768794}]^
          2)/(2*Root[{-2 + E^#1*(2 - 2*#1) +
              3*#1^2 & ,
     1.554653058468533267935\
      17428741457642172`20.286009576768794}]) *)

The {x, a} point for max a is
(pt = {x, amax} /. xa) // N

(* {1.55465, -0.0347424} *)

where N has converted the Root expressions to their approximate numeric values.
ContourPlot shows the solutions to the equation
ContourPlot[Evaluate@eqn, {x, -13, 5}, {a, -10, 0},
 PlotPoints -> 50,
 Epilog -> {AbsolutePointSize[4], Tooltip[Point[#], #] & /@ {pt1, pt2},
   Red, Tooltip[Point[#], #] &[N@pt]},
 FrameLabel -> (Style[#, 14, Bold] & /@ {x, a})]

A: You can use AsymptoticSolve to get a solution near x=k as following:
    AsymptoticSolve[(1 - E^x + (3 x^2)/2)/(2 x) == a, {x, k}, {a, (1 - E^k + (3
    k^2)/2)/(2 k), 2}]

    (*{{x -> k + (4 k^2 (a - (1 - E^k + (3 k^2)/2)/(2 k)))/(-2 + 2 E^k - 2 E^k k +
 3 k^2) + (16 k^3 (-2 + 2 E^k - 2 E^k k + E^k k^2) (a - (1 - E^k + (3 k^2)/2)/(2 k))^2)/(-2 + 2 E^k - 2 E^k k +
  3 k^2)^3}}*)


text:
Q: WPF stretch image without Stretch="Fill" I am trying to make responsive WPF app which shows image. One of the program's functionalities is selecting a piece of an image by clicking and draging the mouse. I use Point p = e.GetPosition((IInputElement)sender); to find cursor position, and I found out I cannot use Stretch="Fill" because it causes the MouseUp cursor to select a little lower than it should and MouseMove is also inaccurate (I have to drag the mouse a lot further than I should). On the internet, I found the reason for this behavior that you cannot use Fill and have to use None instead. However, the image is much smaller without Fill.
This is my XAML:
<Grid Grid.Row = "1"
      Grid.Column="1"
      HorizontalAlignment="Left"
      VerticalAlignment= "Top"
      Margin="0,30,0,0">
    <Image x:Name= "image1"
           Grid.Row = "1"
           Grid.Column="1"
           Cursor="Cross"
           MinWidth="300"
           MinHeight="300"
           MaxWidth="512"
           MaxHeight= "512"
           Stretch = "None"
           RenderOptions.BitmapScalingMode="NearestNeighbor"
           RenderOptions.EdgeMode="Aliased"
           VerticalAlignment="Top"
           MouseDown="picOriginal_MouseDown"
           MouseMove="picOriginal_MouseMove"
           MouseUp="picOriginal_MouseUp" />
</Grid>

I don't know how to embed my image so that in the window view it fills the grid without this Fill property and at the same time is responsive for fullscreen. Should I wrap Image with something else from the WPF toolbox?

A: I find it easier using the background of the picture box to be the image then use the stretch in that. Alternatively, you could use the image with any of the other options, try using the the properties tab, here are the other stretch options tho: None, Fill, Uniform, UniformToFill
Tell me if this helps, tryna get rep, thanks!


text:
Q: No puedo incluir carrousel en laravel include Gente como va?
Lo que quiero hacer es a mi home incrustarle dos carrouseles, estos carrouseles se van a repetir en el sitio por lo que me gustaría programarlos en su propio archivo blade.
El problema que tengo es que no se están mostrando a pesar de que ya los incluí en la vista con include('')
layout/app.blade.php
<!doctype html>
HTML HTML...

            @yield('content')
            @yield('uploadProduct')
            @yield('profile')

content.blade.php
@extends('layouts.app')

@section('content')

    @include('slider')

    @include('carrousel_last_products')

@endsection

slider.blade.php
@section('slider')

SLIDER PRUEBA SLIDER PRUEBA

@endsection

carrousel_last_products.blade.php
@section('carrousel_last_products')

.col-md-4

.col-md-4

.col-md-4

@endsection

No estoy entendiendo bien..
Agradezco de antemano!


text:
Q: Updating state always remain same value I have simple state like this
const [number, SetNumber] = React.useState<number>(0)

Then, i create an updater function in the first-render hooks like this
  const increaseNumber = () => {
    console.log(number);
    SetNumber(number + 1);
  };

  React.useEffect(() => {
    setInterval(() => {
      increaseNumber();
    }, 1000);
  }, []);

From the console.log statement in increaseNumber function i got this output
0
0
0
0
0

Why the number state is not updating and always remain the same value?
Here's the full code
import * as React from 'react';

const App = () => {
  const [number, SetNumber] = React.useState<number>(0);

  const increaseNumber = () => {
    console.log(number);
    SetNumber(number + 1);
  };

  React.useEffect(() => {
    setInterval(() => {
      increaseNumber();
    }, 1000);
  }, []);

  return (

{number}

  );
};

export default App;

My expectation from the console.log output is like this
0
1
2
3
4

A: two things,

*

*clear the interval on clean up of effect,

*use functional updater of state

const {useState, useEffect} = React;

const App = () => {
  const [number, SetNumber] = useState(0);

  const increaseNumber = () => {
    SetNumber(prev=>prev+1);  // react takes care of updating number
  };

  console.log(number);

  React.useEffect(() => {
    const id = setInterval(() => {
      increaseNumber();
    }, 1000);

    return ()=> {clearInterval(id)}   // as it continues to execute on unmount if you won't do
  }, []);

  return (

{number}

  );
};

ReactDOM.createRoot(
    document.getElementById("root")
).render(
    <App/>
);


text:
Q: How to check if there is a new e-mail in background - ios how can I check if there is a new email and show an alert to user when my app is running in background?
For pushing a notification when app is not active I have to set a "show" time to notification but an email can be received any time... I need to check emails when my app is not active?

A: You should use the Apple Push Notification Service to send push messages when your server detects there is a new message. Your app on the phone should not do this as it will run down the battery quickly.


text:
Q: Why isn't DRY considered a good thing for type declarations? It seems like people who would never dare cut and paste code have no problem specifying the type of something over and over and over.  Why isn't it emphasized as a good practice that type information should be declared once and only once so as to cause as little ripple effect as possible throughout the source code if the type of something is modified?  For example, using pseudocode that borrows from C# and D:
MyClass<MyGenericArg> foo = new MyClass<MyGenericArg>(ctorArg);

void fun(MyClass<MyGenericArg> arg) {
    gun(arg);
}

void gun(MyClass<MyGenericArg> arg) {
    // do stuff.
}

Vs.
var foo = new MyClass<MyGenericArg>(ctorArg);

void fun(T)(T arg) {
    gun(arg);
}

void gun(T)(T arg) {
    // do stuff.
}

It seems like the second one is a lot less brittle if you change the name of MyClass, or change the type of MyGenericArg, or otherwise decide to change the type of foo.

A: I don't think you're going to find a lot of disagreement with your argument that the latter example is "better" for the programmer. A lot of language design features are there because they're better for the compiler implementer!
See Scala for one reification of your idea.
Other languages (such as the ML family) take type inference much further, and create a whole style of programming where the type is enormously important, much more so than in the C-like languages. (See The Little MLer for a gentle introduction.)

A: Repetition may lead to more readable code, and sometimes may be required in the general case.  I've always seen the focus of DRY being more about duplicating logic than repeating literal text.  Technically, you can eliminate 'var' and 'void' from your bottom code as well.  Not to mention you indicate scope with indentation, why repeat yourself with braces?
Repetition can also have practical benefits: parsing by a program is easier by keeping the 'void', for example.
(However, I still strongly agree with you on prefering "var name = new Type()" over "Type name = new Type()".)

A: It isn't considered a bad thing at all. In fact, C# maintainers are already moving a bit towards reducing the tiring boilerplate with the var keyword, where
MyContainer<MyType> cont = new MyContainer<MyType>();

is exactly equivalent to
var cont = new MyContainer<MyType>();

Although you will see many people who will argue against var usage, which kind of shows that many people is not familiar with strong typed languages with type inference; type inference is mistaken for dynamic/soft typing.

A: Albert Einstein said, "Everything should be made as simple as possible, but not one bit simpler."
Your complaint makes no sense in the case of a dynamically typed language, so you must intend this to refer to statically typed languages.  In that case, your replacement example implicitly uses Generics (aka Template Classes), which means that any time that fun or gun is used, a new definition based upon the type of the argument.  That could result in dozens of extra methods, regardless of the intent of the programmer.  In particular, you're throwing away the benefit of compiler-checked type-safety for a runtime error.
If your goal was to simply pass through the argument without checking its type, then the correct type would be Object not T.
Type declarations are intended to make the programmer's life simpler, by catching errors at compile-time, instead of failing at runtime.  If you have an overly complex type definition, then you probably don't understand your data.  In your example, I would have suggested adding fun and gun to MyClass, instead of defining them separately.  If fun and gun don't apply to all possible template types, then they should be defined in an explicit subclass, not as separate functions that take a templated class argument.
Generics  exist as a way to wrap behavior around more specific objects.  List, Queue, Stack, these are fine reasons for Generics, but at the end of the day, the only thing you should be doing with a bare Generic is creating an instance of it, and calling methods on it.  If you really feel the need to do more than that with a Generic, then you probably need to embed your Generic class as an instance object in a wrapper class, one that defines the behaviors you need.  You do this for the same reason that you embed primitives into a class:  because by themselves, numbers and strings do not convey semantic information about their contents.
Example:
What semantic information does List convey?  Just that you're working with multiple triples of integers.  On the other hand, List, where a color has 3 integers (red, blue, green) with bounded values (0-255) conveys the intent that you're working with multiple Colors, but provides no hint as to whether the List is ordered, allows duplicates, or any other information about the Colors.  Finally a Palette can add those semantics for you: a Palette has a name, contains multiple Colors, but no duplicates, and order isn't important.
This has gotten a bit far afield from the original question, but what it means to me is that DRY (Don't Repeat Yourself) means specifying information once, but that specification should be as precise as is necessary.

A: It's a bad thing. This very topic was mentioned in Google's Go language Techtalk.


text:
Q: Query cache efficiency I'm using MySQLTuner.pl to optimize my site.... though I'm not entirely sure how to resolve some of these issues and am wondering if someone can help me out.
I'm running 16GB of RAM with the following MySQL settings:
key_buffer              = 1024M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8

myisam-recover         = BACKUP
max_connections        = 1500
table_cache            = 256
thread_concurrency     = 4

query_cache_limit       = 2M
query_cache_size        = 32M
query_cache_type        = 1

tmp_table_size          = 512M
max_heap_table_size     = 128M
join_buffer_size        = 128M
myisam_sort_buffer_size = 512M

Here's the output of my tuner
   -------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.41-3ubuntu12.6-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 98M (Tables: 402)
[--] Data in InnoDB tables: 16K (Tables: 1)
[!!] Total fragmented tables: 17

-------- Performance Metrics -------------------------------------------------
[--] Up for: 10s (1K q [132.400 qps], 443 conn, TX: 119K, RX: 82K)
[--] Reads / Writes: 100% / 0%
[--] Total buffers: 1.2G global + 130.6M per thread (1500 max threads)
[!!] Maximum possible memory usage: 192.4G (1225% of installed RAM)
[OK] Slow queries: 0% (0/1K)
[OK] Highest usage of available connections: 0% (2/1500)
[OK] Key buffer size / total MyISAM indexes: 1.0G/72.5M
[!!] Key buffer hit rate: 72.3% (47 cached / 13 reads)
[!!] Query cache efficiency: 0.0% (0 cached / 875 selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 2 sorts)
[OK] Temporary tables created on disk: 23% (48 on disk / 201 total)
[OK] Thread cache hit rate: 99% (2 created / 443 connections)
[!!] Table cache hit rate: 4% (128 open / 2K opened)
[OK] Open file limit used: 3% (257/7K)
[OK] Table locks acquired immediately: 100% (449 immediate / 449 locks)
[OK] InnoDB data size / buffer pool: 16.0K/8.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_limit (> 2M, or use smaller result sets)
    table_cache (> 128)

When I decrease query_cache_limit and table_cache it doesn't appear to have any effect.  I have restarted MySQL within the last 24 hours which could be part of the issue.
update
After running SHOW STATUS LIKE  '%cache%' the output is
Variable_name   Value
Binlog_cache_disk_use   0
Binlog_cache_use    0
Com_assign_to_keycache  0
Qcache_free_blocks  436
Qcache_free_memory  23551488
Qcache_hits 72553
Qcache_inserts  26954
Qcache_lowmem_prunes    0
Qcache_not_cached   7164
Qcache_queries_in_cache 5877
Qcache_total_blocks 12347
Ssl_callback_cache_hits 0
Ssl_session_cache_hits  0
Ssl_session_cache_misses    0
Ssl_session_cache_mode  NONE
Ssl_session_cache_overflows 0
Ssl_session_cache_size  0
Ssl_session_cache_timeouts  0
Ssl_used_session_cache_entries  0
Threads_cached  3

A: I found this website helpful in optimizing my own mysql server: http://www.omh.cc/mycnf/
It allows you to tune your variables and know what the total ram capacity will be. You need to optimize for 60% ram usage. So try to lower your total memory footprint to about 60% to 70% of your total ram. If you have other stuff running on the same machine, you probably need to reduce that number. Forget Query cache, it's not going to add too much value, but Table cache should improve your performance if done right.
Try reducing the number of connections and keeping your total memory footprint under 60% of total system memory.


text:
Q: Installing Hadoop on MacOS resulting in build failure with CMake I am trying to build the hadoop native for the first time as given below
    [ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:3.0.3:cmake-compile (cmake-compile) on project hadoop-common: Error executing CMake: Cannot run program "cmake" (in directory "/Users/krishnanand/projects/hadoop/hadoop-common-project/hadoop-common/target/native"): error=2, No such file or directory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:3.0.3:cmake-compile (cmake-compile) on project hadoop-common: Error executing CMake
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing CMake
    at org.apache.hadoop.maven.plugin.cmakebuilder.CompileMojo.runCMake(CompileMojo.java:176)
    at org.apache.hadoop.maven.plugin.cmakebuilder.CompileMojo.execute(CompileMojo.java:97)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: java.io.IOException: Cannot run program "cmake" (in directory "/Users/krishnanand/projects/hadoop/hadoop-common-project/hadoop-common/target/native"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at org.apache.hadoop.maven.plugin.cmakebuilder.CompileMojo.runCMake(CompileMojo.java:166)
    ... 23 more
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 24 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]

The requirements to build the native code states that CMake v3.1 is required. I have installed CMake with brew and my list of installed packages is given below
hadoop (release_3_0_3) $ brew list
autoconf    cmake       gzip        libtool     protobuf@2.5
automake    gcc     isl     mpfr        snappy
bzip2       gmp     libmpc      openssl     zlib

More information about cmake
hadoop (release_3_0_3) $ brew list cmake
/usr/local/Cellar/cmake/3.12.0/bin/ccmake
/usr/local/Cellar/cmake/3.12.0/bin/cmake
/usr/local/Cellar/cmake/3.12.0/bin/cmakexbuild
/usr/local/Cellar/cmake/3.12.0/bin/cpack
/usr/local/Cellar/cmake/3.12.0/bin/ctest
/usr/local/Cellar/cmake/3.12.0/share/aclocal/cmake.m4
/usr/local/Cellar/cmake/3.12.0/share/cmake/ (2376 files)
/usr/local/Cellar/cmake/3.12.0/share/doc/ (8 files)
/usr/local/Cellar/cmake/3.12.0/share/emacs/site-lisp/cmake/cmake-mode.el
/usr/local/Cellar/cmake/3.12.0/share/man/ (20 files)

I am trying to install Hadoop v3.0.3. Any help would be gratefully appreicated.


text:
Q: Hiding column of a gridview in visual webpart I am adding columns to gridview by following code..
SPQuery query = new SPQuery();
query.Query = "<Where><Eq>"
   + "<FieldRef Name='Filter' />"
   + "<Value Type='Integer'>1</Value>"
   + "</Eq></Where>";

What do I need to do if I have to hide the column but need to use the column data.

A: *

*Bind the data to column in gridview, and set visibility property of that column to false

*Or you can hide using javascript

similar post