What do I need to prove in order to show that a map is an isomorphism?

Question: I need to show that a diffeomorphism from a differentiable manifold $M$ to a differentiable manifold $N$ is an isomorphism. We have defined a diffeomorphism to be a $C^{\infty}$ homeomorphism with a $C^{\infty}$ inverse.
But, as I am new to pure mathematics, I don't know what it means for something to be an isomorphism(structure-preserving map would be my guess, whatever that means precisely) and I don't know what I need to show in order to prove that the map is an isomorphism.
Any help will be appreciated.
Comment: This question makes no sense as stated: "Isomorphism" of what kind of a structure? Your tag suggests that this structure is a Riemannian metric, but in this category one  says "an isometry", not "an isomorphism",
Comment: @QiaochuYuan Well, our definition of diffeomorphism is a map that is a homeomorphism and $C^{\infty}$.  Yes, I will ask my professor, although I originally thought that it would be a good idea to ask here since this question has not been asked before(as far as I know), so others might also have this question.
Comment: Okay, cool, so now there is at least a possible reasonable reading of the question: namely, to prove that a smooth homeomorphism has a smooth inverse. Unfortunately, this statement is *false*, and in fact that is not a correct definition of diffeomorphism: the map $\mathbb{R} \ni x \mapsto x^3 \in \mathbb{R}$ is a homeomorphism and $C^{\infty}$ but not a diffeomorphism because its inverse $\sqrt[3]{x}$ fails to be differentiable at $x = 0$.
Comment: Yes and yes. The statement is certainly not true if $\phi$ is not a diffeomorphism.
Comment: @MoisheCohen I just have a map from a differentiable manifold M to another differentiable manifold N. No Riemannian metric. Sorry for the confusion
Comment: The diffeomorphisms are the isomorphisms in the category of smooth manifolds and smooth maps nearly by definition, depending on your definitions. Can you say exactly what your definitions are? If not, you should ask whoever gave you this question for their definitions.
Comment: @QiaochuYuan All our definitions are the same as those in Do Carmo's Riemannian geometry. We haven't talked about isomorphisms is the lectures. We just have to prove the above as an exercise.
Comment: By the way, this is related: https://math.stackexchange.com/questions/211254/if-f-is-diffeomorphism-the-linear-map-f-is-an-isomorphism?rq=1
Comment: Then the question is underspecified. In category theory, in order to say what an isomorphism is you need to specify a category to be working in. If the category is the category of smooth manifolds and smooth maps, then an isomorphism is a smooth map with smooth inverse. That may or may not be your definition of diffeomorphism; if it is, then the statement is true by definition. So what is the question? Can you ask your professor?
Comment: @QiaochuYuan Just to state everything, the professor did mention something about the map being linear. Also, the exercise is the same as the link I posted above.
Comment: The link you posted above is a different question from the question you stated: the question as you wrote it here makes no mention of the differential at a point. (There's still the more important issue that the definition of diffeomorphism you just gave is incorrect, so either you wrote it down incorrectly or your professor's using an incorrect definition.)
Comment: @QiaochuYuan Yes, my question is more general. But, I just wanted to state the place where it originated from since it might give you a clue of what's going on!
Comment: Your question is not more general; it is just a different question.
Comment: @QiaochuYuan I don't understand why it's not more general. The question is about a general map being an isomorphism. Isn't the differential also a map? Also, yes, my definition is incorrect. We also stated that the inverse must also be $C^{\infty}$
Comment: The other question asks to show that if some map $f$ is a diffeomorphism then another map, namely the differential, constructed out of $f$ is an isomorphism, presumably in the category of vector spaces. This question asks to show that if $f$ is a diffeomorphism then it, not another map, is an isomorphism (presumably in the category of smooth manifolds although this is still ambiguous). It's just a different question. Neither statement implies the other.
Comment: @QiaochuYuan Yes, you are right. Sorry.   I just want to know what I need to show in order to prove that a map is an isomorphism. I think that if I actually learn this, I will be able to prove the other question too.
Comment: That is yet another question! By definition, an isomorphism is a map with an inverse (in some category). So the obvious way to show that a map is an isomorphism is to write down its inverse. There are less obvious ways but this is enough to do the linked problem.
Comment: @QiaochuYuan Lol, yeah, I turned this question into a carnival! Thanks for the patience! So, for MY exercise, I will prove that an inverse exists and it is a differential that takes tangent vectors from $T_{\phi (p)} N$ to $T_pM$, right? I'll probably have to use somewhere that the map $\phi$ is a diffeomorphism.
Comment: @QiaochuYuan Wow, at last! haha! Sorry for being such a pain! In any way, thanks a lot. Appreciate the clarifications.
Answer: In differential topology, isomorphism can be taken to mean homeomorphism, ie. Isomorphism between topological spaces. An isomorphism between topological spaces is a continuous bijection with continuous inverse.
Comment: This isn't an answer to the question until the OP clarifies what they mean by isomorphism.
Comment: Any input as to why this is voted down?
Comment: @QiaochuYuan I have edited to include my definition of a diffeomorphism. But, as I had already stated in the question, I had no idea of what an isomorphism meant in that context. Hope it's clearer now.


Using TableField with Node:Create?

Question: I've been struggling with this for a few days. I currently have a form which I am creating and rendering through Drupal 8's Form API. I am saving the inputted field values using Node::create() which has been working great. I am now using the Tablefield module for some of the fields. I am struggling to save this data as part of the Node::create() function however. I am reasonably new to Form API so I'm sure I'm missing something obvious.
My current Node::create() is a little like this
$node = Node::create([
      'type'                      => 'business',
      'status'                    => 1,
      'field_membership_type'     => $form_state->getValue('type_of_membership'),
      'field_type_of_business'    => $form_state->getValue('membersInTheQuarter_type'),
      'field_business_size'       => $form_state->getValue('businessSize_antique'),
      'field_business_size_shop_' => $form_state->getValue('businessSize_independentShops'),
      'field_category'            => $form_state->getValue('businessCategory'),
      'field_additional_category' => $form_state->getValue('additionalBusinessCategory'),
      'field_category_custom_'    => $form_state->getValue('businessCategoryCustom'),
      'title'                     => $form_state->getValue('business_name'),
      'field_tag_line'            => $form_state->getValue('tag_line'),
      'field_about'               => $form_state->getValue('about'),
      'field_opening_hours'       => /**This is where I need to access the individual cells of tablefield to set values from my form**/
    ]);

  $node->save();

Comment: Sounds like you'll need to iterate the values of the table field and add them to the actual field, however, without knowing _what_ type of field opening hours is (text, date, numeric, Field Collection, Paragraph?), it will be hard to offer any further answer.
Answer: This has not much to do with form API, only with the structure of the field.
You need to pass in the values that the field type expects, based on its propertyDefinitions() method for example. Looking at http://cgit.drupalcode.org/tablefield/tree/src/Plugin/Field/FieldType/TablefieldItem.php?h=8.x-2.x#n141, it does some special processing on it, so might have to account for that.
The easiest option for that kind of stuff is usually to just create a node in the UI, then load it and call $node->toArray(). The structure that you get back ther for your field is usually also what it expects to be set.

Using TableField with Node:Create?


Must antisymmetric relation also be irreflexive

Question: On Polish Wikipedia article on binary relations one can find the following statement: "a relation is antisymmetric iif it is irreflexive and transitive".
Is it correct? Does a given relation have to be irreflexive to be antisymmetric?
As far as I understand a relation ($R \subseteq A \times A$) is irreflexive iif:
$$\forall_{x \in A}: \lnot (x R x) $$
and antisymmetric iff:
$$\forall_{x, y \in A}: (xRy) \land (yRx) \rightarrow x = y$$
As so, if we define relations over the set $A = \{1, 2, 3, 4\}$ then both following relations should be antisymmetric:
$$
R_1 = \{ (2,1), (3,1), (3,2), (4,1), (4,2), (4,3) \}\\
R_2 = \{ (1,1), (1,2), (1,3), (1,4), (2,2), (2,3), (2,4), (3,3), (3,4), (4,4) \}
$$
although only $R_1$ is also irreflexive ($R_2$ is actually reflexive).
Do I miss something?
Comment: The "iif" in the text is "if" or "iff"? It makes a big difference. With "if" the statement is correct, with "iff" it's wrong: equality is certainly antisymmetric and transitive, but obviously not irreflexive (on a nonempty set).
Comment: It actually says "if" - my mistake. (Now you know why I'm horrible in math & double check everything. ;P)
Answer: No, an antisymmetric relation doesn't have to be irreflexive. However, if a relation $R$ is both transitive and irreflexive, then it is automatically antisymmetric. Here is the reason:
Say we have $(a,b)\in R$. Then, because of transitivity, if we also have $(b,a)\in R$, we must have $(a,a)\in R$, which breaks irreflexivity. Therefore we can never have both $(a,b)$ and $(b,a)$ in $R$, which means that the statement "If $(a,b)\in R$ and $(b,a)\in R$, then $a=b$" is vacuously satisfied, and $R$ is thus antisymmetric.
Answer: It's a common misunderstanding of "if". Consider the following true statement about Alice, who's outside at the beach:

Alice gets wet if it rains

Does it need to rain in order that Alice gets wet? Of course not! She could be swimming in the sea in a very hot sunny day!
Now change "Alice gets wet" with "the relation $R$ is antisymmetric" and "it rains" with "the relation $R$ is irreflexive and transitive": you get the statement on Wikipedia.
The statement says, expressed in a different way: a sufficient condition for a relation to be antisymmetric is to be irreflexive and transitive.
The statement doesn't say that this condition is also necessary. Indeed, a trivial example is the relation $\{(1,1),(2,2)\}$ on the set $\{1,2\}$ (the equality).
More generally, a partial (non strict) order is a reflexive, antisymmetric and transitive relation. We surely don't want it to be irreflexive, do we? <code>;-)</code>
There is a relation that's reflexive and irreflexive, but it's a very boring one: the empty relation on the empty set.


How do I change the default country on the billing address form in Commerce 2?

Question: I want to set the default country when customers check out in Commerce 2.  How do I do that?
Answer: You need to edit the form display for the Customer Profile Type.
You can find it in the Admin menu under "Users", or go directly there by this path:
<code>/admin/config/people/profiles/manage/customer/form-display</code>
Then, on the widget for the address field, click the gear to set the default country.
Answer: Path for me was: /admin/config/people/profile-types/manage/customer/fields
No gear to click, but there was an edit button:

Clicking the [edit] button dumps you off here: /admin/config/people/profile-types/manage/customer/fields/profile.customer.address
Scroll to the bottom and change this:

... to whatever you need the default country to be.


Mschart gridlines not starting from zero

Question: In VS2010 VB I am using MSChart (.Net 4) and I have a FastLine chart with values from -2000 to 2000 for X axis and -20 to 20 on Y axis.
The interval for the gridlines in X axix is 250 and I need the gridlines to be "mirrored" from origin (i.e. -250, 250; -500, 500;...) but when I execute the applications always the first gridlines are -200, 50 and then -450, 300...
I tried using StartFromZero = True in the axes properties without success. Is there any way to force the gridlines to be symetric from the origin (zero) ?
Comment: you can try setting `ChartAreas[0].AxisY.Crossing` property as per the point you need
Answer: Thank you for your comments.
I solved this issue by setting the IntervalOffset of the Axis. This offset represents the offset of the first gridline from left of the chart (in the case of X axix) . By calculating the displacement required (myChart.ChartAreas(0).AxisX.IntervalOffset = myChart.ChartAreas(0).AxisX.Maximum Mod yourIntervalValue) to reach 0 from left most value with the interval used, I was able to make the gridline in the middle of the chart to match the zero line.
I hope it helps others.


Show a dialog with a text input field and an image in AppleScript

Question: I am very new to AppleScript. I am writing a bash script and I need the user type a CAPTCHA. I am trying to use AppleScript to show  a dialog with the CAPTCHA image (a simple .png image) and a text input box to the user and then get the result.
Answer: AppleScript's native dialog display facilities (aka display dialog and display alert) are rather limited and won't allow you to display an image, unless you define it as an OS X icon file (.icns) of the right size, which might not be very practical for a captcha.
However, there is at least one alternative I am aware of: Carsten Blüm's Pashua will allow you to create native Cocoa dialogs containing both textfield and image elements. As these are defined in a DSL and created by Pashua, they can be used straight from a shell script (no need to interpose AppleScript – check out the documentation and example shell script distributed with Pashua).


Core blog module only shows two blog entries?

Question: I've enabled the core blog module, but it only shows two entries on exampe.com/blog
If I "unpublish" one of them, it brings up the next published blog post, which shows me that it does recognize that there are additional blog posts.
There are about 137 in the database. How do I show them all with pagination? The core blog module doesn't seem to have any config settings.
EDIT: The site was recently migrated from D6 to D7, is there anything that may have caused this issue given this fact?
Answer: Can you reproduce this behavior using your module set, but with fresh install and blog posts entered manually / generated with devel generate? If not, it's migration failure and your best bet is to export content from old site (you have backup, don't you) and import it to the new one, without Drupal's built in migration tool.
If this happen with fresh setup too, try changing theme to one of the supplied core themes. If it works, then, it means you have a bug in your templates. If it's not, I need to get more info to further expand my answer.


