Have flexbox fill up vertical space of browser for sidemenu

Question: I need to have a sidemenu that scales depending on the browser size. But also i need a header and footer, and the also a content container next to the sidemenu. So lets say that the sidemenu is 1/4 of the width and the content container is 3/4 of the width, but the height of both the sidemenu and the content container is always 100% of the browser size or more, depending on the content inside the content container and the sidemenu.
I would think this would be simple, just have the flext-dir. to col. and "flex: 1" on the childeren. (and a little more code, its in the fiddle link under)
But as soon as I wrap the sidemenu inside a new div, so that I can make the content container go next to the sidemenu and not under. The vertical fill from flexbox, fails.
https://jsfiddle.net/frrvdq2n/2/
So do anyone have som suggestions on how to solve this, or maybe other tips to create this idea. Thanks ahead :)
IMG. of how om thinking the sizing should be on most browser sizes.
Here is also the code, just incase:
HTML

Option One

Option Two

Option Three

CSS
.wrapper, html, body {
  height:100%;
  margin:0;
}

.wrapper {
   display: flex;
   flex-direction: column;
}

.row3 {
   background-color: green;
   flex:2;
   display: flex;
}

Answer: With your initial code sample, all you need is to also give .container a height.

.container, .wrapper, html, body {
    height:100%;
    margin:0;
}

.wrapper {
    display: flex;
    flex-direction: column;
}

.row3 {
    background-color: green;
    flex:2;
    display: flex;
}

Option One

Option Two

Option Three

From the above sample, you can now easily create a layout that looks like the image posted, by adding 2 children to the middle row3, to be the side bar and the content

.container, .wrapper, html, body {
    height:100%;
    margin:0;
}

.wrapper {
    display: flex;
    flex-direction: column;
}

.row3 {
    background-color: green;
    flex:2;
    display: flex;
}

.col2:nth-child(1) {
    background-color: lightblue;
    flex-basis: 25%;
}

.col2:nth-child(2) {
    background-color: lightgreen;
    flex-basis: 75%;
}

Option One

Option Two A

Option Two B

Option Three

And by start playing with the flex-grow and flex-basis on the row3 elements, you can have them sized by content, a set height and fill the remaining space.

.container, .wrapper, html, body {
    height:100%;
    margin:0;
}

.wrapper {
    display: flex;
    flex-direction: column;
}

.row3:nth-child(1) {
    background-color: green;
    flex-basis: 50px;              /*  a set height  */
}

.row3:nth-child(2) {
    flex:1;                         /*  fill the remain  */
    display: flex;
    margin: 10px 0;
}

.row3:nth-child(3) {
    background-color: green;        /*  sized by content  */
}

.col2:nth-child(1) {
    background-color: lightblue;
    flex-basis: 25%;
}

.col2:nth-child(2) {
    background-color: lightgreen;
    flex-basis: 75%;
    margin-left: 10px;
}

Option One

Option Two A

Option Two B

Option Three

Answer: You can inbricate flex boxes  and use typical HTML5 structure:
DEMO (with aside sliding off screen to see the flex behavior )

body {
  min-height:100vh;
  margin:0;
}
html {
  height:100%;
}
html,body {
  display:flex;
  flex-direction:column;
}
header {
  margin:0 0 10px ;
  background:rgb(52, 110, 174);
}
footer {
  background:rgb(173, 53, 54);
  margin:10px 0 0px ;
}
main {
  flex:1;
  display:flex;
}
aside {
  min-width:200px;
  flex:1;
  background:rgb(53, 174, 79);
}
section {
  flex:5;
  margin-left:10px;
  background:rgb(190, 67, 181);
}
header,footer,aside,section {
font-size:3vmax;
color:white;
display:flex;
align-items:center;
justify-content:center;
line-height:2em;
header

    aside

    section or single div

footer

Here is a similar layout How can I make my flexbox layout take 100% vertical space? Almost a duplicate, similar method but different layout order :)
Answer: Check out the below code snippet. The secret sauce to all of this is wrapping all of the components in a div that has 100vh height. Using viewport units is a great way to ensure content remains in the browser viewport regardless of browser size. The only place I use Flexbox is to put the sidemenu and content next to each other.

body {
  padding: 0;
  margin: 0;
}

.view_wrapper {
  width: 100%;
  height: 100vh;
}

header, footer {
  position: relative;
  left: 0;
  width: 100%;
  height: 10%;
  background: #616D74;
  color: white;
}

header {
  top: 0;
}

footer {
  bottom: 0;
}

.main_container {
  width: 100%;
  height: 80%;
  display: flex;
}

.sidemenu_container {
  width: 25%;
  height: 100%;
  padding: 10px 5px 10px 0px;
  box-sizing: border-box;
}

.sidemenu {
  width: 100%;
  height: 100%;
  background: #F36E55;
}

.content_container {
  width: 75%;
  height: 100%;
  padding: 10px 0px 10px 5px;
  box-sizing: border-box;
}

.content {
  width: 100%;
  height: 100%;
  background: #E2DCD0;
 }
}


How can I bind the Window title to a string

Question: I am trying to build a WPF desktop app and my HomeWindow is defined like this:
<Window x:Class="App1.HomeWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:App1"
    xmlns:MainWindow="clr-namespace:App1"
    xmlns:uc="clr-namespace:App1.UserControls.Home"
    mc:Ignorable="d" UseLayoutRounding="True"
    Title="App 1" Height= "750" Width="1200" MinHeight="500" MinWidth="800" WindowStyle="ThreeDBorderWindow" WindowStartupLocation="CenterScreen">

When the app is first loaded, I store the username and the client name in a simple class that is defined like this:
public static class LoggedInData
{
   public static string LoggedInUserName { get; set; }
   public static string LoggedClientName { get; set; }
}

What I would like to accomplish is, instead of just displaying a text in the title of the window, I would like to display the static text App1, the value of LoggedInUserName and the value of LoggedClientName.
I have tried some of the answers I have seen here but I have failed to reproduce them with my app. Can someone help me?
Answer: You can achive that with a multi-binding in the Title property of the window and string formatting. All you have to do is ensure that the static LoggedInUserName and LoggedClientName properties are assigned before the window is shown.
<Window x:Class="App1.HomeWindow" ...>
   <Window.Title>
      <MultiBinding StringFormat="{}App1 {0} {1}">
         <Binding Source="{x:Static local:LoggedInData.LoggedClientName}"/>
         <Binding Source="{x:Static local:LoggedInData.LoggedInUserName}"/>
      </MultiBinding>
   </Window.Title>

</Window>

You can adapt the StringFormat to fit your requirements. The {} prefix is just an escape sequence and {0} and {1} are placeholders for the bindings, the rest is up to you. Of course, you can also extend this to bind other properties on controls, the data context or view model.
Comment: I have tried everything but I can't reproduce it. It's fair to mention that I am learning on my own and I have 0 background in programming. Can you show how the full code shoud be please?


Portability of SQL Server applications between 32 and 64 bit versions of SQL Server?

Question: I have an application that is currently running against a 32-bit SQL Server 2005 Standard Edition database. For reasons I won't go into here, I need to move the database to a 64-bit SQL Server 2005 Standard edition running on 64-Bit Windows Server 2003 R2 Datacenter.
Are there any migration issues I should be aware of in the Application code, stored procedures, or SQL configuration? That is, is the functionality equivalent on both platforms?
If there are functional differences, could you post a link to a document with migration planning tips?
Answer: In general, it's a piece of cake. We do that exact thing all of the time, with no problems. Functionality of pure t-sql code is identical (64 bit just performs better ;-).
The one exception to this that I have encountered is extended stored procedures. Since these are written in C they would have to be recompiled as 64 bit binaries. Even then, no source code changes should be required.
If you aren't using extended stored procs you should have no problems.
Answer: The main thing I'm aware of is that the SSIS 32-bit mode version of dtexec needs to be run in when dealing with data sources where there are no 64-bit version of Jet (Excel or Access, basically).


Analysis of residuals from generalized linear model with binomial family

Question: I have fit a GLM where the response variable represents ratio and used Binomial family. Below is my model
library(foreign)
df <- read.dta("http://fmwww.bc.edu/ec-p/data/wooldridge/401k.dta")
df$prate <- df$prate/100

myglm <- glm(prate ~ mrate + age + sole, data = df, family = binomial)
summary(myglm)

Now I want to get quantile residuals of above fit. As per the discussion in the paper https://www.researchgate.net/publication/2647151_Randomized_Quantile_Residuals, in order to estimate quantile residuals, I need to convert the response variable to standard normal variable.
However, given that in my case I only have ratios (not actual realization of binomial distribution), I could not figure out how exactly I should estimate the quantile residuals in this case.
Is there any direct or approximate method available to obtain such residuals for this type of model fit?
Any pointer will be very helpful.
Comment: Use the DHARMa package https://cran.r-project.org/web/packages/DHARMa/index.html
Answer: You cannot compute randomized quantile residuals without the binomial numbers.
In fact you cannot fit a binomial glm corrrectly without them either.
But the dataset you have loaded does include the binomial realizations.
You need:
library(foreign)
df <- read.dta("http://fmwww.bc.edu/ec-p/data/wooldridge/401k.dta")
df$prate <- df$totpart / df$totelg
myglm <- glm(prate ~ mrate + age + sole, data = df, family = binomial, weights = totalelg)
library(statmod)
qr <- qresid(myglm)


cannot implicitly convert type 'char' to type Test, why?

Question: I am making a sample program for later students who take C# for their independent study. I thought I understood <T> but apparently I'm lacking some magical secret that allows me to use it to its full extent.
When I try to make a variable it works fine:
 static Test<char> c = new Test<char>('n');

As you can see it's instantiated and everything.
Now when I go to assign it to a different value via Console.Read() then it gives me the error:
Cannot implicitly convert type 'char' to 'ConsoleApplication1.Test<char>'
I have tried both :
c = (char)Console.Read();

and:
c = Convert.ToChar(Console.Read());

