Is there a computer programm or CAS (maybe GAP?) that can calculate with projective (indecomposable) A-modules (A is a finite dimensional k-algebra)?

Question: I have the following question(s):
I have an "Algebra-With-One" $R$ as a subalgebra of a full matrix algebra in GAP.
Furthermore, I have 5 primitive orthogonal idempotents $e_1,...,e_5$, which sum up to $1_R$ (the identity matrix).
I would like to compute the projective indecomposable modules $P_1=e_1R,...,P_5=e_5R$ with GAP (or another computer programm (e.g. SAGE) which can handle with algebras and modules and maybe even the GAP data (e.g. the algebra R) I have produced so far)
and then I would like to test, whether $P_i$ and $P_j$ are isomorphic as $R$-modules for $i\neq j$.
I also would like to compute the algebras $e_i R e_j$ for all $i$ and $j$.
I can access the generators (as matrices) of the algebra $R$ and I know $e_i=...$ (as matrices).

Is GAP or any other freely available  computer program able to calculate with these things (projective R-modules, etc.)?

Thank you very much.
Comment: If you can rephrase your problem in terms of basic algebras, the calculations become significantly easier (and magma has nice methods for them).  Otherwise in GAP you are basically looking at the meataxe which can have trouble if the simple modules have large dimension (typical finite groups can have simple modules with dimensions in the thousands, but the routines are already slow in the low hundreds).
Comment: Thank you very much for your comment. I knew that GAP can do these things with meataxe for
group algebras, but I unfortunately don't know, how to let GAP calculate these things
(for example to compute $P_1$ and $P_2$ and test, whether they are isomorphic or not) for matrix
algebras. I, therefore, would be very thankful, if you could give me a small example, which shows, how to do this.
Answer: GAP's meataxe works with finite dimensional $k[G]$-modules for finite groups $G$ and finite fields $k$. However, the way you specify these modules $V$ does not actually keep track of $G$, only of the image of a generating set of $G$ in $\operatorname{Aut}_k(V) =  \operatorname{GL}(V)$.
Conversely given any finite field $k$, finite dimensional $k$-vector space $V$, and matrices $g_i \in \operatorname{GL}(V)$, we can define a finite group $G=\langle g_i \rangle$ and $k[G]$-module $V$, such that the images of its generators in $\operatorname{GL}(V)$ are precisely the $g_i$.
Every $n$-dimensional $k$-algebra $A$ with one for $n < |k|$ is generated by invertible matrices, and so is a $k[G]$ module for $G=A^\times$.
If your field is infinite, or if you just happen to be studying some sort of very diagonal algebra over a small field, then the meataxe does not apply, but for most $k$-algebras, $k$ finite, the meataxe should be ok.
Given a generating set X of $A$ consisting of invertible matrices over the field k, just use m:=GModuleByMats(X,k);.
The projective indecomposables are given by SMTX.Indecomposition(m) and to check if two projective indecomposables are isomorphic it suffices to check their heads,
gap> h1 := SMTX.InducedActionFactorModule( m1, SMTX.BasisRadical( m1 ) );;
gap> h2 := SMTX.InducedActionFactorModule( m2, SMTX.BasisRadical( m2 ) );;
gap> m1_iso_m2 := SMTX.Isomorphism( h1, h2 ) <> fail;
true

If you really want GAP to try harder, you can ask it to find isomorphisms between the actual modules too:
`
gap> m1_iso_m2 := SMTX.Isomorphism( m1, m2 ) <> fail;
true
`
Comment: I think the only non-invertible generators I have ever used have had minimal polynomial dividing $x^n(x-1)^m$ so that (over a field of characteristic not 2), either $a_i$ or $a_i + a_i^0$ is always invertible. The general idea is to let $z$ be a non-eigenvalue and then $a_i - z a_i^0$ is invertible. If the field is so small that $a_i$ has every element as an eigenvalue, then my simple ideas don't work and sometimes the algebra really is not the image of a group algebra (so no choice of $g_i$ is possible).


ProCurve ACL to prevent a subnet from leaving the switch

Question: I have a single HP ProCurve 2610 in a remote location that is connected in with the rest of the network via SHDSL. There are two Layer-3 networks on this segment. ACLs are setup to deny one subnet (192.0.2.0/24) from ever being able to leave the switch by virtue of being applied to port attached to the upstream connection. The other subnet should be permitted to freely leave the switch. Both subnets are on the same VLAN.
Unfortunately SFlow very clearly show broadcast traffic from 192.0.2.0/24 on the upstream connection. ProCurve ACLs are not my strong suit but I feel like I'm missing something very simple here.
<code>ip access-list extended "Filter for Camera Network"
   deny ip 192.0.2.0 0.0.0.255 0.0.0.0 255.255.255.255 log
   permit ip 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255
   exit

interface 24
   name "DSL - UPLINK"
   access-group "Filter for Camera Network" in
exit
</code>
Unless I am mistaken traffic from 192.0.2.0/24 should be dropped as it crosses the uplink port (int 24) whereas all other traffic will be permited by the following default allow rule.
What exactly am I missing here?
EDIT:

Firstly, why do you have two subnets contained in the same VLAN?

Because that's how it was configured by a previous administrator and while it makes conceptual sense that a single subnet is "mapped" to a single VLAN there's no technical constraint that I am aware of that makes this have to be the case.

Instead of filtering inbound traffic on your uplink, you should be filtering outbound traffic.

The HP2600 series can only filter inbound traffic on interfaces. Should I change my filter to deny any to 192.0.2.0/24?
Comment: No, changing your filter to deny any to 192.0.2.0/24 would block any externally initiated connections to 192.0.2.0/24.  In order to block that subnet from getting out of that interface, you need to filter outbound traffic.
Answer: Firstly, why do you have two subnets contained in the same VLAN?. Although, that's not your problem here.  I can't speak to the syntax of the commands as I haven't configured HP ProCurves, but it seems your logic is off.  Instead of filtering inbound traffic on your uplink, you should be filtering outbound traffic.  The uplink interface wouldn't receive traffic from that subnet, it would pass traffic through.
Comment: Please see my edit.
Answer: The simple answer is reconfigure the Layer3 device providing routing to NOT have an interface or secondary IP in the subnet that you don't want to leave the switch.  If there is no layer 3 route from/to that subnet then traffic will only exist in the layer2 switching environment of the switch for that subnet.
Edit: if it has an uplink to another switch you can filter the subnet on THAT switch inbound.
Answer: If you're right about the traffic filters on the 2610 (it's been a while since i've looked at them), then you should be adding this filter on the individual ports which are part of that address range.  Filtering traffic on the uplink would only work if the 2610 supports outbound filters.
Presumably you've got a server collecting the camera data on the same VLAN?  In that case, you'll probably also need an extra rule in there which allows 192.0.2.0/24 to 192.0.2.0/24, and you probably don't want to apply the ACL to the server port, otherwise you won't be able to access it remotely.


how to connect to snowflake via configure via spring bean in mule3

Question: i am using database connector in mule 3 to connect to snowflake , Can any one suggest how can i connect to snowflake via spring bean config in mule 3
Attaching the screenshot for the reference.
Comment: try with database URL .You must be having snowflake account URL .
Answer: You need to create a Spring Bean datasource that wraps your database JDBC driver. Usually that is done by using a pool library (don't try your own implementation).
Example using the c3p0 pool library:
<code><spring:beans>
 <spring:bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  <spring:property name="driverClass" value="${JDBC.driver}"/>
  <spring:property name="jdbcUrl" value="${JDBC.URL}"/>
  <spring:property name="user" value="${JDBC.user}"/>
  <spring:property name="password" value="${JDBC.password}"/>
  <spring:property name="minPoolSize" value="5"/>
  <spring:property name="maxPoolSize" value="20"/>
  <spring:property name="acquireIncrement" value="1"/>
  <spring:property name="idleConnectionTestPeriod" value="100"/>
  <spring:property name="maxStatements" value="0"/>
  <spring:property name="checkoutTimeout" value="60000"/>
 </spring:bean>
</spring:beans>

<db:generic-config name="dbConfig" dataSource-ref="dataSource"
    doc:name="Generic Database Configuration"  />
</code>
There are more examples at https://help.mulesoft.com/s/article/Spring-based-datasources


Powershell or other Windows method to copy datestamped html file to network share

Question: Im new to powershell - so serious noob.
But I wanted to see if anyone could help in doing the following.
We have a folder on a server that has reports written to it every night.
The reports are named in the following format:
DiskSpaceReport_26102012.html
and location of C:\Powershell\WebReport\
I would like a PS script to copy these 1 of these files from the folder using a daterange of -8 Days from the date the script runs - the script would be run as part of a windows scheduled task or through SQL Agent job.
So at present there are 8 files in the folder dating from Friday 26 Oct to Friday 19th Oct.
I would like the process to run today and copy the file -8 days back from todays date.
So copy the file named DiskSpaceReport_19102012.html
And this process should repeat weekly on friday and copy the last file from 8 days ago.
The copy is to a network share
\\Server01\Powershell\Webreports_Archive
And as I mentioned in title I dont mind if this is easier to do via robocopy in a batch file for example.
Would prefer it via PS though.
Answer: The following will do what you want:
$pastdays = -8
$pastdate = [datetime]::Now.AddDays($pastdays)
$filename = "DiskSpaceReport_" + $pastdate.Day + $pastdate.Month + $pastdate.Year+".html"
Copy-Item -Path "C:\Powershell\WebReport\$($filename)" "\\Server01\Powershell\Webreports_Archive"

regards
Jon
Comment: Excellent - does exactly what is says on the TIN !


SDWebImage downloadWithURL doesn't response sometimes

Question: I am trying to use SDWebImage library to download in efficiency images. I use to download 10 photos at the same time in serial order (the function downloadWithURL create a thread for every request). sometimes with specific urls the function is like stacking in infinite loop. neither success callback is called nor error. I know im using not the newest version of the library but I guess its strange that the bug is there.
my code looks like this:
<code>SDWebImageManager *manager = [SDWebImageManager sharedManager];

[manager downloadWithURL:[NSURL URLWithString:self.imageURL]
  delegate:self
  options:SDWebImageRetryFailed
  success:^(UIImage* image)
   { NSLog(@"downloaded successful"); }
  failure:^(NSError* error)
   { NSLog(@"downloaded failure"); }];
</code>
Answer: Just add BOOL completed in success brackets, and then it will work like a charm...
<code>    SDWebImageManager *manager = [SDWebImageManager sharedManager];

[manager downloadWithURL:[NSURL URLWithString:self.imageURL]
  delegate:self
  options:SDWebImageRetryFailed
  success:^(UIImage* image,BOOL Completed)
   { NSLog(@"downloaded successful"); }
  failure:^(NSError* error)
   { NSLog(@"downloaded failure"); }];
</code>


How can I simulate pointers without using them?

Question: I've got a C# code that runs on Azure and is web enabled so it should be safe. That means I can't use pointers.
I've got this problem - My Data structure is a SortedList where each node is an object X. Each object X includes an array where each cell is another SortedList of object Y. objects of type X and Y have distinct IDs (so they are searchable of course).
Now, I need a way to get directly to a Y object, without searching it through X objects and then Y objects. (It could be millions on objects)
In C/C++ I'd use a list of Y object IDs with pointers to the actual object. Such way I'd search only once for the object.
Any ideas how this could be accomplished in C#?
Thanks!
Comment: The reason there are no pointers in C# is *almost everything is a pointer*. If you say `MyClass p = a[i];`, `p` is a pointer. `a` is an array of pointers, and both `a[i]` and `p` are pointing at the same object. What you can't do is *pointer arithmetic*.
Comment: http://msdn.microsoft.com/en-us/library/t63sy5hs%28v=VS.100%29.aspx
Comment: If you simulate pointers, you will also simulate the associated problems. Pointers are essentially means of indirection. It is in the nature of indirection that it can lead you nowhere, unless you take extra steps (check every indirect reference if it's still valid).

To put it differently: simulating pointers doesn't give you any essential security benefits over simply using them.
Comment: ohh... so I CAN have a list of pointers. Just declare them as objects (without initializing them)?
Comment: Thanks. It seems that my objects qualify to be of reference type, i.e - a kind of pointer :)
Comment: People often talk about reference types vs value types in .NET. Nobody ever seems to mention the mysterious third type - References! Because they are in fact pointers and pointers scare people...
Answer: Just use instances in C# as you would in your C++ solution, but without the <code>-></code> C++ pointer deref. All things that refer to an instance of a class type in .NET are object references, which are actually pointers. If you construct an instance of a type in C# and assign it to a variable and an array element and pass it as an argument, all of those are pointers to the same object data in memory.
No need to simulate pointers in C#. Everything already is a pointer.
Comment: Thanks :) That's the answer I was looking for!
Answer: well you could try hashing, there is the Hashtable
class. If everything is in a sorted list though you can use binary search which even with millions of records wont take that long.
Rereading your explanation of your data structure i have this question. what is the point of object X storing Object Y if your initial plan is to store a list of all Y's separately anyway? why cant you store a sorted list of X where each X contains a sorted list of the ids of associated Y objects, and you have a separate sorted list of Y objects? if its possible to search Y without knowing its related X then you are creating a bad data structure to hold you objects. Or you could create a database and use SQL to grab what you need when you need it, which if you have millions of records is probably a good way to go.
Comment: Well, the problem with a HashTable is the need to make it bigger after several operations (mostly A LOT operations) - my data is highly dynamic and the operation of creating a new HashTable every so and then can result in really bad results.