Mouseenter event on parent when a child is absolute positioned

Question: I'm tring to make a simple drop-down menu, which would be triggered on hover event over some element and stay active as long as the cursor is over that element or is over the dropdown list.
Sample code:
HTML

       Caption

Item 1

Item 2

Item 3

Item 4

<input type="text">

CSS
.items {
    float: right;
    position: relative;
}
.item {
    text-align: right;
}
.items_hidden {
    display: none;
    margin-top: 7px;
    list-style: none;
    z-index: 2000;
    width: 80px;
    border: 1px solid #f2f2f2;
    text-align: left;
    padding: 10px;
    color: #333;
    line-height: 30px;
    border-bottom: 3px solid #f2f2f2;

}

input {
  width: 100%;
}

JS
$(function() {
    $('.items').on('mouseenter', function(e) {
        $('.items_hidden').show();
    });

    $('.items').on('mouseleave', function(e) {
        $('.items_hidden').hide();
    });

});

I got that working, when the dropdown list is positioned relative, but the problem is once the list is displayed, it causes all following content to move down.
Here is an example: https://jsfiddle.net/2ya06aLo/
Another way would be to position the list absolute, so it wouldn't affect the content below. But in that case the list disappears as soons as I move the cursor out of 'Caption' (in contrast with the first fiddle).
Here is the second example https://jsfiddle.net/8L6ojqLm/
What would be a solution to make the list behave like in 1 and at the same time do not affect the rest of the content like in 2 ?
Comment: The reason this doesn't work with the absolute positioning is that you leave a gap between both elements, so that the mouse cursor can not pass from the "Caption" element to the dropdown element directly. Give them both a background color to see what I mean. And then, eliminate that gap to solve the problem.
Comment: @CBroe That helped, thank you.
Answer: You can don't use JS
Example

.items {
    float: right;
    position: relative;
}
.item {
    text-align: right;
 padding: 10px;
}
.items_hidden {
    position: absolute;
    right: 0;
 top: 20px;
    display: none;
    margin-top: 7px;
    list-style: none;
    z-index: 2000;
    width: 80px;
    border: 1px solid #f2f2f2;
    text-align: left;
    padding: 10px;
    color: #333;
    line-height: 30px;
    border-bottom: 3px solid #f2f2f2;

}

input {
  width: 100%;
}

.items:hover .items_hidden{
 display: block;
}

      Caption

Item 1

Item 2

Item 3

Item 4

 <input type="text">

Live JSFiddle - https://jsfiddle.net/grinmax_/8L6ojqLm/1/
Answer: Couldn't it be done via pure css?
https://www.w3schools.com/howto/howto_css_dropdown.asp
Answer: Maybe this would help.

.navigation {
  width: 100%;
}
.mainmenu, .submenu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mainmenu a {
}
.mainmenu a:hover {
    background-color: #D90000;
}
.mainmenu li:hover .submenu {
  display: block;
  max-height: 400px;
}
.submenu{
  max-height: 400px;
}
.submenu a {
  background-color: #FF4D4D;
}
.submenu a:hover {
  background-color: #D90000;
}
.submenu{
  overflow:hidden;
  display:none;
}

Link

Link

Link

Link

Link

Home

Answer: To take up the comment of CBroe: The problem seems to be the "gap" between the  and the  element. To remove it you could either

give the "item"-Element a height so that it "reaches down" to the ul-element or
or remove the margin-top of the ul-element


How do I specify arguments with the check_model function in the performance package in R?

