Advice on most fitting choice of virtualization platform: Xen | OpenVZ | KVM | other? What suits the purpose best?

Question: I am aware of the multitude of virtualization threads here but they all seem to be oldish and i'd like to have a brand new one ready for 2012.
I'm currently evaluating Xen, OpenVZ and KVM for virtualization purposes.
I'm having trouble deciding what to use.
The OS this will be running off of is Debian, preferably. The guest OS's will all be *nix based, mostly Debian as well. No windows, macos or other exotic stuff required.
I have a single server, which has 16gigs of ram and a xeon processor on it. I also have a software raid 1 disk configuration with 3tb raid capacity.
I am setting up this environment so separate the sites my current server hosts by level of trust, and software version.
For example, there are some sites i know might have security holes, others which should be perfectly secure, and others that require an archaic version of PHP.
All in all, i'd like to set up 3 different guests: one for trusted, one for untrusted, one for old php.
Part of my problem is managing backups properly:
I enjoy using Bacula or duplicity to manage my backups because of incremental, encrypted backups.
I do not want any of my client sites to ever have to go offline due to backup processes.
I also only have 100 gigs of remote off-site backup space, so i want to use that wiseley, and not just dump all i have up there. Restoring from backups should be fast [no downloading huge iso files!].
I also want to do the disk space allocation right.
I've read marvelous things about LVM and how it makes ones life easier.
Assuming a raid 1 [two 3tb disks under raid1], how would you lay out your partition map?
I'd be happy if somebody could share his personal experiences, setup configurations and win/fails regarding different virtualization platforms, for a similar goal as mine.
Thanks!
Answer: I'd say use KVM - that way your hypervisor & Dom0 can be the standard debian you're familiar with.  With KVM, the hypervisor and the Dom0 are the same machine - it's one of the design principles behind KVM that the best hv to have is a full-featured linux system.
With Xen, the hypervisor runs on the bare metal and the Dom0 runs inside it along with all the guest DomUs, kind of like a special purpose VM.
I don't think container-style virtualisation offers enough real benefits over simple vhosting that it's worth the bother.
For performance, I think your plan to use LVM for VM images (rather than, say, image files on a fs) is a good one.
Alternatively, you could use zfsonlinux (note: not zfs-fuse, it's too slow) which is pretty stable and reliable.  the "catch" is you have to download the debianised source packages from the ubuntu zfsonlinux PPAs and recompile them for debian.  easy if you're comfortable with compiling packages, probably not very easy if you're not.
zfs gives you everything that LVM with fewer restrictions and limitations (e.g. snapshotting even running VM volumes is fast and easy), and with a much less steep learning curve.  If you're already familiar with LVM that last one isn't a big deal.
Disclaimer: I'm opinionated and therefore biased.
I'm not a fan of Xen.  I've used Xen & KVM, dabbled with vmware (and virtualbox too although that's more of an end-user/desktop-oriented virtualisation tool rather than server virtualisation) and I strongly prefer KVM.  It just works, without stupid hassles.
I'm hoping that the recent merge of Xen into the mainline kernel results in rapid improvement of Xen.  It certainly can't hurt to escape being stuck with ancient kernel versions.
similarly, i'm not a huge fan of LVM either.  I used it in the past because there was nothing else that did what it did.  However, I have never liked it and have always thought that it is clumsy and obtuse and gratuitously complicated.  i've been using zfsonlinux for a few months now and it's everything i ever wanted LVM to be.  I hope i never have to build or administer another lvm system again.
Comment: it's not up to me to explain the benefits of a technology that i don't use, especially when i clearly stated (and clearly identified it as just an opinion, not claimed it as objective fact) that i don't think it's worth the bother (in my experience, it's *more* effort than running kvm or xen VMs).  if YOU think container VMs are worthwhile, then write your own answer extolling their virtues rather than just lazily downvoting an answer because you disagree with one sentence.  this site benefits from lots of people sharing their *different* experiences. group-think agreement is not mandatory.
Comment: Thanks for the input. I've gone ahead and set up KVM+libVirt+qemu and i'm using two virtual debian machines already. It seems quite simple and straightforward. I'll take a look at using zfsonlinux too.
Comment: I would agree with using KVM for this, KVM includes the KSM service which does memory deduplication on the fly. If all of your VMs are going to be running very similar OSes then this will really help.
Comment: -1 Saying that containerization has not enough more benefits than vhosting is not well explained and simply not right. Containers isolate memory, network, disk, processes, and system resources. There are many benefits to that. Example: one of your web interfaces has a remote vulnerability that gives shell and there is a local vulnerability that escalates to root. Your kernel is up to date. In this case all your other services which are in different containers are protected. With vhosts your entire machine would be f'ed. For Xen vs OpenVZ pref. please see http://wiki.openvz.org/Performance
Answer: You should also give a try to LxC (Linux Containters) which offers an OS-level Virtualization like OpenVZ but supported in the mainline Kernel. This technique might be preferable to you because you can expect an higher density (more "virtual machines" than with KVM / Xen).
Comment: Thank you for your mentioning of LxC, i didnt know about it. Yet, i'm more interested in finding out the setups that people use, than in knowing that there is "yet another technology available". Furthermore, im interested in the various advantages of a specific soultion in regard to the backup aspect.
Comment: LxC was well behind OpenVZ in March 2010. I don't know if that changed over the year. Please see http://openvz.livejournal.com/30998.html?thread=97046#t97046


Problems in XSLT

Question: I am new to XSLT, and I have the following problem: I want to get the description and maximum date of the following elements,
Facebook 01/01/2020
WhatsApp 02/01/2020
Instagram 04/01/2020
Twitter 05/01/2020
YouTube 03/01/2020
<xsl:variable name="fechas" as="element()*">
    <Item><xsl:value-of select="20200101"/></Item>
    <Item><xsl:value-of select="20200102"/></Item>
    <Item><xsl:value-of select="20200104"/></Item>
    <Item><xsl:value-of select="20200105"/></Item>
    <Item><xsl:value-of select="20200103"/></Item>
</xsl:variable>

<xsl:variable name="description" as="element()*">
    <Item><xsl:value-of select="Facebook"/></Item>
    <Item><xsl:value-of select="Whatsapp"/></Item>
    <Item><xsl:value-of select="Instagram"/></Item>
    <Item><xsl:value-of select="Twitter"/></Item>
    <Item><xsl:value-of select="YouTube"/></Item>
</xsl:variable>

The result I hope to get is:
Twitter 05/01/2020
Comment: Hello Cristy, Welcome to Stack Overflow! To get useful answers, please use the question title as a summary of the question you are asking, and please try to ask only _one_ question (I think you are trying to ask at least two questions in one post - "how to join two element lists pair-wise?" and "how to take the maximum from a list according to some ordering?"). Also, please specify the XSLT version you are using.
Comment: What if there's a tie?
Answer: You have shown us some data contained in XSLT variables, not in any XML source document. You haven't told us why the data is organized in this rather strange way. If I were handling this data, I would probably put it in an XML document of the form
<data>
  <item site="Facebook" date="2020-01-01"/>
  <item site="Whatsapp" date="2020-01-02"/>
  ...
</data>

Why is this better?

Data held in an XML document is more reusable than data held as variables in your XSLT code
It's always best to use ISO date formats rather than non-standard formats.
Standard practice for converting an object data model into XML is that objects become elements and properties of the objects become attributes (or child elements).

If the data takes this form, and the document is accessed as
<xsl:variable name="data" select="document('data.xml')"/>

Then in XSLT 2.0+, one way of solving your problem is:
<xsl:for-each select="$data//item">
  <xsl:sort select="xs:date(@date)"/>
  <xsl:if test="position()=last()">
     <xsl:copy-of select="."/>
  </xsl:if>
</xsl:for-each>

You're new to XSLT so you may not yet be aware that there are different versions of XSLT. Back in 2000, a great many vendors (including Microsoft, Sun, IBM, Oracle and quite a few open source vendors, as well as all the browser vendors) delivered implementations of the new XSLT 1.0 standard. Many of these have not been updated since. But the language has moved on, and XSLT 2.0 and 3.0 are much more powerful. You need to decide whether you want to take advantage of the power of the newer versions, or whether you want to write code that will still run on the maximum number of platforms. It's therefore important when you ask XSLT questions on StackOverflow about XSLT that you specify which version.
(I've just noticed you are using xsl:variable/@as, which implies XSLT 2.0 or later).
For example, this particular problem involves manipulation of dates, and date arithmetic is provided in XSLT 2.0, but can only be done "by hand" in XSLT 1.0.
If there really is a good reason for starting with the data in the form you have shown it in your question, it's probably best to start by transforming it into a more easily handled form. You can do that (again in XSLT 2.0) with code like this:
<data>
  <xsl:for-each select="1 to count($fechas)">
    <xsl:variable name="i" select="."/>
    <item site="{$description[$i]}" date="{$fechas[$i]}"/>
  </xsl:for-each>
</data>

Problems in XSLT


Orchard Custom Content Type isn't saving

Question: I have created a custom content type called 'AccessFolder'. I can see it in the list of content types and can create a new one. When I create a new AccessFolder, I get my editor template that I created for it. After I enter the information and click save, I'm directed to a Not Found page however the indicator message tells me my AccessFolder was created successfully.
In the driver, I can see the model after it is bound using the updater.TryUpdateModel. The correct values are assigned to the model's properties.
It just never gets to the database.
AccessFolderPart:
public class AccessFolderPart : ContentPart<AccessFolderPartRecord>
{
    public virtual string Name
    {
        get { return Record.Name; }
        set { Record.Name = value; }
    }

    public virtual IEnumerable<RoleRecord> DownloadRoles
    {
        get { return Record.DownloadRoles.Select(x => x.RoleRecord); }
    }
}

AccessFolderPartRecord
public class AccessFolderPartRecord : ContentPartRecord
{
    public virtual string Name { get; set; }
    public virtual List<ContentAccessFolderRoleRecord> DownloadRoles { get; set; }
}

Relevant Pieces of AccessFolderPartDriver
    protected override DriverResult Editor(AccessFolderPart part, dynamic shapeHelper)
    {
        var viewModel = new AccessFolderViewModel(part, _roleService.GetRoles());
        return ContentShape("Parts_AccessFolder_Edit", () =>
            shapeHelper.EditorTemplate(TemplateName: templateName, Model: viewModel, Prefix: Prefix));
    }

    protected override DriverResult Editor(AccessFolderPart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper)
    {

        var viewModel = new AccessFolderViewModel { Part = part };
        updater.TryUpdateModel(viewModel, Prefix, null, null);

        if (part.ContentItem.Id != 0)
        {
            _roleService.UpdateRolesForAccessFolder(part.ContentItem, part.DownloadRoles);
        }

        return Editor(part, shapeHelper);

    }

I've been stuck on this since Friday. I've created custom types before and never had any problems with it. I can't see what I've done wrong here.
Update - Added content Handler class
Here's the one line for the handler:
public class AccessFolderPartHandler : ContentHandler
{
    public AccessFolderPartHandler(IRepository<AccessFolderPartRecord> repository)
    {
        Filters.Add(StorageFilter.For(repository));
    }
}

Comment: Did you remember to add the storage filter inside a content handler?
Comment: @BrandonJoyce Yep, I already have that. I updated the question to reflect it.
Comment: without log file it is not possible to find the problem.please post log file here so we can help you out.
Comment: Have you tried delete the nhibernate mappings (App_Data\Sites\[sitename]\mappings.bin? I have had similar experiences where there are no errors but data is not persisted to DB when coding new records. After the mappings regenerate the data saves as expected.
Answer: I Think you are missing the proper mapping on your driver:
    if (updater.TryUpdateModel(viewModel, Prefix, null, null))
            {
               part.Name= viewModel.Name;

               if (part.ContentItem.Id != 0)
               {
                   _roleService.UpdateRolesForAccessFolder(part.ContentItem, part.DownloadRoles);
               }
            }


How to insert superscript characters (e.g: 2^2) in HTML?

Question: As the title says, is it possible in HTML (or with special characters) to type for example: 2^2 so the square is smaller and placed at the top.
Any ideas how to achieve that?
Comment: Do you *really* want just 2²? I find that hard to believe. If you generally want superscripts, then the question would be too broad really, and one that has been asked several times at SO. If you have some specific use for superscripts in a specific context, you should describe that, if problems remain after studying general advice on different ways of using superscripts.
Answer: It's called Superscript and there's a slight difference in it's use with a  tag and directly using the Unicode Character called "Superscript Two":
HTML Tag: 22  22
HTML entity: (see the difference) 2²  2²
Encodings :

HTML Entity (decimal)              ²
HTML Entity (hex)                  ²
HTML Entity (named)                ²
Windows                            Alt +B2
                                   Alt 0178
                                   Alt 253
UTF-8  (hex)                       0xC2 0xB2 (c2b2)
UTF-8  (binary)                    11000010:10110010
UTF-16 (hex)                       0x00B2 (00b2)
UTF-16 (decimal)                   178
UTF-32 (hex)                       0x000000B2 (b2)
UTF-32 (decimal)                   178
C/C++/Java source code             "\u00B2"
Python source code                 u"\u00B2"

Fileformat link
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
http://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts
Comment: The superscript 2 character and the normal 2 character in superscript style are different beasts, not just slightly different.
Answer: You can use ² html entity:
2²

It will be displayed as "2²".
Answer: Try this:
22

Comment: Or even `2²` for a tidier result.
Comment: Cool, I didn't realize that was an HTML entity.  Thanks.
Answer: You need the superscript tag.
22

This outputs 22
Comment: I just tested this answer with NVDA (a screenreader) and it reads as "twenty two", which obviously isn't the desired result. So **be careful** doing this if you care about accessibility, which you should. So using `2²` might be better as it at least reads "two superscript two" (because `²` [is a different character entirely](https://stackoverflow.com/a/25938710/486434)). Results might differ in different screenreaders, though.
Answer: You can use the "superscript 2" unicode character (HTML entity ² or ²), e.g.

2²

It looks like this:
2²
Answer: You could use the  tag which is used for superscripts. Alternatively if you wanted more control you could use a span with a special style and an offset of relative.
HTML (Example)

22

CSS
.superscript {
    font-size: 0.4em;
    line-height: 1.2em;
    vertical-align: top;
    position: relative;
}

You can see this example working in JSFiddle here.
Comment: This is not elegant and there are more appropriate ways to display superscript in HTML (e.g.: `²`).
Answer: Using MathML,

<math>
  <msup>
    <mn>2</mn>
    <mn>2</mn>
  </msup>
</math>
Comment: *... if browser supports it*
Comment: @RokoC.Buljan Yes, it's a shame, not all browsers support it, even though MathML 2.0 is a W3C Recommendation since 21 October 2003.


Erro ao buscar a description em outra tabela relacionada

Question: Erro:
Trying to get property of non-object

View
@foreach ($titulos as $titulo)

        {{ $titulo->id }}
        {{ $titulo->titulo_tipos->description }}	 //ERRO NESSA LINHA
        {{ $titulo->cliente->nome }}
        {{ $titulo->devedor->nome }}
        {{ $titulo->Valor }}

@endforeach

Models Titulo
class Titulo extends Model
{
     public function titulo_tipos()
     {
         return $this->belongsTo('App\Models\TituloTipo');
     }
}

Model Titulo Tipo
class TituloTipo extends Model
{
    public function titulo()
    {
        return $this->hasMany('App\Models\Titulo');
    }
}

Migration
Schema::create('titulos', function (Blueprint $table) {
    $table->increments('id');

    $table->integer('tipo_id')->unsigned();
    $table->foreign('tipo_id')->references('id')->on('titulo_tipos');

    $table->integer('cliente_id')->unsigned();
    $table->foreign('cliente_id')->references('id')->on('clientes');

    $table->integer('devedor_id')->unsigned();
    $table->foreign('devedor_id')->references('id')->on('devedors');

    $table->date('vencimento_titulo')->nullable();
    $table->string('status')->default('pendente');
    $table->decimal('Valor')->nullable();

    $table->timestamps();
});

Comment: Na Model de Titulos referencie a foreign key tipo_id
 return $this->belongsTo('App\Models\TituloTipo', 'tipo_id');
Comment: Perfeito, funcionou!
Answer: O seu erro está em
return $this->belongsTo('App\Models\TituloTipo');

Ao usar o belongsTo com apenas um parâmetro você assume que a foreign key será o nome da model relacionada acompanhada de _id, no caso titulotipo_id, mas esse campo não existe em sua model. Você tem que referenciar então, manualmente, qual seria o campo foreignkey que fará referência a tabela de TituloTipo. Aplicando a correção ficaria da seguinte forma:
$this->belongsTo('App\Models\TituloTipo', 'tipo_id');

Essa e outras explicações você pode encontrar na Documentação do Laravel.


perimeter of an ellipse: values required for verification of precision of a function

Question: I have a function for the calculation of the perimeter of an ellipse based on the inputs a and b. So far tested, it act similar to testing tools in the internet; example https://www.mathsisfun.com/geometry/ellipse-perimeter.html#tool
Has anybody some numerical precise examples of ellipse (perimeter, a and b) where the precision is quite high? (at least the first 10 digits after "," should be "correct" or should have been calculated with high and long computational power).
I will make a python script on a 64bit PC later then compare the data I will receive from here, from where the data diverge after the ",".
Example
a= 0.1234567890123456
b= 2.345678901234567
Perimeter = 9.4xxxxxxxxxxxxx
After I will use my python script, I will numerically evaluate my result on my 64bit PC and the Perimeter above.
(I have not started the mathematical proof phase of the precision of the function; I just want to have few numerical examples to "quick and dirty" check my function before I spend the next days working).
Comment: You may need Carlson's algorithm: [Computing elliptic integrals by duplication](http://dx.doi.org/10.1007/BF01396491).
Comment: Must watch in this context: https://www.youtube.com/watch?v=5nW3nJhBHL0
Answer: With $a=0.1234567890123456$ and $b=2.345678901234567$
The exentricity is $\quad e=\sqrt{1-\frac{a^2}{b^2}}$
The perimeter is  $\quad p=4 * b * EllipticE(e)$
$$p=9.4098873248446338450884417196493252931085343348684439058378...$$
You can use WolframAlpha, for example :
https://www.wolframalpha.com/input/?i=4*2.345678901234567*EllipticE%28sqrt%281-%280.1234567890123456%2F2.345678901234567%29%5E2%29%29
For large number of digits clik on the button "More digits".


Question about functions that are not uniformly continuous.

Question: I am not asking for any particular question today rather I need some help to understand the concept of a function that is not uniformly continuous. Ok, so If I understand this correct, to prove a function that is not uniformly continuous, we have to find some $\epsilon>0$ and some $x,y$ within their domain such that these violate the definition of uniform continuity(if I want to get a contradiction), right? But, my problem is, I am always getting stuck when finding such $x$ and $y$. For example, you can see I asked this question here yesterday, and my choices of $x$ and $y$ weren't the correct ones, and the idea I've got from the answers and the comments is that choosing $x$ or $y$ values with $\delta$ in it might do the trick. But, that's not always the case because if you watch this youtube video of a function that is not uniformly continuous, you can see the instructor didn't choose the $y$ value with $\delta$ in it. So, my question is, is there any rule of thumb when working with functions that are not uniformly continuous? Also, if I choose such $x$ and $y$ values with $\delta$, does it mean I  am guaranteed to get a answer that can give me a contradiction?
I am new to real analysis, so I need all the help I can get to understand this subject. Also, I don't know if this question fits here, but then again I don't know where to ask such questions. Thanks so much.
Answer: There's more going on than you've said here. It's actually just one more thing, but it's a very important thing.
Uniform continuity says that
$$(\forall \varepsilon > 0)(\exists \delta > 0)(\forall x,y \in D) \: |x-y|<\delta \Rightarrow |f(x)-f(y)|<\varepsilon.$$
When you go to negate this, you get
$$(\exists \varepsilon >0)(\forall \delta > 0)(\exists x,y \in D) \: |x-y|<\delta \text{ and } |f(x)-f(y)|\geq \varepsilon.$$
The key thing that you've missed is that there is a universal quantifier over $\delta$. This means that you need to pick a universal $\varepsilon$, such that for any given $\delta$, you can choose $x,y$ (probably depending on $\delta$) such $x,y$ are $\delta$-close but $f(x),f(y)$ are not $\varepsilon$-close.
In thinking about this it may help to realize that if an existential quantifier follows a universal quantifier, then the existentially quantified variables can be treated as functions of the preceding universally quantified variables*. So $x,y$ in the statement above are functions of $\delta$ (maybe trivial ones that don't actually depend on $\delta$, but probably not). On the other hand $\varepsilon$ is not a function of $\delta$, since it comes before that quantifier.
For example, let's prove that $f(x)=x^2$ is not uniformly continuous on $[0,\infty)$. Pick $\varepsilon=1$ and let $\delta>0$. Now let's find two points $x,y$ with $|x-y|<\delta$ but $|x^2-y^2|\geq1$. To do that, notice that $|x^2-y^2|=|x+y||x-y|$. So to have $|x^2-y^2| \geq 1$, it is necessary and sufficient to have $|x+y| \geq \frac{1}{|x-y|}$. Putting the pieces together, you can choose $x=\frac{1}{\delta}$ and $y=x+\delta/2$. Checking our work:
$$\left | \left ( \frac{1}{\delta} + \frac{\delta}{2} \right )^2 - \frac{1}{\delta^2} \right | = \left | 1 + \frac{\delta^2}{4} \right | \geq 1$$
and $|x-y|=\delta/2<\delta$.
* There are some set-theoretic issues with this statement in general, but they do not matter in this context.
Comment: @Jellyfish That's the thing, it doesn't work like that--you have to introduce the variables left-to-right (except if $f$ has an actual discontinuity).
Comment: @Jellyfish In the video you linked the style is a little bit different, but at the end of the day $x$ and $y$ really do depend on $\delta$, albeit not through an explicit formula. It would have been a little bit clearer if they had said $x=\frac{\delta}{2}$ and $y=\frac{\delta}{4}$, instead of $x<\delta,y=x/2$.
Comment: @Jellyfish I would recommend working with the negation of the statement as I wrote it, rather than trying to assume the assertion and derive a contradiction. I admit, knowing when to use which of these two approaches is not easy, but here I think the easier answer is the one I've given.
Comment: Sorry I am still editing my comment.
Comment: @Jellyfish That's OK; you can add an extra case to deal with that. Basically, if $x=\delta/2$ and $y=\delta/4$, then $\frac{1}{y}-\frac{1}{x}=\frac{2}{\delta}>1$ provided $\delta<2$. So to handle arbitrary $\delta$, just choose $x=\min \{ \delta,1 \}$ and $y=x/2$. This sort of problem usually happens, since at the end of the day continuity only really cares about small $\varepsilon$ (while discontinuity only really cares about small $\delta$).
Comment: for the video linked, if I choose $x = \delta / 2$ and $y = \delta/4$ just like you've suggested, we'll get $\mid x - y\mid = \mid \delta /2 - \delta / 4\mid = \mid \delta / 4\mid < \delta$. And, $\mid f(x) - f(y)\mid = \mid 1/(\delta/2) - 1/(\delta / 4)\mid = \mid 2/\delta - 4/\delta\mid = 2 /\delta$. And, it is only  going to work if we choose $0<\delta<1$. But, if we choose $\delta > 1$, $\mid f(x) - f(y) \mid$ won't be $\geq1$. Two questions: 1. Does $\delta$ have to be in the same domain as for $x$ and $y$? 2. If we change the domain to $[0, \infty)$, would the same choice of x,y work?
Comment: @Jellyfish Technically, as I put in my answer, the domain restrictions only apply to $x,y$; $\delta$ should technically be allowed to be anything in $(0,\infty)$. But if you can handle all $\delta \in (0,1)$ then you can handle all $\delta \in (0,\infty)$ by simply choosing the same $x,y$ that you used for $\delta=1/2$ when you deal with $\delta \geq 1$. Again this is intuitively because continuity is *local*.
Comment: Ok, thanks. I should've read your comment before make mine. Thanks again.


Replace node tabs with user tabs on website

Question: Unlike the author of https://stackoverflow.com/questions/3530756/how-to-hide-edit-view-tabs I'd like to totally replace node tabs with what users see on their user profile pages.
Users on this website won't be able to edit their nodes and admins can just type node/%/edit or be provided with a link on special block, so node tabs are useless for this project, but user tabs are essential as there are no community nodes, users are locked to their accounts and need to see all their nodes under user accounts.
I tried to use the hook_menu_local_tasks_alter, it correctly adds new tab items, but I don't know how to get rid of the existing ones. I tried to hide them with Tabtamer module, but unfortunately it gives:
Notice: Undefined index: count in menu_primary_local_tasks() (line 2240 of ../includes/menu.inc).

Thus the existing items must exists, so instead of adding new individual items with hook_menu_local_tasks_alter, I would like to just check if arg(0) == 'node' then replace the node tabs totally with what users usually see on their profile pages.
How could I totally replace node tabs with user tabs on node pages?
Comment: I'm not clear which tabs you want on node pages. Do you mean user view and user edit tabs?
Comment: First of all, before anyone even attempts to answer this question, we need to know your Drupal version as the answer will differ.
Comment: @no-sssweet, sorry I've just edited and indicated Drupal 7 in the title.
Comment: @Jaypan, yes I mean view and edit tabs, but not for nodes.
Answer: For Drupal 7, you should be able to do the following:
1) Implement hook_menu(), and define new tabs as local tasks on the node path.
2) Set the callback for these tabs to redirect to the relevant user pages
3) Implement hook_menu_alter() to remove the tabs from the node pages.
Step 1: Implement hook_menu(), and define new tabs as local tasks on the node path.
function hook_menu()
{
  $menu['node/%node/user_view'] = array
  (
    'title' => 'View',
    'page callback' => 'node_user_redirect',
    'page arguments' => array('view'),
    'access callback' => 'user_is_logged_in',
    'type' => MENU_LOCAL_TASK,
  );

  $menu['node/%node/user_edit'] = array
  (
    'title' => 'Edit',
    'page callback' => 'node_user_redirect',
    'page arguments' => array('edit'),
    'access callback' => 'user_is_logged_in',
    'type' => MENU_LOCAL_TASK,
  );

  return $menu;
}

Step 2: Set the callback for these tabs to redirect to the relevant user pages
function node_user_redirect($type)
{
  global $user;

  drupal_goto('user/' . $user->uid . '/' . $type);
}

Step 3: Implement hook_menu_alter() to remove the tabs from the node pages.
function hook_menu_alter(&$menu)
{
  // Remove the view tab altogether
  unset($menu['node/%node/view']);
  // Set the edit page to not present a tab on node pages
  $menu['node/%node/edit']['#type'] = MENU_CALLBACK;
}

Comment: Jaypan, thank you very much, but apparently we were submitting answers at the time. I have already found the right solution to my case, but I'll accept your answers as the correct one too.
Answer: Sometimes so obvious solutions do not appear at once to average minds like mine ;) I just had to run check if (arg(0) == 'admin' || arg(0) != 'node') { return; } in my hook and everything works just as expected - I can add user tabs to nodes tabs.


$\mathbb{Z}_4\times\mathbb{Z}_4 \simeq\mathbb{Z}_2\times\mathbb{Z}_8$ true or false?

Question: True or false exercise

Is $\mathbb{Z}_4\times\mathbb{Z}_4$isomorph to $\mathbb{Z}_2\times\mathbb{Z}_8$ ?

Acording to the Theorem of finitely generated abelian groups:
$\mathbb{Z}_4\times\mathbb{Z}_4\simeq\mathbb{Z}_2\times\mathbb{Z}_2\times\mathbb{Z}_2\times\mathbb{Z}_2$
$\mathbb{Z}_2\times\mathbb{Z}_8\simeq\mathbb{Z}_2\times\mathbb{Z}_2\times\mathbb{Z}_2\times\mathbb{Z}_2$
Therefore  $\mathbb{Z}_4\times\mathbb{Z}_4\simeq\mathbb{Z}_2\times\mathbb{Z}_8$
However the solution claims the statement to be false.
According to John Hughes comment:

Theorem of finitely generated abelian groups:If $G$ is an finitely generated abelian so that $G\simeq\mathbb{Z}_{{p_1}^{n_1}}\times...\mathbb{Z}_{{p_k}^{n_k}}\times \mathbb{Z}^n$ or $G\simeq\mathbb{Z}^n$
where $p_1,...,p_k$ are prime and not necessarily distinct, $n_1,...,n_k\in\mathbb{N}$ and $n>0$.

Question:
What am I doing wrong? Is the solution wrong?
Thanks in advance!
Comment: What is the order of each element in each of those two groups? For instance, what's the order of $(1, 1)$ in the first, and of $(0, 1)$ in the second one? Do this for every $(a, b)$ in each group. It won't take long, and it'll be instructive.
Comment: Also: you're apparently misreading the theorem of finitely generated abelian groups. Perhaps you could write whatever version you're using here, and we can show you in what way you're misunderstanding it.
Comment: Note that $\Bbb Z_4 \times \Bbb Z_4 = \Bbb Z_{2^2} \times \Bbb Z_{2^2}$, so $\Bbb Z_4 \times \Bbb Z_4$ is already in the form guaranteed by the theorem ($p_1 = p_2 = 2; n_1 = n_2 = 2$), so you can't just say that it has to be equal to some other form that also satisfies the theorem! Otherwise, you could say it's just $\Bbb Z_{13} \times \Bbb Z_{19} \times \Bbb Z^3$. :)
Comment: @JohnHughes Please Check my edit!
Comment: @JohnHughes Could you point out what did I do wrong with the decomposition of the given groups?
Answer: Every element of $\mathbb{Z}_2\times{}\mathbb{Z}_2\times{}\mathbb{Z}_2\times{}\mathbb{Z}_2$ has order 2, but this is not true for $\mathbb{Z}_4\times{}\mathbb{Z}_4$. So the two groups aren't isomorphic.
Comment: Please check my edit!
Answer: I think you already make an implicit mistake when replacing $\mathbb Z_4$ with $\mathbb Z_2\times\mathbb Z_2$. Those two groups are not isomorphic, they just have the same number of elements.
It is true that $\mathbb Z_p\times\mathbb Z_q $ is isomorphic with $\mathbb Z_{pq} $ if $p $ and $q $ are coprime (Chinese remainder theorem), but obviously 2 isn't coprime with 2.
Comment: I think you may still have mistyped the theorem. It should say $\mathbb Z_{p_1^{n_1}}\times\ldots\times\mathbb Z_{p_k^{n_k}}\times \mathbb Z^n $, i.e. the orders of the finite cyclic groups are *powers* of primes - not necessarily primes. (That is why they say that the primes may not all be mutually different.)
Comment: $\mathbb Z_4\times \mathbb Z_4=\mathbb Z_{2^2}\times \mathbb Z_{2^2}$ is already decomposed. Nothing in the theorem guarantees you that you can either decompose it *further* or decompose it *differently*.
Comment: Please check my edit!
Comment: Actually, the theorem is often stated in a bit stronger form: up to the order of the cyclic group, this representation is unique! From there, it directly follows that $\mathbb Z_4\times\mathbb Z_4$ is not isomorphic to $\mathbb Z_2\times\mathbb Z_8$. I don't know if you've seen this stronger statement already, or is this exercise some sort of introduction to it...
Comment: (sorry, meant to say "up to the *ordering* of the cyclic groups...")
Comment: Teacher did not provide a proof of this theorem nor the book has one. I have been looking for proofs on the internet but the statements ,I found of the theorem, are not specifically this one, with the $\mathbb{Z}_n$. I am not understanding when and how I can make  use  of  this result. Thanks for the answers!
Comment: Could you point out what did I do wrong with the decomposition of the given groups?
Answer: I think you make confusion between
1) Every abelian group of order $16$ is isomorphic to one of the following group : $$\mathbb Z_{2}\times \mathbb Z_2\times \mathbb Z_2\times \mathbb Z_2,\quad \mathbb Z_2\times\mathbb Z_8 ,\quad \mathbb Z_4\times \mathbb Z_4,\quad \mathbb Z_{16},$$
and
2) All abelian group of order 16 are isomorphic.
The last proposition is of course wrong, and it's the first one that is true. As you can see, none of groups of 1) can be isomorphic since for example $\mathbb Z_{16}$ has an element of order $16$, whereas $\mathbb Z_2\times \mathbb Z_8$ has none element of order $16$.
Comment: Could you point out what did I do wrong with the decomposition of the given groups?
Answer: The theorem you state is simply wrong - $\mathbb Z_4$ is a counterexample. In the correct version of the theorem $p_j$ is not required to be prime, it is just a power of a prime.
Comment: @PedroGomes I thought I did point that out. Your application of the "theorem" was correct. But the "theorem" you're using is simply _wrong_ - if you correctly apply a false "theorem" you're going to get false results.
Comment: Could you point out what did I do wrong with the decomposition of the given groups?
Comment: I guess I have corrected the theorem in one of my last updates. Thanks for the insight!
Comment: @PedroGomes ??? The version of the theorem I see here still says $p_j$ is prime. Wrong. False. Untrue, incorrect.
Comment: It is the one the teacher provided me.
Comment: @PedroGomes Ok, the theorem is now correct - for some reason the latest edit took a long time to appear. Now the correct version of the theorem simply doesn't imply that $\mathbb Z_4$ is isomorphic to $\mathbb Z_2\times\mathbb Z_2$.