About SQL - all the data is stored in SQL. The data structure is for the cache because I must have real-time data querying. SQL just won't do what I need.

I could reverse it as you say - store all Y objects in a sorted list and store pointers to them in the X object. Sounds like it would perform the same.


Let $m$ be a natural number with digits consisting entirely of $6'$s and $0'$s. Prove that $m$ is not the square of a natural number.

Question:
Question: Let $m$ be a natural number with digits consisting entirely of $6'$s and $0'$s. Prove that $m$ is not the square of a natural number.

My approach: Given that $m\in\mathbb{N}$ with digits consisting entirely of $6'$s and $0'$s. Let this property be called $P$.
Now for the sake of contradiction let us assume that $m$ is a perfect square, that is $m=k^2$ for some $k\in\mathbb{N}$. Now since $m$ ends either with $6$ or $0$, implies that $m$ is even, which in turn implies that $2|m$. Therefore, $2|k^2\implies 2|k\implies k=2l$, for some $l\in\mathbb{N}$.
Thus $k^2=4l^2\implies m=4l^2\implies 4|m.$
Also observe that the sum of the digits of $m$ is equal to $6j$, for some $j\in\mathbb{Z}.$ Now since $3|6j$, implies that $3|m$. Proceeding as above we will have $9|m$.
Now since $\gcd(4,9)=1$ and $4|m, 9|m$, implies that $36|m$.
Now clearly two cases are possible:
$1.$ $m$ ends with $6$ and
$2.$ $m$ ends with $0$.
Observe that if $(1)$ holds true then $\frac{m}{6}$ ends with $1$, which implies that $\frac{m}{6}$ is odd. But $6|\frac{m}{6}\implies 2|\frac{m}{6},$ which implies that $\frac{m}{6}$ is even. Thus this case leads to a contradiction, which implies that $m$ doesn't ends with $6$. Or in other words this implies that all the natural numbers $m$ (the natural numbers having property $P$) ending with $6$ cannot be a perfect square.
Now if $(2)$ holds true, then $5|m.$ Now since $m$ is a perfect square, implies that $5^2|m$. Now since $\gcd(5^2,6^2)=1$, implies that $5^2\times 6^2|m$. Now this clearly means that $m$ ends with $00$.
How to proceed from here?
The problem can be solved by taking$\pmod {100}$ of all the natural numbers and eventually arrive at a contradiction, but that doesn't seem to be efficient enough.
Comment: Does this answer your question? [Proving that a natural number made entirely of 6's and 0's is not a square.](https://math.stackexchange.com/questions/335673/proving-that-a-natural-number-made-entirely-of-6s-and-0s-is-not-a-square)
Comment: In line 6, we deduce that 9 divides m; can somebody explain this to me? Because m is made up of 0 and 6, it is true that 3 divides the sum of m's digits, i.e., m. But, based on this logic, can we deduce that 9 divides m as well? Consider the numbers 60 and 606, which do not fulfil the reasoning. Thank You.
Answer: If $m$ ends with $00$, you can simply start again with $m'=m/100$.
And if $m$ ends in $60$, then $5|m$, therefore $25|m$; but multiples of $25$ must end in $00,25,50,$ or $75$, a contradiction.
Answer: Okay, here goes my solution.
Given that $m\in\mathbb{N}$ with digits consisting entirely of $6'$s and $0'$s. Let this property be called $P$.
Now for the sake of contradiction let us assume that $m$ is a perfect square, that is $m=k^2$ for some $k\in\mathbb{N}$. Now since $m$ ends either with $6$ or $0$, implies that $m$ is even, which in turn implies that $2|m$. Therefore, $2|k^2\implies 2|k\implies k=2l$, for some $l\in\mathbb{N}$.
Thus $k^2=4l^2\implies m=4l^2\implies 4|m.$
Also observe that the sum of the digits of $m$ is equal to $6j$, for some $j\in\mathbb{Z}.$ Now since $3|6j$, implies that $3|m$. Proceeding as above we will have $9|m$.
Now since $\gcd(4,9)=1$ and $4|m, 9|m$, implies that $36|m$.
Now clearly two cases are possible:
$1.$ $m$ ends with $6$ and
$2.$ $m$ ends with $0$.
Observe that if $(1)$ holds true then $\frac{m}{6}$ ends with $1$, which implies that $\frac{m}{6}$ is odd. But $6|\frac{m}{6}\implies 2|\frac{m}{6},$ which implies that $\frac{m}{6}$ is even. Thus this case leads to a contradiction, which implies that $m$ doesn't ends with $6$.
Now if $(2)$ holds true, then $5|m.$ Now since $m$ is a perfect square, implies that $5^2|m$. Now since $\gcd(5^2,36)=1$, implies that $5^2\times 6^2|m$. Thus $100|m$, which clearly means that $m$ ends with $00$. Now this also implies that $m'=\frac{m}{100}$ is yet again a perfect square ($\because$ $100=10^2$ is a perfect square) consisting entirely  of digits $6'$s and $0'$s. Then we can yet again conclude that $100|m'$ and $m'$ ends with $00$. Now let $m''=\frac{m'}{100}$ and keep continuing this iteration. After this iteration ends we can certainly conclude that $m=100^j$ for some $j\in\mathbb{N}$. This also implies that $m$ is entirely a combination of $1$ and $2j$ $0'$s, which contradicts the fact that $m$ has property $P$. Hence $m$ does not end with $0$.
Thus $m$ does not end neither with $0$ nor with $6$, which is a clear contradiction to the property $P$.
Hence $m$ is not the square of a natural number.
Comment: This is what the first answer by TonyK said already, so you really should give credit to that.
Answer: The answer given by @TonyK establishes that $m$ cannot end in a string of one or more $0$s, so it must end in $06$ or $66$. Hence, $m=100k+6$ or $m=100k+66$. Since $m$ is even, its square must be evenly divisible by $4$. But $(100k+6,\ 100k+66)\equiv 2 \bmod 4$, so a contradiction results, and the hypothesis that $m$ can be a square composed entirely of the digits $0,6$ must be false.
Answer: You don't have to do it for 2).
Let $N = N'\times 10^k$ so that $N$ ends with $k$ zeros but once you remove the $k$ zeros $N'$ will end with $6$.
If $N=m^2$ is a perfect square then $k$ is an even number of zeros and $m^2 = N'\times 10^k$ and $m = \sqrt {N'}\times 10^{\frac k2}$ and $N'$ is a perfect square that ends in $6$ and which contains only sixes and zeros.
......And you are back to case 1).
.....
Or if you grab the tiger from the other end (the one without the point teeth) and say
$n$ is a number that ends with $k$ zeros ($k$ could be zero and $n$ could and with no zeros).  Then $n = m\times 10^k$ where $m$ is a number that does not equal $0$.
Then $m = 10a + b$ where $b = 1,....,9$ and
$n = (10a + b)\times 10^k$.
And $n^2 = (100a^2 + 20ab + b^2)\times 10^{2k}$.
Now suppose $n^2$ has only $0$s and $6$s.  Then $100a^2 + 20ab + b^2$ has only $0$s and $6$es.
So $b^2$ must end in a six or zero but of $1^2, 2^2, 3^3....., 9^2$ only $4$ and $6$ will end in a $6$ and none of them end in a $0$.  So $b = 4$ or $b = 6$.
If $b = 4$ then $100a^2 + 80a + 16$ contains only zeros and sixes.  So $80a + 16$ must end with either $06$ or $66$.  Which means $8a$ must end in either $9$ or $5$. But that's impossible as $8a$ is even.
If $b = 6$ then $100a^2 + 120a + 36$ contains only zeros and sixes.  So $120a+36$ must end with either $06$ or $66$.  Which means $12a$ must end in either $7$ or $3$.  But that's impossible as $12a$ is even.
So it is impossible for $n^2$ to have only sixes and zeros.
Answer: Another approach which I think is simpler is to use the following fact:

If $m$ is a perfect square, then for every prime $p$ the power of $p$ occurring in $m$ - that is, the largest $s$ such that $p^s\vert m$ - must be even.

To see how this is relevant, first consider ${m\over 2}$. This has only $3$s and $0$s as digits. In particular, we have ${m\over 2}=10^k\cdot c$ for some $k$ and some $c$ which is not divisible by either $2$ or $5$ (since $c$ ends in "$3$").
But then we have $$m=2\cdot 10^k\cdot c=2^{\color{red}{k+1}}5^kc$$ for some $k$ and some $c$ not divisible by either $2$ or $5$, and this is impossible: if $k$ is odd then $m$ can't be a square since the power of $5$ occurring in $m$ is odd, and if $k$ is even then $m$ can't be a square since the power of $2$ occurring in $m$ is odd.

A bit more snappily: let $Pow_a(b)$ be the largest $n$ such that $a^n\vert b$. Then if $m$ consists only of $6$s and $0$s, we have $Pow_2(m)=Pow_5(m)+1$. This means that one of $Pow_2(m)$ and $Pow_5(m)$ is odd. But if $m$ were a perfect square then $Pow_p(m)$ would be even for every prime $p$.
Answer: I have another approach
Any number is of the form $10^n a$  where n is a whole number so if we square it we get $10^{2n} a^2$ basically if we remove the trailing zeroes the resulting number must also be a square.
Incase of m it looks like
m=6.....6
or
$m=6(1.....1)=2*3(1....1)$ and we notice that the resulting number is odd  but for m to be square we needed at least another two.
Therefore m is not perfect square


List of String Insert method increases its size

Question: Here is the code
    Public Class FrmPatientFolder

Dim tab1RTBtext As List(Of String)
Dim comboboxprevious As Integer
Dim comboboxcurrent As Integer

Private Sub FrmPatientFolder_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'this contains 12 string which are too long to include in code
tab1combolist = New List(Of String)(New String() {"1",..to..,"12"}

ComboBox1.Items.AddRange(tab1combolist.ToArray)
ComboBox1.SelectedIndex = 0

comboboxprevious = -1
comboboxcurrent = 0

'this performs a select query that either returns a list of 12 strings or nothing
tab1RTBtext = selectFromTable(New List(Of String)(New String() {"*"}), "chronicle", "amka", Me.Text)

If tab1RTBtext Is Nothing Then
tab1RTBtext = New List(Of String)
tab1RTBtext.Add(Me.Text)

For Each item In tab1combolist
tab1RTBtext.Add("")
Next

insertNewPatientIntoTable("chronicle", tab1RTBtext)
tab1RTBtext.RemoveAt(0)

Else
tab1RTBtext.RemoveAt(0)
RichTextBox1.Rtf = tab1RTBtext(0)

End If

End Sub

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

     If comboboxprevious <> -1 Then
        comboboxprevious = comboboxcurrent
        comboboxcurrent = ComboBox1.SelectedIndex

    Else
        comboboxcurrent = ComboBox1.SelectedIndex
        comboboxprevious = comboboxcurrent
    End If

    If comboboxcurrent <> comboboxprevious And comboboxprevious <> -1 Then

        Console.WriteLine(tab1RTBtext.Count)
        Console.WriteLine(comboboxprevious & tab1RTBtext(comboboxprevious))

        tab1RTBtext.Insert(comboboxprevious, RichTextBox1.Rtf.ToString)
        Console.WriteLine(tab1RTBtext.Count)
        Console.WriteLine(comboboxprevious & tab1RTBtext(comboboxprevious))
        RichTextBox1.Rtf = tab1RTBtext(comboboxcurrent).ToString
    End If

End Sub

End Sub

and this is what happens if select the second item of combobox at runtime
12
0
13
0{\rtf1\ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f\fnil\fcharset161 Trebuchet MS;}}
\viewkind4\uc1\pard\f0\fs24\par
}

So I'm telling the list, that if the index of the combobox changed, to store the richtextbox.rtf at the index of the previous combobox item. And yet every time the insert method is being called, it increases the list size. Why is this happening??? Besides that, when I change the selected item in the combobox, it doesn't do what it's supposed to, it doesn't display the correct values which means that the list's size doesn't expand from the end but from the insertion point?
Maybe the handling of rtf is wrong here and I should check for formatting with empty string, then clear the contents before storing but I can't imagine how this could have any effect to the problem I'm facing.
I read here https://www.dotnetperls.com/list-insert that the list class is optimized for the add method, and If one wants to use insert instead, should consider using the linkedlist class, but If I were to do that then I would have to adapt my code in many other places.
Comment: Well I'm stupid... insert shouldn't be used in this case... I should directly place the value inside my list at the previous index... no wonder Noone wants to state the obvious.
Answer: change this
tab1RTBtext.Insert(comboboxprevious, RichTextBox1.Rtf.ToString)

into
tab1RTBtext(comboboxprevious) = RichTextBox1.Rtf.ToString

and this is what happens when you make assumptions about how a method works. I hope you had a good laugh, or giggle at least. :)


How can it be explained that /proc/uptime does not match ctime of system files?

Question: I have a small webspace (PHP + MySQL). Nothing special.
I can read /proc/uptime using PHP and it returns:
51967189.77 1731371689.58

So the uptime is 601 days (51967189 / 60 / 60  / 24).
I have also listed the files in the /dev folder. On the left there is the creation time (d.m.Y).
17.03.2023 .
17.03.2023 ..
17.03.2023 full
28.07.2021 log
17.03.2023 null
17.03.2023 random
17.03.2023 tty
17.03.2023 urandom
17.03.2023 zero

Other folders like /bin /sbin /var /lib64 also have 17.03.2023 as creation time.
Because these files and folders are created on boot it means the uptime is only 5 days.
So I have 601 days vs. 5 days.
How can it be /proc/uptime does not match creation time of files like /dev/null?
Answer: Note how few devices your /dev actually has.
Your webspace is in a container – it has its own dedicated /dev (and its own /bin, etc.) and overall an isolated view of the filesystem, but still shares the actual "OS" (the running kernel) with all other webspaces on that system. The various customers' containers come and go, with each getting a brand new /dev, but the host OS remains running continuously and that's the uptime reported via /proc.
(It's the same kind of "container" as in Docker or LXC.)
/dev/log is the odd one, because it's a socket that gets mounted from the outside (i.e. from the /dev/log of the host OS) so that all containers' logs would be collected by the same syslog daemon.

Also, "ctime" is not creation time – it's inode change time, updated whenever any metadata is changed. The actual creation time field is "btime" (birth time), which is a relatively new addition to Linux (PHP's stat() does not support it yet).
Comment: Thanks. Does 601 days uptime mean they never update the kernel or do they use live patching? It's a big hoster I cannot imagine they never apply security patches.
Comment: You'll have to ask them specifically. (Or poke around e.g. in /proc/modules for signs of livepatch, or /proc/version for signs of Ksplice.)


PHP Variable Scope Issue

Question: I am writing a plugin for WordPress but I can't seem to get my flag going.  It is driving me nuts!  Here's the code without the class wrapper:
<code>static $js_flag;

function init()
{
    add_shortcode('jw_html5', array(__CLASS__, 'jw_html5_shortcode'));
    add_action('init', array(__CLASS__, 'jw_add_js' ));
}

public function jw_html5_shortcode( $atts, $content = null )
{

    self::$js_flag = true;
    $vid = '';

    extract( shortcode_atts( array(
        'src' => '/vids/video.mp4',
        'width' => 480,
        'height' => 320
        ), $atts ) );

    $vid = "<video id='player' src='$src' width='$width' height='$height' type='video/mp4'> </video>";

    return self::$js_flag;
    //return $vid;
}

public function jw_add_js()
{

    if(self::$js_flag)
    {
        wp_register_script('jw_player', plugins_url('scripts/player.php', __FILE__), array('jquery'), '.01', true);
        wp_register_script('jw_player_script', plugins_url('scripts/jquery.jwplayer.js', __FILE__), array('jquery'), '.01', false);
        wp_register_script('jw_playlist', plugins_url('scripts/jquery.playlist.js', __FILE__), array('jquery'), '.01', false);

        wp_enqueue_script('jw_player_script');
        wp_enqueue_script('jw_playlist');
        wp_enqueue_script('jquery');
        wp_enqueue_script('jw_player');
    }

}
</code>
I've set the flag in the shortcode function but it's not passing it to the jw_add_js() function.  It's sort of a bitch to debug in WP.  Any advice would be super appreciated.
Update:  I found the answer to this after messing around.  I had to register my scripts and then store the handles in an array.  I then pass the array with wp_print_scripts() method.  Hope this will help someone!
Comment: *Are* the methods being called statically?
Comment: the code looks fine to me, are your sure that that jw_html5_shortcode is being called first?
Comment: Yea, it'll output the value to 1 when I check the page so the method does set it to true.
Comment: I'm calling the init method after the class is define by doing this:
My_Class::init();
Comment: If you found a solution to one of your questions you should answer your own question with that solution and then accept that answer.
Comment: I didn't know you could do that.  Thank you for letting me know.
Answer: I found the answer to this after messing around. I had to register my scripts and then store the handles in an array. I then pass the array with wp_print_scripts() method. Hope this will help someone!

PHP Variable Scope Issue


Prove similarity of triangles

Question:

I found this question in one of my textbooks.

In the given figure, ABCD and AEFG are 2 squares.
Prove that:
$i) \frac{AF}{AG} = \frac{AC}{AD}$
$ii) ∆ACF \sim ∆ADG$

This is what I could do:

$i) AF^2 = AG^2 + GF^2\\
\rightarrow AF^2 = 2•AG^2
\rightarrow AF = AG•\sqrt{2}
\rightarrow \frac{AF}{AG} = \sqrt{2}$
Similarly, $\frac{AC}{AD} = \sqrt{2}$
Therefore, $$\frac{AF}{AG} = \frac{AC}{AD}$$