Question: I'm using the check_model function within the performance package in r (version 4.0.3) to check the assumptions of a linear mixed model I've built in lmer4. I want check_model to give me all checks apart from the check for influential observations. The problem is I can use the check = argument to specify a single check, but as soon as I ask it to perform multiple checks, it spits out an error. The reproducible code is below
library(tidyverse)
library(lme4)
test_data <- read_csv("https://raw.githubusercontent.com/gjpstrain/mixed_models_assignment/main/assignment1_data1(1).csv")`
tidy_test_data <- test_data %>%
  mutate(subj = factor(subj), item = factor(item), (condition = factor(condition))
test_model <- lmer(DV ~ condition + (1 | subj) + (1 | item), data = tidy_test_data)
check_model(test_model, dot_size = .65, check = "ncv", "qq)

When I ask for more than one check I get the following error:

Error in munched$size[start] * .pt :
non-numeric argument to binary operator
Comment: Please, provide a snapshot of your data and model. Please have a look [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example).
Comment: Thanks Francesco I've amended my question now
Comment: You should really tidy up your question by including a whole code block. Please, carefully read how to do that.
Answer: This solves your problem. You should read the documentation of the function check_model() with much more attention. The argument check can be a character vector so all you were missing was to wrap up "mcv" and "qq" in a vector with c().
Also, you did not specify all the required packages. Please, edit your question accordingly to make your problem reproducible.
library(tidyverse)
library(lme4)
#> Loading required package: Matrix
#>
#> Attaching package: 'Matrix'
#> The following objects are masked from 'package:tidyr':
#>
#>     expand, pack, unpack
library(performance)
library(see)
library(qqplotr)
#>
#> Attaching package: 'qqplotr'
#> The following objects are masked from 'package:ggplot2':
#>
#>     stat_qq_line, StatQqLine

test_data <- read_csv("https://raw.githubusercontent.com/gjpstrain/mixed_models_assignment/main/assignment1_data1(1).csv")
#>
#> ── Column specification ────────────────────────────────────────────────────────
#> cols(
#>   subj = col_character(),
#>   item = col_character(),
#>   DV = col_double(),
#>   condition = col_character()
#> )
tidy_test_data <- test_data %>%
  mutate(subj = factor(subj), item = factor(item), (condition = factor(condition)))

test_model <- lmer(DV ~ condition + (1 | subj) + (1 | item), data = tidy_test_data)
check_model(test_model, dot_size = .65, check = c("ncv", "qq"))
#> `geom_smooth()` using formula 'y ~ x'

Created on 2021-03-03 by the reprex package (v1.0.0)


Sqoop ExportTool to Oracle NullPointer Exception

Question: Using command like:
sqoop export \
--connect jdbc:oracle:thin:'@somehostname.com:1521/prod1_adhoc' \
--username fbaggins \
--P \
--table MIDDLEEARTH \
--hcatalog-database MORDOR \
--hcatalog-table MORDOR \
--columns IS_DWARF,IS_ELF \
--verbose

Results in this error:
16/08/25 10:08:31 INFO hive.metastore: Trying to connect to metastore with URI thrift://somehostname.com:1521
16/08/25 10:08:31 INFO hive.metastore: Connected to metastore.
16/08/25 10:08:31 DEBUG util.ClassLoaderStack: Restoring classloader: sun.misc.Launcher$AppClassLoader@56aac163
16/08/25 10:08:31 ERROR tool.ExportTool: Encountered IOException running export job: java.io.IOException: java.lang.NullPointerException
16/08/25 10:08:31 DEBUG manager.OracleManager$ConnCache: Caching released connection for jdbc:oracle:thin:@somehostname.com:1521/prod1_adhoc/fbaggins

Not sure where the null is coming from as there are no nulls in the Hive table.
For reference, from hive:
hive> describe MORDOR;
OK
IS_DWARF bigint
IS_ELF   string

From Oracle:
describe MORDOR
Name                    Null Type
----------------------- ---- -----------
IS_DWARF                     NUMBER(12)
IS_ELF                       VARCHAR2(3)

Comment: *"NullPointerException ... Not sure where the null is coming from as there are no nulls in the Hive table"* -- your sense of humor reminds me of the Monty Python *(or maybe the Monty Java would be more appropriate)*
Answer: Is MORDOR a Hive view and not actually a table?
I have exactly the same problem when an object specified for sqoop --table is a view. DESCRIBE commands just prints columns of that view - so it does not show if it's a view or not. You could run SHOW CREATE TABLE MORDOR to confirm that's a view or table ("show create table" works for a view too as there is no separate command like "show create view").
SQOOP documentation explicitly states that sqoop import from a view is supported, but sqoop documentation on sqoop export for a view is silent - it's not stated if it's supported or not - it might be a SQOOP or HMS bug. Sqoop might not like what HMS returns for a view. So not exluding it might be an HMS bug.
Comment: Even Im facing similar issue.I'm using Hive view in Sqoop export job. Whats the workaround u did? Did you create hive table instead? In my case i have created hive view on hive-hbase table because we have Struct datatype . Any suggestions would appreciated. Thanks.
Comment: We had to export from a table and not a view. I am not aware of any workarounds.
Answer: Look at the logs again: don't you see anything absurd?

Trying to connect to metastore with URI thrift://$HOSTNAME:$PORT
  Caching released connection for jdbc:oracle:thin:@$HOST:$PORT/$ALIAS/$SCHEMA

Yes. The bloody environment variables (or shell variables) have not been resolved by the shell. Although I'm not sure what happened to the Metastore URI (it's defined in a Hadoop conf file, no shell/env variables there...)
That's because you have enclosed them in SINGLE QUOTES.
--connect jdbc:oracle:thin:'@$HOST:$PORT/$ALIAS'
So you have a 3-step solution:

use double quotes whenever you want the shell to resolve variables inside
learn script shell
learn about pointers, Null pointers, and what happens when some buggy code fails to check whether an Object variable has been properly initialized (i.e. NullPointerException in Java)
Comment: Samson, I purposefully put variables in to protect sharing of sensitive data in a public forum.  I assure you that what goes in those spaces is an actual value (e.g. thrift://db21.mydomain.com:1521, and same for all other spaces).


Flutter image assets not loading after redirect with go_router & login

Question: I have a small Flutter app with 2 screens (/login & /home) and I use go_router to navigate and animated_login. The assets are placed on the home screen and they load fine if I directly access the screen, so pubspec.yaml is correctly defined.
The images fail to load only when I redirect to /home after /login. One interesting observation is that when this happens, the Flutter dev server seems to be hanging (stops responding, but doesn't crash, can't restart it with R, the browser tab complains that it lost connection to the server etc.). This problem occurs also with a combination of auto_route and flutter_login.
Thanks for any hints.
Router setup (tried also w/ the redirect parameter at router level rather than individual routes):
GoRouter routerGenerator(UserData userData) {
  return GoRouter(
      initialLocation: Routes.home,
      refreshListenable: userData,
      debugLogDiagnostics: true,
      routes: [
        GoRoute(
            path: Routes.home,
            builder: (_, __) => BasicScreen(),
            redirect: (state) => userData.loggedIn ? null : Routes.login
            ),
        GoRoute(
            path: Routes.login,
            builder: (_, __) => AnimLoginScreen(),
            redirect: (state) => !userData.loggedIn ? null : Routes.home
            ),
        GoRoute(path: '/', builder: (_, __) => BasicScreen())
      ]);
}

abstract class Routes {
  static const home = '/home';
  static const login = '/login';
}

Main app:
void main() {
    runApp(
      MultiProvider(providers: [
        //other providers here
        ChangeNotifierProvider(create: (_) => UserData()),
      ], child: MyApp()),
    );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    final router =
        routerGenerator(Provider.of<UserData>(context, listen: false));
    return MaterialApp.router(
      title: 'Playground',
      routeInformationParser: router.routeInformationParser,
      routeInformationProvider: router.routeInformationProvider,
      routerDelegate: router.routerDelegate,
    );
  }
}

Basic screen:
class BasicScreen extends StatelessWidget {
  BasicScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          Image(image: AssetImage("assets/images/image1.png")),
          Image(image: AssetImage("assets/images/image2.png")),
          Image(image: AssetImage("assets/images/image3.png")),
        ],
      ),
    );
  }
}

Answer: Solution
Provide a simple proxy over both Flutter DevTool & backend services with SSL capabilities.
Explanation
The issue has nothing to do with routing, but rather the dev setup. Our backend services require SSL connections, but Flutter dev tool doesn't support that. Flow:

Flutter DevTool starts the project (plain HTTP) and opens Chrome window.
Assets load ok.
User logs in, backend service requires HTTPS for secure cookies.
Browser upgrades all localhost connections to HTTPS.
Flutter DevTools fails to provide SSL connection.
Assets fail to load.

The hanging DevTool is caused by the same issue: seems to me that the DevTool is pending the WebSocket connection to be opened by the JS code running in the browser, but as the browser initiates an HTTPS connection to the DevTool, it even fails to load the JS code. Therefore, the DevTool never completes the init process (as it has no incoming connection).


Back and Forth relations on linear orderings.

Question: I am going through C. Ashe and J. Knight Computable structures and the Hyperarithmetic Hierarchy and am stuck at proving one of their Lemmas on back and forth relations and linear orderings (Chapter 15.3.3.).
Ashe and Knight define the standard back and forth relation as follows. I will only state the (slightly simpler) definition for finite languages here.

For two structure $\mathcal{A},\mathcal{B}$ in a finite language $L$ and tuples $\overline a\in \mathcal{A}$ and $\overline b \in \mathcal{B}$ of the same size we define the relation $\leq_\beta$ by induction.

$(\mathcal{A},\overline a) \leq_0 (\mathcal{B},\overline b)$ if and only if all quantifier free formulas $\phi(\overline x)$ true of $\overline{a}$ in $\mathcal{A}$ are true of $\overline{b}$ in $\mathcal{B}$,
for $\beta\geq 1$, $(\mathcal{A},\overline a)\leq_\beta (\mathcal B,\overline b)$ if and only if, for each $\overline{d}\in \mathcal{B}$ and each $0\leq \alpha<\beta$, there exists $\overline{c}\in \mathcal{A}$ of the same length such that $(\mathcal{B},\overline b \overline d)\leq_\alpha (\mathcal{A},\overline a \overline c)$.

The Lemma I am struggling with is the following.

Lemma 15.7. Suppose $\mathcal{A}$ and $\mathcal{B}$ are linear orderings. Let $\overline{a}=(a_0,\cdots, a_{n-1})$, $\overline{b}=(a_0,\cdots,a_{n-1})$ be increasing tuples from $\mathcal A$, $\mathcal B$, respectively, and let $\mathcal {A}_i, \mathcal{B}_i$ be intervals such that
  $$ \mathcal{A}=\mathcal{A}_0 + \{a_0\}+\mathcal{A}_1+\cdots+ \{a_{n-1}\} + \mathcal{A}_n,$$
  $$ \mathcal{B}=\mathcal{B}_0 + \{b_0\}+\mathcal{B}_1+\cdots+ \{b_{n-1}\} + \mathcal{B}_n.$$
  Then $(\mathcal{A},\overline a)\leq_\beta (\mathcal{B},\overline b)$ if and only if for all $0\leq i\leq n$, $\mathcal{A}_i\leq_\beta \mathcal{B}_i$.

They claim that this is easily proved by induction on $\beta$. For $\beta=0$ it is easy, but I am stuck at the induction step. I was trying using the fact that $(\mathcal A,\overline a)\leq_\beta (\mathcal B,\overline b)$ iff $\Sigma_\beta^{\mathrm{in}}\mbox{-}tp(\overline b)\subseteq \Sigma_\beta^{\mathrm{in}}\mbox{-}tp(\overline a)$ (Proposition 15.1 in their book) but could not come up with anything substantial. (Here $\Sigma_\beta^{\mathrm{in}}\mbox{-}tp^{\mathcal{B}}(\overline b)$ is the set of infinitary $\Sigma_\beta$ formulas true of $\overline b$ in $\mathcal{B}$.)
Comment: Please define some of your notation. What is the meaning of  $\leq_{\beta}$. Is it just embedding ?
Comment: Sorry, I added the definitions to my question. I hope that it is clearer now.
Comment: In the def'n of $\leq_{\beta}$ there is no def'n of  $(B,\bar b,\bar d)\leq_{0} (A,\bar a,\bar c)$ so how do we know whether $(A,\bar a)\leq_1 (B,\bar b) $ ?
Comment: If $\overline b$ and $\overline d$ are tuples of size $m$ and $n$, respectively, then $\overline b, \overline d$ is the canonical tuple of size $m+n$ obtained by concatenation of $\overline b$ and $\overline d$. This is the notation used in _Computable structures and the hyperarithmetic hierarchy_. If I recall correctly this is often written without comma and I agree that this notation might be confusing. I will edit my question accordingly.
Answer: Here's the argument for the inductive step $\beta\geq 1$.
Suppose $(\mathcal{A},\overline{a})\leq_\beta (\mathcal{B},\overline{b})$. We want to show that $\mathcal{A}_i\leq_\beta \mathcal{B}_i$ for all $i$. By definition, we need to show that for any $\overline{d}\in \mathcal{B}_i$ (which we might as well assume is in ascending order - if you don't believe this, you should check it) and $\alpha<\beta$, there is $\overline{c}$ such that $(\mathcal{B}_i,\overline{d})\leq_\alpha(\mathcal{A}_i,\overline{c})$. Well, since $(\mathcal{A},\overline{a})\leq_\beta (\mathcal{B},\overline{b})$, there is some tuple $\overline{c}$ such that $(\mathcal{B},\overline{b}\overline{d})\leq_\alpha (\mathcal{A},\overline{a}\overline{c})$. In particular, the quantifier-free types of $\overline{b}\overline{d}$ and $\overline{a}\overline{c}$ agree, so the elements of $\overline{c}$ are in increasing order and are all in $\mathcal{A}_i$. So we have
\begin{align*}
\mathcal{A} &= \mathcal{A}_0 + \{a_0\} + \dots + \{a_{i-1}\} + (\mathcal{A}_i^0 + \{c_0\} + \mathcal{A}_i^1 + \{c_1\} + \dots \{c_{k-1}\} + \mathcal{A}_i^k) + \{a_i\} + \dots + \mathcal{A}_n\\
\mathcal{B} &= \mathcal{B}_0 + \{b_0\} + \dots + \{b_{i-1}\} + (\mathcal{B}_i^0 + \{d_0\} + \mathcal{B}_i^1 + \{d_1\} + \dots \{d_{k-1}\} + \mathcal{B}_i^k) + \{b_i\} + \dots + \mathcal{B}_n
\end{align*}
where the suborders in parentheses are subdivisions of $\mathcal{A}_i$ and $\mathcal{B}_i$. Now by the inductive hypothesis, since $(\mathcal{B},\overline{b}\overline{d})\leq_\alpha (\mathcal{A},\overline{a}\overline{c})$, we have $\mathcal{B}_i^j\leq_\alpha \mathcal{A}_i^j$ for all $1\leq j\leq k$, and by the inductive hypothesis again, this implies that $(\mathcal{B}_i,\overline{d})\leq_\alpha (\mathcal{A}_i,\overline{c})$.
The converse direction is similar: We assume that $\mathcal{A}_i\leq_\beta\mathcal{B}_i$ for all $i$. To show that $(\mathcal{A},\overline{a})\leq_\beta (\mathcal{B},\overline{b})$, we pick $\overline{d}$ from $\mathcal{B}$ and $\alpha<\beta$, and we want to find $\overline{c}$ such that that $(\mathcal{B},\overline{b}\overline{d})\leq_\alpha (\mathcal{A},\overline{a}\overline{c})$. This time, we break up the tuple $\overline{d}$ into the subtuples which land in each interval $\mathcal{B}_i$, find corresponding tuples in the $\mathcal{A}_i$, and apply the inductive hypothesis twice as above.


php5-mssql / freetds : can connect with tsql, not with php5-mssql

Question: i'm trying to set up an Ubuntu workstation for php development with php5-mssql.
First i compiled freetds-nightly 0.8.3 ( with --enable-msdblib )  and installed it to /usr/local/freetds , copying header files from the package to /usr/local/freetds/include
Then, I grabbed the php5 source with apt-get source php5, and compiled the mssql extension as follows:
phpize
cd ext/mssql
./configure --with-mssql=/usr/local/freetds
make
sudo install

this placed mssql.so in to my php extensions dir and php is loading the extension fine.
After all this i added my server in /usr/local/freetds/etc/freetds.conf:
[global]
    tds version = 7.0
    dump file = /tmp/freetds.log
    text size = 64512

[db-02]
host = XXXXX
port = 1433
tds version = 7.0

First of all, i wanted to use tds 8.0 but any value higher then 7.1 is ignored, which is strage since freetds on my mac ( built from macports with +mssql ) does 8.0 while being older. ( 0.8.2 i think )
Anyway, with this i can connect up to my sever with /usr/local/freetds/bin/tsql beautifully. NOT with php5-mssql..
here's some output from freetds.log ( this is all from the failed attempt )
log.c:196:Starting log file for FreeTDS 0.83.dev.20100710
    on 2010-07-13 11:17:23 with debug flags 0x4fff.
iconv.c:337:tds_iconv_open(0x91d3a98, UTF-8)
iconv.c:197:local name for ISO-8859-1 is ISO-8859-1
iconv.c:197:local name for UTF-8 is UTF-8
iconv.c:197:local name for UCS-2LE is UCS-2LE
iconv.c:197:local name for UCS-2BE is UCS-2BE
iconv.c:365:setting up conversions for client charset "UTF-8"
iconv.c:367:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:408:preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
iconv.c:411:tds_iconv_open: done
net.c:225:Connecting to XXXX port 1433 (TDS version 7.0)
net.c:281:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:321:tds_open_socket() succeeded
util.c:156:Changed query state from DEAD to IDLE
login.c:771:quietly sending TDS 7+ login packet
token.c:328:tds_process_login_tokens()
net.c:608:Received header
0000 04 01 00 78 00 49 01 00-                        |...x.I..|

net.c:662:Received packet
0000 04 01 00 78 00 49 01 00-aa 64 00 18 48 00 00 01 |...x.I.. .d..H...|
0010 0e 1f 00 4c 00 6f 00 67-00 69 00 6e 00 20 00 66 |...L.o.g .i.n. .f|
0020 00 61 00 69 00 6c 00 65-00 64 00 20 00 66 00 6f |.a.i.l.e .d. .f.o|
0030 00 72 00 20 00 75 00 73-00 65 00 72 00 20 00 27 |.r. .u.s .e.r. .'|
0040 00 63 00 61 00 6c 00 76-00 69 00 6e 00 27 00 2e |.X.X.X.X .X.X.'..|
0050 00 0d 4e 00 45 00 54 00-4d 00 49 00 4e 00 49 00 |..Y.Y.Y. Y.Y.Y.Y.|
0060 4e 00 47 00 44 00 41 00-54 00 41 00 00 01 00 fd |Y.Y.D.A. T.A.....|
0070 02 00 00 00 00 00 00 00-                        |........|

token.c:337:looking for login token, got  aa(ERROR)
token.c:122:tds_process_default_tokens() marker is aa(ERROR)
token.c:2710:tds_process_msg() reading message 18456 from server
token.c:2783:tds_process_msg() calling client msg handler
dbutil.c:85:_dblib_handle_info_message(0x90180e8, 0x91d3a98, 0xbf8f56d0)
dbutil.c:86:msgno 18456: "Login failed for user 'XXXX'."
token.c:2796:tds_process_msg() returning TDS_SUCCEED
token.c:337:looking for login token, got  fd(DONE)
token.c:122:tds_process_default_tokens() marker is fd(DONE)
token.c:2461:tds_process_end: more_results = 0
        was_cancelled = 0
        error = 1
        done_count_valid = 0
token.c:2477:tds_process_end() state set to TDS_IDLE
token.c:2492:                rows_affected = 0
token.c:437:tds_process_login_tokens() returning TDS_FAIL
login.c:462:login packet accepted
util.c:156:Changed query state from IDLE to DEAD
util.c:331:tdserror(0x90180e8, 0x91d3a98, 20002, 0)
dblib.c:7861:dbperror(0x91d3378, 20002, 0)
dblib.c:7913:20002: "Adaptive Server connection failed"
dblib.c:7934:"Adaptive Server connection failed", client returns 2 (INT_CANCEL)
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:1415:dbclose(0x91d3378)
dblib.c:258:dblib_del_connection(0x997340, 0x91d3a98)
mem.c:615:tds_free_all_results()
dblib.c:305:dblib_release_tds_ctx(1)
dblib.c:5828:dbfreebuf(0x91d3378)
dblib.c:724:dbloginfree(0x91d2f90)
dblib.c:3985:dbsetlogintime(5)
dblib.c:3944:dbsettime(60)
dblib.c:698:dblogin(void)
dblib.c:4890:dberrhandle(0x81a1fd0)
dblib.c:4909:dbmsghandle(0x81a35d0)
dblib.c:746:dbsetlname(0x91d2f90, UTF-8, 10)
dblib.c:746:dbsetlname(0x91d2f90, PHP 5, 5)
dblib.c:1121:dbopen(0x91d2f90, 0x0, [microsoft])

( the same credentials get me in with tsql )
Any help is greatly appreciated.
thanks,
Andrew
ps: some tsql -C output
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.83.dev.20100710
             freetds.conf directory: /usr/local/freetds/etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 5.0
                              iODBC: no
                           unixodbc: yes

Answer: Solved. Should've used the stable release.. 0.8.2 supports tds 8.0, 0.8.3 does not. duh.
which, by the way, still does not explain why i was able to connect up to my mssql server with tsql, using protocol 7.1, but not with php5-mssql.
Comment: I had similar issues with Debian "squeeze". Switching Back to protocol "7.1" (from "8.0") helped...
What a mess...


Bayesian Poisson Regression with Gamma Prior Formulas

Question: Are there closed form formulas for the posterior and evidence of a Poisson-Gamma Bayesian regression model? I was not able to find anything that is accessible online. I am not sure for which model can we find such an expression. I was thinking of the following formulation (notation follow):
Likelihood is Poisson: $P(y|X, \theta) = \prod_{i=1}^m \frac{1}{y_i!}(x_i^t \theta)^{y_i} \exp(x_i^t \theta)$ and prior is Gamma: $P(\theta) = \prod_{j=1}^n \frac{\beta^{\alpha}}{\Gamma (\alpha)} \theta_j^{\alpha-1}\exp(-\beta\theta_j)$.
Notation: $m$ number of observations, $n$ number of parameters, $X \in \mathbb{R}^{m\times n}$ a design matrix with rows $x_i \in \mathbb{R}^n$, $\theta \in \mathbb{R}^{n}$ the parameter I would like to infer and $y \in \mathbb{R}^m$ data.
My questions:

Is there a closed form expression for the posterior / evidence for the above model?
Is there a closed form expression if we formulate the model as a GLM with (e.g.) with a $\log$ link?
If there are no closed form formulas - is there a regression model with a conjugate prior, for positive data and parameters?

Freely available references are great, a complete derivation is even better.
Comment: not exactly what you're looking for, but i wanted to add a reference to auxilliary variable approaches to bayesian poisson glms to this discussion, which means that it can be almost as efficient as a conjugate prior if you're already within a larger hierarchical model: https://www.jstor.org/stable/pdf/20441330.pdf?refreqid=excelsior%3Ae31a112641e3c9287c998e35a14108dc&ab_segments=&origin=
Answer: It depends on what you would call a "closed form expression". If you expand the powers of $y_i$ into of sum of monomials (in $\theta_j$) then you can write the likelihood as a sum of (potentially very large number of) components, where each component has the form of a product of Gamma distributions. So the posterior is also a mixture distribution of independent Gamma components.
Your prior is technically a conjugate prior in this case because it belongs to the same family (a mixture with one component).
Practically however this will not be very useful unless the numbers are really small  - I believe the number of components will be roughly exponential in $\sum y_i$.
On the other hand it is rather straightforward to calculate the gradient  of the likelihood/posterior w.r.t $\theta_j$, so you can use it to find the MLE/MAP using gradient-descent optimization methods.
Answer: There's a conjugate updating solution for Poisson regression, if your model terms are for categorical variables. I.e. whenever you can summarize the results with sufficient statistics (which in this case are number of events for each combination of categories and, if time periods differ between observations, also the total follow-up time). This is basically straight from the theorems on when conjugate priors exist.
The difficult thing is of course, whether you actually get a conjugate prior that is analytically tractable.
Chen and Ibrahim have some results on how to construct priors for generalized linear models (Chen, M.-H. and Ibrahim, J. G. (2003). Conjugate priors for generalized linear models. Statistica Sinica, 13(2):461–476.). I used those in Section 5 of my PhD thesis to provide the analytical solution for conjugate updating for exponential time-to-event with right-censoring (which is also the solution for Poisson regression, because up to constants the likelihoods are the same) comparing two groups (i.e. there is just a single categorical variable in the regression model) in randomized trial (fully analytically tractable, just a bit hard to get specific priors your might want for the regression coefficient - I proposed one particular solution for that in Section 5.3). This solution is equivalent to assuming independent Gamma priors for the rates in the treatment group and for the control group. I gave formulations in terms of hazard (or rate) ratio + control group (hazard) rate, as well as log-ratio + control rate, and while I didn't give it you should be able to get the log-ratio + log-control-rate parameterization via change of variables (no promises that that's nicely tractable). However, once you do a meta-analysis - i.e. you have two categorical variables, one with 2 levels (=treatment vs. control group) and one with many levels (different studies) - you still have conjugate solution, but you are left with an integral that, as far as I am aware, does not have a nice analytical solution and needs to be evaluated numerically.
I also once tried to do this for logistic regression and I believe that's actually less tractable than the Poisson situation (I'd love to hear otherwise, if someone knows a nice treatment of the topic). As far as I know, you are also in trouble, if you try to add random effects to commonly used GLMs. To be honest, I have not encountered many real-life problems, where conjugate solutions for regression models were really an option. Luckily we have really good MCMC samplers nowadays.


Grid-like WPF control

Question: I'd like to implement a 'TabManager' control which can be instantiated much like a Grid in XAML. This looks like a fairly common task, but I couldn't seem to find a tutorial and I still don't want to reinvent the wheel, so I was wondering if anyone here had an example.
I'd want the XAML to generate the control to look something like this:
   <TabManager>
        <TabManager.TabDefinitions>
            <TabDefinition Caption="Tab 1"/>
            <TabDefinition Caption="Tab 2"/>
            <TabDefinition Caption="Tab 3"/>
        </TabManager.TabDefinitions>

        <TabPanel TabManager.Tab="0">
            <TextBlock Text="foo"/>
        </TabPanel>
        <TabPanel TabManager.Tab="1">
            <TextBlock Text="bar"/>
        </TabPanel>
        <TabPanel TabManager.Tab="2">
            <TextBlock Text="baz"/>
        </TabPanel>
    </TabManager>

The TabManager will render a few buttons and some elements to contain the TabPanels' children - e.g. place them into a DockPanel or whatever else I choose to do; shouldn't matter.
Comment: Are you looking to create User control ? [link] WPF User Control http://www.codeproject.com/Articles/32825/How-to-Creating-a-WPF-User-Control-using-it-in-a-W
Comment: I'm more likely to derive from Panel, like Grid does. The main point of my question is how to support multiple children in the TabManager class.
Comment: So basically you want the TabManager to show the Tabs like a Grid layout?? But you only want the Horizontal line at the top so it looks like Tabs?? But the TabControl already has a similar functionality.
Answer: Have you tried <TabControl>?
For instance -
<TabControl>
        <TabItem Header="Tab1" x:Name="Tab1">
            <Grid>
                <TextBlock Text="foo"/>
            </Grid>
        </TabItem>
        <TabItem Header="Tab2" x:Name="Tab2">
            <Grid>
                <TextBlock Text="bar"/>
            </Grid>
        </TabItem>
        <TabItem Header="Tab3" x:Name="Tab3">
            <Grid>
                <TextBlock Text="baz"/>
            </Grid>
         </TabItem>
    </TabControl>

Grid-like WPF control


animated gradient (javascript) background will not extend to full height of window

Question: I have an animated gradient as a background div on my website. However, whenever I try to apply css styling to the HEIGHT such as "100%" or "background: cover", etc., so that it will reach the bottom of any window, the gradient just stops functioning. It only seems to like being styled with a discreet pixel height, which is not ideal. Below is my css and html. Any ideas on how to get the gradient to scale to fit windows as opposed to being just a single discreet length? I have it set at width:100% which functions perfectly in that direction so I am stumped! Link:
http://studiopowell.net/TEST_gradient.html
#gradient

{
  width: 100%;
  height: 1200px;
  padding: 0px;
  margin: 0px;
  opacity: 0.1;
  margin-top: -850px;
  position: relative;
  z-index: 10;

}

M I C H A E L   P O W E L L

Comment: Looks like works here, maybe you have a problem with your browser?
Comment: Use `height: 100%; position: absolute;` instead of `position: relative;`, and remove the `margin-top`. Is that solving it?
Answer: I believe you can solve your problem by locating the gradient div above the rest of the document, and using position:absolute as @blex mentioned in his comment:
http://jsfiddle.net/qj1nz13p/
HTML

    M I C H A E L   P O W E L L

CSS
body {
    padding:0;
    margin:0;
}

#gradient {
    width: 100%;
    height: 100%;
    padding: 0px;
    margin: 0px;
    opacity: 0.1;
    position:absolute;
    z-index: -99999;
}

JavaScript
var colors = new Array(
[62,35,255],
[60,255,60],
[255,35,98],
[45,175,230],
[255,0,255],
[255,128,0]);
var step = 0;
//color table indices for:
// current color left
// next color left
// current color right
// next color right
var colorIndices = [0,1,2,3];
//transition speed
var gradientSpeed = 0.0004;
function updateGradient()
{
if ( $===undefined ) return;
var c0_0 = colors[colorIndices[0]];
var c0_1 = colors[colorIndices[1]];
var c1_0 = colors[colorIndices[2]];
var c1_1 = colors[colorIndices[3]];
var istep = 1 - step;
var r1 = Math.round(istep * c0_0[0] + step * c0_1[0]);
var g1 = Math.round(istep * c0_0[1] + step * c0_1[1]);
var b1 = Math.round(istep * c0_0[2] + step * c0_1[2]);
var color1 = "rgb("+r1+","+g1+","+b1+")";
var r2 = Math.round(istep * c1_0[0] + step * c1_1[0]);
var g2 = Math.round(istep * c1_0[1] + step * c1_1[1]);
var b2 = Math.round(istep * c1_0[2] + step * c1_1[2]);
var color2 = "rgb("+r2+","+g2+","+b2+")";
$('#gradient').css({
background: "-webkit-gradient(linear, left top, right top, from("+color1+"), to("+color2+"))"}).css({
background: "-moz-linear-gradient(left, "+color1+" 0%, "+color2+" 100%)"});
step += gradientSpeed;
if ( step >= 1 )
{
step %= 1;
colorIndices[0] = colorIndices[1];
colorIndices[2] = colorIndices[3];
//pick two new target color indices
//do not pick the same as the current one
colorIndices[1] = ( colorIndices[1] + Math.floor( 1 + Math.random() * (colors.length - 1))) % colors.length;
colorIndices[3] = ( colorIndices[3] + Math.floor( 1 + Math.random() * (colors.length - 1))) % colors.length;
}
}
setInterval(updateGradient,10);// JavaScript Document

Also, I changed z-index from 10 to -99999; the gradient background should be underneath everything, right? Not sure why you had 10...
Comment: Thank you!! *face palm* very intuitive and helpful answers. Learning a ton. :) And thanks @blex as well.
Answer: Apply styling to your HTML tag: http://jsfiddle.net/n6xnsv34/
html{
  height:100%;
  width: 100%;
  background: -webkit-linear-gradient(red, blue); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(red, blue); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(red, blue); /* For Firefox 3.6 to 15 */
  background: linear-gradient(red, blue); /* Standard syntax */

}


Changing entity base field settings

Question: Changing entity base field settings
I have a custom car entity with 8 base fields like the following:
  $fields['color'] = BaseFieldDefinition::create('list_string')
    ->setLabel(t('Color'))
    ->setRequired(TRUE)
    ->setSettings([
      'allowed_values' => [
        'Blue' => 'Blue',
        'Green' => 'Green',
        'Red' => 'Red',
      ],
    ])
    ->setDisplayOptions('view', [
      'label' => 'inline',
      'type' => 'string',
      'weight' => 1,
    ])
    ->setDisplayOptions('form', [
      'type' => 'options_select',
      'weight' => 1,
    ])
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE);

I have a requirement to allow the end user to partially change some parts of some of the base fields like order and allowed values using custom simplified forms.  I have the following code in the 'submitForm' function of a form.
  $field_definition = $this->entityDefinitionUpdateManager->getFieldStorageDefinition('color', 'car_module');
  $field_definition->setRequired(FALSE);
  $this->entityDefinitionUpdateManager->updateFieldStorageDefinition($field_definition);

When the 'Save' button is hit, the server takes a long time to respond like database changes are being made but the field definition does not get updated.
Comment: This is for update hooks after the code has changed. For changing entity base field settings depending on user input use BaseFieldOverride. See https://drupal.stackexchange.com/questions/253257/how-to-easily-alter-an-entitys-base-field-definition-per-bundle
Comment: For form and view display options use EntityFormDisplay and EntityViewDisplay.
Comment: See https://drupal.stackexchange.com/questions/212829/how-to-change-the-entity-view-display-configuration-programmatically
Comment: @4k4 Your answer should allow me to change the 'allowed_values' setting for string lists so thank you for your help. I have also been trying to override the form and view display weight option for the entity but have not found a way to using BaseFieldOverride.
Comment: @4k4 I've never worked with entities in depth. The entity I am working with is a vehicle content entity that does not support bundles similar in complexity to the one in the 'content_entity_example' sub-module of the 'Examples' module. Neither the entity nor any of its base fields are defined in 'config/install' YAML. Everything is defined in an entity class that extends 'ContentEntityBase'. I've tried the EntityViewDisplay load function as in the link you sent using various combinations of the entity ID and fields but nothing worked.
Answer: Base fields are defined in code. When code updates change the database schema you can implement the updates via entityDefinitionUpdateManager in an update hook as shown in the question. This is not possible in a form submit.
If you want to store field settings in a form submit load the field config and save it:
// if the entity type has no bundles use the entity type id:
$entity_type_id = 'vehicle';
$bundle = 'vehicle';

$fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($entity_type_id);
$field_config = $fields['field_example']->getConfig($bundle);
// make changes
$field_config->save();

For form and view display settings you can use EntityDisplayRepositoryInterface::getFormDisplay and EntityDisplayRepositoryInterface::getViewDisplay:
$display_repository = \Drupal::service('entity_display.repository');
$display = $display_repository->getViewDisplay($entity_type_id, $bundle, 'default');
$display->setComponent('field_example', $display_options);
$display->save();

For both code examples if there is no configuration stored yet it will be created.

Your question is about a custom form. Instead you could expose the core field admin UI by adding field_ui_base_route to your entity, even if you don't intend to use bundles or view modes. This works also for base fields marked as configurable. See How do I add a view mode to a simple custom entity?
Comment: Use `'type' => 'number_integer'` in the view display options of an integer field. There is no `integer` field formatter.
Comment: [EntityDisplayInterface::removeComponent](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Display%21EntityDisplayInterface.php/function/EntityDisplayInterface%3A%3AremoveComponent/9.1.x) *Sets a component to be hidden.*
Comment: I wish I could have used the core field admin UI. Unfortunately, it was deemed too complicated for the end users.
Comment: Thank you for your help. Your answer is correct. Saving the form display works but saving the view display throws the following exception: PluginNotFoundException: The "integer" plugin does not exist. Valid plugin IDs for Drupal\Core\Field\FormatterPluginManager are: address_zone_default, address_default...email_mailto, entity_reference_entity_id in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php). I don't even know where to start debugging this one. Thanks again!
Comment: That helped me over another hurdle. Thanks again. The last hurdle remaining is to allow end users the ability to enable/disable fields. Using the field config's 'disable' method doesn't hide disabled fields in the entity forms and views. Neither does using the EntityDisplayRepositoryInterface's 'setComponent' method to set 'region' => 'hidden'. Is it possible to enable/disable fields using field config and/or EntityDisplayRepositoryInterface so they won't appear in forms/views or will I have to use a form hook to prevent them from being displayed?

Changing entity base field settings


How to set a default selected value in a form select in Kendo UI?

Question: I have this select:
<select name="type" required data-bind="source: types, value: model.type" data-template="typeTemplate"></select>

and a template:

This will create a select that contains a a few options and one named default with a selected property, but the select shows empty rather then the default option.
Any ideas?
Answer: It looks like you are missing the data-text-field and data-value-field attributes on your select statement. Here is an example:
<select data-text-field="name" data-value-field="id"
   data-template="optionTemplate"
   data-bind="source: users, value: selectedUserId"></select>

In this example, there is an observable array called users [{ id: 1, name: 'dave'}, { id: 2, 'james'}] on the view model.  There is also a field called selectedUserId on the view model with a value of 1, which is a number that would corresponding to dave's id in this case.


Can I use this as a proof?

Question: Some days ago, I've made this question and I guess I've finally found an answer to this question:

(a) Is it possible to find a polynomial, apart from the constant $0$ itself, which is identically equal to $0$ (i.e. a polynomial
  $P(t)$ with  some nonzero coefficient such that $P(c)=0$ for each
  number $c$)?

Which is mentioned in that post, I tried to proceed in the following way: I decomposed the polynomial in 2 kinds of structures - due to their similar behaviors inside the polynomial - for example:
$$\color{red}{a_nt^n}+\color{red}{a_{n-1}x^{n-1}}+\color{red}{...}+\color{red}{a_1t}+\color{green}{a_0}$$
The red structures are the $t$'s (1) with a coefficient and the green structure is a number alone, for the red structures, it's impossible to have $P(c)=0$ for every number $c$, with nonzero coefficients. Then I eliminated the reds and started to think about the green alone and I perceived that the only number which would allow me to find this polynomial was zero, thus making it impossible to find the requested polynomial.
Is this valid?
(1) - I have no idea on how to call the $t$'s in the polynomial, the book I'm reading provided me with some terms like: Leading coefficient, coefficients, leading term, constant term/constant coefficient, linear coefficient and linear term, but it mentions no name for the $t$'s, can you provide me a name for it?
Comment: Individual $t$ is the indeterminate of the polynomial (and I suppose the $x$ in the second term should be $t$ as well), the powers $t^i$ are monomials. Instead of "structure" most people say "term".

Also your argument is fundamentally flawed, because say a sum of two part (red and green) is always zero does not imply each of the parts is always zero. Consider $\color{red}{-x}+\color{green}{x}$.
Comment: Are you perhaps trying to induct on the number of non-zero coefficients?
Answer: The result is correct over infinite fields (you probably should use induction). Over finite fields you can find such polynomial: for example, you can take $x^2+x$ over $\mathbb{F}_2$
Comment: This is a bit misleading: the **result** is correct over infinite fields, but Gustavo's **argument** is seriously incomplete, if not downright circular.
Comment: I still don't know what are finite fields, but the book still didn't mention them - I guess there's no problem in using this answer, right? Also, I don't know how to use induction, can you recommend me something?
Comment: @BrianM.Scott Can you provide me more information?
Comment: @Gustavo: Hang on just a bit, and I'll finish writing something up.
Answer: No. You're statement that "for the red structures, it's impossible to have $P(c)=0$ for every $c$" is exactly what you're trying to prove. The following statement is true, and it's what you're are trying to prove
$$
\text{Over an infinite field, $P(x)=0$ for every $x$ in the field if and only if $P$ is the zero polynomial}
$$
Based on your vocabulary, you might not know what a field is. If you don't know, all you need to know is that the real numbers are an infinite field. What you call the red structures are generally called the variables, and the green term is called a constant. Do you know what mathematical induction is? It might be a good place to start when trying to prove the above statement.
Mathematical induction is a proof technique where you show that a statement is true for a base case, then you assume it's true for every value up to $n$, and they you prove that the statement is true for $n+1$. For this proof, you want to induct on the degree of the polynomial. You wrote out a polynomial of degree $n$ in your post; that means the highest power of a variable is $n$. For the base case in the proof, we want to look at what happens when $n=0$, or when the polynomial is a constant. If the polynomial is a constant, it has the form $P(x)=a$ for some $a$ in the real numbers (we can write this more compactly as for some $a\in\mathbb{R}$). Clearly, if $a$ is anything but $0$ we can't satisfy the condition that $P(x)=0\;\forall\;x\in\mathbb{R}$ ($\forall$ means for every, or for all). Since that's what we want to show, we've proven the base case. Now we want to assume that the statement is true for every degree up to $n=k$. This is called the induction hypothesis. Finally, you need to use the induction hypothesis to show that the statement is true for polynomials of degree $n=k+1$.
By doing that, you manage to build a sort of staircase that works for every possible polynomial. Since you proved the statement was true for a base case, you built the first step. With the induction hypothesis, we manage to show that there is a next step. Do you have any ideas how to go about showing that
$$
a_{k+1}t^{k+1} + a_k t^k+\dotsb+a_1 t+a_0 =0 \;\forall\;t\in\mathbb{R}\Leftrightarrow a_0=a_1=\dotsb=a_k=a_{k+1}=0
$$
assuming that $a_k t^k+\dotsb+a_1 t+a_0 =0 \;\forall\;t\in\mathbb{R}\Leftrightarrow a_0=a_1=\dotsb=a_k=0$ ($\Leftrightarrow$ means if and only if)?
Comment: I've already read somethings about induction, but it wasn't a guide on how to use it, it was just some examples.
Answer: This really ought to be cast as a proof by induction, but to make the idea a little clearer, I'm not going to do that.
Let $p(x)=a_0+a_1x+\ldots+a_nx^n$ be a polynomial of degree $n>0$, and $c_1$ be any real number. Using ordinary polynomial long division to divide $p(x)$ by $x-c_1$, we can write $$p(x)=(x-c_1)q_1(x)+r\tag{1}$$ for some polynomial $q_1(x)$ of degree $n-1$ and some constant $r$. If $p(c_1)=0$, $(1)$ becomes $$0=p(c_1)=(c_1-c_1)q_1(c_1)+r=r\;,$$ and therefore $p(x)=(x-c_1)q_1(x)$. For future reference note that the leading coefficient of $q_1(x)$ is $a_n$.
Now suppose that $c_2$ is another real number such that $p(c_2)=0$. Then
$$0=p(c_2)=(c_2-c_1)q_1(c_2)\;,$$
and $c_2-c_1\ne 0$, so $q_1(c_2)=0$, and we can repeat the argument to discover that there is a polynomial $q_2(x)$ of degree $n-2$ such that $q_1(x)=(x-c_2)q_2(x)$, and the leading coefficient of $q_2(x)$ is $a_n$; clearly $$p(x)=(x-c_1)q_1(x)=(x-c_1)(x-c_2)q_2(x)\;.$$
If there are at least $n$ real numbers $c_1,\dots,c_n$ such that $p(c_k)=0$ for $k=1,\dots,n$, we can repeat this process a total of $n-1$ times to write $p(x)$ in the form
$$p(x)=(x-c_0)(x-c_1)\dots(x-c_{n-1})q_n(x)\;,$$
where $q_n(x)$ is a polynomial of degree $0$ with leading coefficient $a_n$. In other words, $q_n(x)$ is the constant polynomial $q_n(x)=a_n$, and $$p(x)=a_n(x-c_1)(x-c_2)\ldots(x-c_n)\;.$$
Now let $c$ be any real number different from $c_1,\dots,c_n$; then $$p(c)=a_n(c-c_1)(c-c_2)\ldots(c-c_n)$$ is a product of non-zero real numbers and is therefore not $0$. That is, if there are distinct real numbers $c_1,\dots,c_n$ such that $p(c_k)=0$ for $k=1,\dots,n$, then for any real number $c\notin\{c_1,\dots,c_n\}$ we must have $p(c)\ne 0$, and therefore $p(x)$ cannot be identically $0$. And of course if there are not $n$ distinct real numbers $c_1,\dots,c_n$ such that $p(c_k)=0$ for $k=1,\dots,n$, then $p(x)$ certainly isn't identically $0$. It follows that no polynomial of positive degree is identically $0$, and of course the only constant polynomial that is identically $0$ is the zero polynomial.
Answer: If the polynomials are viewed as having real coefficients, then I think something like Gustavo's argument might work. If we let $a_nt^n$ be the highest term of the polynomial (no further powers higher than the nth, and $a_n$ not $0$, we can arrive at a contradiction in case $n>=1$ by finding the limit of $p(t)/t^n$, which is $a_n$. If $a_n$ is not zero we could then pick a $t$ large enough to dominate the earlier terms of the polynomial and guarantee a nonzero value of $p(t)$.
Maybe Gustavo's idea was one of successively peeling off the higher powers one by one until he arrived at just the constant term, which then would have to be zero, finishing the argument. But I agree with those above that as it stands he has not presented a full proof.

Can I use this as a proof?


Seleção de registros relacionados com SQL

Question: Tenho duas tabelas, uma que chama grupo onde é armazenado os grupos criados para acesso de uma aplicação. Por exemplo, se você tiver no grupo CADASTRO_ADMIN, você terá permissão total; agora, se tiver no grupo CADASTRO_USR terá permissão apenas de usuário.
A outra tabela se chama grupo usuário, onde fica armazenado o CPF do usuário junto com o seu grupo de permissão, vejam:
GRUPO

GRUPO USUÁRIO

O select que preciso fazer é o seguinte: Selecionar os grupos que o usuário é administrador junto com os grupos que possuem o código do grupo administrador na coluna cod_grupo_admin.
Por exemplo, o usuário 222.222.222-11 é administrador do grupo 18, daí minha consulta precisa retornar o grupo 18, 22 e 30, pois tem o cod_grupo_admin = 18.
Tentei essa consulta, mas o problema que ele só me retorna o código do grupo admin, não os demais.
SELECT g.* FROM grupo g
LEFT JOIN grupo_usuario u ON (g.codigo = u.codigo_grupo)
WHERE
g.administrador = true AND u.cpf='222.222.222-11'

Comment: Pergunta: está utilizando MySQL ou PostgreSQL?
Comment: Opa, estou usando o PostgreSQL
Answer: Não testei, mas creio que seja isso que você procura:
SELECT grupo.codigo
  FROM grupo
 INNER JOIN grupo_usuario ON (grupo.codigo = grupo_usuario.codigo_grupo)
 WHERE grupo_usuario.cpf = '...'
   AND grupo.administrador = true
UNION
SELECT grupo.codigo
  FROM grupo
 INNER JOIN grupo_usuario ON (grupo.cod_grupo_admin = grupo_usuario.codigo_grupo)
 WHERE grupo_usuario.cpf = '...'

Explicando um pouco:
O primeiro select pega o grupo em que o usuário é diretamente administrador.
O segundo pega os grupos que tem como grupo administrador o grupo do usuário.
Comment: Amigo muito obrigado! Era isso mesmo que eu precisava, não tenho muita experiência com consultas SQL. Me ajudou bastante, abraços!


Ansible - 'Undefined' at beginning and end of Key when map'ing a Attribute

Question: When map'ing a attribute in a list of variables, Ansible is adding a 'Undefined' to the beginning and end of the key.
The variables:
vault_config_listener_params:
  - address: "0.0.0.0:8200"
  - tls_cert_file: "/etc/ssl/certs/wildcard.crt"
  - tls_key_file: "/etc/ssl/certs/wildcard.key"

The debug task:
- debug: var=vault_config_listener_params|map(attribute="tls_cert_file")|list

The output:
ok: [id70118] => {
    "vault_config_listener_params|map(attribute=\"tls_cert_file\")|list":
"[Undefined, u'/etc/ssl/certs/wildcard.crt', Undefined]"
}

The maping seems to have worked, as the key path has been extracted. But where are the 'Undefined' coming from?
PS: The variables needs to be a list, as they are looped it in another place with jinja2.
Comment: Used with Ansible 22.214.171.124 & Python 2.7.13
Answer: First of all, don't use debug's var when printing arbitrary expressions, use msg instead.
As for your question, map is quite dumb and doesn't do what you don't ask it to, so you actually need to select items with specified attributes defined first, and then get its values:
- debug:
    msg: "{{ vault_config_listener_params | selectattr('tls_cert_file','defined') | map(attribute='tls_cert_file') | list }}"

Comment: Cheers mate!

    "msg": [
        "/etc/ssl/certs/wildcard.laterooms.io.crt"
    ]

That was how i want it!


SensorStreamViewer, HoloLensForCV : "Failed to initialized media capture: Access is denied."

Question: I tried to get sensor stream from HoloLens, so I used the HoloLensForCV.
(https://github.com/Microsoft/HoloLensForCV)
First, I checked that SensorStreamViewer project works, but few days later, I updated HoloLens and then it doesn't work. The error I receive is Access is Denied
HoloLens Camera view capture
HoloLens Privacy Camera capture
The Webcam capability in VS capture
And, I guess the error occurs in this part(SensorStreamViewer.xaml.cpp).
// Initialize MediaCapture with the specified group.
// This must occur on the UI thread because some device families
// (such as Xbox) will prompt the user to grant consent for the
// app to access cameras.
// This can raise an exception if the source no longer exists,
// or if the source could not be initialized.
return create_task(m_mediaCapture->InitializeAsync(settings))
    .then([this](task<void> initializeMediaCaptureTask)
{
    try
    {
        // Get the result of the initialization. This call will throw if initialization failed
        // This pattern is docuemnted at https://msdn.microsoft.com/en-us/library/dd997692.aspx
        initializeMediaCaptureTask.get();
        m_logger->Log("MediaCapture is successfully initialized in shared mode.");
        return true;
    }
    catch (Exception^ exception)
    {
        m_logger->Log("Failed to initialize media capture: " + exception->Message);
        return false;
    }
});

When I start others project like 'ComputeOnDevice', I can see an alert message window asking me allow to access camera. However, when I start 'SensorStreamViewer', I didn't see any alert message asking about camera access.
I started debugging, and confronted this error message.

Exception thrown at 0x772C3332 in SensorStreamViewer.exe: Microsoft C++ exception: Platform::AccessDeniedException ^ at memory location 0x0180E680. HRESULT:0x80070005 Access is denied.
  WinRT information: The required device capability has not been declared in the manifest.

How can I solve this problem?
Comment: Yes, I enabled the Webcam capability in 'Package.appxmanifect' file. Also, I checked the Camera Privacy in HoloLens Settings. I added some captured images.
Comment: Can you provide more details on your error message?
Comment: sure, The full message is "Failed to initialize media capture: Access is denied."
Comment: Did you enabled the WebCam capability, right?
Comment: I am experiencing the same problem. My HoloLens is running WIndows `17686.1003.x86fre.rs_prerelease.180603-1447
`. What's your version?
Answer: In your Package.appxmanifest file, you need to add the following capability.
<rescap:Capability Name="perceptionSensorsExperimental" />


Why is code after `else` in a multi-line conditional considered valid ruby syntax?

Question: I was surprised to see that (in Ruby 2.7.4) it is possible to add code after the else keyword, as I've never encountered this before.  The following code is considered valid by ruby's built-in syntax checker, and runs quite happily:
if false
  puts 'noop'
else puts 'why is this possible'; 'not returned'
  puts 'and not a syntax error?'
  'returned'
end

# # Output
# why is this possible
# and not a syntax error?
# => "returned"

The in-line code after else is interpreted (puts 'why is this possible') , but the result ('not returned') is discarded.
However if I add return to the else line things get really unexpected:
if false
  puts 'noop'
else puts 'why is this possible'; return 'inline returned'
  puts 'this is now not called'
  'not returned'
end

# # Output
# why is this possible
# => "inline returned"

I don't know what this would be called, so I'm unable to google it – I can't find this documented or mentioned anywhere and don't know if it is an intentional language feature (possibly a side-effect of the single-line if/then/else syntax...?).
Can anybody shed any light on why this works, and if there is a valid use-case for it?
Comment: I'd say code after `else` is perfectly valid if the code you're adding is syntactically valid. As there's no other keyword (like `if`) after the `else` then the parser does it right and works the same as if you'd put a break line after it.
In the 1st example "not returned" is not used for anything, so Ruby does what the code tells it to do. If you do `...; puts 'not returned'` you'll see it's printed.
Comment: Does the code makes sense to you if you replace the space after `else` with the newline? Well, that's it :) From the parser's point of view, both newline and space are just valid whitespaces separating `else` from the branch code itself...
Comment: To add a note which wasn't very explicit: Ruby will automatically return the last item in a method, so in the first case `"returned"` is said item. If you manually declare a return as done in your second example the automatic/implicit return will be overwritten.
Comment: "From the parser's point of view, both newline and space are just valid whitespaces separating else from the branch code itself." <- this is what I was missing, thanks @KonstantinStrukov. Somehow I never knew these were the same, and was expecting something along the lines of `syntax error: unexpected X, expecting end-of-input` on the `else` line.
Answer: It might be more obvious with explicit line breaks. Your first example is equivalent to:
if false
  puts 'noop'
else
  puts 'why is this possible'
  'not returned'
  puts 'and not a syntax error?'
  'returned'
end

The 'not returned' string literal doesn't do anything on its own. What's left are two puts calls and a return value of 'returned'.
Your second example:
if false
  puts 'noop'
else
  puts 'why is this possible'
  return 'inline returned'
  puts 'this is now not called'
  'not returned'
end

Here, the return keyword will exit the enclosing method after the first puts call right-away with a return value of 'inline returned'. Hence, the following puts and the implicit return value of 'not returned' are ignored.
Comment: Technically, `'not returned'` is shot into outer space.
Comment: Somehow despite writing ruby for over 10 years I never knew that space and newline were syntactically equivalent in this case. I always thought that the newline after `else` was in some way part of the syntax requirement, similar to after the `if ...` clause:

`if true 'this is invalid syntax' else 'no' end`

...is _not_ valid and returns "syntax error, unexpected `else', expecting end-of-input" which is what I had been expecting in my example. It makes more sense now but still doesn't sit quite right!