Is ITIL worth implementing?

Question: I see from "The Joel Test for sysadmin jobs" question on ServerFault that no one said the company better be using ITIL or they wouldn't work there.  In fact, no one mentioned ITIL at all.
Is ITIL a fad?  Is it too cumbersome to be practical?  Do you have to be a certain size for ITIL to work well?
The ITIL definitions of "incident" vs "problem" are interesting, but in a fast-paced help desk environment, have organizations really found it useful to distinguish between the two?
Answer: Absolutely.  ITIL is not a set in stone 10 commandments that have to be followed to the letter.
It's simply a foundation or a framework to operate out of.
The real problem comes in the interpretation.  If you take ITIL to a level that circumvention becomes easier than implementation, it will never work.  But when properly implemented, IT Service level goes up, and Sysadmin stress goes WAAAAY down!
Answer: Anyone who implements ITIL dogmatically is a fool (and they told me that on an "official" ITIL course).
You can/are supposed to adapt and adopt parts of it to your needs. It's obviously nuts for a one IT person shop to try and implement ITIL, when most of the conversations between the various "areas" of change management, release management, etc are actually going to take place inside one person's brain but having said that, at the other end of the scale, if you just got offered a fortune to be internal helpdesk manager for Microsoft or HP or Apple or whoever, with users and helpdesk callcentres all over the place, how could you possibly do the job at all without ITIL or something similar as a guideline?
I really should add at this point that we've implemented incident vs. problem management for our helpdesk and it has been very helpful.
Answer: ITIL isn't a on/off decision, you gradually roll out the things that are relevant for your environment and tackle the areas which cause the most friction/pain in your organization.
For example: If your helpdesk is being overwhelmed with requests it helps to start categorizing them, analyzing the sources and decide on actions to alleviate the situation.
It's really just a set of best common practices and rules which have proven themselves to work in organizations.
Answer: What I like most about ITIL, is that it defines a common language to use when talking to IT pros from other companies, even more so in the European multi-lingual multi-cultural environment. ...
issue management, problem management .. etc. are understood and mean the same.
Besides that, I agree with Robert Moir: Anyone who implements ITIL dogmatically is a fool
ITIL is a tool .. not your salvation.
Comment: +1 for common language
Answer: In my experience ITIL has also been a framework that allows support staff and IT staff to hold their ground against unreasonable demands from the business and implement real solutions to technology problems as opposed to "quick fixes" and "WE WANT IT NOW CUZ IT'S COOL!" demands.
I have worked in an organization that used "business-serving changes" as a an excuse to destroy, bypass, or override nearly every standard IT tried to implement (hardware, software, authentication systems, storage systems, etc.).  That company failed and was purchased by a company that lives and breathes ITIL in the support model.
I made the transition to the new company and not only is life better for IT staff, but in the long run the BUSINESS is happier because they get a stable environment, and they actually get better support and new technology FASTER because there are defined standards for support which feed into defined standards of technology.  When a standard is upgraded, we know what our upgrade path is, and we know it can be applied to a very wide swath of our deployed systems.  This allows us to move along that path much quicker.
We DO still have a proess for allowing business units and various app devs to request "special" equipment or services, but since we do charge-backs this is VERY "expensive" budget-wise for those requesting it.  The ITIL framework gives you the
Answer: Yup, but while your at it why don't you take a good look at your organizations procedures and support requirements, talk with the managers and users what kind of support level do they expect if they have to make a trade off between money. Then document this and the procedures used to do your job. What you actually did is the same as what all these ITIL/ISO stuff is about too.
Knowing standards like ITIL makes the above task easier because you have a framework which results in the right questions to ask to cover the task completely, but the most important thing is documentation about:

What is required
Why is it required
For Who is it required
When is it required
Which person owns the requirement (is responsible)

Splitting down the documentation to the lowest entity (like a single task) is tremendous amount of work but as soon as you do that you probably discover that large amount of tasks done now manually are either unnecessary, can be automated and/or can be delegated.
Taking a in-depth harsh look at your organization is never popular or easy to do but it will result in a better understanding of the company and help you be more profitable by just stop doing things that are unnecessary and delegating tasks down to a lower pay level.
What really is going to make you unpopular is when you do these kinds of standardization is that often you inadvertently describe that a lot of management layers are only there because of themselves and that cutting them out will likely improve communication and performance.
Answer: The idea of ITIL makes a lot of sense, unfortunately in my experience it's often a tool to allow support/operations staff to get their way over, and slow down, business-serving changes.

Is ITIL worth implementing?


Examples of clique in categories

Question: Let $I$ be a non empty set and $\mathcal{C}$ a category. Let $(A_{i})_{i\in I}$ be a family  of objects of $\mathcal{C}$ and $\big(f_{ij}:A_{j}\longrightarrow A_{i}\big)_{(i,j)\in I\times I}$. We say that is a $\textbf{clique}$ of $\mathcal{C}$ if the following conditions holds:

For any $i,j,r$ in $I$ we have:
$$ f_{rj}\circ f_{ji} = f_{ri}.$$
For any $i\in I$, $f_{ii}=id_{A_{i}}$, that is, the identity morphism of the object $A_i$.