In $(ii)$ part, $\frac{AF}{AG} = \frac{AC}{AD}$ can be one reason for similarity. What will be the other reason?
Answer: Since a spiral similarity centred at $A$ maps $GF$ to $DC$, so there's also a spiral similarity (see for lemma #3 of this for a sketch of proof ) centred at $A$ mapping $GD$ to $FC$, hence QED.
Comment: FYI I'm 16 year old, and I would **highly** recommend working on the book "Eucledian Geometry in Mathematical Olympiad" by Evan Chen if you're interested in geo. Also, which part you didn't understand ? (Spiral similarity basically means what you see in the image, a composition of a rotation and a dilation, both centred at same point; mapping just a fancy term for a transformation; and lemma basically means a part of a proof)
Comment: I appreciate your help. But actually, I would prefer something a bit easy as I can't make head or tail out of terms like 'spiral similarity','mapping' and 'lemma'. Something comprehensible to a 14-year old would help.
Comment: What does dilation mean? BTW, this image will give you an idea of my level of understanding. This is my textbook's pic - https://photos.app.goo.gl/jh6WxUYrCTjutIwx2
Comment: Sorry - then when I have free time I'll write a detailed and elementary explanation of what I wrote.
Comment: When you're free, come [here](https://chat.stackexchange.com/rooms/73654/explaining-spiral-similarity-to-aditya) and give me a @ping.
Answer: Take $\Delta ADG$ and increase it at $\sqrt2$ such that you'll get $\Delta AD'G'$ with $D\in AD'$ and $G\in AG'.$
Now, rotate $\Delta AD'G'$ around $A$ on $45^{\circ}$.
You'll get $D'\rightarrow C$ and $G'\rightarrow F$ and we are done!
Maybe it will help to understand the Alex's reasoning.
Answer: Reason 1 - $$\frac{AF}{AG} = \frac{AC}{AD}$$
Reason 2 -  $\angle DAC = \angle GAF = 45°$
$\rightarrow \angle DAC - \angle GAC = \angle GAF - \angle GAC $
$$ \rightarrow \angle DAG = \angle CAF$$

$\therefore$ By $Side-Angle-Side$ congruency,

$$ \triangle ACF \sim \triangle ADG $$

Prove similarity of triangles


WebStorm SCSS configuration for keeping empty lines

Question: How should I configure WebStorm in order to keep empty lines placed into a SCSS file? When formatting it removes them.
Comment: Can you please attach a code sample? WebStorm by default keeps 1 empty line between the block and inside the blocks.
Comment: `@import "validation";
empty line here
@import "dag-view";
// sometimes css items in scss at component level are ignored
@import "patches/patches";
` just consider you have a line per import and comment
Comment: there is no such feature; please feel free to file a request for it to youtrack, https://youtrack.jetbrains.com/issues/WEB
Answer: U can use ij_scss_keep_blank_lines_in_code option in ur .editorconfig file like that
[*.scss]
ij_scss_keep_blank_lines_in_code = X

X - is the maximum allowable amount of blank lines


Two default Ubuntu instances cannot access each over through Amazon VPC

Question: I am running two Ubuntu 12.04 instances, both of which cannot access each other.
Machine 1:
eth0 - 10.0.0.20
eth1 - 10.0.0.30

netstat -nr:
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG        0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth1
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0

Machine 2:
eth0 - 10.0.0.100
eth1 - 10.0.0.40

netstat -nr:
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG        0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth1

Both machines have access to each other only through internet, but not through VPC (LAN, in other words). Disabling firewall does not help. Machine 1 can ping only 10.0.0.100. Machine 2 can ping only 10.0.0.30. I am unable to connect to any of the machines in TCP/UDP protocols through LAN. There are no ACLs and the daemons on the machines are listening on all IPs, all interfaces. What could be the problem?
Edit 1:
It seems that the problem was in routing tables. I have solved the issue on Machine 1 after deleting 1 NIC on Machine 2 and doing some random actions. This resulted in DHCP obtaining these rules:
~$ ip rule
0:      from all lookup local
32765:  from 10.0.0.30 lookup 2
32766:  from all lookup main
32767:  from all lookup default
~$

I cannot reproduce this on Machine 2, but I can add the rules and routing tables manually with:
ip route add default via 10.0.0.1 dev eth0
ip route add default via 10.0.0.1 dev eth1 table 2
ip rule add from 10.0.0.167 lookup 2 prio 1000