MPU6050 Settings?

Question: Does anybody have any good experience with the gy-521 / MPU6050 ?
I want to use the accelerometer portion to determine movement on a  swinging object.
I think i need some high precision settings, but for the life of me have not understood most of what i've found because they get to talking in "their" language, and i just get lost.
I know its probably just mathematical calculations, but i just don't seems to be getting the data from the module, at least the numbers don't seem to change as mush as i think they should when i move the module around.
I don't think i need decimal points of precision, just "high accuracy" as the module moves, whenever i request the data from it.
I suppose i could use decimal numbers, but like  i said i will just be reading on the fly and will track whatever number i get to see if its greater or less than the previous data read.
Sad part is right now if i just let the module sit still on my table top, about every 4-5 seconds, the numbers change without me doing anything to the module.
I'm pretty sure its a setup problem, because i'm just using the settings from the sample code i extracted from some example script i found.
Any help would be greatly appreciated.
Comment: Fundamentally not really a generic Tcl question, so I removed that tag.
Comment: No problem i just put that on there because at som epoint i thought someone would ask some details, in which wold be refernce to the tcl script i am using.
Answer: I spent a lot of time last month just to understand MPU6050. From what I understand, you can change the settings correctly only if you understand the register map of MPU6050. After that, you can do the register setup. You may refer my repo (readme.md) for the setup and register details: https://github.com/aaryaapg/Digital-Level-Meter
I have also added references and links. You may check those out too.