and even:(I know it's dumb to do this, but I was getting annoyed and wanted to see if it would work)
c = (char)Convert.ToChar(Console.Read());

So, I am thoroughly confused as to how to continue. Help please.
EDIT:
Current Constructors in Test class:

    public Test() { }//empty constructor

    public Test(T obj)
    {
        variable = obj;
    }//filled constructor

Comment: Well in the first case you're calling the constructor. In the other cases you're not. Is there any reason why you're not using `c = new Test((char) Console.Read())`?
Comment: Because you're trying to create a new *instance* of `Test`. I think you're confused about the relationship between variables and constructors.
Comment: Sure, you'll definitely need to use both constructors and variables. But your comment of "I am not trying to make a new variable at that point so why would I call the constructor again?" suggests that you have fundamentally misunderstood the purpose of calling a constructor.
Comment: I am not trying to make a new variable at that point so why would I call the constructor again?
Comment: Since this is a demo program for other students to use in the future I will try to use both at seperate occasions.
Note: I am learning in the process, so I find this very fun. =D
Comment: @JonSkeet I guess I may have misunderstood. My understanding of constructors is that they are used for instantiating a new instance of a variable. Is that false?
Comment: Yes, it's absolutely false. They're used to create a new instance of a *type*. The result of a constructor call *may* be used as the initial value when declaring a variable, but it certainly doesn't have to be.
Comment: Well that is certainly eye opening...
Comment: this works well I will use this in the future, but the implicit type converter looks more extensive and maybe more uses...
Answer: Test<char> isn't a char. It's a new generic type (Test<T>) that (presumably) does something with the object of the type argument (i.e. T) provided.  In your example, you've stated you want to use the char type as the type argument for this generic type.
Imagine you have a property on Test<T> that is of type T:
class Test<T>{
    public T MyTypeValue { get; set; }
}

You can then create an new instance of this generic type, and assign the property the instance of the thing your trying to get (in this case, the console read):
static Test<char> c = new Test<char>(){ MyTypeValue = 'n'};

Since MyTypeValue is of type char by way of the generic type's T type argument, you can assign an actual char to it, but just not to c.  That is, without implementing some other conversion method which is what it appears @Austin is suggesting.
Comment: I am creating the variable as global so I believe it would be `static Test c = new Test{ c.MyTypeValue = 'n'};`
Comment: The `{ }` syntax after the constructor is an example of an [object initializer](http://msdn.microsoft.com/en-us/library/vstudio/bb384062.aspx).  You don't include the instance name you are modifying.  It's assumed to be the new instance.  (Also, I edited my response: constructor call was missing parens.)
Comment: The `{ }` syntax was not what I added the formatter must have changed it when I posted.I actually had those as parenthesis.


O `WebBrowser` usa como base algum navegador nativo do windows?

Question: Estou vendo que da pra usar um WebBrowser no Form do C# mas queria saber se ele é como um iFrame que usa o próprio navegador para criar essa janela de navegação.
Minha duvida é se ele usa o Edge ou algo do tipo pra criar esse WebBrowser.
Cada negador teu seu modo de interpretar o código, por exemplo no Google Chrome ele usa o webkit qual o WebBrowser usaria ?
Comment: https://docs.microsoft.com/pt-br/dotnet/framework/winforms/controls/webbrowser-control-overview
Answer: O controlo WebBrowser de WinForms utiliza por omissão a versão 7 do IE, mas isso pode ser contrariado alterando um valor no Registry: Internet Feature Controls (B..C)
Se no seu código pretender utilizar sempre a última versão disponível no SO, pode implementar a classe abaixo (disponível no SOen: Use latest version of Internet Explorer in the webbrowser control):
public class WebBrowserHelper
{
    public static int GetEmbVersion()
    {
        int ieVer = GetBrowserVersion();

        if (ieVer > 9)
            return ieVer * 1000 + 1;

        if (ieVer > 7)
            return ieVer * 1111;

        return 7000;
    } // End Function GetEmbVersion

    public static void FixBrowserVersion()
    {
        string appName = System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().Location);
        FixBrowserVersion(appName);
    }

    public static void FixBrowserVersion(string appName)
    {
        FixBrowserVersion(appName, GetEmbVersion());
    } // End Sub FixBrowserVersion

    // FixBrowserVersion("<YourAppName>", 9000);
    public static void FixBrowserVersion(string appName, int ieVer)
    {
        FixBrowserVersion_Internal("HKEY_LOCAL_MACHINE", appName + ".exe", ieVer);
        FixBrowserVersion_Internal("HKEY_CURRENT_USER", appName + ".exe", ieVer);
        FixBrowserVersion_Internal("HKEY_LOCAL_MACHINE", appName + ".vshost.exe", ieVer);
        FixBrowserVersion_Internal("HKEY_CURRENT_USER", appName + ".vshost.exe", ieVer);
    } // End Sub FixBrowserVersion

    private static void FixBrowserVersion_Internal(string root, string appName, int ieVer)
    {
        try
        {
            //For 64 bit Machine
            if (Environment.Is64BitOperatingSystem)
                Microsoft.Win32.Registry.SetValue(root + @"\Software\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", appName, ieVer);
            else  //For 32 bit Machine
                Microsoft.Win32.Registry.SetValue(root + @"\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", appName, ieVer);

        }
        catch (Exception)
        {
            // some config will hit access rights exceptions
            // this is why we try with both LOCAL_MACHINE and CURRENT_USER
        }
    } // End Sub FixBrowserVersion_Internal

    public static int GetBrowserVersion()
    {
        // string strKeyPath = @"HKLM\SOFTWARE\Microsoft\Internet Explorer";
        string strKeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer";
        string[] ls = new string[] { "svcVersion", "svcUpdateVersion", "Version", "W2kVersion" };

        int maxVer = 0;
        for (int i = 0; i < ls.Length; ++i)
        {
            object objVal = Microsoft.Win32.Registry.GetValue(strKeyPath, ls[i], "0");
            string strVal = System.Convert.ToString(objVal);
            if (strVal != null)
            {
                int iPos = strVal.IndexOf('.');
                if (iPos > 0)
                    strVal = strVal.Substring(0, iPos);

                int res = 0;
                if (int.TryParse(strVal, out res))
                    maxVer = Math.Max(maxVer, res);
            } // End if (strVal != null)

        } // Next i

        return maxVer;
    } // End Function GetBrowserVersion
}

Utilização
WebBrowserHelper.FixBrowserVersion();
WebBrowserHelper.FixBrowserVersion("SomeAppName");
WebBrowserHelper.FixBrowserVersion("SomeAppName",intIeVer);

Comment: Com esse controlo não, terá mesmo de se "contentar" com o IE. Mas dê uma olhada aqui, pode ser que ajude! [Replacing .NET WebBrowser control with a better browser, like Chrome?](https://stackoverflow.com/questions/790542/replacing-net-webbrowser-control-with-a-better-browser-like-chrome)
Comment: Não tem como fugir do IE ? usar um chrome ou outro navegador ?


Amp picking up radio stations

Question: When I plug my combo practice amp into a normal wall outlet I pick up a local public radio station, just loud enough to be annoying.  The only way I've found to reduce it is to plug it into a UPS or to wrap the input cable around the amp.  Anyone have a technical explanation of why this happening and/or any solutions?
Edit: Crate combo amp (pretty cheap), and Epiphone Les Paul with Humbuckers.  Tried testing again and plugging into UPS doesn't complete eliminate radio, but does diminish it.  Radio sounds still happen when guitar and cable are NOT plugged in.  Implying the problem must be in the amp itself and not necessarily from the cable/pickups acting as an antenna - although I can't imagine that helps.
Comment: "it's the power cord picking up the signal!" That's not very likely. The powercord is carrying 115 VAC which would overwhelm any radio signal received. The guitar cord, which carries the signal from the guitar to the amp is a more likely culprit as a poorly shielded cable would act as an antenna, with the radio signal being amplified by the pre-amp. Replacing that cord would (dis)prove that theory. If the sound occurs without the cable plugged in I lean toward it being the amp itself, or its grounding. The UPS helping could be because of grounding issues too.
Comment: Incidentally, this exact thing can be heard at the end of RATM's Sleep Now in the Fire — see http://en.wikipedia.org/wiki/Sleep_Now_in_the_Fire
Comment: The difference might be in the A/C wiring of the apartment. OLD buildings often didn't have grounding, or, if it was added as a retrofit, was done wrong. Though the outlet has a ground and the amp does too, if that ground is not connected or was wired wrong, you can get noise. You can also get electrocuted too, which is why it's always good to carry an A/C line tester, and check the outlet before you plug in. Getting shocked hurts, and can kill.
Comment: Does it happen when the guitar isn't plugged into the amplifier?
Comment: Guitar cord could be acting as an antenna and picking up signals at a frequency that resonates with the amp speaker...when you wrap the cable around the amp, the signal constructively interferes and you hear nothing. the UPS most likely gets rid of extraneous signals? not sure...was a physics major (shame)!
Comment: Wait, if this happens when the guitar is *not* plugged in, then it's the power cord picking up the signal! Is that what you call the *input cable*, because that's slightly confusing?
Comment: Name/brand of the amp?
Comment: Are you in an apartment complex? I know this sounds funny, but I'm on the 5th floor of a building and I seem to be picking up interference more easily than I was when I lived on the ground floor of a condo. The problem is still related to grounding/shielding, but I thought I'd throw this fact into the mix.
Comment: PUNYON! Cheap amps always seem to play radio stations the minute they are plugged in, and then it gets louder when you plug in a guitar - the funny thing is that when you move the chord around the reception gets better or stops.  I thought that it was a "New York" thing, live and learn...
Comment: Not to dig up an old question, but I'm having the same problem, and want to verify: If it only happens with an instrument cable plugged in, is it most likely the cable? I've done a little testing, and it happens without a guitar on the other end of the cable too. (amp only: no radio; amp + cable: radio; amp + cable + guitar: radio)
Answer: Sounds like your amp's shielding isn't good, as radio interference shouldn't happen like that.
You don't say what brand it is, but you really shouldn't hear interference/noise/radio from the amp, except maybe for hiss if your gain is turned up.
A good amp technician can check all the solder joints and make sure the grounding is good. They can also add additional shielding to help cut out radio waves.
Comment: Shielding is **likely** the issue. Radio interference occurs due to lack of shielding or poor grounding of anything from the guitar to the amp, to even pedals. I remember when I built a custom fuzz pedal and screwed up the ground wiring to the case of the pedal. When I plugged it into my chain I was suddenly listening to latin Polka. When I removed it the radio interference was gone.
Comment: "...I was suddenly listening to latin Polka." Nothing like the blistering sounds of shredding concertina set to 11. Maybe some of the components were "Hecho en Mexico"? :-)
Answer: This is a well-known issue with a fairly straightforward solution. Use an isolated input jack, keep the signal ground isolated from chassis earth, and shunt the input jack shield to the chassis with a 10nF capacitor.
c.f. https://www.aikenamps.com/index.php/grounding
In most mass-produced practice amps, all you should need to do is add the capacitor. If there isn't a convenient screw with continuity to the chassis, you may need to drill a hole and/or scrape a little paint to get continuity.
Answer: Does this happen when your guitar is plugged in?  If so, is your guitar use single coil pickups?
If both of the above are true, then you are witnessing one of the common fallbacks of a single coil pickup, and one of the main driving factors for the creation of the humbucker dual coil pickup.
A pickup is just a magnet surrounded by coils of wire, where when a string is plucked in a pickup's presence, an alternating current is generated, essentially producing a audio signal.  Consequently, due to the coils of wire, the pickup also acts as an antenna, making it liable to picking up stray radio frequencies (usually producing a hum).  To rectify this issue, the dual-coil humbucker was introduced, where two magnets are placed in series with reversed polarities.  Since the coils are connected in series and out of phase, noise and interference are significantly reduced via common-mode rejection, reducing the amount of hum you hear.
Not sure if I'm on the right track here, especially since plugging the amp into a UPS helps fix the issue...
Comment: Not true at all. My amp picks up stations regardless of if I use my Les Paul or my Telecaster. It has nothing to do with pickup type.
Answer: It's likely your house doesn't have a good ground, you need to put a couple more copper sticks in to the ground(garden) and connect it to your grounding system.
Answer: I've played in all kinds of different venues and places and this very thing only happens at home in my studio. I contribute it to weak ground in the studio wiring..
Answer: Usually when Ive picked up background interference it was due to poorly wound coils in my guitar pickups. If u talk near the pickups an you can hear your voice through the amp that's a good sign that it is the case.
Comment: Why would plugging in to a UPS reduce the problem if it was poorly wound pickups?
Comment: Pickups becoming microphonic is actually a mechanical issue rather than actually 'electrical' It can occur when the glue/resin used to hold the windings in place ages & starts to crack up, allowing the individual windings to move in relation to each other.
Comment: Also, I suppose that hearing your voice through the amp when you talk close to the guitar has to do with the (mechanical) wave generated by your vocal cords just slightly vibrating the strings, since your voice alone can't do anything with the magnetic field generated by the pickup.

Radio waves are eletromagnetical waves, a whole different realm just to start with.
Answer: flat out, your going to hate this answer, but try moving your amp, and try using different settings, if that fails, find a stud in your wall, put the amp as close to that as you can (DO NOT have on a shelf) and if all else fails, face the back of the amp away from radio-station, i have done all of the above and the only unwanted interference i get is the interference of my kids messing with the tuning.

Amp picking up radio stations


how to show map scale during zoom of MKMapView like Apple's Maps.app

Question: i am using MKMapView in my custom app and would like to show a map scale (tape measure) during zooming like Apple's Maps.app. Is this possible?
If not, and i would implement my own map scale, how can i get continious update information while the zoom ov the MKMapView is changed?
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated

seems to be called only once at the begining of a zoom while
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated

is called only once at the end of the zoom.
Maps.app map scale is shown and updated in realtime continiously during a zoom.
thanks in advance.
Answer: I had a similar problem, getting the camera.altitude based on user zooming, to display in a label.
Since there is no method such as "regionISChangingAnimated", but only WillChange and DidChange, I start a timer at WillChange and invalidate it at DidChange. The timer calls a method (updateElevationLabel) that calculates the altitude of the camera above the map.
However, since camera.altitude is not calculated until regionDidChange is called, use the zoomscale and the starting height of the map (zoomscale = 1.0 does not always equal altitude = 0m, it depends on where you are in the world) to calculate the current height. Starting height is a float in the method below, set it once on load and for each region change.
Finally you can change the format of the altitude, e.g. from km from m beyond a certain altitude (10'000 metres below).
For the oldschool: 1m = 3.2808399 ft.
-(void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated {

    if (showsElevation) {

    //update starting height for the region
    MKMapCamera *camera = map.camera;
    CLLocationDistance altitude = camera.altitude;
    MKZoomScale currentZoomScale = map.bounds.size.width / map.visibleMapRect.size.width;
    float factor = 1.0/currentZoomScale;
    startingHeight = altitude/factor;

    elevationTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
                                                      target:self
                                                    selector:@selector(updateElevationLabel)
                                                    userInfo:Nil
                                                     repeats:YES];
    [elevationTimer fire];

    }
}

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {

    [elevationTimer invalidate];
}

-(void)updateElevationLabel {

//1. create the label
if (!elevationLabel) {
    elevationLabel = [UILabel new];
    [elevationLabel setFrame:CGRectMake(0, 18, 200, 44)];
    [elevationLabel setBackgroundColor:[UIColor redColor]];
    [self addSubview:elevationLabel];
}

//2. grab the initial starting height (further updated on region changes)
if (startingHeight == 0) {
    MKMapCamera *camera = map.camera;
    CLLocationDistance altitude = camera.altitude;
    MKZoomScale currentZoomScale = map.bounds.size.width / map.visibleMapRect.size.width;
    float factor = 1.0/currentZoomScale;
    startingHeight = altitude/factor;
}

//3. get current zoom scale and altitude, format changes
MKZoomScale currentZoomScale = map.bounds.size.width / map.visibleMapRect.size.width;
float altitude = startingHeight * (1/currentZoomScale);
if (altitude>10000) {
    altitude = altitude/1000;
        [elevationLabel setText:[NSString stringWithFormat:@"%.1fkm", altitude]];
} else {
        [elevationLabel setText:[NSString stringWithFormat:@"%.0fm", altitude]];
}

}

Answer: From Apple's docs on MKMapView's regionWillChangeAnimated: method (emphasis mine):

This method is called whenever the currently displayed map region
  changes. During scrolling, this method may be called many times to
  report updates to the map position. Therefore, your implementation of
  this method should be as lightweight as possible to avoid affecting
  scrolling performance.

Sounds like you should be able to use this method continuously as the map view scrolls, which solves part of your problem - so when that method is called, take a look at (I'm guessing here) the mapview's region attribute and derive your map scale from that.
Comment: Contrary to what the docs say, this method is not continuously called but rather once when the zoom starts as stated in the original post.


How to Add Block with Page on the same view?

Question: Initially, I have displayed the contents in the Block on View. Now I am trying to display Taxonomy Term in the Page ,with Block on the same view.
There is a ADD button in the View, if I add the page for Taxonomy Term in that view, It's showing the same content information for the Page.
How do I add Taxonomy Term for Page and Content for Block on the same View.
Please anyone help me how to sort out this problem.
Comment: If I understand correctly, why don't you try 'Attachment' option from the list?
Answer: In Views, click on +Add button and select Attachment. (This part is optional, if you have a view block already created you can just attach that).
Make your attachment look like your block.
Now go to your page view in the FOOTER add Global: View area and select your attachment or block.
Comment: Oh, you're fast. I just provided this as a comment. ;)
Comment: I have done your instruction , but there is no change happened in the view. Its still showing only the content of Block


javascript location.reload doesn't reload the page in a wrong way

Question: I'm trying to refresh a page every time a user click the button so the page is set back to source code. but the location.reload() is executed after the code, and not at the beginning.
btn.addEventListener("click", () => {
      location.reload()
      //code...
}

Why does not reload the page immediately when the button is clicked, but only when the function ended?
Is there another way to set the page back to the source code?
Comment: You could add a `return;` after `location.reload()` to stop the other code. I guess `location.reload()` is non-blocking and triggers a browser function.
Comment: is there another way to do it, because also with return doesn't work
Comment: As jabaa said, put a "return;" after the location reload. If it is the case, the code should not have any other code because it will destroy everything. So, your problem here is the logic, if there are any code that must be executed after refresh you must put it on onload() function and clean the code...
Answer:
why does not reload the page immediately when the button is clicked but only when the function ended?

Because JavaScript blocks navigation.
If it didn't, then the page would reload and the rest of the function wouldn't run at all (because the page it was running in has been destroyed and a new version loaded instead).
If you want to cause the page to reload and then a function to run on the new page, then you need to pass the instruction to run that function to the newly reloaded page (e.g. via sessionStorage).
When the page loads (e.g. wait for a DOMContentLoaded event), check for the instruction, act on it if needed, then delete the instruction so it won't trigger automatically next time the page loads from another mechanism).


Uniform Convergence Implied By Converging Sum

Question: Let $T>0$ and $$f_n : [0,T] \rightarrow \mathbb{R} $$ be a sequence of continuous functions. Furthermore, let
$$ \sum_{k = 0}^{\infty} \sup_{t \in [0,T]} \lVert f_{k+1}(t) - f_{k}(t) \rVert < \infty. $$
Does this already imply, that there exists a continuous function
$$f : [0,T] \rightarrow \mathbb{R} $$
such that $(f_n)$ converges uniformly to $f$ on $[0,T]$?
Answer: Yes. For $n <m$ we have $|f_n(t)-f_m(t)| \leq |f_n(t)-f_{n+1}(t)|+|f_{n+1}(t)-f_{n+2}(t)|+\cdots+|f_{m-1}(t)-f_m(t)|$. Can you verify from this that $\{f_n\}$ is uniformly Cauchy. This would then show that $f_n$ converges uniformly to a function $f$ which is necessarily continuous.


can someone just quickly explain the notation here, thank you

Question: enter image description here
$$\boxed{\vec r=r\,\hat r}$$
thats all thanks
Comment: Absent context, there is no way to guess.  Generally speaking, notation that appears in a reference ought to be defined there.
Comment: a vector ($\overrightarrow r$) can be thought of as the product of its length ($r$) and a unit vector in the same direct ($\hat r$).
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comment: The $r := \left\Vert \overrightarrow{r} \right\Vert_2 $ is the length of the vector, $\hat{r}$ is the normalized version of $\overrightarrow{r}$ - so a vector of length 1 pointing in the same direction. So this says that a vector is its direction vector scaled up to its length. Note that this is all just convention an in other contexts could be very different
Comment: While this is a very common notational convention in physics, which is why three people were able to immediately give an answer despite the criticism, for any similar questions in the future, you should at the very least tell where you encountered the notation. And almost certainly, lulu is correct that simply searching in your source would have found the definition.
Answer: Vector $\vec{r}$ is in length r in the direction of the unit vector $\hat{r}$ .
Comment: This question goes against our [quality standard policy](https://math.meta.stackexchange.com/q/33508). Instead of posting an answer, you should encourage the person who posted the question to improve it.


Graph theory with trees and adjacency matrix

Question: For $n \in \Bbb N$ we define the set $\Bbb Z_n = \{1, 2, \ldots , n - 1\}$ and on this set we define the modular product as follows:
For $x, y, z \in \Bbb Z_n : (x\cdot y = z) ⇔ (x\cdot y \equiv z \pmod{n})$.
In other words, we get the number $z$ by computing the product of $x$ and $y$ as the ordinary product of two natural numbers and then calculating the remainder of this product after dividing by $n$.
Examples for $n = 5$ and different values of $x$ and $y$:
in $\Bbb Z_5 : 3\cdot 4 = 2 , 2\cdot 3 = 1 , 2\cdot 4 = 3 \ldots$
Problem: We construct a graph $G$ such that its vertices are elements of the set $\Bbb Z_{101}$ and the two vertices corresponding to the elements $x$ and $y$ are connected by an edge if and only if $x\cdot y = 1$
in the sense of the modular product defined above.
a) Is the graph $G$ ordinary?
b) Is the graph $G$ continuous?
c) Is the graph of $G$ a tree?
d) What will be the sum of all the numbers in the adjacency matrix of graph $G$?
Comment: Interesting homework problem. What are your thoughts on it? What have you tried? Where are you stuck?
Comment: honestly, I wrote a script to find all the possible solutions, and I found that there are 50 edges and 2 loops. so the graph isn't ordinary, because there are loops, and it isn't continuous because the edges are just between the pairs  --> it also isn't a tree
Comment: And the sum of all numbers is 102(2*50for the edges +2*1 for the loop),but I can't say that this is the solution, because my program said so
Comment: That's a good attempt. Please edit your question to add your attempts : until then, I will edit it to cover the MathJax.
Answer: Suppose $[x] \in \mathbb{Z}_n$ such that $gcd(x,n) = 1$.
By Bézout's Identity there exists $a,b \in \mathbb{Z}$ such that $xa + nb = 1$. Therefore $xa \equiv 1 \pmod {n}$, and $[x][a] = [1]$ in $\mathbb{Z}_n$.
Now if there exists $[a],[b] \in \mathbb{Z}_n$ such that $[x][a] = [x][b] = [1]$, then we have
$$ a \equiv a(xb) \equiv (ax)b \equiv b \pmod{n} $$
Hence $[a] = [b]$.
In summary, if $[x] \in \mathbb{Z}_n$ with $gcd(x,n) = 1$, there exists a unique element $[x]^{-1} \in \mathbb{Z}_n$ such that $[x]^{-1}[x] = [x][x]^{-1} = [1]$. We call $[x]^{-1}$ the multiplicative inverse of $[x]$.
Therefore if $p$ is a prime number, then every non-zero element of $\mathbb{Z}_p$ has a unique multiplicative inverse. Since $101$ is a prime number we can use this fact to understand the structure of the graph $G$.
The vertices of $G$ are the non-zero elements of $\mathbb{Z}_{101}$ and the edges of $G$ are just the multiplicative inverse pairs of the vertices. That is,
$$V(G) = \{[x] \in \mathbb{Z}_{101} \mid [x] \neq [0] \} $$
$$E(G) = \{ \{[x],[x]^{-1} \}  \mid [x] \in V(G) \} $$
Notice that $[1]$ and $[p-1]$ are multiplicative self-inverses in $\mathbb{Z}_p$. Furthermore, none of the remaining elements of $\mathbb{Z}_p$ are multiplicative self-inverses. To see this, let $x \in \mathbb{Z}$ such that $0 < x < p$ and $[x]^2 = [1]$. Then $x^2 \equiv 1 \pmod{p}$, and by definition $p \mid x^2 - 1 = (x-1)(x+1)$. Since p is prime, $p \mid (x-1)$ or $p \mid (x+1)$. But this is only possible if $x = 1$ or $x = p-1$.
Therefore $G$ has exactly two loops, and they are at the vertices [1] and [100]. The remaining $98$ vertices are adjacent to exactly one other distinct vertex. This gives a complete picture of the structure of $G$. The answers to your questions can be readily deduced from this.


apexcharts range bars not displayed correctly

Question: I'm trying to display a Range Bar Chart with AppexCharts for team due date tasks (2 tasks or above).
every task can have multiple bars
if the number of bars in each task is more than 2 the bars of each task get into each other
please take a look at this example that can explain my point clearly .
Thank you .
var options = {
          series: [
             {
            name: 'task1',
            data: [
                {
                x: 'Team Health',
                y: [
                  new Date('2021-03-01').getTime(),
                  new Date('2021-03-02').getTime()
                ]
              },
                   {
                x: 'Team Health',
                y: [
                  new Date('2021-03-02').getTime(),
                  new Date('2021-03-05').getTime()
                ]
              },
                 {
                x: 'Team Health',
                y: [
                  new Date('2021-03-01').getTime(),
                  new Date('2021-03-07').getTime()
                ]
              },
                   {
                x: 'Team Health',
                y: [
                  new Date('2021-03-02').getTime(),
                  new Date('2021-03-08').getTime()
                ]
              },
                    {
                x: 'Team Health',
                y: [
                  new Date('2021-03-01').getTime(),
                  new Date('2021-03-05').getTime()
                ]
              },

            ]
          },
            {
            name: 'task2',
            data: [
                {
                x: 'Team Health',
                y: [
                  new Date('2021-03-01').getTime(),
                  new Date('2021-03-10').getTime()
                ]
              },

                 {
                x: 'Team Health',
                y: [
                  new Date('2021-03-01').getTime(),
                  new Date('2021-03-03').getTime()
                ]
              },

                    {
                x: 'Team Health',
                y: [
                  new Date('2021-03-3').getTime(),
                  new Date('2021-03-08').getTime()
                ]
              },

            ]
          },

        ],
          chart: {
       height:400,
          type: 'rangeBar'
        },
        plotOptions: {
          bar: {
            horizontal: true,
            barHeight: '80%',
            rangeBarOverlap: false,

           columnWidth: '10%',
          }
        },
        xaxis: {
          type: 'datetime',
             position: 'top',

        },
        stroke: {
          width: 1
        },
        fill: {
          type: 'solid',
          opacity: 0.6
        },
        legend: {
          position: 'top',
          horizontalAlign: 'center'
        }
        };

Answer: probably caused by using the same x: category
you could try prepending the task name
  name: 'task1',
  data: [
    {
      x: 'task1: Team Health',  // <-- prepend task name here
      y: [
        new Date('2021-03-01').getTime(),
        new Date('2021-03-02').getTime()
      ]
    },

Comment: see example [here](https://codepen.io/WhiteHat1999/pen/NWwqJxm)


Forçar que pelo menos um campo seja obrigatorio

Question: Tenho 4 CheckBox no meu formulário HTML, estou trabalhando nas validações somente com Jquery.Validate, existe um modo de que eu defina que pelo menos 1 desses checBox esteja acionado?
Alguma propriedade do validate? Ou somente criando uma função na raça?
Achei alguma coisa sobre aqui Aparentemente a solução parece pratica e viavel, so que no meu caso não tenho um nome para o grupo de checkedbox
Meu código está assim:
Você conversou com quem?
   <input type="checkbox" name="Diretor" id="Diretor" />Diretor
   <input type="checkbox" name="Vice" id="Vice" />Vice-Diretor
   <input type="checkbox" name="Coordenador" id="Coordenador" />Coordenador
   <input type="checkbox" name="Nenhum" id="Nenhum"  />Não conversei com ninguem

Answer: Acho que o que precisa é o método require_from_group que valida se um elemento num grupo estiver preenchido.
Na página do plugin (link em cima) tem esse exemplo:
$( "#myform" ).validate({
  rules: {
    mobile_phone: {
      require_from_group: [1, ".phone-group"]
    },
    home_phone: {
      require_from_group: [1, ".phone-group"]
    },
    work_phone: {
      require_from_group: [1, ".phone-group"]
    }
  }
});

No seu caso o código podia ser assim: http://jsfiddle.net/n1581gkx/1/
e precisa então de ter estes ficheiros carregados:

Comment: adaptei alguns negocios aqui e aparentemente funcionou, enfim, agradecido velho :)
Comment: kkkk o que eu não gostei foi desse phone-group . . . ele vem da [biblioteca]?(http://jqueryvalidation.org/files/dist/additional-methods.min.js)
Comment: @MarceloBonifazio adaptei o jsFiddle para usar o seu HTML. Mas vai ter de juntar essa biblioteca sim.
Comment: da esse erro: Uncaught TypeError: Cannot read property 'param' of null
na linha 4 do jquery.validate.min.js
Comment: @MarceloBonifazio pode adaptar o meu jsFiddle com o seu código e colocar aqui um exemplo do jsFiddle com o erro?
Comment: velho, o problema é que aqui na empresa usamos bibliotecas padrões, não podemos ficar adaptando desse modo rs tipo, o jquery que usamos é o v1.4.2 ainda p.exp.... ai ficamos meio que presos com nossa tecnologia :(
Comment: @MarceloBonifazio então faça um validate customizado com JS simples... tipo `if( !$('.phone-group').filter(function(){ return this.checked; }) ) return false; // caso nenhum checkbox clicado`


Can a -2 Log likelihood be calculated with only one model?

Question: I am using the glmfit function in MATLAB. The function only returns the deviance and not the log likelihood. I understand that the deviance is basically twice the difference between the log likelihoods of the models but what I don't get is I am only using glmfit to create one model, but somehow I am getting a deviance.

Doesn't calculation of the -2 Log likelihood require 2 models?
How can the deviance be analysed when there is only one model?

Another question I am having is say I did have two models and that I was comparing them using log likelihood test. The null hypothesis would be the first model and the alternative hypothesis would be the second model. After getting the log likelihood test statistic would I check it against the chi squared cdf to determine the p-value? Am I right that if it is less than the alpha level I would reject the null and if it is greater I would fail to reject the null?
Comment: To your first question. Yes there are 2 models. The other one is a perfect model with log likelihood = 0. In this way your deviance is just equal to your model's log likelihood.
Comment: would it be perfect model - my model, or my model - perfect model? And would dividing it by -2 really give me the log likelihood of the model and I could use that to do the log likelihood test?
Answer: The statistical term deviance is thrown around a bit too much. Most of the time, programs return the deviance
$$ D(y) = -2 \log{\{p(y | \hat{\theta})\}},$$
 where $\hat{\theta}$ is your estimated parameter(s) from model fitting and $y$ is some potentially observed/observable occurrence of the random quantity in question.
The more common deviance that you refer to would treat the deviance above as a function of two variables, both the data and the fitted parameters: $$ D(y,\hat{\theta}) = -2\log{\{p(y|\hat{\theta})\}}$$
and so if you had one $y$ value but two competing, fitted parameter values, $\hat{\theta}_{1}$ and $\hat{\theta}_{2}$, then you'd get the deviance you mentioned from $$-2(\log{\{p(y|\hat{\theta}_{1})\}} - \log{\{p(y|\hat{\theta}_{2})\}}).
$$
You can read about the Matlab function that you mentioned, glmfit(), linked here. A more fruitful, though shorter, discussion of the deviance is linked here.
The deviance statistic implicitly assumes two models: the first is your fitted model, returned by glmfit(), call this parameter vector $\hat{\theta}_{1}$. The second is the "full-model" (also called the "saturated model"), which is a model in which there is a free variable for every data point, call this parameter vector $\hat{\theta}_{s}$. Having so many free variables is obviously a stupid thing to do, but it does allow you to fit to that data exactly.
So then, the deviance statistics is computed as the difference between the log likelihood computed at the fitted model and the saturated model. Let $Y=\{y_{1}, y_{2}, \cdots, y_{N}\}$ be the collection of the N data points. Then:
$$DEV(\hat{\theta}_{1},Y) = -2\biggl[\log{p(Y|\hat{\theta}_{1})} - \log{p(Y|\hat{\theta}_{s})} \biggr]. $$
The terms above will be expanded into summations over the individual data points $y_{i}$ by the independence assumption. If you want to use this computation to calculate the log-likelihood of the model, then you'll need to first calculate the log-likelihood of the saturated model. Here is a link that explains some ideas for computing this... but the catch is that in any case, you're going to need to write down a function that computes the log-likelihood for your type of data, and in that case it's probably just better to create your own function that computes the log-likelihood yourself, rather than backtracking it out of a deviance calculation.
See Chapter 6 of Bayesian Data Analysis for some good discussion of deviance.
As for your second point about the likelihood test statistic, yes it sounds like you basically know the right thing to do. But in many cases, you'll consider the null hypothesis to be something that expert, external knowledge lets you guess ahead of time (like some coefficient being equal to zero). It's not necessarily something that comes as the result of doing model fitting.
Comment: @SibbsGambling In [this link](http://www.csun.edu/~msteele/classes/biometry/lectures/22_log-linear%20and%20independence_2012.pdf) there is an example with coolibah tree data showing a "full" or "saturated" model where the log-likelihood is not zero. I believe there are certain situations where the saturated model must have a likelihood of one by definition, but not in all situations.
Comment: Thank you EMS! You really helped me understand what deviance is a lot! I still have a few questions, but I am not sure how to ask them. Once I figure out how to word it I will definitely reply here.
Comment: Ok first question, how would I extract the log likelihood for the model I created from the deviance considering that matlab only gives me the deviance? Also, (I know this make me look fairly stupid but) for     p(y |θˆ2) would that be the probability of getting a certain y value from the outcome data set or the independent variables given the fitted parameter
Comment: It appears I was mistaken about Matlab's method. It computes deviance by looking at two models, and I have edited the answer above to reflect this.
Comment: +1, this is a really nice answer. I hope to see more of them in the future.
Comment: Thanks for the nice explanation, but shouldn't the log-likelihood of the saturated model be just $0$? So the log likelihood is just $-0.5\times$ the deviance? @gung Will greatly appreciate if an authority like you can confirm this. :-) Thanks!


Set that is not well-ordered

Question: I want to find a set that is transitive, every non-empty subset of it has $\in$-maximum and is not $\in$-well ordered.
Any hint?
Comment: Please specify if ouy speak about *maximal* or *greatest* elements. I.e. $\forall x\ne m\colon \neg(m\in x)$ or $\forall x\ne m\colon x\in m$? Chris Eagle gives a valid example with *maximal*, the others show non-existence with *greatest*.
Comment: @HagenvonEitzen Why is there even room for confusion? Isn't $\in-\text{maximum }$ clear enough?
Comment: @GitGud Yes, *maximum* is, but as discussions below show, there is often confusion about the distinctions between *maximal* and *maximum/greatest*. A clarification won't have hurt.
Answer: Let $S$ be a non-empty set such that every non-empty subset of it has an $\in$-maximum.
Then for $x,y \in S$ with $x \ne y$, we have either $x \in y$ or $y \in x$ because by hypothesis, $\{x,y\}$ has an $\in$-maximum. Therefore, $(S, \in)$ is a linear order. In the degenerate case that $S$ has only one element, clearly $(S, \in)$ is also a linear order.
Now suppose that a non-empty subset $T \subseteq S$ had no $\in$-smallest element. By the Axiom of Foundation, $T$ does have an $\in$-minimal element, i.e. an $x \in T$ with $x \cap T = \varnothing$.
But this then means that for all $y \in T$, we have $y \notin x$. Since $\in$ is a linear ordering on $S$, we conclude that $x \in y$ (if $x \ne y$). But then $x$ is an $\in$-smallest element; hence $S$ is well-ordered by $\in$.
Therefore, no set $S$ matching your conditions can exist. Note that the assumption that $S$ is transitive was not necessary to arrive at this conclusion.
Comment: It explains that I haven't been able to find a such set. Thank you very much.
Comment: One could find such sets if one drops the axiom of foundation.
Answer: I'm not an expert in Set Theory, but I'd say that if you're working in $ZF$, i.e, in particular, if you assume the Axiom of Foundation, then you can't find an example of what you're looking for. Indeed, if a set $x$ is transitive and each of its non empty subsets has $\in -$ maximum element, then trivially $x$ is totally (linearly) ordered by the membership relation. But in $ZF$ we can prove that a set $x$ is an ordinal (defined as a transitive set which is well-ordered by membership) if and only if it is transitive and totally ordered by $\in$ (you might try to show this as an exercise), and then there's nothing more to say.
Answer: $\{\varnothing,\{\varnothing\},\{\{\varnothing\}\}\}$
Comment: I think the subset $\{\varnothing,\{\{\varnothing\}\}\}$ has no $\in$-maximum.
Comment: Yes, but neither is a maximum, i.e. _greatest_ element.
Comment: Both elements are maximal.
Answer: (I argue on the basis of $\sf{ZF}$).
Let $X$ be a set such that every nonempty subset has an $\in$-maximal element (or more precisely: greatest element).
Assume that $\in$ is not a wellorder on $X$.
As $a,b\in X$ implies that $\{a,b\}$ has an $\in$-maximal element, exactly one of $a\in b$, $a=b$, $a\ni b$ holds (the Axiom of Foundations forbids that two of these hold concurrently).
For $a,b,c\in X$ with $a\in b$ and $b\in c$, it is again the Axiom of Foundation that forbids $a=c$ and $c\in a$, hence $a\in c$. We conclude that $\in$ is a linear order on $X$.
Then the inverse relation $\ni$ is a well-order, hence there is an ordinal $\alpha$ and a bijection $f\colon \alpha\to X$ that inverts the order, i.e. $a\in b$ implies  $f(b)\in f(a)$.
Then a nonempty subset of $X$ without minimal element corresponds to a nonempty subset of $\alpha$ without maximal element.
For such a subset to exist, we need $\alpha\ge\omega$.
The Axiom of Foundation demands that $S:=\{f(n)\mid n\in\omega\}$ has an element $f(n)$ with $f(n)\cap S=\emptyset$. As $f(n+1)\in f(n)\cap S$, we get a contradiction.
No such $X$ can exist (and we didn't even use transitivity).
Comment: Minor nitpick: If $a,b$ are incomparable, then both would be considered $\in$-maximal elements of $\{a,b\}$, though neither would be a $\in$-maximum element in that case. Foundation guarantees that *at most* one of $a\in b$, $a=b$, $a\ni b$ holds. We need a $\in$-maximum condition to know that *at least* one holds ($\in$-maximal isn't enough).

Set that is not well-ordered


How can i certify cabling with a cat5 certifyer if the cabling is mixed cat5 and cat6 thanks

Question: Hello I'm getting ready to certify some cabling and realized it is mix matched cat5 and 6 but my certifier is only for cat5. So I wonder if I needed a speacial certifier to do that thanks.
Answer: If you need to ask you shouldn't be  allowed to certify either cat5 or cat6.
Simple testers (for home use) only detect if all wire pairs connect and if so are wired correctly in the regard that pin 1 on one end is also pin 1 on the other end. (In that regard there is no difference between cat 5 and 6 by the way.)
Certification requires much more such as actually measuring the performance of the structured cabling and connections and subsequently generating test reports that verify if the cable length meets the standards and requirements for a certain industry standard or not.
Tooling that only supports cat5 can never be used to certify cat6 as cat6. Cat 6 needs to support higher frequencies (250 MHz compared to 100 MHz for cat 5e) and has much stricter requirements with regards to allowed crosstalk and attenuation. When your tooling can't measure that, you can only measure if a cable length meets the requirements for Cat 5.
Comment: I agree, automated tester costs really a couple thousands


The special case of the Riemann lebesgue lemma

Question: I'm trying  to prove the following
Let $A$ be a measurable subset of $[0,2\pi]$
$$\lim_{n\to \infty} \int_A e^{inx} \, dx=0$$
There is a hint "this is the special case of the Riemann Lebesgue lemma"
But I have no idea how to approach this problem using the hint. Since the problem is in Hilbert space chapter, I have considered $e^{inx}$  as a element of orthnormal basis of $L^2$ space. But it's of no use I think.
Can I get some hints? Thank you:)
Comment: To apply the Riemann Lebesgue lemma, you just need that $f\in L^1(\mathbb{R})$ where the integrand is $f(x)e^{inx}$.  In this case, $f(x) = \chi_A(x)$, which is $L^1$ for this $A$.
Answer: The Riemann–Lebesgue lemma says that if $\displaystyle\int_{\mathbb R} |f(x)| \, dx < \infty$ then $\displaystyle\lim_{n\to\infty} \int_{\mathbb R} f(x) e^{inx}\,dx = 0$.
Since the set $A$ is bounded, we have $\displaystyle\int_{\mathbb R} 1_A(x)\,dx = (\text{the Lebesgue measure of A}) <\infty$ (where $1_A$ is the indicator function of $A$, taking the value $1$ at arguments in $A$ and $0$ elsewhere).  Therefore, by the Riemann–Lebesgue lemma, $\displaystyle \lim_{n\to\infty} \int_{\mathbb R} 1_A(x) e^{inx}\,dx=0$, or, in other words $\displaystyle\lim_{n\to\infty} \int_A e^{inx} \, dx = 0$.
Comment: Right. Thank you so much !! :) Then I'm wandering why this problem is in hilbert space chapter. Is Riemann  Lebesgue lemma related to hilbert space?


HTML button link is not clickable

Question: I inherited this pretty messy site to revamp for a client. There's alot of weird stuff in the css, but I can't figure out this one. The "buttons" on the homepage (actually links) are not clickable and I can't figure out why. Here's the code.
HTML
LEARN MORE

CSS
a {
    background: transparent;
}

a {
    color: #01a1dd;
    text-decoration: none;
    line-height: inherit;
}

.btn {
    display: inline-block;
    font-size: 14px;
    text-transform: uppercase;
    font-weight: 600;
    text-align: center;
    border-radius: 3px;
    padding: 12px 29px 12px 29px;
    letter-spacing: .25px;
    position: relative;
}

.btn.orange {
    color: #f98803;
    border: 2px solid #f98803;
}

.btn.solid {
    background: #f98803;
    color: white;
    padding-right: 45px;
}

All the other buttons on the site are clickable, just not these two on the homepage.
Here's a codepen with the code, and the same issue. https://codepen.io/kathryncrawfor/pen/NwLRoP
Comment: The attribute is `href`, not `src`. Voting to close as a typo. A [validator](https://validator.nu) would have identified this problem.
Comment: Well, this is facepalm moment.
Answer: But you are using src and not href in the link tag, try to modify
LEARN MORE

with
LEARN MORE

Answer: I think you meant to use href instead of src.
Answer: You used wrong attribute to set the link. You should use href.
Link text.
Answer: use href instead src

a {
    background: transparent;
}

a {
    color: #01a1dd;
    text-decoration: none;
    line-height: inherit;
}

.btn {
    display: inline-block;
    font-size: 14px;
    text-transform: uppercase;
    font-weight: 600;
    text-align: center;
    border-radius: 3px;
    padding: 12px 29px 12px 29px;
    letter-spacing: .25px;
    position: relative;
}

.btn.orange {
    color: #f98803;
    border: 2px solid #f98803;
}

.btn.solid {
    background: #f98803;
    color: white;
    padding-right: 45px;
}

Make your IT Partnerships Productive

I AM AN
IT PROFESSIONAL

            LEARN MORE

I AM A
SOLUTION PROVIDER

            LEARN MORE

Answer: The anchor Tag needs a HREF attribute for it to work as a link
LEARN MORE

the above should work

HTML button link is not clickable


How to find the covariance of sample mean and sample variance $Cov(M,S^2)$ for Poisson distribution?

Question: Suppose that I have a Poisson distribution $P(\lambda)$.
Let $X_1,X_2,\ldots,X_n$ be independent random variables from the distribution mentioned above.
Let us define sample variance $S^2 = \frac{1}{n-1} \sum (X_i - M)^2 $ and sample mean as $M = \frac{1}{n}\sum X_i $.
I want to find the covariance, $Cov(M,S^2)$. I've seen from this answer that when the distribution is symmetric, they are uncorrelated, which makes it zero. I also know that for large $\lambda$ values Poisson distribution is very close to Gaussian distribution, thus becoming symmetric, and probably the covariance is close to zero.
However, I want to find the exact value of $Cov(M,S^2)$, as I am working with small values of $\lambda$

Currently I tried the following:
$Cov(M,S^2) =E( (M-\lambda) (S^2-\lambda) ) = E(MS^2)-\lambda E(M) - \lambda E(S^2) + \lambda^2$
Thus,
$Cov(M,S^2) = E(MS^2) - \lambda^2 - \lambda^2 + \lambda^2  = E(MS^2) -\lambda^2$
I am having trouble with calculating $E(MS^2)$.
Any idea?
Comment: We can expand the square in the definition of $S^2$ to get a more simple expression, then express $E(MS^2)$ as a double sum. You will have to distinguish when the indexes are the same or not.
Comment: A square is missing in the definition of $S^2$, isn't it?
Comment: @DavideGiraudo, you are right, I made a typo. Thanks for pointing that out.
Answer: One can solve this more generally. For any random variable whose moments exist, the covariance between the sample mean $M$ and the sample variance $S^2$ is:
$$\text{Cov}(M, S^2) = \frac{\mu_3}{n}$$
where $\mu_3$ denotes the $3^{\text{rd}}$ central moment of the parent random variable $X$.
If $X \sim \text{Poisson}(\lambda)$, then $\mu_3 = \lambda$, so the answer is $\large\frac{\lambda}{n}$.
Comment: Could you either provide a reference to the general result or outline a proof?
Answer: Let us first center everything, using $\bar X_k=X_k-\lambda$ and $\bar M=M-\lambda$. Then
$$
\mathrm{Cov}(M,S^2)=\mathbb E(\bar MS^2)=\mathbb E(\bar X_1S^2)=\frac1{n-1}\mathbb E(\bar X_1U),
$$
where
$$
U=\sum\limits_{k=1}^n(\bar X_k-\bar M)^2.
$$
Note that $U$ is a linear combination of products $\bar X_k^2$ and $\bar X_k\bar X_i$ for $i\ne k$. Amongst these products, many will not contribute to the expectation of $\bar X_1U$ since $\mathbb E(\bar X_1\bar X_k\bar X_i)=0$ for every $k\ne i$ and $\mathbb E(\bar X_1\bar X_k^2)=0$ for every $k\ne1$.
Hence, one needs only the coefficient of $\bar X_1^2$ in $U$, which is $c_n=\left(\frac{n-1}n\right)^2+(n-1)\frac1{n^2}=\frac{n-1}n$. This yields $\mathbb E(\bar X_1U)=c_n\mathbb E(\bar X_1^3)$ and $\mathrm{Cov}(M,S^2)=\frac1{n-1}c_n\mathbb E(\bar X_1^3)=\frac1n\mathbb E(\bar X_1^3)$.
Finally, the third central moment of the Poisson distribution with parameter $\lambda$ is $\mathbb E(\bar X_1^3)=\lambda$ hence
$$
\mathrm{Cov}(M,S^2)=\frac\lambda{n}.
$$
Comment: The argument needs some refining. When $\lambda\to\infty$, what happens is really that the **scaled** and centered versions are more and more gaussian-like, hence symmetric. The proper scaling is to center each $X_k$ and to divide it by $\sqrt{\lambda}$ hence one should divide $M$ by $\sqrt{\lambda}$ and $S^2$ by $\lambda$. Thus, $\mathrm{Cov}(M,S^2)/\lambda^{3/2}$ should go to zero when $\lambda\to\infty$ (and it does).
Comment: Thanks for your answer. I haven't fully understood it, and it will take me some time to analyze what you wrote, yet I have a question. I had an intuition that the covariance should get close to zero (because it becomes almost like Normal distribution), when \lambda becomes very large. From your answer, it looks like it grows when \lambda grows. Is my intuition wrong? Thanks again
Comment: @Nan For every constants $x$ and $y$, $\mathrm{Cov}(X-x,Y-y)=\mathrm{Cov}(X,Y)$. Is this your question?
Comment: Hi Did, It's a very late reply, not sure whether you will see it or not. Intuitively, I can see that after centering the variables, we did not change $S^2$, and we did not change the $Cov(\bar{X},S^2)$. But I am not sure how to show that the covariance doesn't change by centering the variable.
Comment: @Did Yes! Thank you so much!


differentiability of $(x,y)\mapsto\max\{x,y\}$

Question: At what points are the partial derivatives of the following function not defined? And how to check for the same?
$$f(x,y) = \max \{x,y\}$$
I was able to find the partial derivatives of $f$ for $x=y$ (in which case they do not exist), but I don't know how to take the limit of the partial derivative expression when $x>y$ or $x< y$ .
Comment: How did you find the partial derivatives for $x=y$ if they don't exist??
Comment: @JackLee I guess OP means that they proved that the partial derivative do not exist at $(x,x)$.
Comment: well for every $x<y$ there is a small neighborhood of $x$ where $f(x,y)=y$ and so $\partial_x f(x,y)=0$ and $\partial_y f(x,y)=1$ for $x<y$.
Answer: If it could help
we can observe that
$$\max(x,y)=\frac 12(x+y+|x-y|)$$


What AIC is necessary to select this model?

Question: I have read this page but am a little confused and I think a real example might help solidify the idea in my mind regarding how to use the AIC in model selection.
Equivalence of AIC and p-values in model selection
Say I have two nested models (that differ in 6 parameters) - these are from real data. The simpler model is mod1 and the more complex, mod2.
<code>> AIC(mod1)
[1] 191.2335
> AIC(mod2)
[1] 190.5257

> BIC(mod1)
[1] 206.9418
> BIC(mod2)
[1] 225.084

> lmtest::lrtest(mod1,mod2)
Likelihood ratio test

Model 1: y ~ x1 + x2 + x3 + x4
Model 2: y ~ x1(NLR) + rcs(x2) + x3 + x4
  #Df  LogLik Df  Chisq Pr(>Chisq)
1   5 -90.617
2  11 -84.263  6 12.708    0.04792 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
</code>
The p-value from the LR test would suggest that the model fit is compromised with the simpler model (and thus mod2 is better).
The AIC is lower for mod2 but not by a margin that I think suggests it's the optimal fit. What I want to know is how much lower (on 6 df) does the AIC need to be for mod2 (the more complex model in this case) to justify the extra parameters? Is it 6 x 2 = 12 units?
Clearly the BIC would suggest mod1.
Answer: AIC takes model complexity into account by construction. You do not need to adjust for that any further. If you like adjusting for model complexity manually, you can compare likelihoods and adjust them. But then you end up with... AIC (or BIC, or some other IC)! So there is really no point in doing that by hand if you have AIC available.
If the AIC of model 2 is lower than the AIC of model 1 (AIC2<AIC1), then the estimated expected likelihood of a new observation from the same data generating process is higher in model 2. If that is what you are looking for, select model 2. If you are looking for something else, perhaps AIC is not the criterion you want to use.
(You may also consider model averaging, especially if the differences in AICs between the models are not too large.)
Comment: So it is truly nothing more than picking the model with the lowest AIC (if that's want you want to do). So if you have a model with an extra parameter that is lower on the  AIC by only a fraction, that is still a better fit based on AIC? I read somewhere that AIC for a more complex model with 1 extra df should be lower by 2 (and that is equivalent to p = 0.15). Clearly I have more work to do to understand this.
Comment: @LucaS, AIC tells you which model is best in a particular sense. Would you rather select another model that is worse in that specific sense? I guess not. On the other hand, you can consider model averaging, especially if the differences in AICs between the models are small. AIC does not tell you cannot do that. It just serves its purpose, and it is up to you whether you find that relevant. Regarding *I read somewhere that AIC for a more complex model with 1 extra df should be lower by 2 (and that is equivalent to p = 0.15).*, it is the loglikelihood, not AIC.
Answer: How big a difference in AIC you need to be able to say 'mod2 is better than mod1' is going to depend a bit on your field, your data, your sample sizes etc. Generally, in ecology, models are considered approximately equal (in terms of performance) if the AIC value for two models is within 2 AIC.
As you pointed out, BIC favours mod1 over mod2 because BIC is a system of model evaluation that more strongly 'penalizes' having more variables/ predictors, and mod1 has fewer predictors. This results in more conservative approach. Choosing the appropriate metric will depend on your data and your question, but this paper may be helpful: Model selection for ecologists: the worldviews of AIC and BIC.


Order of execution of print with pthreads in Linux

Question: I'm using C and I want to get the String "ABCABCABCABCABCABC" in the output screen through multithreading. One thread displays the 'A' character, the second one displays the 'B' and the third one displays the 'C'. If I compile the following code:
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

#define cantidad_impresion_letra 6
pthread_mutex_t semaforo = PTHREAD_MUTEX_INITIALIZER;

void *escribirA(void *unused){
    int i;
    for(i=0;i<cantidad_impresion_letra;i++){
        pthread_mutex_lock(&semaforo);
        printf("A");
        pthread_mutex_unlock(&semaforo);
    }
}

void *escribirB(void *unused){
    int i;
    for(i=0;i<cantidad_impresion_letra;i++){
        pthread_mutex_lock(&semaforo);
        printf("B");
        pthread_mutex_unlock(&semaforo);
    }
}

void *escribirC(void *unused){
    int i;
    for(i=0;i<cantidad_impresion_letra;i++){
        pthread_mutex_lock(&semaforo);
        printf("C");
        pthread_mutex_unlock(&semaforo);
    }
}

int main(){
    pthread_t thread1, thread2, thread3;

    pthread_create(&thread1,NULL,escribirA,NULL);
    pthread_create(&thread2,NULL,escribirB,NULL);
    pthread_create(&thread3,NULL,escribirC,NULL);

    pthread_join(thread1, NULL);
    pthread_join(thread2, NULL);
    pthread_join(thread3, NULL);

    return(0);
}

On Windows through Dev-C++, the console throws me: ABACBACBACBACBACBC but if I compile the same code in Linux, I get CCCCCCBBBBBBAAAAAA.
Can someone explain me this please?
Comment: With multi-threading, generally speaking you *want* the threads to work independently and in parallel. If you want a specific order, then *don't* use threads, because then you would be wasting resources.
Comment: If you must do this pointless exercise, note that you only need one thread function.  Pass an index as the pthread_create argument.  Use three condvars or semaphores so that each thread can signal the next along the chain.  The global counter/poll solution is hopele...'non - optimal' and get a lower mark.
Answer:
Can someone explain me this please?

The different output in linux has to do with the used scheduler.
man sched

Since Linux 2.6.23, the default scheduler is CFS, the "Completely Fair Scheduler".

Completely Fair Scheduler:

Each per-CPU run-queue of type cfs_rq sorts sched_entity structures in a time-ordered fashion into a red-black tree (or 'rbtree' in Linux lingo), where the leftmost node is occupied by the entity that has received the least slice of execution time (which is saved in the vruntime field of the entity). The nodes are indexed by processor "execution time" in nanoseconds.

What does that mean:
Each thread runs so fast, that the scheduler doesn't deem it necessary to perform a context switch.
There are only 6 iteration steps and an output into a buffered stream (no newline, therefore no output to the terminal until a flush occurs).
Do the test, increase the iteration steps, add more characters to the output and add a newline character (\n).
The sequence will start to change.
On my system, the sequence started to change with 200 iteration steps and 3 characters (plus \n).

I'm using C and I want to get the String "ABCABCABCABCABCABC"

1. Sequential output is best achieved through sequential execution.

use only one thread (single threaded)

2. Notify/Wait

each thread performs an iteration, signals the other thread and then waits for a signal to arrive in order to continue on the next cycle

3. Barrier
//introduce NUM_THREAD lists
char dataA[cantidad_impresion_letra];
char dataB[cantidad_impresion_letra];
char dataC[cantidad_impresion_letra];

//let the thread do their work without any disturbance
void *escribirA(void *unused){ //unused could be used to pass the lists
    int i;
    for(i=0;i<cantidad_impresion_letra;i++){
        //pthread_mutex_lock(&semaforo); //not needed
        //instead of printf("A");
        dataA[i] = 'A';
        //pthread_mutex_unlock(&semaforo); //not needed
    }
}

//same for escribirB but write into dataB
//same for escribirC but write into dataC

int main()
{
    //...
    //after joining the threads
    //collective output in any desired order
    for (int i=0; i < cantidad_impresion_letra; ++i) {
        printf("%c", dataA[i]);
        printf("%c", dataB[i]);
        printf("%c", dataC[i]);
    }
    return 0;
}

The advantages:

no lock/unlock (if the global lists are not accessed otherwise)
no waiting and broadcasting
guaranteed synchronized output
let the OS decide when it is best to yield a thread (scheduler)

Disadvantage:

more memory intensive (depends on the number of threads and the iteration steps)
Comment: The references about the scheduling are interesting for sure but I guess that the OP wanted a portable solution (at least on both Linux and Windows) to serialize the thread execution. And it is possible to make it with user space pthread API even if this is unusual to serialize threads in a multi-threaded environment (as you said).
Comment: @RachidK. Agreed, but the OP also asked for an explanation and i've tried to give one (that it is an os thing). The user Cheatah in the comments above, gave a reason not to use parallelism and the user Rachid K. presented a solution on how the desired output could be realized. So, i think there is now enough information, that the OP is able to rethink the implementation (if the increasing cost is worth it).
Comment: I agree with you: this is finally a complementary information.
Answer: You can store the order of execution in a global volatile variable named for example order which is set with the values 0, 1 and 2 circularly (thanks to an incrementation and a modulo operation). This variable is checked with a condition variable:
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

int order = 0;

#define cantidad_impresion_letra 6
pthread_mutex_t semaforo = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;

void *escribirA(void *unused){
    int i;
    for(i=0;i<cantidad_impresion_letra;i++){
        pthread_mutex_lock(&semaforo);
        while (order != 0) {
          // Wake up another thread before going to sleep
          pthread_cond_signal(&cond);
          pthread_cond_wait(&cond, &semaforo);
        }
        printf("A");
        order = (order + 1) % 3;
        fflush(stdout);
        // Wake up another thread
        pthread_cond_signal(&cond);
        pthread_mutex_unlock(&semaforo);
    }
}

void *escribirB(void *unused){
    int i;
    for(i=0;i<cantidad_impresion_letra;i++){
        pthread_mutex_lock(&semaforo);
        while (order != 1) {
          // Wake up another thread before going to sleep
          pthread_cond_signal(&cond);
          pthread_cond_wait(&cond, &semaforo);
        }
        printf("B");
        order = (order + 1) % 3;
        fflush(stdout);
        // Wake up another thread
        pthread_cond_signal(&cond);
        pthread_mutex_unlock(&semaforo);
    }
}

void *escribirC(void *unused){
    int i;
    for(i=0;i<cantidad_impresion_letra;i++){
        pthread_mutex_lock(&semaforo);
        while (order != 2) {
          // Wake up another thread before going to sleep
          pthread_cond_signal(&cond);
          pthread_cond_wait(&cond, &semaforo);
        }
        printf("C");
        order = (order + 1) % 3;
        fflush(stdout);
        // Wake up another thread
        pthread_cond_signal(&cond);
        pthread_mutex_unlock(&semaforo);
    }
}

int main(){
    pthread_t thread1, thread2, thread3;

    pthread_create(&thread1,NULL,escribirA,NULL);
    pthread_create(&thread2,NULL,escribirB,NULL);
    pthread_create(&thread3,NULL,escribirC,NULL);

    pthread_join(thread1, NULL);
    pthread_join(thread2, NULL);
    pthread_join(thread3, NULL);

    return(0);
}

Example of execution:
$ gcc order.c -o order -lpthread
$ ./order
ABCABCABCABCABCABC

Answer:
On Windows through Dev-C++, the console throws me: ABACBACBACBACBACBC but if I compile the same code in Linux, I get CCCCCCBBBBBBAAAAAA.
Can someone explain me this please?

The Linux behavior is what you should expect. Some thread has to start running first. Whichever thread it is, the other two threads will be blocked. That thread will be able to continue running for some time since there is nothing that it needs to wait for.
The behavior you see in Windows is awful -- the worst possible. Either it's keeping all three threads scheduled or it's not. If it's keeping all three threads scheduled, it's using three cores for work that can be done equally fast with just one core. If it's not keeping all three threads scheduled, then you are getting one context switch per character of output and wasting CPU time constantly populating the code and data caches because you just switched from another task.


Finite generation of modules over rings contained in other rings

Question: Let $A$ and $B$ be rings such that $A \subseteq B$ and let $M$ be a finitely generated $A$-module. Is it always the case that $M$ is also finitely generated as a $B$-module?
I ask because there is a characterisation of fractional ideals $F$ of the ring of integers of a number field $K$ which says that they are finitely generated $\mathcal{O}_K$-modules. If we then define the set $\tilde{F} = \lbrace \alpha \in K : \alpha F \subset \mathcal{O}_K\rbrace$, we are able to show that it is a finitely generated $\mathcal{O}_K$-module.
The source I'm reading makes this deduction by first showing that $\tilde{F}$ is finitely generated as a $\Bbb Z$-module, and hence also as an $\mathcal{O}_K$-module, which I presume is just because $\Bbb Z \subseteq \mathcal{O}_K$, and then the generators of $\tilde{F}$ as a $\Bbb Z$-module are just identified with their counterparts in $\mathcal{O}_K$.
Here is the particular quote which I'm having trouble understanding:

Pick a non-zero $y \in F$. Then $y\tilde{F}\subset \mathcal{O}_K$, so that $\tilde{F} \subset (1/y)\mathcal{O}_K$. Therefore, $\tilde{F}$ is a submodule of a finitely generated free $\Bbb Z$-module, so $\tilde{F}$ is a finitely generated $\Bbb Z$-module, hence finitely generated as an $\mathcal{O}_K$-module too.
Comment: Per se, $M $ doesn't have to be a $B $-module at all. But if you assume that it is, and that its $B $-module structure restricts to the given $A $-module structure, then the answer is "yes".
Answer: What if $M$ does not even have a $B$-module structure? A classical question in introduction courses is weather the module structure of the subring can be extended to a module structure on the whole ring, the answer to this is no.
For instance consider the finitely generated $\Bbb Z$-module $M=\Bbb Z / 4\Bbb Z$, this module structure can not be extended to a $\Bbb Q$-module structure, construct the element $ a=(1/2) \cdot 1 \in \Bbb Z / 4\Bbb Z$, this element has the property $a + a =1$, but no such element exists in $\Bbb Z / 4\Bbb Z$.
Comment: How does the author of the quoted example deduce that $\tilde{F}$ must also be finitely generated as an $\mathcal{O}_K$-module then? Does it have to do with the fact that $\mathcal{O}_K$ itself is a free $\Bbb Z$-module?


Equivalent definitions of markov chains

Question: I have the following 2 definitions of a Markov chain but I can't see how they are equivalent.
i) Let $X_i$ be a sequence of random variables taking values in a measurable state space $(S,A)$. This process is a discrete Markov chain iff $P(X_{n+1}\in B|\sigma(X_0,X_1,..,X_n))=P(X_{n+1}\in B|\sigma(X_n))$. I'm assuming that $$P(X_{n+1}\in B|\sigma(X_0,X_1,..,X_n))=E[1_{\{X_{n+1}\in B\}}|\sigma(X_0,X_1,..,X_n)]$$
i.e. the conditional expectation of $1_{\{X_{n+1}\in B\}}$ given $\sigma(X_0,X_1,..,X_n)$
ii) The other definition states that $P(X_{n+1}= s|X_0=x_0,X_1=x_1,..,X_n=x_n)=P(X_{n+1}= s|X_n=x_n)$ for all $s,x_0,x_1,x_2,..\in S$. Here, I suppose $$P(X_{n+1}= s|X_0=x_0,X_1=x_1,..,X_n=x_n)=\frac{P(X_{n+1}= s,X_0=x_0,X_1=x_1,..,X_n=x_n)}{P(X_0=x_0,X_1=x_1,..,X_n=x_n)}$$
How are these 2 definitions equivalent?
Edit:
From the following link: https://en.wikipedia.org/wiki/Markov_property it seems to be the case that they are not equivalent. However, if $S$ is a discrete set with the discrete $\sigma$-algebra then they are equivalent.
In this case the following link provides an explanation: Why are these two definitions of Markov property equivalent?
Comment: $\mathsf{E}[Y\mid \sigma(X)]\equiv \mathsf{E}[Y\mid X]$...
Comment: Could you elaborate please
Answer: The definitions will be equivalent IF all these random variables are discreet (i.e. their ranges are countable). The $\sigma$-algebra $\sigma(X_1,\ldots, X_n)$ is then generated by the events $\{X_i=x_i\}$.
If $X_{n+1}$ is not discreet, then $P(X_{n+1}=x_{n+1} \mid \ldots)$ could be identically zero, so it's not clear what the second definition means in that case. The first one, however, is universal.
Conditioning on the event $\{X_1=x_1,\ldots, X_n=x_n\}$ is rather problematic when the random variables involved are continuous.
Comment: By discrete you mean countable?
Comment: Yes. I clarified the answer.
Comment: why do the set $\{X_i=x_i\}$ generate the sigma algebra. The sets $\{X_i=x_i\}$ need not be measurable itself. i.e. $\{x_i\}$ need not be measurable in the sigma algebra of S
Comment: $\sigma(X_1,\ldots, X_n)$ is generated by the events $\{X_i \leq x_i\}$, by definition. In the discreet case, $\sigma(X_1,\ldots, X_n)$ is also conveniently generated by $\{X_i = x_i\}$.
Comment: I think $\sigma (X_1,..,X_n)$ is generated by $\{X_i\in B\}$ where $B\in A$. How do we know that singleton sets are in A?
Comment: If you are assuming $S=\mathbb{R}$ then yes you would be right. But S is an arbitrary (countable in your case) statespace
Comment: Not sure what $S$ is. I assumed all $X_i$s to be real-valued and defined on a probability space $(\Omega, \Sigma, P)$. Secondly, you are correct: $\sigma(X_1,\ldots,X_n)$ can also be generated by $\{X_i \in B_i\}$, with $B_i$ being a Borel set.
Comment: Thanks for the answer but in this case I cant assume that S is the set of reals
Comment: You are welcome. However, my answer won't change after replacing $\mathbb{R}$ with $\mathbb{R}^k$, $\mathbb{C}$, or similar. Note that $X^{-1}_i(x_i) \in \Sigma$, for every $x_i$, if that's what you mean by singleton sets.

Equivalent definitions of markov chains


Setting up SVN with Plesk

Question: I'm setting up a new dev webserver that is on Cent OS 6 with Plesk 10.4. I've had a look around and can't find anything about an SVN module for Plesk so am thinking of just installing SVN and manually setting up each site as a repo.
Is there anything I need to take into consideration when doing this such as permissions/usernames? Or is it okay to just go ahead and treat it like any other installation of SVN?
Answer: Okay I've managed to set up SVN on this server. I'm leaving this here in case anybody else wants to see how I did it.
I assumed that you don't need to do anything special just because Plesk is on the system and this turned out to be true.
I followed the instructions here to install and setup svn and then the instructions here to set up the repos.
NOTE: If you use the instructions from the first link then when it comes to checking out your code remotely then the correct url would be svn+ssh://username@yourhost/yourproject as the wrapper script automatically looks in /var/svn/repos/
Comment: First link is dead, unfortunately.

Setting up SVN with Plesk


A detail in this textbook's proof of the Chinese Remainder Theorem.

Question: I have a question regarding a line in this proof:
The system of congruences $x \equiv a_1 (\mod m_1)$ and $x \equiv a_2 (\mod m_2)$ where $(m_1, m_2) = 1$, has a unique solution modulo $m_1m_2$.
Proof: If $x \equiv a_1 (\mod m_1)$, then $x = a_1 + k_1m_1$ for some $k_1$. If in addition $x = a_2 (\mod m_2)$, then $$a_1 + k_1m_1 \equiv a_2 (\mod m_2)$$ or $$k_1m_1 \equiv a_2 - a_1 (\mod m_2).$$
Because $(m_1, m_2) = 1$, we know that this congruence, with $k_1$ as the unknown, has a unique solution modulo $m_2$. Call it $t$. Then $k_1 = t + k_2m_2$ for some $k_2$, and $x = a_1 + (t + k_2m_2)m_1 \equiv a_1 + tm_1 (\mod m_1m_2)$.
My question is the line "Then $k_1 = t + k_2m_2$." I have studied this proof for a couple of hours and I cannot figure out where this line is coming from. It doesn't appear obvious at all, where is it coming from?
Answer: It is not very clearly formulated. I guess that it means that if $t$ is one solution satisfying $tm_1\equiv a_2-a_1\pmod{m_2}$, then all solutions $k_1$ satisfying $k_1m_1\equiv a_2-a_1\pmod{m_2}$ are given by the class of $t$ modulo$~m_2$, in other words $k_1 = t + k_2m_2$ for some integer$~k_2$. Note that $k_2$ later gets absorbed into the final congruence modulo $m_1m_2$ anyway.
Comment: Thank you for your reply, that helped. I just have one remaining question: How does $x = a_1 + (t + k_2m_2)m_1 \equiv a_1 + tm_1 (\mod m_1m_2)$ satisfy the second congruence condition? We need $x \equiv a_2 \mod m_2$. But it's not immediately clear to me that this is true, since $x = a_1 + (t + k_2m_2)m_1 \equiv m_1t + a_1 \mod m_2$.
Comment: Well, adding $a_1$ to both sides of $tm_1\equiv a_2-a_1\pmod{m_2}$ does give you $a_1+m_1t\equiv a_2\pmod{m_2}$.
Answer: $t$ is $k_1$ mod $m_2$, so $\exists k_2$ s.t. $t=k_1 + m_2 k_2$
Comment: Sorry if this seems dense, but what implies that $t \equiv k_1 \mod m_2$?
Comment: Just a problem of formulation i think. Read what says Marc above...
Comment: Thanks. I have one last question. How does $x = a_1 + (t + k_2m_2)m_1 \equiv a_1 + tm_1 (\mod m_1m_2)$ satisfy the second congruence condition? We need $x \equiv a_2 \mod m_2$. But it's not immediately clear to me that this is true, since $x = a_1 + (t + k_2m_2)m_1 \equiv m_1t + a_1 \mod m_2$.


How to create a table of contents from Strapi rich text field

Question: I've searched everywhere for this but I could only find one article about it which was pretty vague.
So I'm rendering the rich text content using the BlocksRenderer component from Strapi itself. Is it possible to create a table of contents from the data gotten from strapi rich text?
This is my Blog component:

import { BlocksRenderer, type BlocksContent} from "@strapi/blocks-react-renderer";

const Blog = () => {

  const { data } = useGetBlogsByIdQuery(slug);

  const content: BlocksContent = data ? .data ? .attributes ? .content;

  return (
    <BlocksRenderer content = {content} />
  )
}

I would appreciate any tips
Answer: Use can use filter to get headlines, and in the blocks renderer you have to create id's for headlines so you can scroll to anchor. However this is not going to be supported by blocks, so likely you gonna need to fork blocks render repo. And modify the functions…


mysql query does not respect the date parameter

Question: I have a query as follow:
SELECT   ch.id, ch.checkname, MAX(ch.CheckDate) AS CheckDate,
         ch.SeverityNumber, md.CheckRef1, md.CheckSubject,
         DATEDIFF(FROM_UNIXTIME( ch.CheckDate),CURDATE()) AS dateFromalarm
FROM     checks ch, model md
WHERE    ch.SysName='MV3R'
AND      ch.environment='Z/OS'
AND      md.CheckName=ch.CheckName
AND      ***ch.CheckDate <=1569785343***
GROUP BY CheckName
ORDER BY ch.CheckName DESC;

This query supposed to return one row for each checkname that has the latest checkdate.
checkname is not unique and there are many rows for each checkname in the table.
The problem is that when i change the number in the bolded section (ch.CheckDate <=1569785343) it does NOT change the result at all..
any ideas?
Comment: checkDate might be `Date` or `Datetime` or `timestamp` type variable, so you cannot just directly check the date as comparing a integer to date.
try something like ch.checkDate <= '2019-02-01';
Comment: my CheckDate field is an a number (unixdatetime) so i can compare it.
Answer: lets try to isolate your max(checkdate) to avoid grouping multiple columns, i believe you only have 1 info for each checkname.
select ch.id
    , ch.checkname
    , t1.CheckDate
    , ch.SeverityNumber
    , md.CheckRef1
    , md.CheckSubject
    , datediff(from_unixtime(ch.CheckDate),CURDATE()) as dateFromalarm
from
    (select checkname, max(CheckDate)as CheckDate from checks where CheckDate <=1569785343 group by checkname) as t1
join checks ch on ch.checkname = t1.checkname
join model md on md.CheckName=ch.CheckName
where ch.SysName='MV3R'
    and ch.environment='Z/OS'
order by ch.CheckName desc;

Comment: thank you for your answer but what i need is to get one row for each checkname where the date is the heist in that group. so i believe i need to add a group by checkname at the end of the query before the order by.


Service Layer validation vs. Domain Object validation; potential "abuse" of Domain Objects?

Question: I've seen lots of book and article examples saying to put validation code in your Service Layer. Keep the Domain Objects "dumb" (aka, pure POCO's) and handle all validation that a Domain Object might do in the Service Layer.
The Service Layer is responsible for so much it seems (or at least it can be); user authentication, role authentication, scripting dependency objects for IoC's (loggers, error-handlers, etc...), scripting Domain Objects, scripting repositories and passing Domain Objects to and from the repository... whew!
Doesn't creating all these rules in the Service Layer pose a substantial threat to your Domain Objects? For instance, what happens is some programmer decides to write consuming code directly against your Domain Objects and just bypasses the Service Layer altogether? That would be bad, but a believable situation.
If you are going to put a lot of the responsibilities in the Service Layer, including all Domain Object validation, is there a way to "protect" your Domain Objects is someone tries to script them directly? For instance, maybe some way your Domain Objects now they're not being used by a certain client (in this case, the Service Layer?).
Good design makes me think the Domain Objects should know nothing about who's calling them and how they're being called.
If there is no way to "lock down" the Domain Objects, then why are so many articles, books, etc suggesting that putting Domain Object validation in the Service Layer the way to go? I would imagine by taking a defensive programming position, that you should build your Domain Objects to be bullet-proof, and rely on your Service Layer for a simple layer of code to forwarding and receiving requests between the UI and the BAL/DAL.
Has anyone had some real-life project experiences with "abuse" of their Domain Objects from people that have bypassed their Service Layer?
Answer: I think you may misunderstand the purpose of a POCO.  A POCO, as I understand it, is not an anemic domain object with only properties and attributes.  Rather a POCO simply is not tied to a framework or complicated inheritance model.  The object is flexible and only concerned about its role in the domain.
Comment: Agree with Joshua. Anemic domain model is considered an anti-pattern for many well defended reasons. From the man himself, http://martinfowler.com/bliki/AnemicDomainModel.html
Answer: They are 2 different design philosophies.  Rich Domain Model vs Anemic Domain Model.
The short answer is yes, you can prevent direct access to your domain objects.
You can do so with a number of techniques:
1) You can make all public facing domain objects immutable (i.e. you can't change the data) via only having the only public methods be getters.  All methods that modify your objects can be protected or package private so only the correctly packaged services can access them (in Java at least)
2) You can expose only separate classes to your external developers -- so if you have a Person domain class you can have a PersonInfo class that you pass up, that does nothing but contain info.
3) You should expose a coherent API to your app consumers.  You basically prevent them from bypassing your Service layer.
Comment: #2 sounds a lot like a Data Transfer Object, I think? I guess I could use a DTO, OR maybe return an interface that only exposes the properties I feel the end consumer should be able to set/get? I'll play around with some different approaches. I was hoping to avoid DTO's, as they can add another layer of complexity into a project. Thanks for the reply!
Comment: @indiecodemonkey, yes it does.  but the point is there are ways to lock down an api.


What is a 7/6 chord?

Question: I am reading James Hober's paper "The 43 Four-Note Qualities", that is based on a Ted Greene paper. You can find it here.
It mentions that there are a total of 43 four-note qualities, nothing more and nothing less (meeting certain criteria, like inversions and homonyms being the same quality). He proves this mathematically in the continuation of that paper here.
At the end of the first paper (page 6, it is not a long paper) he lists the 43 qualities, along with the homonyms (names of the chord) that he considered were "not stretching it too far". On that list there are some chord names that I don't recognize, here is an example:

3) 1 - 2 - 3 - 6 =
   C7/11 no R =
   Gm7/6 no 5 =
   F∆9sus no 5 =
   Bb6#11 no 3 =
   E(7)#9b9b5 no 3,b7 =
   Db13#9b5 no R, b7 =
   Dm+/9/11 no R

What is a Gm7/6 chord? What is a C7/11 chord? Which notes compose them? Why are they called like that? Where can I find more about them? How do you pronounce them?
Answer: What he's pointing out is that you can use multiple names (homonyms) for the same combination of notes.
For example, with three notes, C-E-G is obviously a C major chord. But you can also describe it as E minor, with the 5th (B) omitted, and a 6th (C) as the bottom note. In his notation, "Em/6 no 5"
I would read this as "E minor over sixth no five".
The notes are described in the first part of the item - "1 - 2 - 3 - 6", with each number describing the number of semitones to the next note. So if you were to start on B (I picked B because it results in no sharps/flats).

B,
B+1 = C
C+2 = D
D+3 = F
F+6 = back to B

What Hober has done is, for each shape, he's picked the "simplest" name for that chord, then applied that to a root note of C, then used the notes in that chord as the basis for picking the root note for naming it other ways.
That's a bit complicated, so let's step through the example.
He's decided that 1-2-3-6 is most simply named as X7/11 no R. That applies no matter what note X is, but he's written C7/11 no R.
That's:

A C major chord - C,E,G
Plus the dominant 7th - C,E,G,Bb
Over the 11th - C,E,F,G,Bb
Minus the root - E,F,G,Bb

... and you can see that it fits the numeric description:

E to F is 1 semitone
F to G is 2 semitones
G to Bb is 3 semitones
Bb back to E is 6 semitones

Then he picks what he considers the next simplest name for the chord: Ym7/6 no 5.
Since he's already picked the notes E,F,G,Bb, in this case Y = G:

G minor - G,Bb,D
Plus the dominant 7th - G,Bb,D,F
Over the 6th - E,G,Bb,D,F
minus the 5th - E,G,Bb,F

... the same notes as C7/11 no R.
Perhaps the easiest example is 2-4-3-3. He treats inversions as equivalent. So 4-3-3-2 is equivalent to 2-4-3-3. Experienced musicians can immediately see that the intervals 4-3-3-2 correspond to the third, fifth, dominant 7th, octave, so that's a X7 chord. If X=C, that's C7: C,E,G,Bb. Or you could call those same four notes F#b9b5 no R.
Answer:
Chord symbol:     Gm13
Chord name:   G minor thirteenth
Chord importance: Rarely used
Chord notes:  G Bb D F E
Interval structure:   R m3 5 m7 13
   Comments:    minor seventh chord with added 13th (6th). Most of the time
   the 5th is left out (3rd note). The 13th = 6th, 13th is used when the
   chord is a 7th chord with added 6th, 6th chords are not 7th chords
   with added 6th.
Chord belong to these categories: Minor chord ; 7th
   chord ; 6th chord ; 13th chord ;
Alternative symbols    Gminor13 ;
   Gmin13 ; Gm7/13 ; Gm7(add13) ; G-7(add13) ; G-7/13 ; Gmin7/13 ;
   Gmin7(add13) ; Gm7/6 ; Gm7(add6) ; G-7(add6) ; G-7/6 ; Gmin7/6 ;
   Gmin7(add6) ;

(Note that you can see a minor chord listed as -, min and m.
So Gmin, Gm and G- is the same thing)
via scale-chords.com
C7/11:

Third column, second chord
Comment: What is your source for the text you quoted?
Comment: @Shev - all good, but the 3rd in Gm will always be Bb, rather than A#, as the major 3rd is B, so to flatten it, making it minor,it becomes Bb. The same syndrome makes the min. 3rd of C into Eb rather than D#. It's not me - it's the rules !! And C7 will have Bb, not A#.And C11 will have F, not F#.And C13 will have A, not G#.
Comment: Sorry, timed out. I meant Cadd11 will have F, not F#.And C7-9 has Db, not C#.It's all in the spelling - see what note is altered,keep the same name.
Comment: The site you used is called 'Useful Musicians Tools'. I feel that they got the first word wrong...

What is a 7/6 chord?


How do I unset/hide certain fields from being indexed by the core search module?

Question: If a content type has additional text fields, search core automatically indexes them because search core extracts all text from the result of node_view()
I can easily add extra index data via MODULE_node_update_index( $node ). This particular hook argument, $node, is passed by value and not by reference which means I can't unset certain items.
I hook into node_view, and alter it there but I don't want to change the output of the node normally, only when it's being indexed.
Answer: Goto the Manage Display page for each content type (eg, admin/structure/types/manage/page/display).
Click on the tab for Custom Display Settings.
You will see the view modes that your system knows about.  Tick Search Index and save.
You can now configure which fields get indexed from the tab for that new display mode (eg admin/structure/types/manage/page/display/search_index)
Dump the search index from Configuration -> Search -> Search Settings ( admin/config/search/settings), and cron runs will re-index everything.  Or, do a drush -y search-reindex; drush -y search-index from the command line.
Start reading from node_update_index() which is invoked from search_cron(), and you will eventually see a node_view($node, 'search_index');, which is how that display mode gets used.
Comment: If I do this and make no fields displayed for Search Index, will this eliminate that content type from showing up in search results?
Comment: @ChristiaNot sure, never tried that.  Pretty sure the custom_search module will handle this, though.  There should be one or more questions here about how to hide content types from search.