How could I avoid doing it manually?
Comment: can i ask: why do you have two ip's from same subnet on different interfaces? you can have multiple ip addresses assigned to the same interface.
Comment: As I understand, Amazon does not allow binding more than 2 external IP (Elastic IPs) to one network interface. Am I right? Or should I bind it to local network address and then it would work? But still - shouldn't it work the way I'm trying to make it work?
Comment: Could you please show a traceroute from machine1 to machine2 and vice-versa? But as GioMac already said, your routing tables look messed up because you use the same subnet on multiple interfaces. Doing that may produce the side-effects you encounter.
Comment: If you need that many IPv4 addresses, something is probably wrong with your architecture. (Or you're trying to send spam....)
Comment: I need at least 2 IP addresses because I am running several HTTP servers. If I were sending spam, Amazon wouldn't work (they limit the amount of traffic on 25 port and they are very cautious, meaning that they check bounces and etc. from time to time). By the way - sometimes the ping as well as traffic from machine 2 to 10.0.0.30 goes through and sometimes it doesn't. The traceroutes are in case they don't: http://pastebin.com/CGjmSAR9
Comment: What are the contents of your security groups?
Comment: have a look at ethernet aliases for the proper way to do this.  Also, simplify, test, confirm, then proceed: make sure connectivity works with 1 address per interface per machine first before adding complexity.
Comment: Security groups allow all traffic in all protocols.
Ethernet aliases do not work and this is NOT the proper way to do this in Amazon VPC, because EIP are usually attached to NICs, not private IPs.

P. S. I added some more information by editing. The problem was in the routing tables.
Answer: Try adding the routes more specifically. Routing will prefer the first matching route ordered by specificity, metric, then order of addition.
For example, on machine 1, add the following route:
ip route add 10.0.0.40/32 dev eth1 src 10.0.0.30

And on machine 2:
ip route add 10.0.0.30/32 dev eth1 src 10.0.0.40

you may want to delete the more general routes for eth1 on both machines:
ip route del 10.0.0.0/24 dev eth1

Since they are in /24s, you should try to get them in different subnets, for example, if both eth1s were in 10.0.1.0/24, you wouldn't have this problem at all.
Comment: Now I get this: http://pastebin.com/NVu36Hiq
Comment: hmm, it's not particularly clear which two are your internal interface pair and which are your external; that should work.
Comment: Both of them are internal and external.


What is the legal basis for fining players for out-of-game actions?

Question: How is it that sports leagues are able to fine players for things like expressing their displeasure with the league or its employees, or wearing the wrong clothes? There must be some sort of special employee-employer thing going on, because I can't imagine any employer I've ever had being legally able to fine me for legally protected speech. Is this something the unions agree to on collective bargaining? Is there standard boiler-plate language in every contract?
Update: I'm referring to the US-based leagues (MLB, NHL, NBA, NFL, MLS, WNBA) since they operate under US law. Leagues based in other countries may operate under different legal regimes and therefore may have different ways of doing things.
Comment: You might not be fined, but if you criticize your CEO or your company publicly, I don't imagine you'd be up for a raise next year...
Comment: @Joe More to the point, my company has no legal grounds to fine me. So what makes sports leagues different?
Comment: You also probably don't have a binding, largely uncancellable contract with your employer, do you?
Answer: In the case of the NHL, this is definitely covered by the CBA, in particular section 18-A.2:

Whenever the Commissioner determines that a Player [...] has been or is guilty of conduct (whether during or outside the playing season) that is detrimental to or against the welfare of the League or the game of hockey, he may discipline such Player in any or all of the following respects:
[...]
(c) by imposing a fine on the Player not exceeding the maximum permissible fine
under Section 18.7(b).

The MLB Basic Agreement contains similar language in Article XII - B:

Players may be disciplined for just cause for conduct that is materially
detrimental or materially prejudicial to the best interests of Baseball

where "discipline" can include a fine.
For the NFL, "conduct detrimental to the Club" can result in

maximum fine of an amount equal to one week's salary and/or suspension without pay for a period not to exceed four (4) weeks.

Source: Article 42 1(a)(xv) of the NFL CBA. Note that this is what may be imposed by a club; I don't believe there are any limits to the discipline that the league / the Commissioner can impose specified in the CBA.


Manage zoom level on Xcode9 simulators

Question: Since Xcode 9 came out the simulator scale is disturbed. Here there is not any option of scaling further to 100% on some simulators and sometimes I am unable to switch to 100 % scale at all.
After searching on net I found out that sometimes if zooming doesn't work I need to do following to get it 100% zoom.

Uncheck Window -> Show Device Bezels
Click Window -> Zoom
Check Window -> Show Device Bezels

Is it something that I am missing to scale it further if I want to or current Xcode doesn't support further scaling at all.
Comment: This question is already been answered [here](https://stackoverflow.com/questions/18606926/adjusting-the-xcode-iphone-simulator-scale-and-size) by someone.
Answer: Just drag the corner of the simulator window.
Comment: I mean there's no real indicator that you could do that. I mean yeah it's an os convention to be able to pull on the sides to grow a window but there's no frame to pull so it makes people not treat it like a normal OS/X app. When you think about it's kinda poorly designed in that respect :P
Comment: Yeah obvious its an option but we can't zoom it beyond screen size or if we make it zoom, we can't scroll all the way to bottom.
Comment: amazing, I really could not even thought about it)

Manage zoom level on Xcode9 simulators


Correlation between daily average and individual observations

Question: I just want to calculate the correlation between two variables. One of them ($Y$) is measured daily while the other ($X$) is measured multiple times per day. The two obvious options are:

Calculate the correlation between $Y$ and the daily average of $X$
Broadcast the value of $Y$ for each value of $X$ on a given day and calculate the correlation.

Obviously this question applies to regression more broadly, but all I really want is to calculate the correlation.
It doesn't seem like multi-level models are exactly what I want, because I think they assume the effect of $X$ on $Y$ differs by group. In my case, the relationship between $X$ and $Y$ should be fixed.
Answer: Multilevel analyses do not assume that effects are fixed, they can be specified as fixed or random, but it is up to you to choose.
I would regress $X$ on $Y$ and adding days as clusters. The nice thing about multilevel analysis is that it weights the effects of days. For example, consider two scenarios, you could either (a) pool your data per day (average by day), or (b) ignore day and put all data in a single regression. In (a) you lose the within day variation and in (b) you are mixing within and between day variation altogether. The multilevel analysis will weight between these two scenarios.
Comment: This would be better than averaging all X within a day because that approach would not account for possibly different numbers of X's on different days. How would they estimate the correlation after fitting that model?


Looping through an array and displaying data

Question: I am trying to loop through an array and display that. The problem I've got is that for some reason only the ID is being displayed. I've gone through and debugged and can't understand why this doesn't work. All the data I want to process is available as I've checked through debugging and logging out the array.
Here is the HTML to display:

  <p *ngIf="carsArray.length < 1">No cars are available

= 1">

{{ car.id }}

{{ car.type }}

{{ car.manufacturer }}

{{ car.colour }}

Here is my typescript that retrieves said data.
fetchData() {
  this.http
    .get<{ [key: string]: car }>(
      'actual URL goes here'
    )
    .pipe(
      map((ResponseData) => {
        const carsArray: car[] = [];
        for (const key in ResponseData) {
          if (ResponseData.hasOwnProperty(key)) {
            carsArray.push({ ...ResponseData[key], id: key });
          }
        }
        return carsArray;
      })
    )
    .subscribe((post) => {
      this.carsArray = post;
      console.log(this.carsArray);
    });
}

Here is a what I'm currently getting:

Any help would be appreciated as I'm completely stumped!
Comment: I see `Colour` and you're trying `colour` ... case mismatch ?
Comment: So you're doing `{ ...ResponseData[key], id: key }` and only seeing `id` ... coud you `console.log(ResponseData[key])` just before the `push` ... maybe the data is in a sub object ?
Comment: Would you mind providing the sample response object? whats getting inside `carsArray`?
Comment: @SélimAchour I logged `console.log(ResponseData[key]);` and this is what I get: https://i.imgur.com/8qSJ0En.png so the array looks okay to me
Comment: @sunnyprakash this is my cars object if that's what you mean?
`export interface car {
  manufacturer: string;
  colour: string;
  type: string;
  id?: string;
}`
Comment: @SélimAchour where are you seeing upper case Colour. It looks to be the same everywhere for me.
Comment: @TomCockram in the png you provided
Comment: @TomCockram i saw the image you have provided. there, keys are capitalized, but the interface which you have given all are in lowercase. maybe case issue.
Comment: Yeah this is screenshot from the firebase database I'm using and for some reason when I submit the data they're uppercase!!! https://i.imgur.com/g1lFvR2.png
Comment: Basically you're getting { Colour: ..., Type: ...} and you're printing .colour and .type. Just change `{{ car.type }}` to `{{ car.Type }}` and see if that fixes the issue
Comment: .................................. So I changed my types inside the model to have upper case and they're all displayed. Thanks guys!!! I just couldn't work out what was wrong
Answer: The solution was to change my model file to have upper case types. The data that was being submitted to the database was in uppercase...
export interface car {
  Manufacturer: string;
  Colour: string;
  Type: string;
  id?: string;
}


Can we maximize the log of the odds instead of log of the probability?

Question: As above. This question relates to all optimization formulations in statistics.
Answer: Yes, because if you have two different probabilities $p_1$ and $p_2$ with $p_1 < p_2$, the following are all equivalent:
\begin{align}
p_1 & < p_2 \\
- p_1 & > - p_2 \\
1 - p_1 & > 1 - p_2 \\
\frac{1}{1 - p_1} & < \frac{1}{1 - p_2}
\end{align}
because applying an increasing function does not reverse the inequality (like $f(x) = x + 1$ from line 2 to 3) while applying a decreasing function (like $g(x) = -x$ from lines 1 to 2 and $h(x) = 1/x$ for positive values of $x$ from lines 3 to 4) does reverse the inequality. Then multiplying the first and last lines gives you
$$
\frac{p_1}{1 - p_1} < \frac{p_2}{1 - p_2}.
$$
These are also equivalent to $\log(p_1) < \log(p_2)$ and
$$
\log \left( \frac{p_1}{1 - p_1} \right) < \log \left( \frac{p_2}{1 - p_2} \right)
$$
because $\log$ is an increasing function.
Comment: I've never seen an example. You would want to choose whichever made the optimization an easier problem to solve. If using the log odds $\log(p/(1-p)) = \log(p) - \log(1 - p)$ simplifies the problem, then it would be good to use it. But I think minimizing $\log(p)$ is typically easier than trying to minimize log odds $\log(p) - \log(1 - p)$ unless the problem has a form that is simplified by this, since the latter includes the former as a subexpression.
Comment: From your experience, have you seen examples of problems where this is done indeed?
in deeplearning we always go after log of likelihood / prob.


Best practices for creating cross platform application using xamarin

Question: I'm trying to create a business application for Android and iOS, using Xamarin.
Applications for both operating systems (Android and iOS) will have the same layout.
Functionality is simple - User login, Table views, Map views, Search & filter, Navigation menu, video play lists etc.
I'll pick one of these approaches when creating the app:

Create separate versions of the app with Xamarin.Android and Xamarin.Ios
Make the app cross-platform with Xamarin.Forms

What are the pros and cons that I should be aware of with both approaches?
Comment: This can't be meaningfully answered on SO.  It depends on your specific requirements and preferences - there is no "right" answer.  I suggest visiting the Xamarin forums if you want to get some opinions about the pros and cons of each approach.
Answer: Xamarin.Forms is best for:
Apps that require little platform-specific functionality
Apps where code sharing is more important than custom UI
Developers comfortable with XAML
Xamarin.iOS & Xamarin.Android are best for:
Apps with interactions that require native behavior
Apps that use many platform-specific APIs
Apps where custom UI is more important than code sharing
If i was in your place, would've chosen Xamarin.Forms


Why is coxph() so fast for survival analysis on big data?

Question: I frequently do survival analysis on large data sets. One million samples or more is typical, and this seems to be much more than typical research usage. Many algorithms I've used are prohibitively slow at this scale.
Fortunately, the coxph routine in R's survival package is remarkably fast and scales much better with sample size than other packages. Why is this? Is there a reference for the algorithm implemented in coxph?
I'd like to understand so that I can investigate numerically efficient methods for time-dependent covariates on large data. Existing methods seem to be very slow (including the time transform functionality in survival) and I suspect that they may consume much more time and/or memory than necessary.
At the very least, it seems that some delicate algorithmic techniques have been used. Here's a relevant note from the time-dependent covariates vignette:

Although handy, the computational impact of the tt argument should
  be considered before using it. The Cox model requires computation of a
  weighted mean and variance of the covariates at each event time, a
  process that is inherently $O(ndp^2)$ where $n =$ the sample size, $d =$ the number of events and $p =$ the number of covariates. Much of the algorithmic effort in coxph() is to use updating methods for
  the mean and variance matrices, reducing the compute time to
  $O((n+d)p^2)$. When a tt term appears updating is not possible; for
  even moderate size data sets the impact of $nd$ versus $n + d$ can be
  surprising.

This is a tantalizing hint but I don't know how the overall algorithm works and thus cannot really understand it. I'd prefer a mathematical exposition over wading through the source, and I wasn't able to find one in the references for coxph in the survival package manual on CRAN.
Answer: Believe it or not, it's just Newton-Raphson. It's right here. The weighted mean and covariance matrices mentioned in the vignette passage are Equations (3.4) through (3.6).
Comment: Why are you surprised? Newton-Raphson is extremely fast; it has quadratic convergence. Given one can get a reasonable and not too expensive approximation to the Hessian N-R is probably his best bet to optimise a function. The whole battle is when one cannot get a Hessian and has to use quasi-Newton stuff (eg. BFGS) or  derivative-free *deep magic* (aka. linear/quadric approximations - eg. NEWUOA).
Comment: I like Newton-Raphson, but it is not always fast after accounting for the cost of computing the Hessian, as in this case. Sometimes specialty approaches (or special variants of N-R) can be faster. In this case it's N-R with tricks to speed up the gradient/Hessian computation.
Comment: Agreed. I specifically said "*not too expensive approximation*" and then pointed to quasi-Newton methods.


If there a way to know the IP address of a machine when I use "\\" to access to?

Question: I normally access to an organisation shared folder by typing \\someserver in Windows run command, Is there any method to know the IP address of the server that I am accessing to?
Answer: Name resolution in recent Windows systems is done via DNS protocol. Old versions were using WINS and NBNS.
The tool to resolve a name using DNS is nslookup.
For WINS you can use nblookup
Comment: Can a simple ping the server name work?
Comment: I do not think that `ping` will use other resolving mechanisms besides `hosts` file  and DNS.


CSS & JS files not rendered when deploy of ASP.Net MVC application on IIS 8 (Windows 8)

Question: I'm having an issue when deploying my Asp.NET MVC 5 web application on a remote IIS 8 ! when i'm starting the server, the application works well, but no css or js file is working !
my local machine :

my remote machine :

my view when I click on view page source (in the browser) :
<!DOCTYPE html>

  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Log in - My MVC Admin Template</title>
    <link href="/Test/Deploy/Content/Theme?v=A1Wwh5B5yTT6Q-34hA0bU7wzaNpIMgCZT8xJ-IAWWVY1" rel="stylesheet"/>

       <form action="/Test/Deploy/" class="bootstrap-admin-login-form" method="post"><input name="__RequestVerificationToken" type="hidden" value="C7q6oci5GoiOMjIeCGgn9-U4lMlx54WJz8117lyBbFcbDak6TzJE2z3kKeBkvyJTJxg6viMGh8dOxCUV2qUP87bZBWyXgMsx3g9Tozmxoc41" />

Login

            <input class="form-control" type="text" name="Email" placeholder="Email">

        <input class="form-control" type="password" name="Password" placeholder="Password">

                <input data-val="true" data-val-required="The Remember me? field is required." id="RememberMe" name="RememberMe" type="checkbox" value="true" /><input name="RememberMe" type="hidden" value="false" />
                Remember me?

    <button class="btn btn-lg btn-primary" type="submit">Submit</button>
  </form>

©  2015 -  Test

my BundleConfig.cs :
    public class BundleConfig
{
    public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
    {
        if (ignoreList == null)
            throw new ArgumentNullException("ignoreList");
        ignoreList.Ignore("*.intellisense.js");
        ignoreList.Ignore("*-vsdoc.js");
        ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
        //ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
        ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
    }

    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.IgnoreList.Clear();
        AddDefaultIgnorePatterns(bundles.IgnoreList);
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
            "~/Scripts/bootstrap.js",
            "~/Scripts/respond.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
            "~/Content/bootstrap.css",
            "~/Content/site.css"));

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
            "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery.unobtrusive*",
            "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
            "~/Scripts/bootstrap.js"
            , "~/Scripts/twitter-bootstrap-hover-dropdown.js"
            ));

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

        bundles.Add(new StyleBundle("~/Content/Theme/base/css").Include(
            "~/Content/Theme/base/jquery.ui.core.css",
            "~/Content/Theme/base/jquery.ui.resizable.css",
            "~/Content/Theme/base/jquery.ui.selectable.css",
            "~/Content/Theme/base/jquery.ui.accordion.css",
            "~/Content/Theme/base/jquery.ui.autocomplete.css",
            "~/Content/Theme/base/jquery.ui.button.css",
            "~/Content/Theme/base/jquery.ui.dialog.css",
            "~/Content/Theme/base/jquery.ui.slider.css",
            "~/Content/Theme/base/jquery.ui.tabs.css",
            "~/Content/Theme/base/jquery.ui.datepicker.css",
            "~/Content/Theme/base/jquery.ui.progressbar.css",
            "~/Content/Theme/base/jquery.ui.theme.css"));

        //Calendar css file
        bundles.Add(new StyleBundle("~/Content/fullcalendarcss").Include(
            "~/Content/themes/jquery.ui.all.css",
            "~/Content/fullcalendar.css"));

        //Calendar Script file
        bundles.Add(new ScriptBundle("~/bundles/fullcalendarjs").Include(
            "~/Scripts/jquery-ui-1.10.4.min.js",
            "~/Scripts/fullcalendar.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/vendors").Include(
            "~/Content/Theme/vendors/uniform/jquery.uniform.js"
            , "~/Content/Theme/vendors/chosen.jquery.js"
            , "~/Content/Theme/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/wysihtml5.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/core-b3.js"
            , "~/Content/Theme/vendors/twitter-bootstrap-wizard/jquery.bootstrap.wizard-for.bootstrap3.js"
            , "~/Content/Theme/vendors/boostrap3-typeahead/bootstrap3-typeahead.js"
            , "~/Content/Theme/vendors/easypiechart/jquery.easy-pie-chart.js"
            , "~/Content/Theme/vendors/ckeditor/ckeditor.js"
            , "~/Content/Theme/vendors/tinymce/js/tinymce/tinymce.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/wysihtml5.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/core-b3.js"
            , "~/Content/Theme/vendors/jGrowl/jquery.jgrowl.js"
            , "~/Content/Theme/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"
            , "~/Content/Theme/vendors/sparkline/jquery.sparkline.js"
            , "~/Content/Theme/vendors/tablesorter/js/jquery.tablesorter.js"
            , "~/Content/Theme/vendors/flot/jquery.flot.js"
            , "~/Content/Theme/vendors/flot/jquery.flot.selection.js"
            , "~/Content/Theme/vendors/flot/jquery.flot.resize.js"
            , "~/Content/Theme/vendors/fullcalendar/fullcalendar.js"
            ));

        bundles.Add(new StyleBundle("~/Content/Theme").Include(
            "~/Content/bootstrap.css",
            "~/Content/bootstrap-theme.css",
            "~/Content/Theme/css/bootstrap-admin-theme.css",
            "~/Content/Theme/css/site.css"));

        bundles.Add(new StyleBundle("~/Content/Vendors").Include(
            "~/Content/Theme/vendors/bootstrap-datepicker/css/datepicker.css"
            , "~/Content/Theme/css/datepicker.fixes.css"
            , "~/Content/Theme/vendors/uniform/themes/default/css/uniform.default.min.css"
            , "~/Content/Theme/css/uniform.default.fixes.css"
            , "~/Content/Theme/vendors/chosen.min.css"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/stylesheets/bootstrap-wysihtml5/core-b3.css"
            , "~/Content/Theme/vendors/easypiechart/jquery.easy-pie-chart.css"
            , "~/Content/Theme/vendors/easypiechart/jquery.easy-pie-chart_custom.css"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/stylesheets/bootstrap-wysihtml5/core-b3.css"
            , "~/Content/Theme/vendors/jGrowl/jquery.jgrowl.css"
            , "~/Content/Theme/vendors/bootstrap-datepicker/css/datepicker.css"
            , "~/Content/Theme/vendors/fullcalendar/fullcalendar.css"));
    }
}