MPU6050 Settings?


Minimal polynominal: geometric meaning

Question: I am currently studying Chapter 6 of Hoffman & Kunze's Linear Algebra which deals with characteristic values and triangulation and diagonalization theorems.
The chapter makes heavy use of the concept of the minimal polynomial which it defines as the monic polynomial of the smallest degree that annihilates a linear transformation.
I am currently finding the proofs in the book that use this definition of the minimal polynomial to be very opaque: just chains of calculations with polynomials that turn out to give the right answer in the end.
I was therefore wondering if there is a more geometric view of the minimal polynomial? What information about the linear transformation is it carrying and why? I guess the answer would be simpler in the case of an algebraically closed field but is there an answer which also works for a general field?
Answer: One way to visualize the minimal polynomial (and characteristic polynomial) is to first ask why they are annihilating polynomials. This intuition is probably easiest for diagonalizable operators so let us start there.
If $A: V\rightarrow V$ is diagonalizable, then we can write
$$V=\bigoplus_{i=1}^k E_{\lambda_i}$$
where each $E_{\lambda_i}$ is the eigenspace of $A$ corresponding to eigenvalue $\lambda$. To annihilate $A$, it is therefore sufficient to annihilate $A$ on each of the eigenspaces and the annihilator for each $E_{\lambda_i}$ is just $A-\lambda I$. Now as far as invariant subspaces go, eigenspaces are pretty much as simple as possible. This means that a single iteration of $(x-\lambda_i)$ on $A$ is enough to eliminate the space $E_{\lambda_i}$. Therefore the minimal polynomial is
$$p(x) = (x-\lambda_1)\cdots (x-\lambda_k)$$
and intuitively this is why the minimal polynomial of a diagonalizable operator splits into linear terms.
However, not all operators are diagonalizable and so we need to talk about generalized eigenspaces instead. If you are familiar with the Jordan form, then generalized eigenspaces need no introduction. If you are not (which I think might be the case since Jordan forms are chapter 7 in Hoffman) then we can summarize as follows: Just as a diagonalizable operator "decomposes" into eigenspaces, any operator (diagonalizable or not) decomposes into what are called generalized eigenspaces.
Normal eigenspaces $E_{\lambda_i}$ are defined as the set of vectors $\mathbf{v}\in V$ for which
$$(A-\lambda_i I)\mathbf{v} = \mathbf{0}$$
generalized eigenspaces $W_{\lambda_i}$ are defined as the set of vectors $\mathbf{v} \in V$ for which there exists some $m\in \mathbb{N}$ such that
$$(A-\lambda_i I)^m \mathbf{v} = \mathbf{0}$$
And we then have
$$V = \bigoplus_{i=1}^kW_{\lambda_i}$$
The representation of the operator $A$ corresponding to the above decomposition is then the Jordan Normal Form of the matrix.
With each generalized eigenspace, we can make a conceptual distinction. We separate the space into sets
$$S_j = \left\{\mathbf{v}\in V \big|\ j\ \text{is the smallest integer such that } (A-\lambda_i)^j\mathbf{v} = \mathbf{0}\right\}$$
for example, $S_1 \cup \{\mathbf{0}\} = E_{\lambda_i}$. In this notation, we can view the action of the operator $A-\lambda I$ as shifting the sets
$$S_m \rightarrow S_{m-1} \rightarrow \cdots \rightarrow S_1 = E_{\lambda_i} \rightarrow S_0 = \{\mathbf{0}\}$$
In this way, the exponent of $e_i$ each factor $(x-\lambda_i)^{e_i}$ in the minimal polynomial can be seen as the "depth" of the generalized eigenspace $W_{\lambda_i}$.
I am not sure if the above explanation is satisfying, but this gives us a very rough geometrical intuition of the minimal polynomial. The minimal polynomial can be seen as a sequence of steps taken to eliminate the vectors of $V$ which reflects the structure of $A$. We decompose $V$ into invariant generalized eigenspaces $V = \bigoplus_{i=1}^kW_{\lambda_i}$. For each generalized eigenspace, we apply the operator $(A-\lambda_i)$ enough times so that the space is eliminated. Each application of the operator corresponds to a shift of the form $S_{i+1} \rightarrow S_i$ in the space. Doing this for all the generalized eigenspaces then eliminates the entire the vector space.
Comment: Thanks a lot for your very detailed answer. I need to study ahead a bit to understand it fully. But if I am not wrong, the existence of the Jordan form is guaranteed for only algebraically closed field. Is there some way to extend the logic of your answer to the general case?
Comment: It is certainly easier for algebraically closed fields. You can probably extend the above answer using real canonical form but I don't think it's as geometrically intuitive.
Comment: Thanks again for the answer. I would have liked to accept both your and Marc's answers but since I have to accept one I am accepting his as I think his is the point of view I will have to take if I start with general fields.
Answer: I think the minimal polynomial is an inherently algebraic notion, and you should accept it as that. There are geometric consequences though, such as the fact that a decomposition of the minimal polynomial of $\phi$ into a product of powers of irreducible polynimials leads to a canonical decomposition of the vector space as direct sum of $\phi$-stable subspaces (generalized eigenspaces in the case the minimal polynomial splits).
The basic intuition I have for minimal polynomials is that they form a extension to linear maps of the notion of order of a permutation. If you iterate a permutation, the only "remarkable" thing that can happen is that at some point you get the identity; this defines the order of the permutation. For a linear operator, when you compute successive powers you are unlikely to get the identity (except trivally for the power $0$), but (in finite dimension) you are bound to run into a linear dependence between the powers. This first linear dependence defines your minimal polynomial. Just like it is the case that for a permutation once you hit the order futher iteration is just repetitive, similarly further powers of a linear map can be reduced to lower powers once the minimal polynomial is found.
For permutations you can also look at orbits of individual elements being permuted, which may have a length that divides the order of the permutation. Similarly you can look at the first linear dependence among iterated images by the linear operator of a given vector, leading to a "minimal polynomial" for this vector, which is a divisor of the (global) minimal polynomial of the operator.
Answer: Consider the following matrices:
$$
A = \left(\begin{array}{cc}2&0\\0&2\end{array}\right) \ \ \text{ and } \ \
B = \left(\begin{array}{cc}2&1\\0&2\end{array}\right).
$$
The first matrix has minimal polynomial $X - 2$ and the second has minimal polynomial $(X-2)^2$. If we subtract $2I_2$ from these matrices then we get
$$
\left(\begin{array}{cc}0&0\\0&0\end{array}\right) \ \ \text{ and } \ \
\left(\begin{array}{cc}0&1\\0&0\end{array}\right),
$$
where the first has minimal polynomial $X$ and the second has minimal polynomial $X^2$.
The different exponents here reflect the fact that a matrix can have a power that is $O$ without being $O$ itself (this doesn't happen with ordinary numbers, like in ${\mathbf R}$ or ${\mathbf C}$). A matrix has a power equal to $O$ precisely when its minimal polynomial is some power of $X$, and the exponent you need on $X$ to achieve that can vary. As another example, compare
$$
M =
\left(\begin{array}{ccc}
0 & 1 & 1 \\
0 & 0 & 1 \\
0 & 0 & 0
\end{array}
\right)
\ \ \text{ and } \ \
N =
\left(\begin{array}{ccc}
0 & 0 & 1 \\
0 & 0 & 0 \\
0 & 0 & 0
\end{array}
\right).
$$
These are not the zero matrix, but $N^2 = O$ while $M^3 = O$ and $M^2 \not= O$. So $M$ has minimal polynomial $X^3$ and $N$ has minimal polynomial $X^2$.
To describe a (monic) polynomial we could provide its roots and the multiplicities for those roots. For a square matrix, the roots of its minimal polynomial are easy to connect with the matrix: they are the eigenvalues of the matrix. The subtle part is their multiplicities, which are more algebraic than geometric.
It might be natural to hope that the multiplicity of an eigenvalue $\lambda$ as a root of the minimal polynomial is the dimension of the $\lambda$-eigenspace, but this is false in general, as we can see with the matrices $A$ and $B$ above (e.g., $B$ has minimal polynomial $(X-2)^2$ but its 2-eigenspace is 1-dimensional). In the case when the matrix has all distinct eigenvalues, the minimal polynomial is the characteristic polynomial, so you could think of the distinction between the minimal and characteristic polynomials as reflecting the presence of repeated eigenvalues.

Minimal polynominal: geometric meaning


Gem::LoadError Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile

Question: Esse erro aparece constantemente, no meu caso, instalei o ruby, as gems, rails, o mysql2 tudo certo. Mas quando tentava:
rake db:create

aparecia outro erro:
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'mysql2' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
Gem::LoadError: can't activate mysql2 (~> 0.3.13), already activated mysql2-0.4.0. Make sure all dependencies are added to Gemfile.
Nesse caso, qualquer tentativa que buscava gerava erro, a solução que encontrei foi, acessar o Gemfile e alterar para:
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.13'

salvei e executei:
bundle exec rake db:create

voalá db criado!
Espero poder ajudar mais alguém com esse post.
Answer: Na verdade, por algum motivo que desconheço, está havendo um problema de incompatibilidade do Rails 4.2.4 com essa mais nova 0.4.0 do mysql2, portanto se você utilizar a segunda versão mais nova 0.3.20, vai dar certo.
gem 'mysql2', '~> 0.3.20'
bundle install

Espero ter ajudado de alguma forma.
Valeu.


Confusing with technical terminology between Thread and Queue

Question: I am newer to iPhone development. With focusing on develop multi-threading Apps, I have referred to some Apple documents and others explaining thread and multi-threading concepts. But as far as work-queue is concerned, I am confused in understanding relation between Thread, Task and Queue. Some documents says, a thread can have multiple tasks and those tasks is stored in queue, thus each thread may have its own queue. Whereas, some says that, threads themselves are stored in queue.
My question is, can we say:
(1) Threads can have multiple Tasks and those task are stored and managed inside a Queue of that thread.
OR
(2) Threads themselves are stored and managed inside a Queue.
Secondly, I also read something like this:

Another advantage of using a thread pool over creating a new thread for each task is thread creation and destruction overhead is negated.

Is thread pool synonym for work-queue?
Answer: I am clear now.
Thread and queue is totally different things. Thread is separate code of execution while queue is data structure for maintaining tasks. A thread can have multiple tasks and all threads may be created for particular goal that is Process. A thread has its own space in memory for its variables and other things.
So, in multi-threading programming, queue is a mechanism that handle sequence of tasks to be executed. Queue always executes tasks in serial order. However, if we want to execute tasks concurrently, we would have to create concurrent queues. Thus multiple queues can executed concurrently benefiting multiprogramming. With latest API, it is upto operating system that how to schedule those tasks. Tasks may or may not be executed on separate thread. Structure always depends on our requirement.


Using Fieldgroups with Entity Registration Module

Question: I'm using the Entity Registration module to create event signup forms.  I've got my first event registration form up and running and now want to group some of the fields into fieldsets.
I have the Field Group module installed, and have used it to group my fields into fieldsets (via Manage Display):

The effect I want to achieve is something like this:

However the fieldsets are not showing on the registration form or in the markup:

According to Field Group module, it should work with any entity:

Fieldgroup will, as the name implies, group fields together.  All fieldable entities will have the possibility to add groups to wrap their fields together.

I've searched the Entity Registration issue queue, but can't find anything relating to this.  Has anyone managed to get fieldsets working with Entity Registration?
Answer: You need to add corresponding group to add steps in it. See image.
Comment: Thanks Nikhil.  I tried your suggestion but I still don't see any fieldsets on the registration form.  I've updated my question with the result I want to achieve, I don't need a multi step form, only fieldsets but it's not working for some reason.
Answer: Turned out I was missing a step, I didn't realise that you had to create your field groups in Manage Display AND Manage Fields.  Seems a bit strange having to re-create the same field groups twice, but doing that fixed the problem.


How to add a DNS record with no subdomain in Mac OS X Server?

Question: How do I add a DNS record, through the GUI or command line, to Mac OS X Server that is simply the domain name (with no subdomain)?
For example I want to resolve http://foo.com to 192.168.1.100.
There is no facility in the GUI, it forces you to add a subdomain.
Comment: (Just a guess) Try the at symbol: "@", it works on Bind and I'd be surprised if there's something else behind the scenes.
Comment: The GUI throughs an error saying "Numbers, letters, hypens only". What would the zone look like on the command line? @   IN  A 192.168.1.100
Answer: Create a zone named "foo.com.", and inside it create a machine (A) record for "foo.com." -- the trailing period on the machine name indicates that the name is "fully qualified", and that the zone name shouldn't be implicitly added.


What is wrong with hook_schema()?

Question:     function recipe_submit_schema() {
  $schema['recipe_submit'] = array(
    'description' => 'Recipe base table.',
    'fields' => array(
      'recipe_id' => array(
        'description' => 'Primary identifier for recipe.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not_null' => TRUE,
      ),
      'recipe_title' => array(
        'description' => 'Recipe Title.',
        'type' => 'varchar',
        'length' => 255,
        'default' => '',
      ),
      'author_name' => array(
        'description' => 'The author of the recipe.',
        'type' => 'varchar',
        'length' => 255,
        'default' => '',
      ),
      'author_email' => array(
        'description' => 'The author email.',
        'type' => 'varchar',
        'length' => 255,
        'default' => '',
      ),
      'recipe_description' => array(
        'description' => 'Recipe description.',
        'type' => 'text',
      ),
      'recipe_instructions' => array(
        'description' => 'Recipe instructions.',
        'type' => 'text',
      ),
      'recipe_ingredients' => array(
        'description' => 'Recipe ingredients.',
        'type' => 'text',
      ),
    ),
    'primary key' => array('recipe_id'),
  );

  return $schema;
}

gives me following error
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead in /home/insasse/test_workspace/drupal7/includes/database/database.inc:2227                                                     [error]
Stack trace:
#0 /home/insasse/test_workspace/drupal7/includes/database/database.inc(2227): PDOStatement->execute(Array)
#1 /home/insasse/test_workspace/drupal7/includes/database/database.inc(697): DatabaseStatementBase->execute(Array, Array)
#2 /home/insasse/test_workspace/drupal7/includes/database/schema.inc(664): DatabaseConnection->query('CREATE TABLE {r...')
#3 /home/insasse/test_workspace/drupal7/includes/database/database.inc(2776): DatabaseSchema->createTable('recipe_submit', Array)
#4 /home/insasse/test_workspace/drupal7/includes/common.inc(7114): db_create_table('recipe_submit', Array)
#5 /home/insasse/test_workspace/drupal7/includes/module.inc(479): drupal_install_schema('recipe_submit')
#6 /home/insasse/.composer/vendor/drush/drush/commands/core/drupal/environment_7.inc(143): module_enable(Array)
#7 /home/insasse/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1167): drush_module_enable(Array)
#8 /home/insasse/.composer/vendor/drush/drush/includes/command.inc(422): drush_pm_enable('recipe_submit')
#9 /home/insasse/.composer/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#10 /home/insasse/.composer/vendor/drush/drush/includes/command.inc(199): drush_command('recipe_submit')
#11 /home/insasse/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#12 /home/insasse/.composer/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#13 /home/insasse/.composer/vendor/drush/drush/drush.php(12): drush_main()
#14 {main}

What am I doing wrong?
Answer: Try replacing 'primary_key' with 'primary key'
Comment: Try using 'not null' instead of 'not_null' in the recipe_id field definition
Comment: Do you still get the same error, even when you use `primary key`? I also think that should fix your error.
Answer: Change from 'not_null' => TRUE, to 'not null' => TRUE.

What is wrong with hook_schema()?


RewriteMap problem in .htaccess

Question:
Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

I need to do one change in mywebsite. i have two websites. i want to redirect some of the page from website1.com to website2.com based on one mapping file. that mapping file will be on txt file in which the mapping will be in this way like -   /page1.html www.website2.com/page1.html  and so on... i dont want to put rewrite rule in this mapping file. can anybody help me how i can modify the .htaccess file for this.
thanks..
Answer: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap
has a fairly good example.

RewriteMap problem in .htaccess


How to evaluate powers of powers (i.e. $2^3^4$) in absence of parentheses?

Question: If you look at $2^{3^4}$, what is the expected result? Should it be read as $2^{(3^4)}$ or $(2^3)^4$? Normally I would use parentheses to make the meaning clear, but if none are shown, what would you expect?
(In this case, the formatting gives a hint, because I can either enter $2^{3^4}$ or ${2^3}^4$. If I omit braces in the MathML expression, the output is shown as $2^3^4$. Just suppose all three numbers were displayed in the same size, and the same vertical offset between 2, 3 and 3, 4.)
Comment: @MathGems, this operation is deemed right-associative (in programming-language-speak), i.e. $a * b * c$ means $a * (b * c)$. That makes sense, because otherwise $a^{b^c}$ would be just the same as $a^{b c}$, and the extra power would be just a waste of `^` ;-) In the end, that is just a convention, like $a b + c$ means $(a b) + c$, not $a (b + c)$.
Comment: In normal mathematical usage, the exponential operation is "right" associative, i.e. if you see $a^{b^c}$, it means $a^{(b^c)}$. If you see "a^b^c", it usually means "a^(b^c)". However, this is not universal. e.g. Excel will interpret "a^b^c" as "(a^b)^c".
Comment: @MathGems, it is universal enough for me. Haven't ever (outside of APL, that is) seen any other interpretation: In mathematics, and in computer languages like FORTRAN and others.
Comment: Without any convention it is ambiguous, same as it is for any operation that is nonassociative, i.e. $\rm\: x \circ ( y \circ x) \ne (x \circ y) \circ z.\ $
Comment: @vonbrand That is one possible convention. But it is not universal.
Comment: @vonbrand "Universal enough?" You cannot even typeset it unparenthesized *here*, as mathjax/LaTeX will reject it.
Comment: See http://math.stackexchange.com/questions/534578/xyz-is-it-xyz-or-xyz
Answer: Barring parentheses, $2^{3^4}$ should definitely be read as, and is equivalent to $\;2^{\left(3^4\right)}$:$$2^{3^4} = 2^{(3^4)} = 2^{81}$$ whereas $${(2^3)}^4 = 2^{3\cdot 4} = 2^{12}$$