I would like to have examples of this structure, can you suggest one ?
Comment: I haven't thought about it too hard, but I believe your definition of a clique can also be formulated as simply a functor into $\mathcal{C}$ from the [indiscrete category](https://ncatlab.org/nlab/show/indiscrete+category) generated by the set of objects $\{A_i\}_{i\in I}$. Actually, it would be better to just say from the indiscrete category generated by $I$ itself.
Comment: There are many, I think. For example, the transition functions of a vector bundle over some open cover.
Comment: @B.Pasternark Thank you. I don't know that one I will search on that.
Comment: I was looking for a basic example to write an introductory book on category theory.
Comment: Good idea, I will try to prove it and see if I can give an example from there. Thank you!
Comment: One of the simplest examples are the trivial cases one object but it is boring. The next simplest example corresponds to isomorphisms.
Comment: @leibnewtz: Thank you very much
Answer: From your definition, each $f_{ij}$ is invertible, i.e. an isomorphism, since $f_{ij}\circ f_{ji}=1_{A_i}$ and $f_{ji}\circ f_{ij}=1_{A_j}$.
So, a clique is just a collection of isomorphic objects, with a distinguished isomorphism between each of them.
Note that all the remaining $f_{ij}$'s are automatically generated once some $f_{ij}$ isomorphisms are given along a spanning tree of the full graph $I\times I$.
For example, once a bunch of isomorphic objects is given, pick one of them and pick an arbitrary isomorphism from this one to the other ones. This is a spanning tree, a star, and by rule 1. all your other isomorphisms gets evaluated.

Examples of clique in categories


jQuery attr src

Question: i've got the following Problem / Question:
I have HTML Code like this:

No i have jQuery and i want to get the img src of a Picture on "click" event. For that i have this code:
jQuery('#tab a').click(function() {
alert(jQuery(this).attr('src'));
});

But i do not get the code because it has to be
jQuery('#tab img')

and working with
jQuery(this 'a')

or something like this is not possible - so what to do?
But i cannot use jQuery('#tab img') because i also need the

Can somebody help?
Thanks a lot.
Greetings,
Sascha
Answer: The reason your code is not working is that jQuery(this) in your alert is actually an anchor, and not an image, and thus, it does not have any src attribute. Since your anchor contains an image, you'll be able to adjust your code to:
jQuery('#tab a').click(function() {
   alert(jQuery(this).find('img').attr('src'));
});

Answer: You could simply find the image within the anchor tag you have clicked (i.e. search within the anchor container.)
$('#tab a').click(function()
{
   alert($("img", $(this)).attr("src"));
});

Comment: You can use `$("img", this)`, jQuery can get DOM element as context (second argument), not only jQuery object.

jQuery attr src


Does playing a musical instrument indeed benefit the brain?