my login page :
@model LoginViewModel
@{
  ViewBag.Title = "Log in";
 }

     @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "bootstrap-admin-login-form" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

Login

        <input class="form-control" type="text" name="Email" placeholder="Email">
        @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })

        <input class="form-control" type="password" name="Password" placeholder="Password">
        @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })

                @Html.CheckBoxFor(m => m.RememberMe)
                @Html.LabelFor(m => m.RememberMe)

    <button class="btn btn-lg btn-primary" type="submit">Submit</button>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
 }

in my Web.Config file i put this:
 <system.webServer>
   <modules runAllManagedModulesForAllRequests="true">
     <remove name="BundleModule" />
     <add name="BundleModule" type="System.Web.Optimization.BundleModule" />
     <remove name="FormsAuthentication" />
     <remove name="ApplicationInsightsWebTracking" />
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" />
   </modules>
   <validation validateIntegratedModeConfiguration="false" />
 </system.webServer>

I saw a lot of solutions on the web, both on server and project side ! I enabled the static content in windows features. I changed the BundleConfig.cs file as told here Bundler not including .min files, but nothing worked for me !
NB: One of my pages has some styles defined in the razor file, it's rendering well ! so I think that the problem is somewhere within the bundle file !
can anyone help me please ?
<==== EDIT =====>
I just put in my Web.Config file :
  <compilation debug="false" targetFramework="4.5" />

and the result in my local machine is without styles (just like the remote one) if it can help someone to understand...
Comment: Did you check in global.asax if you are registering bundles?

In Application_Start method, you should have this line:
     BundleConfig.RegisterBundles(BundleTable.Bundles);
Comment: @MárcioGonzalez Yes I have it in my global.asax
Comment: What are the response status codes returned by the missing resources?
Comment: @Neps I tried to click on  and I got :
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Comment: @Neps I enabled the directory browsing in IIS, and when I clicked again on the same link, I saw that the bundle is working ! because it took me to the directory where my css files are !
I really don't understand why it's not rendering in my page !
Comment: That's odd, that link should take you the CSS file itself, not the directory.
Comment: @Neps what to do then ? what to modify ??
Answer: I solved the problem!
Thanks to Bundling & minification not applying css & js using Asp.net 4.0 C# !
All I had to do is to change in my bundleConfig.cs file the name from :
  bundles.Add(new StyleBundle("~/Content/Theme").Include(
            "~/Content/bootstrap.css",
            "~/Content/bootstrap-theme.css",
            "~/Content/Theme/css/bootstrap-admin-theme.css",
            "~/Content/Theme/css/site.css"));

to
  bundles.Add(new StyleBundle("~/Content/allcss").Include(
            "~/Content/bootstrap.css",
            "~/Content/bootstrap-theme.css",
            "~/Content/Theme/style/bootstrap-admin-theme.css",
            "~/Content/Theme/style/site.css"));