Added:
As pointed out in the comments, it is fairly standard practice that exponents are "right associative" - which is somewhat of a misnomer which should only be taken to mean, evaluate rightmost first: read a^b^c as a^(b^c) and read a^b^c^d as a^[b^(c^d)], and so on. As the example above shows,the exponential operator is not associative.  So as you have indicated you typically do, use parentheses, when possible, in your own usage, to avoid any possible confusion.
Comment: Ok, with your edit I think this is just fine. Wikipedia hinted me at the same in the entry about operator associativity in programming languages ("In order to reflect normal mathematical usage, addition, subtraction, multiplication, and division operators are usually left-associative while an exponentiation operator (if present) is right-associative.").
Comment: @Dolma, I lost my brain and was thinking of $3^6$ in the exponent for some reason! ;-)
Answer: In the same way that any expressions in brackets inside other brackets are done before the rest of the things in the brackets, I'd say that one works from the top down in such a case.
i.e. because we do $(a*d)$ first in$((a*b)*c)*d$, I'd imagine it'd be the expected thing to do $x^{(y^z)}$


Django Admin Tables Functionality

Question: Is there anyway to add the functionality of Datatables
to the django admin interface. I'm using Django + Mezzanine and for my project we need the ability to sort  by every column, have pagination, search, etc.
Answer: Yes.
The simplest implementation without server-side pagination would be overriding change_list.html for the model in order to:

print the table in {% block result_list %}
initialize datatable in {% block extrahead %}
import css in {% block extrastyle %}

Django Admin Tables Functionality