Question: I found many real researches about the benefits of listening to music, but so far I found none about the benefits of actually playing music on an instrument.
The internet is flooded with "how playing music is good for your brain" but none had a reference to a research.
Why am I asking: At this point, I am basically forcing myself to play the guitar (home hobby, not a profession) believing it is good for me for the long run, but with all my love to music (mainly listening to it) I find this activity boring and pointless.
Comment: I'm voting to close this question as off-topic because about psychology, not musical practice.
Comment: I very much doubt that anyone takes up playing an instrument to obtain 'brain improvement'. There are many other good reasons. That one is possibly a by-product which could be beneficial.
Comment: If your  brain is engaged when you play music, that is probably good for your brain, but if you find playing music pointless and boring then your brain is not engaged, and what good could you expect to come from that? There is no point in playing music if you find the activity pointless and boring.
Comment: The title question is different from the question in the body.
Comment: Close vote is based on the title question and the mid-match
Comment: I'm voting to close this question as off-topic because it's about neurology  (**not** psychology) .
Answer: I'm tempted to think this has a good chance of being closed as 'opinion-based'. However, before it does... my opinion...
If you're doing something you really enjoy; striving to improve, learning new things every day, that in itself is good for you. They say life is made of the new experiences we find.
Repetition is dull; we learn nothing & get bored.
If you're already bored sh... ermm... witless by the entire process, you will gain nothing.
Comment: Funny that the French word for 'practice'  and 'rehearsal' is - *repetition*...
Answer: Playing guitar, in my case at least, helped me to chill when I was anxious. So at least, it was helping my mental state.
But it really depends. It seems you were getting bored by the mechanical repetition, then it's probably not working.
Answer: What a strnage agenda. The idea of music being a chore is very alien to me !
A brief bit of research reveals playing an instrument reduces the change of dementia.
A word regarding your enjoyment of music:
This is akin to forcing yourself to play football when you'd rather just watch it, in order to get fit. It'll work but it's not a given that you'll enjoy it. But there's a difference:  If you enjoy listening to music, try listening to yourself play. Make stuff up. Find where the bits are that you enjoy.
If you're able to do that, and find enjoyment in just playing, then you don't need to practice. Just play. play what you like, vary it, play that .. whatever. "play" is the keyword, not "work".
If you sit down and try to practice something regimentally, then yes that is boring. Are you deliberately choosing difficult exercises to test yourself? That might be your problem.
If you look for a favourite part of a song you're learning (eg for me it was the guitar solo at the end of Sultans of Swing, and Voodoo Chile by J. Hendrix), then you've got something to aim at which is more rewarding. Soon you'll realise that it's not just that part, but the context & how the music got there that's just as important. Next thing you've learnt the whole piece.
Or just noodling about and finding what the guitar has to offer you will work: you might end up writing a song.
All these will work the same on your brain, if indeed such cognitive improvements are generally the case, but going for something you want to achieve / hear is miles more fun and that means you're more likely to keep it up.


Good source on current 'views and thoughts' on mathematics