Answer: The answer by the author is correct but its not helpful. I had to look a little more deeper to solve this issue.
I found that when you release the application to production or whatever reason and your bundle.config file is not configured properly then you will have CSS/JS not rendered problem.
In order to solve this i had to make some changes in bundle.config file.
All the style files in the same folder go under one Virtual path and if you have other CSS files that are located under different folder you have to create a new bundle for those.
e.g. i had my custom css called "site.css" and "bootstrap.css" in same folder so i created
bundles.Add(new StyleBundle("~/Content/allcss").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"

                  ));`

Then i also had font-awsome which i wanted to include in the project. so i created another bundle
bundles.Add(new StyleBundle("~/Content/css/font-awsome").Include(
                 "~/Content/css/font-awesome.css"
            ));

And afterwards i add both paths to my Layout.cshtml file.
 @Styles.Render("~/Content/allcss")
@Styles.Render("~/Content/css/font-awsome")

Works like a charm.
Comment: sir, are you sure you are referring to "bundle.config" and not BundleConfig.cs? if so, I couldn't find it. Can you tell me where it is? I am new to mvc
Answer: If the website is SSL secured, make sure you have a fully qualified address for your resources. That is the first thing that comes to my mind.
-G
Comment: no, I just checked, it's not SSL secured ! it's http not https !
Comment: Remove the extensions from the bundle names then. This will cause .NET to process the request and run it through the BundleModule. Try that out eh.
Comment: can you take one bundle from my file and remove its extention please ? I don't understand what you want to say ! new ScriptBundle("~/bundles/jquery") has no extension !
Comment: Add this to your web config then, under system.webserver.
Comment: I already put it in my web.config file ! but seems it's not working too ! I just added that in my problem description, you can have a look


mouse_event vs real mouse event

Question:
Is there a difference between a real mouse click (by hand) and execution of the click from code (by mouse_event in c#)?
Similarly, is there a difference between the real moving the mouse cursor and setting Cursor.Position?

If there is a difference:

How to recognize source of that event?
There is a way to simulate a mouse click / cursor move as if it came from a mouse or keyboard driver?

Edit1: Code sample added for @Marco Forberg.
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

    Button button;

    private void Form1_Load(object sender, EventArgs e)
    {

        button = new Button();
        button.Text = "Click";
        button.Location = new Point(50, 50);
        button.Size = new System.Drawing.Size(100, 20);
        button.Click += button_Click;
        Controls.Add(button);

        Button simulate = new Button();
        simulate.Text = "Simulate";
        simulate.Location = new Point(50, 100);
        simulate.Size = new System.Drawing.Size(100, 20);
        simulate.Click += simulate_Click;
        Controls.Add(simulate);

    }

    void button_Click(object sender, EventArgs e)
    {
        Console.WriteLine(sender);
    }

    void simulate_Click(object sender, EventArgs e)
    {
        Point location = button.PointToScreen(Point.Empty);
        Cursor.Position = new Point(location.X + (button.Width / 2), location.Y + (button.Height / 2));

        mouse_event(0x02 | 0x04, 0, 0, 0, 0);
    }
}

Comment: A real click could get intercepted and may cause more than one event to be thrown, running an event will only fire the one event.
Comment: Yes for example. Left mouse click should be created by 2 events: DOWN 0x02 and UP 0x04.
Answer: There is no difference if you create proper Event arguments. The only way to find out that event is from "machine" is to analyze moments.
Comment: So if I change Cursor.Position and run mouse_event randomly in time or will simulate the behavior of the human hand, it is impossible to identify the origin event?
Answer: @Garath,
MSLLHOOKSTRUCT contain a LLMHF_INJECTED flag witch is set when the event come from a call to mouse_event function.
You can retrieve this information by using SetWindowsHookEx as I explained here.
Answer: The difference between a real click on a control and programmatical call to your mouse event handler should be the sender prarameter.
For real mouse clicks you receive the control that was clicked as sender. when you call an event handler programmatically you should provide a sensible sender
Comment: I know what you mean, but the question was about the origin of the event rather than an object which event was executed.
Comment: what do you mean by "origin". the `sender` parameters holds/should hold the element where the event came from
Comment: For me it is not important on which the control was done event. Whether I click with the mouse manually (by hand), or I use mouse_event (programmatically), sedner is identical in both cases.
Comment: cann you please show me a code snippet how you call the event?
Comment: ah looks like i missunderstood you. thought you called the handler and not simulate a click
Answer: I'm also trying to do this in C# but within an injected c# dll, hosted clr.
A friend of mine suggested reading this article http://pastebin.com/rj4YcW4C
I'v tried mouse_event, PostMessage,SendMessage,SendInput and Cursor.Position.
All ignored but i beleave that article has the answers we both seek.

mouse_event vs real mouse event


Testing an update hook that updates fields?

Question: I wrote an update hook for a site that moves data from one field to another. It looks a lot like this gist:
<code>  foreach ($node_ids as $node_id) {
    try {
      $node_wrapper = entity_metadata_wrapper('node', $node_id);
      $node_wrapper->field_new_field->set($node_wrapper->field_old_field[0]->value());
      $node_wrapper->save();
    }
    catch (Exception $e) {
      watchdog('mymodule', 'Problem with node @node_id', array('@node_id' => $node_id), WATCHDOG_ERROR);
    }
    $sandbox['progress']++;
  }
</code>
It's being tested on CI (Travis) which runs "drush updatedb -y" so what I was wondering is if there is a way to query a particular node and make sure the field is populated? Like for example make sure the data in field_new_field is the same as _field_old_field and printing that on the command line?
Answer: Yes, very quickly. You already have part of the code. Since you have already loaded the node via the entity_metadata_wrapper() you have all of the information at your finger tips.
An example is this in your hook_update_N()
<code>foreach ($node_ids as $node_id) {
    try {
      $node_wrapper = entity_metadata_wrapper('node', $node_id);
      $node_wrapper->field_new_field->set($node_wrapper->field_old_field[0]->value());
      $node_wrapper->save();
      if ($node_wrapper->field_new_field->value() == $node_wrapper->field_old_field->value()){
        print_r('Success. Old field data is in new field data');
      }
    }
    catch (Exception $e) {
      watchdog('mymodule', 'Problem with node @node_id', array('@node_id' => $node_id), WATCHDOG_ERROR);
    }
    $sandbox['progress']++;
  }
</code>
I added a comparison of the old field data and the new field data. If it is the same, it will print 'Success. Old field data is in new field data' in the console of Travis-CI. You can do this for any entity. You can use print_r() to output data that you can see in Travis-CI's console. I do this for troubleshooting my test scripts when I may be using a new test method I have never used before and I want to see what Drupal is giving me. Most of the modules I maintain on D.O are tested with Travis-CI.


Proving that a given function is continuous in a given set.

Question: Consider the function $q(x) = \frac{1}{2} \| x \|^2$ defined in $C := \{ x \in \mathbb R^n \colon Ax = b \},$ for some matrix $A \in \mathbb R^{m \times n}$ and $b \in \mathbb R^m$ such that the system in question is feasible.
I aim to prove that such function is continuous.
My attempt. By definition, $q$ is continuous if
$$ \forall \epsilon >0, \exists \delta > 0 \colon \, \| x -y\| < \delta \implies | q(x)-q(y)| < \epsilon.$$
Consider arbitrary elements $x,y \in C, \epsilon > 0$ and take $\delta = \sqrt{2\epsilon}.$ Now, suppose that $\| x - y \| < \delta.$ Then,
$$ |q(x)-q(y)| = \frac{1}{2} | \, \|x\|^2 - \|y\|^2  | \leqslant \frac{1}{2} \| x - y\|^2 < \frac{1}{2}\delta^2 = \frac{2}{2}\epsilon = \epsilon. $$
Since the elements taken were arbitrary, this proves continuity.
My concerns after reviewing. Initially, I tought my attempt might just be right, but after some further thought, I figured that the inequality I used:
$$ | \, \|x\|^2 - \|y\|^2 \, | \leqslant \| x-y\|^2$$
doesn't (even) hold for real numbers, let alone for $C$. At the same time, I don't another way to do this.
Thanks for any help in advance.
Comment: Your set $C$ and your factor $\frac12$ are irrelevant. I suggest you suppress them from your post, and simply ask for the continuity of $x\mapsto\|x\|^2$ on $\Bbb R^n.$
Answer: Write instead
$$ 2|q(x)-q(y)| =  \bigl| \|x\|^2 - \|y\|^2  \bigr| =\bigl| \|x\| - \|y\|\bigr|\cdot(\|x\| + \|y\|)\le \|x- y\|\cdot ( \|x-y\| +2 \|y\|)|.
$$
To show that $q$ is continuous at a given $y$ note that if $\|x-y\|<\delta$, then
$$
2|q(x)-q(y)| \le \delta( \delta +2 \|y\|).
$$
Now you just need to take $\delta$ sufficiently small.
Answer: Everything works fine if you drop the squares. I mean: you seem ready to prove that the map $x\mapsto\|x\|$ is continuous on $\Bbb R^n.$
You certainly know that the map $t\mapsto t^2$ is continuous on $\Bbb R, $ and that the composition of two continuous maps is continuous. (If you don't, better concentrate on proving these two basic facts than solving your exercise.)
So, you have won.
Comment: That's a cool approach - a good way to avoid a direct approach. Thanks for your help.


Why do only one controller used to serve all incoming requests in Java?

Question: I'm coming from .NET world. Know for, pretty sure, that in Web applications (MVC),

.NET: A new controller instance is created for each & every incoming request
  to the webserver and the result is rendered.

See SO Question & Answer for more details.
But, I'm about to develop a Java web application and was shocked to hear this:

Java: One controller instance is used to serve each & every incoming
  request to the web-server. (Singletons)

I also googled to learn that the above statement is true. Here
As for as I know, MVC is a framework and that is independent of implementing languages.
Why is this discrepancy ?
Or am I missing something out of here ?
Comment: Not sure how useful this question is. You are trying to compare 2 distinct frameworks that have completely different implementation details. You also seem to suggest (though I may be wrong) that MVC as a concept seems to favour one way or the other, that wouldn't be accurate. (still, not my downvote)
Comment: @downvoters: Please feel free to leave your comment with your vote.
Comment: In java, you can use 1 controller to serve many request, or make individual controller for each request. It's entirely upto you.
Comment: You are right, it is independent. It's your choice to implement as many controllers as you need. I think you are coming from the Spring side. There the framework is already implemented and you have to use it's structures.
Comment: @MarcelHöll There's nothing Spring specific about this. A basic `Servlet` is reused instead of creating a new instance every time. This means that you can't have state in servlets, although sounds like you can't have state on .NET side either (but for a different reason).
Answer: I don't know of any specific reason why this is the case, but I can think of some pros and cons.
Java's way pros

Avoids object creation which could affect things when you're getting a lot of requests
Allows you to keep state inside controller

Java's way cons

Allows you to keep state inside controller. As the objects are multithreaded, you must make sure that any state you keep inside the controller (which is strongly discouraged) is used in a thread-safe way. This is not always obvious and can cause bugs.

.NET's way pros

Simple
State can be kept in the object for the duration of the request (sort of "semi-global variables") without any specific thread-safe code. No chance of the next request seeing state from a previous one (one reason why Java discourages the keeping of state in controller).

.NET's way cons

May be a (minor) issue if handling a lot of requests at once

Probably others too, but these I can think of off the top of my head. The difference is most likely due to a design decision, which may be impossible to track down. However, as explained in the comments, neither way is "correct". MVC doesn't require one or the other.


Is $L$ order isomorphic to $\mathbf{R}$?

Question: Let $L$ be a linearly ordered set which is equinumerous to $\mathbf{R}$, and  $L$ is order dense,which means that  for every $x,y\in L$,if $x<y$ ,then there is a $z$ such that $x< z < y$. And $L$ has no  first and no last element. Is it true that $L$ is order isomorphic to $\mathbf{R}$?
Comment: You can find in model theory textbooks that the theory of dense linear orders with no endpoints is $\aleph_0$-categorical but not $\kappa$-categorical for $k>\aleph_0$.
Answer: No. Let $\Bbb P$ be the irrationals in their usual order. Then $\Bbb R$ and $\Bbb P$ have the same cardinality, and both are dense linear orders without endpoints, but $\Bbb R$ is order-complete, and the irrationals are not, so they are not order-isomorphic.
Answer: Brian Scott's answer is excellent, but maybe it's worth noticing the following too:

Say you have a copy of $\mathbb Q$ followed by a copy of $\mathbb R$.  Or you can intersperse lots of copies of $\mathbb Q$ and $\mathbb R$, and get a linearly ordered set satisfying all the stated conditions, but not order-isomorphic to $\mathbb R$.
Look at the plane whose points are $(x,y)$, which  $x,y$ real, in lexicographic order.  It's not order-isomorphic to $\mathbb R$.
Look at the set of all countable ordinals.  That's an uncountable set.  Between each such ordinal and the next, put a copy of the interval $(0,1)$.  Then the cardinality of that ordered set is $\aleph_1 2^{\aleph_0}=2^{\aleph_0}$.  But it's not order-isomorphic to $\mathbb R$ since the latter has no subset that's order-isomorphic to the set of all countable ordinals.  Every subset of $\mathbb R$ that's well-ordered in the usual order on $\mathbb R$ is at most countable.


How to insert node in TreeView as the first one?

Question: I have tree view structure , and I need to implement function:
public void InsertNodeAtTheBeginning(TreeView tree, TreeNode node)
{
  tree.Nodes.Add_(node); // node should be added as tree.Nodes[0]
}

And every other nodes should be offset: tree.Nodes[1]...tree.Nodes[tree.Nodes.Count + 1].
All nodes in the tree have .Level property is equal to 0 ( so it's like a list)
Answer: Try TreeView.Nodes.Insert(0, ...)


Weird stuttering issues that I cannot get rid of (full source included)

Question: I based my game off the lunarlander example and have been having stuttering issues since I first started making it. Nothing I have tried has gotten rid of them, so I have gotten to the point where I have spent a few hours creating a stripped down version of the lunarlander example and put a simple scrolling image in to show the stuttering. NOTE: it is not related to the garbage collector. If you think it is, just look at the log, the garbage collector runs no-where near as often as the stutter appears.
The image that scrolls down the screen stutters approximately every second for about 1/10th of a second on my phone (Motorola Milestone, 2.2). This kind of stuttering does not exactly completely destroy gameplay, but it is very distracting and frustrating. My game also involves a lot of fast scrolling and quick movements so it is generally more obvious there.
If any of you have the time could you take a quick look at this eclipse project and see if:

It stutters for you on your phone (look closely as it scrolls, it has a small hitch every half second to second and a half)
If you can see any way to fix the stuttering

I am hoping I simply have an errant line of code that is causing this whole thing without me realising. I just can't believe that even after stripping out this much, it still has the exact same amount of stutter as my full game with 1000 objects, especially since it runs at a solid 60fps on my phone.
I have profiled my game on Traceview; it seems fine.
Source download link: http://dl.dropbox.com/u/4972001/LunarLander.rar
Comment: did you try profiling your game with traceview? http://developer.android.com/guide/developing/tools/traceview.html
Comment: Yeah I have, it seemed fine - there were even gaps between each "updatePhysics" call, and I couldnt see any unusual gaps without calls.
Comment: I'm not sure if it's me, but I think there is a *barely* noticeable stuttering (tried on LG Optimus One 2.2)
Comment: Thankyou for testing it bigstones, I am getter that barely noticable stuttering on every phone I test (I just tested it on another phone myself). Does anyone have any idea how to get rid of it?
Comment: I've stumbled on this, don't know if it might be related actually: http://stackoverflow.com/questions/4985563/preventing-flickering-when-calling-drawable-draw
Answer: I tried it on my phone (nexus one), it was the same for me.
I made a few changes which made it better for me:

Instead of declaring new variables every time during loop, i declared the as properties of the class
Canvas c = null;
// becomes
private Canvas c;
// in the loop now just use
c = null

Do this for all the variable you declare over and over again in the doDraw and updatePhysics  function.

instead of increasing the viewY until forever, i just put a little if statemant
if(viewY > mCanvasHeight){
  viewY -= mCanvasHeight;

}

I am not sure if it's working 100% now but seems much better to me.
Comment: Ah, I gave that a go and it does seem to make it a little smoother, but sadly it still stutters on my phone. I managed to try it on a friend's Desire HD and it was liquid smooth on his phone. It only seems to affect some devices which is a bit odd.
Comment: What's the plausibility this change impacts anything? I'm skeptical this code change makes any real difference and I think it's just placebo that you think it's now smoother @Smills: The Desire HD is much more powerful than the Milestone. The Milestone seems a lot slower for games than most newer phones. I've noticed some of my stuttering Milestone apps are liquid smooth on newer phones.
Answer: It sounds like your scrolling generates lots of garbage that needs to be collected frequently. If you're creating lots of short-term little objects, consider managing your own pool of them. As long as you don't let the pool grow without bounds, this can greatly cut down on the gc preempting your timing.
Comment: The part "NOTE: it is not related to the garbage collector. If you think it is, just look at the log, the garbage collector runs no-where near as often as the stutter appears." was there at the start :) Good suggestion though, I actually assumed the same problem in the original question, and suggested the same solution. http://stackoverflow.com/questions/4867732/traceview-shows-some-methods-arent-being-called-for-200ms-or-more/
Comment: Yeah, sadly it doesn't seem to be the garbage collector, I wish it was as that would be nice and easy to fix. If you have a look at the example I have eliminated all calls (or at least almost all calls) that generate garbage during runtime.
Answer: I tested it on a Verizon DroidX (2.2.1) and it looks like every 3-6 seconds and VERY brief. It seems slightly better with the active wallpaper off and nothing else running. Maybe the graphics subsystem just can't keep up? Have you tried a less graphics intensive image (fewer pixels and fewer colors) just to see what it does?
Answer: You are drawing three enormous background bitmaps per-frame... that's more work than you need to do. It may be better to use a BitmapShader with TileMode set to repeat. Then it's just one call into the native layer.
Add a Paint paint; member somewhere and change your setSurfaceSize() to include the following lines:
BitmapShader shader = new BitmapShader(mBackgroundImage,
    TileMode.CLAMP, TileMode.REPEAT);
paint = new Paint();
paint.setShader(shader);

Then doDraw() only needs to be this:
//translate to viewY position
canvas.translate(0,(float)(-viewY));

//draw backgrounds
canvas.drawPaint(paint);

I haven't actually measured this to prove it's faster, but from what I know about graphics APIs it certainly should be.
(Of course if you really want to fly you should be using OpenGL ES...)


com.sun.proxy.$Proxy1 cannot be cast to

Question: GameV1 game;
<code>  public void connect() {
    connect("//localhost/Game");
    if (getServer() != null) {
        game= (GameV1) getServer();

    }

}
</code>
this method "connect("//localhost/Game");" just sets the server on the upperclase which then is casted to GameV1
Game=interface
GameV1=concrete class with implements Game
if (getServer() != null)
this returns true but i get this error when cast
com.sun.proxy.$Proxy1 cannot be cast to GameV1
Comment: the error is pretty indicative. You're casting between two incompatible types. Look at the hierarchy of your GameV1 object; does it implement the right interfaces?
Answer: With a RMI remote object you can't cast to the concrete class. You have to cast to the remote interface.
Comment: When do i cast to concrete?
when i recieve the object in the client?
Comment: If you are sending an actual object to the client, then you can cast to its type in the client, yes. But if you are just sending a remote reference to the client, then no.
Comment: You don't *what* the method calls? There's a missing word in your comment.
Comment: I casted to interface now but i still get exception
com.sun.proxy.$Proxy1 cannot be cast to servidor.Game

Game contains all the classes in the server, not all the classes are named as remote or serializable could that be the source of the problem???
Comment: Which exception? Which interface? Have you read some RMI tutorial to check what you are supposed to be doing? Maybe you should try to get a really simple example RMI program working first, then try to do something more advanced.
Comment: The remote interface class is supposed to contain all the methods that you want to call remotely. What you describe here doesn't make much sense.

com.sun.proxy.$Proxy1 cannot be cast to


Why can't I disable or enable the block cache?

Question: In the admin/settings/performance page, I (the administrator) cannot enable or disable the block cache. Why?
Answer: I know you asked "why?" not "can i get around that problem"... but you can get around that problem without removing modules that use hook_node_grants(). Try out the Block Cache Alter module. It allows, among other things, the ability to use block caching even if modules implement hook_node_grants().
Comment: Instead of using that module, adding `$conf['block_cache_bypass_node_grants'] = TRUE;` to settings.php should be investigated first if you know what you're doing with your blocks.
Answer: As reported in that page for that setting:

Note that block caching is inactive when modules defining content access restrictions are enabled.

If there are modules implementing hook_node_grants(), the "Block cache" form field is disabled.
This is the code present in system_performance_settings(), which is the form builder for the "Performance" form:
$form['block_cache']['block_cache'] = array(
  '#type' => 'radios',
  '#title' => t('Block cache'),
  '#default_value' => variable_get('block_cache', CACHE_DISABLED),
  '#options' => array(
    CACHE_DISABLED => t('Disabled'),
    CACHE_NORMAL => t('Enabled (recommended)'),
  ),
  '#disabled' => count(module_implements('node_grants')),
  '#description' => t('Note that block caching is inactive when modules defining content access restrictions are enabled.'),
);

As alternative, there could be a module that is disabling the form field to avoid the option can be selected; I don't know of any module that does that, even if I cannot exclude there is a module that is effectively doing it.


How to simulate a symbol table in Common Lisp

Question: i am learning Common LISP at the moment and i encountered a huge roadblock.
I've had an assignment that we were to learn how to create a parser in Common LISP. I have managed to implement everything from the grammar rules to the lexer  with alot of help from different sources online. I cant on the other hand seem to figure out how to implement a symbol table.
This is what i have so far in regards of the symbol table.
<code>(defun symtab-add (state id)
;; *** add symbols to symbol table ***
)

(defun symtab-member (state id)
;; *** look up symbols in symbol table ***
)

(defun symtab-display (state)
   (format t "------------------------------------------------------~%")
   (format t "Symbol Table is: ~S ~%" (pstate-symtab state))
   (format t "------------------------------------------------------~%")
)
</code>
As you can see ive only managed with the display part, if someone could link me a tutorial or give me a code example or just help me with this i would be super thankful.
All source code for my assignment: http://www.cs.kau.se/cs/education/courses/dvgc01/LISP/newstart.lsp
Comment: The code is from here:  http://www.cs.kau.se/cs/education/courses/dvgc01/LISP/newstart.lsp
Comment: "How to simulate a symbol table in Common LISP"  1) It's "Common Lisp", not "Common LISP" (no need to shout).  2) As Rainer points out, that code is taken from elsewhere. You should provide attribution for code that you post, and *certainly* shouldn't claim that it's your own.  3) Why "simulate" a symbol table?  Wouldn't you just want to implement one?  This phrasing suggests that a symbol table couldn't be implemented in Common Lisp, which is silly.
Comment: Yes that is indeed my assignment, i am sorry if that was unclear. Ok so i want to implement a symbol table (the assignment is to parse a simple pascal program). Can you give me some pointers or point me in the right direction? As you can see from the link you sent its unfinished code. It's my assignment to finish it. Everything is done except for the symbol table.
Answer: There are multiple ways of implementing a symbol table, with varying levels of "suitable for purpose" depending on your exact needs. At the end of the day, a symbol table is, effectively, just a mapping from "symbol name" to something.
So any data structure that allows you to add things to it as well as looking things up should work. Fairly common implementations would be "use a hash table" or "use an alist" (the latter is essentially a list of pairs on the form <code>(<symbol> . <data>)</code>).
Comment: Ok so hash table is the way to go? Thats food cause ive found alot on hash tables and clisp. Thanks for the answer!
Answer: First you will have to create the symbol table, say:
<code>(setq my-symbol-table nil)
</code>
To keep it simple, we will ignore packages; you can learn about that later.
Next, you have to decide how you are going to store the symbols in the table. Again, keeping it simple, you can store them as an association list, with pairs of symbol name and symbol value. For example, if you store the symbols a and b with the values 3 and 5, you would have the following symbol table:
<code>> my-symbol-table

> ((a . 3) (b . 5))
</code>
To use this association list, you can use the functions assoc, push, rplacd.
Example:

Add a new symbol
(push '(c . 0) my-symbol-table)
Look up a symbol:
(assoc 'c my-symbol-table)
Change the value of an existing symbol:
(rplacd (assoc 'c my-symbol-table) 18)

I hope this is enough to get you going.
Comment: `setq` is for changing existing bindings. Where do you define `my-symbol-table` and where are the `*earmuffs*`?
Comment: I don't see anything in OP's question that looked like symbols needed to be associated to particular values.  It looked more like there just needed to be a list of "in scope names" (which makes a bit more sense for lexer/parser, though it's still a bit more than pure lexing and parsing would need;  semantic analysis should be responsible for checking variables scopes, etc.).