Question: Recently I've become interested in the history of the way people think about mathematics. What I mean by this is for example how Godels proof basically put an end to the whole school of thought proposed by Bertrand Russel.
Now I wonder if there are any similar 'schools of thought' in current mathematics. And if there are any good sources on the complete history of how all those views and schools of thought came to be and how they ended.
Comment: [Now cross-posted on HSM](http://hsm.stackexchange.com/questions/690/good-source-on-current-views-and-thoughts-on-mathematics), which is not a good thing.
Comment: Godels proof basically _should have_ put an end to the whole school of thought
proposed by Bertrand Russel. But it didn't.
[Mathematical Formalism](http://en.wikipedia.org/wiki/Formalism_(mathematics)),
as promoted by Hilbert, is Russel and Whitehead in disguise. And it hasn't
come to an end. On the contrary: it's the mainstream in nowadays
mathematics. Simply use the "delete" button in a discipline seems to be
problematic, once so much work has been done.
Comment: @CarlMummert Hm I have no idea what you mean by that.
Comment: Perhaps it is just the way that the question is phrased (this may also be why there are not many answers). It seems to me the question is more philosophical than mathematical - and such questions often attract users who want to express their own opinions. @user2520938
Comment: @CarlMummert Oke that I can kind of understand. How would you suggest the question to be rephrased in order to make it better while still asking for the same information?
Comment: That I am not sure about - most of the rephrasings I can think of only make the question seem more philosophical.
Answer: For the "foundational" debate of the '30s, see :

Marcus Giaquinto, The Search for Certainty : A Philosophical Account of Foundations of Mathematics (2002).

For some impact on mathematics of one of the above philosophical "schools" (e.g. Intuitionism and related : Intuitionistic Logic, The Development of Intuitionistic Logic, Luitzen Egbertus Jan Brouwer, Set Theory: Constructive and Intuitionistic ZF) see Constructive Mathematics and :

Errett Bishop, Foundations of Constructive Analysis (1st ed 1967).

It is also worth noting a "connection" between Intuitionism/Constructivism, Alonzo Church's Lambda Calculus and N.G. de Bruijn's Automath (and see here), a formal language "precursor" of proof assistants.
Comment: Some further relevant references w.r.t. constructivism:
[Constructivism](http://en.wikipedia.org/wiki/Constructivism_(mathematics)) ;
[Intuitionism](http://en.wikipedia.org/wiki/Intuitionism) ;
[L. E. J. Brouwer](http://en.wikipedia.org/wiki/L._E._J._Brouwer) .
Comment: Thanks for your answer. I think this is more along the line of what I'm looking for. I will check it out in detail later tonight.
Answer: It sounds like you are interested in what is often called philosophy of mathematics. While there are many books and articles on this subject out there, I can personally recommend Shapiro's Thinking About Mathematics, which takes the reader through an introduction to both the history of the philosophy of mathematics, as well as more recent ideas and schools of thought.
Comment: Hm that seems a bit too philosophy-y for me. I did find 'Mathematics: The Loss of Certainty' though. Do you know it? It seems a bit less 'general philosophy' and more math focussed.


Como mantenho elementos html na mesma linha

Question: Bom teoricamente a minha pergunta é a seguinte, eu criei duas divs em html, contudo ao fazer a segunda, a segunda div não fica na mesma "linha" que a outra mas sim fica por baixo. Eu gostaria de saber se existe alguma tag em html que mantém os elementos todos na mesma linha, sem necessitação há margin-top do css.
Obrigado.
Comment: Mostre seu código pf.
Comment: `display: inline-block`?
Comment: Não sei se compreendi bem, mas parece que tu precisa de float:left na div, porém tem que ter certeza que o width das duas, somados, não fica maior que o width total disponível.
Comment: Usar `` ao invés de ``?
Answer: A pergunta não é muito especifica. Por isso não é possível dar uma resposta concreta, mas tentarei responder generalizado.
A tag div quando é criada por padrão tem o atributo em css "display:block".
Se colocar em css.:
div{
   display:inline;
}

Todas as tags div vão ter essa característica, portanto ficaram na mesma linha.
Também pode "configurar".:
div{
   float:left;
}

Assim, desde que as divs consigam estar na mesma linha ficam seguidas, se não existir espaço vão para a linha abaixo.
Dependendo do objetivo pode também usar tabela.
Answer: Existe a propriedade display dos elementos, e algumas tags já possuem um valor padrão para essa propriedade. O caso mais simples é que a
 tem display:block e o  possui display:inline .
Não recomendo ficar alterando essa propriedade se já temos tags com nomes diferentes para identificar a função de cada uma.
Para ter uma referência um pouco melhor, dê uma lida http://www.w3schools.com/html/html_blocks.asp


Regular Expression, optional character on multiple locations but result must contain at least once

Question: I am performing a string search where I am looking for the following three strings:
XXX-99-X
XXX-99X
XXX99-X

So far I have:
([A-Z]{3}(-?)[0-9]{2}(-?)[A-Z]{1})

How do I enforce that - has to be present at least once in either of the two possible locations?
Answer: You might use an alternation, to match either a - and optional - at the left or - at the right part.
Note that you can omit {1} from the pattern.
^[A-Z]{3}(?:-[0-9]{2}-?|[0-9]{2}-)[A-Z]$

^[A-Z]{3}
(?: Non capture group

-[0-9]{2}-?|[0-9]{2}- Match either  - 2 digits and optional - Or  2 digits and -

) Close non capture group
$ end of string

regex demo
Or use a positive lookahead to assert a - at the right
^(?=[^-\r\n]*-)[A-Z]{3}-?[0-9]{2}-?[A-Z]$

^ Start of string
(?=[^-\r\n]*-) Positive lookahead, assert a - at the right
[A-Z]{3}-? Match 3 chars A-Z and optional -
[0-9]{2}-? Match 2 digits and optional -
[A-Z] Match a single char A-Z
$ End of string

Regex demo
Answer: With your shown samples, please try following.
^[A-Z]{3}(?:-?\d{2}-|-\d{2})[A-Z]+$

online demo for above regex
Explanation: Adding detailed explanation for above.
^[A-Z]{3}        ##Matching if value starts with 3 alphabets here.
(?:              ##Starting a non capturing group here.
   -?\d{2}-      ##Matching -(optional) followed by 2 digits followed by -
   |
   -\d{2}        ##Matching dash followed by 2 digits.
)                ##Closing very first capturing group.
[A-Z]+$          ##Matching 1 or more occurrences of capital letters at the end of value.


Python: strings received with raw_input behave strange

Question: During my work on a remote controlled RC-car I've been faced with a problem: the car is controlled with a simple CLI, and sometimes when I type in correct commands, the CLI says they're incorrect, even if they aren't.
Below you see the code which causes the whole problem. Can somebody explain this behaviour and in best case give a fix?
command = raw_input("?")
   while command != "quit":
    if command == "forwards":
        forwards()
        command = 0
        command = raw_input("?")
    if command == "backwards":
        backwards()
        command = 0
        command = raw_input("?")
    if command == "left forwards":
        leftforwards()
        command = 0
        command = raw_input("?")
    if command == "right forwards":
        rightforwards()
        command = 0
        command = raw_input("?")
    if command == "right backwards":
        rightbackwards()
        command = 0
        command = raw_input("?")
    if command == "left backwards":
        leftbackwards()
        command = 0
        command = raw_input("?")
    if command == "selftest":
        selftest()
        command = 0
        command = raw_input("?")
    if command == "help":
        help()
        command = 0
        command = raw_input("?")
    if command == "distance":
        navix()
        print navix_distance
        command = 0
        command = raw_input("?")
    else:
        print("Invalid input, try again")
        command = 0
        command = raw_input("?")

Comment: Is this Python 2 or 3?
Answer: Use elif instead of if. In you current code each of the if blocks is executed. The else block belongs to only the last if statement. And if the last one fails, The else block is executed. So, even if the input is "forwards", There are two pieces that execute-

if command=="forwards":   block
The only else block (since the last if is false)

So, you get the "Invalid input, try again" message.
Use elif instead of each if (except the first of course) so that only a single block is executed.
Answer: If we simplify the structure of your code, it'll end up looking roughly like this:
command = raw_input('?')
while command != 'quit':
    if command == 'forwards':
        forwards()
    if command == 'backwards':
        backwards()

    # ...snip...

    if command == "distance":
        navix()
    else:
        print('invalid input')

Now, say that you type in forwards when asked for input. Well, then you hit the first if statement, which is true, and execute the correct command.
But then, what happens when you hit the very last if/else statement? Well, command is not equal to distance, so you hit the else case -- the "invalid input" case.
To fix this, you should convert all of your if statements into if/elif/else statements -- restructure your code so that once one command matches, you skip all the rest.
There's also a bunch of repetition in your code. There are a wide varieties of strategies for handling this, but at minimum, you should consolidate the code to ask for user input instead of repeating it in each clause:
command = raw_input('?')
while command != 'quit':
    if command == 'forward':
        forward()
    elif command == 'backwards':
        backwards()
    # ...snip...
    elif command == 'distance':
        navix()
    else:
        print('invalid command')

    command = raw_input('?')

You also don't have to zero out the command before setting it to a new value, since it'll be overridden anyways.


Drupal 7: how to redesign, move stuff around, for a content type page?

Question: If when creating a View, I create a list of a specific content type, let's say Staff. It lists everyone from the Staff content type. I have this setting too: Link to the original piece of content. Then I get a list of content type labels and content type data. How can I rearrange everything? How can I edit the HTML?
I don't want to create a view for a specific content type, I want to redesign (edit HTML) the content type page, example: domain.com/node/5
Comment: That's rather a broad topic - have you read the [Theming Guide](https://drupal.org/documentation/theme)?
Comment: are you asking to have a different page structure for a specific content type?
Answer: Not clear with your questions ,adding some pointers on some assumptions.
Custom Way
1 . If you want to override a node structure for a specific content type
-- You can copy the node.tpl.php to your theme and rename it to node--type.tpl.php. Inside node--type.tpl.php , you will be rearranging the elements.
2 . If you want to override every node,irrespective to any content type.
-- Copy node.tpl.php inside your theme and do the rearrangement of elements.
3 . If you want to override a particular node
-- Copy the node.tpl.php and rename it to node--nodeid.tpl.php and do the rearrangement of elements
Some Helpful Links:
https://drupal.org/node/1089656
http://www.youtube.com/watch?v=dfwU0WtCuPs
Remember to clear the caches after you are done with building of templates.
Using Contrib Module
You can use panels module to override node templates without creating them. panele module will do that for you.
Some Helpful Links:
http://www.youtube.com/watch?v=_VIkE2ZS5oU
Comment: @leonel try [theme developer module](https://drupal.org/project/devel_themer) it will give you clear insight of what templates are responsible to theme a page and alternate overriding options.


Error when running batch file as a scheduled task , win server 2008

Question: I get a Exception in thread "main" Exception in thread "main" java.lang.NoClassDefFoundError error when I try to run a batch file as a scheduled task on windows server 2008. The batch file runs a java program. when I run the batch file regularly it runs fine.
<code>@ECHO OFF

:start

:playback
java -cp ../lib/*; example

:end
</code>

Tue 08/30/2011  9:29:23.19:
  C:\Windows\system32;C:\Windows;C:\Windows\System32\W bem;C:\Program
  Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files
  \Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
  Server\100\ DTS\Binn\;C:\Program Files (x86)\Microsoft SQL
  Server\100\Tools\Binn\VSShell\Com mon7\IDE\;C:\Program Files
  (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program F iles
  (x86)\Microsoft Visual Studio
  9.0\Common7\IDE\PrivateAssemblies\;C:\Windows
  \System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows
  Imaging\;C:\Pro gram Files (x86)\IBM\Director\cimom\bin;C:\Program
  Files (x86)\Common Files\ibm\ icc\cimom\bin;C:\Program Files
  (x86)\IBM\Director\bin;C:\Program Files\System Ce nter Operations
  Manager 2007\ ;C:\Program Files (x86)\Java\jdk1.6.0_25\bin;C:\Pr ogram
  Files\System Center Operations Manager 2007\
Comment: Does the account the scheduled job runs under have the necessary permissions?
Comment: What class does it not find? If it can't find the "main" class, that means it cannot load a particular class referenced by that class (possibly including itself). You need to add all necessary references to your classpath so it can find them.
Answer: The account that runs the batch does not seem to have its PATH configured properly. Can you add:
<code>echo %DATE% %TIME%: %PATH% >> %TMP%\DebugFile.txt
</code>
to see that the value in path.
Comment: Sorry, I meant the CLASSPATH, not PATH - thanks to Chris! Would you please change your script to output the %CLASSPATH% and run your TASK (not the program, just execute the Task through Task Scheduler). Once you get the output, check if the folder containing the Java programs (that you are trying to run) exist in the CLASSPATH that you got output through your script. If not then you might need to modify CLASSPATH environmental variable, but do it through Control Panel - System (not through Command Line - if you do it at CommandLine, I believe it won't persist after Command Window is closed).


How do you convert a log odds ratio into a marginal effect?

Question: Basically, how do you convert a one unit change in $x_1$ to a $Z\%$ change in $Y$?
Answer: You can't (not without more information).  The point here is that the logit / logistic is not a linear transformation.  Therefore, you cannot get a constant correspondence between a starting percentage and a subsequent percentage even though you use the same log odds ratio to move from the one to the other each time.  Here are a few demonstrative numbers for $1$-unit changes in $X$ with a log odds ratio of $1$ (thus, the log odds will simply increase by $1$):
\begin{array}{c}
\text{starting %} &\text{starting lo} & &\text{subsequent lo} &\text{subsequent %} &  &\text{% difference}  \\
\hline
0.20  &-1.37\quad &\Rightarrow  &-0.37\quad  &0.40  &  &0.20 \\
0.50  &0\quad\     &\Rightarrow  &1.0\ \      &0.73  &  &0.23  \\
0.90  &2.20  &\Rightarrow  &3.20   &0.96  &  &0.06
\end{array}
Alternatively, if you simply want to compare two groups (which could be coded $0$ and $1$, for 'control' and 'treatment'), you would need to know the base rate in the control group.
Comment: Thanks for reply!

Yes, I am interested in comparing a control and treatment group. Assuming my data set shows a base rate of 20%, how do I convert it into marginal effect?
Comment: @YashMehta, the % difference is specific to each base rate and log odds ratio combination. You can plug in 0, and then 1, for X and solve the regression equation each time. Then pass the predicted log odds through the link function (see [here](https://stats.stackexchange.com/a/34638/7290)) to get the predicted probabilities, & take their difference.


"Cannot perform '=' operation on System.Int32 and System.String" while performing a search

Question: Trying to search through a DataList, with the parameters being movie genres (loaded through a database, so no switch case) and a name
protected void ButtonFilter_Click(object sender, EventArgs e)
    {
        string filter = "";
        int selectedCount = 0;
        for (int i = 0; i < this.CheckBoxListGenres.Items.Count; i++)
            if (this.CheckBoxListGenres.Items[i].Selected)
                selectedCount++;
        if (selectedCount > 0)
        {
            filter = "GenreID=";
            int n = 0; //Used to determine to which genre the loop has arrived
            for (int i = 0; i < this.CheckBoxListGenres.Items.Count; i++)
            {
                if (this.CheckBoxListGenres.Items[i].Selected)
                {
                    if (n > 0 && n < selectedCount)
                        filter += " AND ";
                    filter+="'*"+this.CheckBoxListGenres.Items[i].Value.ToString()+"*'";
                    n++;

                }
            }

            if (this.TextBoxMovieName.Text!="")
                filter += " AND MovieName LIKE '*" + this.TextBoxMovieName.Text + "*'";
            DataTable dataTable = ((DataSet)Application["DataSetMovies"]).Tables[0];
            DataView dataView = new DataView(dataTable);
            filter = Convert.ToString(filter);
            dataView.RowFilter = filter; //!Getting the error here!
            this.DataListMovies.DataSource = dataView;
            this.DataListMovies.DataBind();
        }
    }

Tried debugging, the string itself seems fine, so I tried using Convert.ToString() on filter, just to make sure but it doesn't matter.
Help?
Thanks in advance
Comment: 1. Is your GenreID a text or nummeric field?
2. Have you tried to check filter expression before assigning? According to your code you can get GenreID='*AAA*' AND '*BBB*' AND '*CCC*' which is not valid expression
Comment: It looks like you are trying to add a filter that checks if `GenreID='2'` or something, perhaps it is treating it as a string but the column is integer, try removing all the extraneous formatting and create a filter that just does `GenreID=2`. Can you provide an example of what `filter` contains when it is being set? Also as Igor points out, your chaining of `AND` expressions cannot just daisy chain values, you need to specify the field each time too: `GenreID=2 AND GenreID = 3`.
Comment: The error is not about ` filter` being a wrong type. The error is about the contents of ` filter` itself
Comment: @SonerGönül The error would be on that line if the exception was from the view trying to apply the filter.
Comment: @AdamHouldsworth That's make sense surely. I thought this is a compiler time error rather than runtime.
Comment: @Acesii Please post an example of what `filter` contains just before you try to set it to the data view. It is very likely incorrectly formed. Please see: http://www.csharp-examples.net/dataview-rowfilter/
Answer: This is not compile time error this is runtime error.
Well in your database the thing for which you are applying filter is type of Int32..
For example if you have something like Num and it is of Int32 but you do somthing like below :-
dv.RowFilter = "Num = '7097'" ////This will have error

It will throw error because it will require :-
dv.RowFilter = "Num = 7097" ////This is correct

So in your case you have GenreID which is of Int32 but in your code you are providing some string against it.
Comment: This error can also occur simply because the length of the variable ('7097') exceeds the string length allowed in the column ('Num') in the DataTable - I have tested this.
Answer: Probably your GenreID column is an INTEGER and you're comparing it with a STRING as in '**'. In this sample I used the INoperator to list all values at once without the AND operator between them, what would cause a logic error as none items would have GenreID=1 and GenreID=2:
protected void ButtonFilter_Click(object sender, EventArgs e)
{
    string filter = "1=1";
    if (this.CheckBoxListGenres.Items.OfType<ListItem>().Any(i => i.Selected))
        filter += String.Format(" AND GenreID IN ({0})'",
            String.Join(",", this.CheckBoxListGenres.Items.OfType<ListItem>()
                .Where(i => i.Selected).Select(i => i.Value)));

    if (this.TextBoxMovieName.Text != "")
        filter += " AND MovieName LIKE '%" + this.TextBoxMovieName.Text + "%'";

    DataTable dataTable = ((DataSet)MediaTypeNames.Application["DataSetMovies"]).Tables[0];
    DataView dataView = new DataView(dataTable);
    dataView.RowFilter = filter;
    DataListMovies.DataSource = dataView;
    DataListMovies.DataBind();
}

Answer: Filter in your condition might be invalid so Use OR at the place of AND

Use % , insted of * in LIKE Operator
I.E filter += " AND MovieName LIKE '%" + this.TextBoxMovieName.Text + "%'";

protected void ButtonFilter_Click(object sender, EventArgs e)
    {
        string filter = "";
        int selectedCount = 0;
        for (int i = 0; i < this.CheckBoxListGenres.Items.Count; i++)
            if (this.CheckBoxListGenres.Items[i].Selected)
                selectedCount++;
        if (selectedCount > 0)
        {
            filter = "GenreID=";
            int n = 0; //Used to determine to which genre the loop has arrived
            for (int i = 0; i < this.CheckBoxListGenres.Items.Count; i++)
            {
                if (this.CheckBoxListGenres.Items[i].Selected)
                {
                    if (n > 0 && n < selectedCount)
                        filter += " OR ";
                    filter+="'%"+this.CheckBoxListGenres.Items[i].Value.ToString()+"%'";
                    n++;

                }
            }

            if (this.TextBoxMovieName.Text!="")
                filter += " OR MovieName LIKE '%" + this.TextBoxMovieName.Text + "%'";
            DataTable dataTable = ((DataSet)Application["DataSetMovies"]).Tables[0];
            DataView dataView = new DataView(dataTable);
            filter = Convert.ToString(filter);
            dataView.RowFilter = filter;
            this.DataListMovies.DataSource = dataView;
            this.DataListMovies.DataBind();
        }
    }

Comment: `*` and `%` can be used interchangeably: https://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(v=vs.110).aspx
Comment: Search works with OR now, thanks (at least with the criteria I've put)
Answer: DataRow filteredRows = dt.Select("Name LIKE '%" + searchstring + "%'
OR
convert(Age, System.String) like '%" + searchstring + "%'");

It works for me


Pullback of a Partition of Unity

Question: I'm trying to prove that the collection of function $\{F^*\rho_\alpha\}$ is a partition of unity on $N$ subordinate to the open cover $\{F^{-1}(U_\alpha)\}$ of $N$. Here $\{\rho_\alpha\}$ is a partition of unity on a manifold $M$ subordinate to an open cover $\{U_\alpha\}$ of $M$ and $F:N\rightarrow M$ is a $C^\infty$ map.
For the partition $\{\rho_\alpha\}$, $\sum\rho_\alpha=1$ implies that
$$\sum F^*\rho_\alpha=\sum\rho_\alpha\circ F=1$$
on $N$. We are reminded that we need to demonstrate is that $\{\mathrm{supp}\ F^*\rho_\alpha\}$ is locally finite. I know that it is easy to verify that the pullback $F^*$ is a linear map and hence we have $F^*(C^\infty(N))\subset C^\infty(M)$, but how can one conclude that $\{\mathrm{supp}\ F^*\rho_\alpha\}$ is locally finite from the fact that $\{\mathrm{supp}\ \rho_\alpha\}$ is locally finite?
At present, I have one idea. By the linearity of $F^*$, it follows from $\rho_\alpha\neq 0$ that $F^*\rho_\alpha\neq 0$. Then we might find some relation between $\{\mathrm{supp}\ \rho_\alpha\}$ and $\{\mathrm{supp}\ F^*\rho_\alpha\}$, but I don't know what to do next.
Could you give me some hints or a solution?
Answer: For each $\alpha$, let's define $V_\alpha := \{ x \in N : F^\star \rho_\alpha (x) > 0 \}$ and $W_\alpha := \{ y \in M : \rho_\alpha (y) > 0 \}$.
Now, let's make some observations by unpacking the definitions.
Firstly, from the definitions of $V_\alpha$ and $W_\alpha$, we can see that $V_\alpha = F^{-1}(W_\alpha)$, for each $\alpha$.
Also, from the definition of a support, it's clear that $\text{supp}(F^\star \rho_\alpha) = \overline{V_\alpha}$ and $\text{supp}(\rho_\alpha) = \overline{W_\alpha}$, for each $\alpha$.
By assumption, $\{ \text{supp}(\rho_\alpha) \}$ is locally finite on $M$. So for any $y \in M$, there exists an open set $S_y \subset M$ such that $y \in S_y$ and such that $S_y$ intersects with only finitely many of the $\text{supp}(\rho_\alpha)$'s.
And finally, because $F: N \to M$ is continuous, $F^{-1}(S_y)$ is an open subset of $N$, for each $y \in M$.
I hope you can assemble an argument from these observations.
Comment: Notice that if $S_y \cap W_\alpha = \emptyset$, then $F^{-1}(S_y) \cap F^{-1}(W_\alpha) = \emptyset$. Does that help?
Comment: I still have a question. I understand $F^{-1}(S_y)$ is open, but why does it intersect with only finitely many of elements of $\mathrm{supp}(F^*\rho_\alpha)$? Could you please give me some more details?
Comment: I got it. Thanks a lot!

Pullback of a Partition of Unity


Question on sum of digits of squares

Question: Let $D$ be the function define as $D(b,n)$ be the sum of the base-$b$ digits of $n$.
Example: $D(2,7)=3$ means $7=(111)_2\implies D(2,7)=1+1+1=3$
Define $S_m(a)=1^m+2^m+3^m+...+a^m$ where $a,m\in\mathbb{Z}_+$

Can it be shown that
(1)$$D(a,S_2(a))\le 2(a-1)?$$
(2) $$D(a,S_2(a))< a\iff a\equiv5\mod6?$$

Note: For $a,m>1$
● $a^m<S_m(a)<a^{m+1}$
● $1\le D(a,S_m(a))\le(a-1)(m+1)$
● $D(a,S_m(a))=1+D(a,S_m(a-1))$proof

Edit
● $a\mid S_2(a)$ then  $D(a+1,S_2(a+1))=a+1$
Proof:

 let $b=a+1$.

Identically, we have
$$
S_2(n)
=
\sum_{i=1}^n i^2
=
\frac{n(n+1)(2n+1)}{6}
$$
hence
\begin{align*}
&a{\,|\,}S_2(a)\\[4pt]
\implies\;&a{\;|}\left(
\frac{a(a+1)(2a+1)}{6}
\right)\\[4pt]
\implies\;&6{\;|}\left((a+1)(2a+1)\right)\\[4pt]
\implies\;&6{\;|}\left(b(2b-1)\right)\\[4pt]
\implies\;&6{\,|\,}b\;\;\text{or}\;\;\Bigl(2{\,|\,}b\;\;\text{and}\;\;3{\;|\,}(2b-1)\Bigr)\\[4pt]
\end{align*}
If $6{\,|\,}b$, then
\begin{align*}
S_2(b)&=\frac{b(b+1)(2b+1)}{6}\\[4pt]
&=\frac{b^3}{3}+\frac{b^2}{2}+\frac{b}{6}\\[4pt]
&=
\left({\small{\frac{b}{3}}}\right)\!{\cdot}\,b^2
+
\left({\small{\frac{b}{2}}}\right)\!{\cdot}\,b^1
+
\left({\small{\frac{b}{6}}}\right)\!{\cdot}\,b^0
\end{align*}
hence
$$
D(b,S_2(b))
=
\left({\small{\frac{b}{3}}}\right)
+
\left({\small{\frac{b}{2}}}\right)
+
\left({\small{\frac{b}{6}}}\right)
=
b
$$
If $2{\,|\,}b\;\;$and$\;\;3{\;|\,}(2b-1)$, then $b\equiv 2\;(\text{mod}\;3)$, so
\begin{align*}
S_2(b)&=\frac{b(b+1)(2b+1)}{6}\\[4pt]
&=\frac{b^3}{3}+\frac{b^2}{2}+\frac{b}{6}\\[4pt]
&=
\left({\small{\frac{b+1}{3}}}\right)\!{\cdot}\,b^2
+
\left({\small{\frac{b-2}{6}}}\right)\!{\cdot}\,b^1
+
\left({\small{\frac{b}{2}}}\right)\!{\cdot}\,b^0
\end{align*}
hence
$$
D(b,S_2(b))
=
\left({\small{\frac{b+1}{3}}}\right)
+
\left({\small{\frac{b-2}{6}}}\right)
+
\left({\small{\frac{b}{6}}}\right)
=
b
$$
Thus, for all cases, we have $D(b,S_2(b))=b$.
Comment: I believe you are on the right track. You can condition on $ n \pmod{6}$ and figure out what the coefficients are.
Answer: We can continue your casework on $ n \pmod{6}$.
Here's a sketch of it. Fill in the rest of the details yourself.
If $ n \equiv 0 \pmod{6}$, then $ \frac{ 2n^3 + 3n^2 + n } { 6} = \frac{2n}{6} \times n^2 + \frac{3n}{6} \times n + \frac{n}{6} \times 1 $,
 so $D_2 = \frac{2n}{6} + \frac{3n}{6} + \frac{n}{6} = n $.
If $ n \equiv 1 \pmod{6}$, then $ \frac{ 2n^3 + 3n^2 + n }{6} = \frac{ 2n-2}{6} \times n^2 + \frac{ 5n - 5 } { 6} \times n + \frac{ n + 5 } { 6}\times 1  $,
so $D_2 = \frac{ 2n-2}{6}  + \frac{ 5n-5}{6} + \frac{n+5}{6} = \frac{ 8n-2}{6}$.
If $ n\equiv 2 \pmod{6}$, then $  \frac{ 2n^3 + 3n^2 + n }{6} = \frac{2n - 4}{6} \times n^2 +  \ldots$
so $D_2 = \ldots $
$\vdots$
If $ n \equiv 5 \pmod{6}$, then $ \frac{ 2n^3 + 3n^2 + n }{6} = \frac{2n+2}{6} \times n^2 + \frac{n+1}{6} \times n + 0 \times 1 $,
 so $D_2 = \frac{2n+2}{6} + \frac{n+1}{6} = \frac{3n+3}{6} < n$.

I have not done the rest as yet, but I believe it will all work out (assuming the statement is true). I'd be happy to review your algebra if you are unable to conclude that $D_2  \leq 2 (n-1)$ and $ D_2 < n \iff n\equiv 5 \pmod{6}$.
Comment: Thanks now I clear to solution. Actually I want to solve, $D(a,S_m(a))\le m(a-1)$ for $a,m>1$ which was already asked here https://math.stackexchange.com/q/3503204/647719
Comment: My unfounded suspicion is that a similar approach will work, at least for small $m$. Track the carry over's (which is essentially what this is doing) to see if you can generalize what is happening.

Question on sum of digits of squares


Integer field with unix timestamp convert to readable date in views

Question: I have an Integer field in a content type, which contains a unix timestamp.  *(It is not a date module field; just a simple Integer field).  In a View, I am rendering this field, but obviously it is just going to spit out the long unix timestamp; and I want it to read Feb 20th, 2013.  How can I have Views format this field so that it spits out the readable date?  I imagine I would create the views-view-field--field-MYTIMESTAMP.tpl.php, and copy in the default code, then use some php logic to convert it, right?  But I am not sure how to do that part.
Comment: why cannot you use date module?
Comment: you could also try views php module.
Comment: It comes through a feed from another site.  At this point in time, It can't be changed.
Comment: Why use another module when you have views field tpl files available?
Comment: If you are using feeds module, there is a module - drupal.org/project/feeds_tamper - which allows you to modify the feeds data before saving to db.
Answer: First you should define a suitable format- Do this in the administrative GUI:

Navigate to: Administration » Configuration » Regional and language » Date and Time
Click the tab "Formats" and click on link "Add format".
Create a new format. You use the same string as you would pass to the PHP date function, i.e.: M jS, Y. Save it.
Click the tab "Types". Click on link "Add date type".
Select the newly created format from the menu, and name it: dateonly, and save it by clicking on "Add date type".

You now have a type of date format named dateonly defined you can use anywhere on your site there is a date field to be displayed without the hour and minutes part.
To format the date in your View, you may should Drupal format_date function with 'dateonly' passed as the type of format to use (second argument). To output this in your view you may have the following in your view-view-field--fieldname.tpl.php:
<?php
$nicedate = format_date($output, 'dateonly');
print $nicedate;
?>

IMHO, there is a big advantage in first defining a standard type of date format and giving it a name.  This ensures that dates are displayed consistently throughot the site.
However, if you can't be bothered to first define the dateonly type of format, you can use custom as your second argument to format_date and then, as your third argument, pass a string that can be passed on to the PHP date function:
<?php
$nicedate = format_date($output, 'custom', 'M jS, Y');
print $nicedate;
?>

Answer: You can override the template for that field as you mentioned, and use the date function to output a timestamp with the "Feb 20th, 2013" format:
print date("M jS, Y", $timestamp);

Comment: How would I wrap the views field output () in that?
Comment: In your view-view-field--fieldname.tpl.php file the $output variable should hold the timestamp, if so you can just pass $output to the date function:

    ``


Why does $\lim_{x\to\infty} (-1)^x$ involve complex numbers and natural exponential?

Question: I was curious and I just put this limit into mathematica and found out an unusual answer so I was wondering if anybody could tell me why is $$\lim_{x\to\infty} (-1)^x=e^{2i0 \; \textrm{to} \; pi} \ ?$$
Thank you.
Comment: How do you define $(-1)^x$ when $x$ is not an integer?
Comment: is the related to $z=x+iy=re^{i\theta}$ ? Or am I completely off?
Comment: wait $(-1)^{non integer}$ is a complex number, $(-1)^{odd number}$ is $-1$ and $(-1)^{even number}$ is $1$ but I can't really classify $\infty$ as any of those.
Answer: $$\lim_{x\to\infty}(-1)^x=\lim_{x\to\infty}(e^{i\pi})^x=\lim_{x\to\infty}e^{i\pi x}=undefined$$
Comment: Ah i didn't see it that way. Thanks for pointing that out!
Answer: First of all: this limit does not exist in the normal sense of a limit e.g. $$\lim\limits_{x\to\infty}\frac{1}{x}=0.$$
Now: if $x$ is an integer, we can easily say $(-1)^x=\begin{cases} 1, & x~\text{even} \\ -1, & x~\text{uneven}\end{cases}$. But already for $x\in\mathbb Q$ we have problems with that term, as e.g. $(-1)^{\frac{1}{2}}\stackrel{?}{=}\sqrt{-1}$. This becomes even more complicated when we allow $x\in\mathbb R$.  Thus by limiting ourselves to the real numbers, we can't define $(-1)^x$ for $x\in\mathbb R$.
This is not a problem when we are allowing complex numbers. For $a\in\mathbb C^*$ and $z\in\mathbb C$ one defines $$a^z:=\exp(z \operatorname{Log}(a))$$ with $\operatorname{Log}$ being the complex logarithm. This is fairly similar to $a^x=\exp(x\ln(a))$ with $a>0,x\in\mathbb R$, which you should know as the definition for exponentiation where the exponent can be any real number. There are still some problems one has to talk about (mainly because there are different branches of the complex logarithm and one has to define which branch $\operatorname{Log}$ refers to), but now one can talk about $(-1)^x$ with $x\in\mathbb R$.
Comment: hm I see. Thanks for help!


Alternative of "oneOf" construct in OpenApi 2.0 JSON

Question: I am trying to create a JSON that will be parsed with OpenApi 2.0 swagger definition in Microsoft Power Automate Custom connector.
This is the JSON i have currently
"connectionParameters" : {
    "param1" : "value1",
    "param2" : "value2"
}

I want to provide an alternative connection parameter schema, in which user has the option to choose from a set of params to provide value. This can be achieved in OpenAPI 3.0 in the following way:
"connectionParameters" : {
    anyOf : [
    {
      "param1" : "value1",
      "param2" : "value2"
    },
    {
      "alternateparam1" : "value1",
      "alternateparam2" : "value2"
    }
   ]
}

How can this be achieved in OpenAPI 2.0? "anyOf" is not available in OpenAPI 2.0 definition. I have explored the "discriminator" construct but couldn't find any implementation that I can provide with my JSON schema.
Comment: So if break it down, do you just want the ability for the user to select from a predefined list of values? Is that right?
Comment: Yes @Skin, I have two possible sets of values. I want user to select one of the sets and provide all the values in that set.
Comment: Do you control the endpoint behind the API definition?
Comment: Yes we control the endpoint
Answer: Personally, I think the approach you're trying with v3.0 would be a little confusing for the end user as I don't really understand what they'd actually be selecting in a dropdown persay.
I think your best bet (given you're limited anyway) is to use the ENUM keyword to define a basic list of values that when selected and passed into your API, you do the work in the background to select the more advanced objects that you've listed in your question.
https://swagger.io/docs/specification/data-models/enums/


Using a property to prove that Annihilator is maximal left ideal

Question: Let $M$ be a nonzero $R$-module.
Suppose the map $\phi_m: R/\text{Ann}(m)\to M$, $\phi_m(r+\text{Ann}(m))=rm$ is a well-defined $R$-module isomorphism for all $m\in M\setminus \{0\}$.
Using this property, prove that $\text{Ann}(m)$ is a maximal left ideal of $R$.

My attempt: I am ok with showing $\text{Ann}(m)$ is a left ideal of $R$, so we are left with showing $\text{Ann}(m)$ is maximal left ideal.
Suppose $I$ is a left ideal of $R$ and $\text{Ann}(m)\subsetneq I$. We wish to show that $I=R$.
What I tried is let $x\in I\setminus\text{Ann}(m)$. Then $xm\neq 0_M$. I am not very sure how to continue...
Thanks for any help!
Comment: R is commutative apparently?
Comment: I think for this question $R$ may not be commutative.
Comment: You may be right: I think what am thinking of is only a problem if $r$ is fixed and $m$ is the thing varying.
Answer: What you have is that for any nonzero $m,n$ in $M$, there exists an $r\in R$ such that $rm=n$. This is equivalent to $M$ being a simple $R$ module. (Prove this if you don't know it.)
By the module first isomorphism theorem, you have that all the kernels of your maps are maximal left ideals.
Comment: I see. Map right?
Comment: I think I get it. What do you mean by "apps" though?
Comment: @yoyostein haha right! Silly autocorrect


how to dynamically set the minPointLength except 0

Question: I like to set dynamically the value of the minPointLengh for high chart. But the below mentioned code is not working. can you please help me to get it done.
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            categories: ['Sep', 'Oct', 'Nov', 'Dec']
        },

        plotOptions: {
        var minPointLength;
                if(this.y > 0)
                  minPointLength = 3,
             else
                  minPointLength = 0,
            series: {
                        minPointLength: minPointLength,
            }
        },
        series: [{
            data: [4, 0, 1, 5]
        }]
    });
});

Comment: minPointLength is a series level option, but you are trying to tell it to look at the y value of a point. There are many reasons why this won't work the way you're trying to do it.  The best option that I have found for accomplishing what you want here, is to change all of your **zero** values for **null** values. minPointLength will not affect null values, but it will affect 0 values.
Answer: My suggestion: change any 0 values to null values.
The minPointLength will not affect any points with null y values.
Update code to:
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            categories: ['Sep', 'Oct', 'Nov', 'Dec']
        },

        plotOptions: {
            series: {
              minPointLength: 3
          }
        },
        series: [{
            data: [4, null, 1, 5]
        }]
    });
});

Example:

http://jsfiddle.net/3d3fuhbb/155/

Additional reason that your code wouldn't work: you are trying to set the minPointLength property directly within the plotOptions object - it needs to be inside one of the series selector objects (ie 'series: {}', 'column: {}', etc).
Answer: Problem with existing solutions:

minPointLength cannot be different for multiple bars in a series. So
that won't work  as I want 0 bar value to be unchanged.
I cannot change the data from 0 to null because I have a tooltip which shows data on hover so I cannot show null as data.

Solution:
We add extra bar height in series data and remove(subtract) that from tooltip data.

Create a property say extraBarHeight and push it to each data point in highchart
data (ie, the one you receive in the tooltip: formatter(data){}
).
Now add this extraBarHeight in the data that you're going to set in buildGraph(){
series:""
}
In tooltip check your data of formatter(data){, you'll find extraBarHeight for each bar. Subtract that amount from the tooltip data (that you probably will be fetching from points property which is automatically updated according to series data)

Now calculating extraBarHeight is tricky.

Iterate through all dataPoints in series data and find the highest
one, maxUnit
extraBarHeight = 10% of maxUnit (You can change percentage)
Compare each data point in series. We are doing this to avoid small units to become larger than big units and leave the zero bars as it is.
if(dataPoint< extraBarHeight && dataPoint !== 0)
 dataPoint = dataPoint + extraBarHeight;

It is a long and complicated solution but this is the only possible way at least for now.
Comment: Right, I also needed to show tooltips, so I followed this approach: https://stackoverflow.com/a/66363877/3339907
Answer: The solution shared by @jlbriggs works fine, but it also removes data from tooltips.
I took similar approach, but instead of making them null, I simply converted 0 values to -1 and set min in yAxis as 1. And also showed 0 for values <0 in tooltip.
Answer: This is not possible. The attribute minPointLength applies to an entire series and cannot be changed for individual points.
If you want to correctly show when values are positive and when they are 0, it may be helpful to show data labels so those columns are clearly marked (see this example at: https://jsfiddle.net/brightmatrix/1spxcsmd/).
Also, anything you want to do dynamically within Highcharts code needs to be in functions called by either events or the formatter function. You can't insert variables or code directly into the chart options. One of the reasons your original code wasn't working was due to your code in plotOptions.
Answer: You cannot use code inside object.
Try to do this:
var minPointLength;

    if(this.y > 0)
                  minPointLength = 3,
             else
                  minPointLength = 0,
        };

    series: {
                minPointLength : minPointLength
        }

Comment: plotOptions: {
        var minPointLength;
          if(this.y > 0)
                  minPointLength = 3,
             else
                  minPointLength = 0,
            series: {
              //if(this.y > 0)
                  minPointLength: minPointLength,
                 //else
                  // minPointLength: 0,
            }
        },
Comment: What is not working? What is the exception? Please elaborate.
Comment: can you please look the updated code in the question.