Use of Reduced Homology

Question: I've been reading Hatcher's Algebraic Topology, specifically the paragraph about reduced homology $\tilde{H}_*$ (for singular homology of topological spaces). Can someone please provide reasons why reduced homology is defined and studied?
I understand the following facts, which are all found in Hatcher's book :
$-$ The reduced homology of a point is $0$.
$-$ The reduced homology is the same in all degrees $*$ as the usual singular homology for pairs of spaces $(X,A)$ with $A\neq \emptyset$ : $\tilde{H}_*(X,A)= H_*(X,A)$, and in positive degrees $(*=n>0)$ for single spaces $X$ (that is when $A=\emptyset$). There is the same long exact sequence in reduced homology for a pair of spaces as in standard homology.
$-$ In degree $0$, one has $\tilde{H}_0(X)\oplus\mathbb{Z}\cong H_0(X)$, with the coefficients for homology in $\mathbb{Z}$.
$-$ For any space $X$, and any point $\mathrm{pt}\in X$, there is an isomorphism $\tilde{H}_*(X)\cong H_*(X,\lbrace \mathrm{pt}\rbrace)$
$-$ This in turn implies that when $A\subset  U\subset X$ is such that $A$ is closed, $U$ is open, and $A$ is a strong deformation retract of $U$, then there is an exact sequence in reduced homology (that stems from an exact sequence for standard singular homology)
$$\cdots\rightarrow\tilde{H}_*(A)\rightarrow\tilde{H}_*(X)\rightarrow\tilde{H}_*(X/A)\rightarrow\cdots$$
All of this is straightforward to prove, but it doesn't tell me why reduced homology is defined and when it is used. Can someone please shed some light on this matter?
Answer: The essential reason for preferring reduced homology (as experts do)
is that the suspension axiom holds in all degrees, as it must when
one generalizes from spaces to spectra and studies generalized
homology theories.  Also, when using reduced homology, one need not
explicitly use pairs of spaces since $H_*(X,A)$ is the reduced
homology of the cofiber $Ci$ of the inclusion $i\colon A\to X$.
The Eilenberg-Steenrod axioms for homology theories have a variant
version for reduced theories, and the reduced and unreduced theories
determine each other.  (See for example my book ``A concise course
in algebraic topology'').
Comment: Welcome to math.SE, Professor May!
Answer: Reduced homology is used, mostly, to simplify statements.
For example, it is not true that the homology of a wedge of two spaces $X\vee Y$ is the direct sum of the homologies of $X$ and of $Y$, but the only problem is actually in degree $0$. It is true, on the other hand, that the reduced homology of $X\vee Y$ is the direct sum of the reduced homologies of $X$ and of $Y$. This happens in various other contexts.
N.B.: You should be careful with those isomorphisms you mention, for they are generally not natural.
Comment: @Olivier: The isomorphism $\tilde H_0(X)\oplus\mathbb Z\cong H_0(X)$ you mention comes from an exact sequence $$0\to \tilde H_0(X)\to H_0(X) \to\mathbb Z\to 0$$ This sequence splits (because $\mathbb Z$ is a projective abelian group, say) (and this splitting gives your isomorphism) but the splitting is not canonical. A splitting corresponds, more or less, to picking an element in $H_0(X)$ which is part of a basis, and this cannot be done, in general, in a natural way.
Comment: Reduced homology is really the relative homology of $X$ relative to a point, right? So I guess it's natural for it to be related to wedge sum.
Comment: The difference lies in that reduced homology is independent of the choice of a point, though :)
Comment: Likewise, The isomorphism $\tilde{H}_*(X)\approx H_*(X,\lbrace \mathrm{pt}\rbrace)$ obviousl depends on the choice of the point $\mathrm{pt}$.
Comment: The isomorphism $\bar{H}_0(X)\oplus \mathbb{Z} \cong H_0(X)$ is indeed unnatural, but somewhat counterintuitively (at least for me) is that the isomorphism $\bar{H}_0(X) \cong H_0(X,*)$ is natural as functors $Top_* \rightarrow Ab$. And similarly as functors $Top_* \rightarrow Ab$,  $\bar{H}_0(X)\oplus \mathbb{Z} \cong H_0(X)$, naturally. So we have an example of two objectwise isomorphic functors that are not naturally isomorphic, that become naturally isomorphic when moving to a slice category.
Comment: An other good example would be alexander duality. See http://en.wikipedia.org/wiki/Alexander_duality
Comment: could you point out the non canonical isomorphisms please? I can see that the long exact sequence in my last point actually depends on the open neighborhood $U$, so might not be natural. The other ones I think are natural... Am I right?
Answer: Firstly $H_0$ isn't particularly interesting since we frequently deal with connected spaces anyway. Apart from that, in various exact sequences, such as Mayer-Vietoris, using standard homology leaves us with a bunch of $\mathbb{Z}$'s at the end. But exact sequences are so much nicer with $0$'s instead! Reduced homology gives us 'exact'ly this!

Use of Reduced Homology


Open interval (Does such a term exist?)

Question:
In a book on jazz harmony in Russian I have noticed the term 'open interval'. Example 57 says that interval -9 in the right arrangement is 'open interval' (in this case it's bad). The left arrangement is 'better' (smth which looks like 67 is in fact 'major 7th' in Russian notation).
My question is: Does 'open interval' here mean that one of the notes which form the -9 interval is THE HIGHEST of all the four notes, i.e. openness implies there is nothing above Bflat here?
Answer: No, when talking about chord voicings, "open" means the voicing covers more than one octave. "Closed" means less than an octave.
So, in this case, the voicing on the left, spreads only a M7, while the one on the right spreads more than an octave (m9).
Comment: Note too that some textbooks call these "closed" and "open" intervals "simple" and "compound," respectively.

Open interval (Does such a term exist?)


Animating onDraw() section

Question: I have the following class:
public class MainActivity extends Activity {
/** Called when the activity is first created. */

String value = "0";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(new GaugeAnimation(this));

       }

     }

My GuageAnimation class is as follows:
public class GaugeAnimation extends View{

private Path p;
private Paint cPaint = new Paint();
private int width = 200;
private int angleStart = 135;
private int sweep = 90;
private int value=0;

Bitmap bottom = BitmapFactory.decodeResource(getResources(), R.drawable.dashboard_rpm_bottom);
Bitmap top= BitmapFactory.decodeResource(getResources(), R.drawable.dashboard_rpm_active);

public GaugeAnimation(Context context){
    super (context);

        //Arc Equations & etc....

}

@Override
public void onDraw(Canvas c){

    Paint paint = new Paint();
    paint.setFilterBitmap(false);
    paint.setColor(Color.BLUE);
    c.translate(55,320);

    //Draw bottom image on canvas

  c.save();

    p.addArc(new RectF(0,0,width,width), angleStart, sweep);
    p.lineTo(width/2, width/2);

    c.clipPath(p);

    //draw Image on top

    c.restore();

   invalidate()

}

 }

so basically this crops a circular image one piece at a time based on arc equations. I want to show an animation like the circle's pieces all being filled in (so showing each clipped path which demonstrates a circle being built). So i was thinking of doing a for loop like:
 for (int i=0; i<100; i++) {
   sweep=i;
   p.addArc(new RectF(0,0,width,width), angleStart, sweep);
    p.lineTo(width/2, width/2);

    c.clipPath(p);
        invalidate();
 }

but this doesn't work it just draws the end result when i=100, anyone have an idea as to how i can do this?
Answer: Currently your loop is performed on the main thread and keeps it busy, so it will not actually update the UI until you finish.
You should do the loop in a background thread (using Timer or AsyncTask) and perform the paint on main thread. Note that without a short sleep, it will probably would look like an animation too much, it will be pretty fast.

Animating onDraw() section


VMware VMFS5 and LUN sizing - multiple smaller datastores, or 1 big datastore?

Question: With VMFS5 no longer having the 2TB limit for a VMFS volume, I'm considering which scenario would be more beneficial overall:-

Less LUNs of larger size, or
More LUNs of smaller size.

In my case, I have a new 24-disk storage array with 600GB disks. I'll be using RAID10, so roughly 7.2TB, and trying to decide whether to go with 1 big 7TB datastore, or multiple stores of 1TB each.
What are the pros and cons of each approach?
Update: Of course, I neglected to include hot spares in my calculation, so it'll be just under 7.2TB, but the general idea is the same. :-)
Update 2: There are 60 VMs and 3 hosts. None of our VMs are particularly I/O intensive. Most of them are web/app servers, and also things like monitoring (munin/nagios), 2 Windows DCs with minimal load, and so on. DB servers are rarely virtualised unless they have VERY low I/O requirements. Right now I think the only virtual DB server we have is an MSSQL box and the DB on that box is <1GB.
Update 3: Some more info on the array and FC connectivity. The array is an IBM DS3524, 2 controllers with 2GB cache each. 4x 8Gbit FC ports per controller. Each ESXi host has 2x 4Gbit FC HBAs.
Comment: Are you licensed to use StorageDRS?
Comment: @Chopper3: we currently have regular Enterprise licenses, not Plus, so no StorageDRS for the moment.
Comment: @ThatGraemeGuy What was the resolution to this?
Comment: @ewwhite: sadly, I can't remember. It was so long ago and I've been away from that job for a year already. :-( I vaguely remember making 4 equally-sized VMFS data stores per 24-disk array & I do know we didn't have any I/O issues at all after moving over to the new arrays, FWIW.
Answer: You didn't specify how many VMs you have or what they're going to be doing. Even without that information, I'd avoid one making one big LUN for blocksize/performance, contention and flexibility reasons.
Answer: I will assume you are going to virtualize servers, not desktops, all right? Next I'm going to assume that you are going to use several ESX/ESXi servers to access your storage and have them managed by vCenter Server.
When deciding on LUN size and the number of VMFS you are balancing several factors: performance, configuration flexibility, and resource utilisation, while bound by supported maximum configuration of your infrastructure.
You could get the best performance with 1 VM to 1 LUN/VMFS mapping. There is no competition between machines on the same VMFS, no locking contention, each load is separated and all is goood. The problem is that you are going to manage an ungodly amount of LUNs, may hit supported maximum limits, face headaches with VMFS resizing and migration, have underutilized resources (those single percentage point free space on VMFS adds up) and generally create a thing that is not nice to manage.
The other extreme is one big VMFS designated to host everything. You'll get best resources utilization that way, there will be no problem with deciding what do deploy where and problems with VMFS X being a hot spot, while VMFS Y is idling. The cost will be the aggregated performance. Why? Because of locking. When one ESX is writing to a given VMFS, other are locked away for the time it takes to complete IO and have to retry. This costs performance. Outside playground/test and development environments it is wrong approach to storage configuration.
The accepted practice is to create datastores large enough to host a number of VMs, and divide the available storage space into appropriately sized chunks. What the number of VMs is depends on the VMs. You may want a single or a couple of critical production data bases on a VMFS, but allow three or four dozen of test and development machines onto the same datastore. The number of VMs per datastore also depends on your hardware (disk size, rpm, controllers cache, etc) and access patterns (for any given performance level you can host much more web servers on the same VMFS than mail servers).
Smaller datastores have also one more advantage: they prevent you physically from cramming too many virtual machines per datastore. No amount of management pressure will fit an extra terabyte of virtual disks on a half-a-terabyte storage (at least until they hear about thin provisioning and deduplication).
One more thing: When creating those datastores standardize on a single block size. It simplifies a lot of things later on, when you want to do something across datastores and see ugly "not compatible" errors.
Update: DS3k will have active/passive controllers (i.e. any given LUN can be served either by controller A or B, accessing the LUN through the non-owning controller incurs performance penalty), so it will pay off to have an even number of LUNs, evenly distributed between controllers.
I could imagine starting with 15 VMs/LUN with space to grow to 20 or so.
Comment: There's far, far less locking contention with VMFS5 than before by the way.
Comment: Added some additional info on the VMs and storage system.
Answer: The short answer to your question is: it all depends on what your IO patterns are, and this will be unique to your environment.
I suggest you have a look here http://www.yellow-bricks.com/2011/07/29/vmfs-5-lun-sizing/ as this may help you consider your anticipated IOPS and how many LUNS might be suitable. That said, if your were to err on the side of caution, some people would advise having many LUNS (If my correction to a previous answer is approved, see my comments re LUN IO queues on the array side). I tend to agree, but would go further to then extent them together into a single/few VMFS volumes (don't believe the FUD about extents, and other VMFS limits http://virtualgeek.typepad.com/virtual_geek/2009/03/vmfs-best-practices-and-counter-fud.html). This will have the benefit of managing a single/few datastores within vSphere and, since vSphere automatically balances VMs over the available extents starting with the first block of each extent, the performance benefit spreading your IO over multiple LUNs.
Something else to consider... You say none of the VMs are particularly IO intensive. Given this, you may like to consider a combination of RAID5 and RAID10, to get the best of both worlds (space and speed).
Further, if you have your VMs configured with multiple VMDKs, with the OS and application IO patterns spread across those virtual disks (ie. OS, web, DB, logs, etc each on a separate VMDK), you can then locate each VMDK on a different datastore to match the IO abilities of that physical LUN (eg. OS on RAID5, Logs on RAID10). Its all about keeping similar IO patterns together to take advantage of the mechanical behaviour of the underlying disks so that, for example, log writes in one VM don't impact your web read rates in another VM.
FYI... you can successfully virtualise DB servers, you just need to analyse the IO patterns & IOPS rates and target that IO to a suitable LUN; all the while being aware of the IO patterns and IOPS that that LUN is already doing. This is why many admins blame virtualiseation for poor DB performance... cos they didn't carefully calculate the IO/IOPS that multiple servers would generate when they put them on a shared LUN (ie. it the admins' fault, not virtualisation's fault).
Answer: Each volume (LUN) has its own queue depth, so to avoid IO contention, a lot of implementations use more smaller LUNs. That said, you can make a datastore span LUNs quite easily. The disadvantage of larger (and fewer) VMWare datastores is, as far as I know, that you can run into some limits on the number of VMs that could be on simultaneously.
Answer: Another consideration is controller performance. I don't know your SAN specifically, but most if not all SANs required that a LUN is owned by a single controller at a time. You want to have enough LUNs on the system so that you can balance out your workload between controllers.
For example, if you had only one LUN, you'd only be using one active controller at a time. The other would sit idle as it would have nothing to do.
If you had two LUNs, but one was much busier than the other, you'd be using both controllers but not equally. As you add more LUNs the controllers share the workload more evenly.
Specific advice for you:
Your VMs are all relatively the same in terms of performance requirements. I'd create two LUNs, one per controller. Start putting VMs on the first LUN, and measure your I/O latency and queue depth over time as the VMs settle in. Don't use the second LUN yet. Continue filling up LUN 1. You will either reach a point where you start to see performance indicators that the LUN is full, or you will have migrated half of your VMs to that LUN, and still have maintained performance.
If you do see performance issues, I'd remove 30% of the VMs from LUN 1 and move them to LUN 2. Then start filling up LUN 2 in the same manner. Go to LUN 3 if necessary... does that make sense? The idea is to achieve maximum VM density on a given LUN along with a roughly 30% overhead for fudge room.
I would also make a pair of "high performance" LUNs for any heavy hitting VMs. Again, one per controller to share the workload.
Answer: Based on your explanations above, you should be fine with 1 datastore. 60 vm's over 3 hosts isn't that bad (20:1). I would, however, recommend you upgrade the HBA's to 8Gb if financially possible on at least one host provided your fiber switch is an 8Gb switch at a minimum.
That being said, I'd make at least 2 if not 3 datastores on the array. 1 datastore per host, with all servers accessing the others for vMotion. I don't know much about the IBM array; with EMC I would create a single RAID10 group with 3 LUNs for each datastore. With this setup, the host with the 8Gb HBAs would be great for your higher I/O systems.
You can do 1 datastore/server, and there are some instances I do that myself, but I only do that with SAN replication on special servers. Managing 87 different datastores over 9 servers for vMotion gets confusing when you set it up! The majority of my vm's are in shared datastores with 5-10 servers on them depending on how much space they need.
One final note. If you have any kind of servers in a failover pair/cluster or load balanced, you're going to want them in different datastores. You don't want the datastore to fail, and then be left with no servers. Admittedly, if you lose the array, you've lost everything, but this is why we backup, right?
Comment: I have a hard time believing that the OP will need more than 2x4Gb bandwidth, or even 1x 4Gb. Can you explain why this upgrade would be worth it, aside from "more is always better"?

Also, creating 3 datastores sounds like a good balance, but saying "one per host" is confusing, because obviously all datastores will be accessible by all hosts. Otherwise you cannot use Storage vMotion, vMotion, or HA...
Comment: I'm not saying add 8Gb across the board, as I said, it's a recommendation not a requirement. 2x4Gb is great, and I'd never do 1x4Gb simply because you need the redundant path. Having it on one just allows for any expansion to higher I/O systems to happen. Heck, I currently run our Exchange system with 2x4Gb HBA's, but they only have 3-4 VM's per host.


Configuring the Popup Calendar Widget

Question: Currently I have a date contextual filter. When I click the date field the popup calendar displays. when I click on a date (for example today's date) it displays as 3/18/2014, but I would like it to display as March 18th, 2014. Would anyone know how I should go about this?
Any help would be much appreciated. Thanks!
Answer: Go to your content type and edit the field. You'll find "More settings and values" as a collapsed fieldset (which is how I always missed it at first.)
The first option will be to change the "Date entry options" and how this is displayed.

You can also modify the default start and end dates here, as well.
Comment: I believe that this is for setting the actual date (when creating a piece of content). I am talking about on the view side when I am searching by a date and click on that calendar widget. Any ideas for that?
Comment: In my experience setting it there made it take effect when using the exposed Views filter.
Answer: Technically, it seems that the issue would be fixed by reformatting the Short date type located in admin/config/regional/date-time. Although, I tried this and it was not working.
Then I remembered that I had altered some javascript to add a calendar image button on my form. That javascript was overriding some of the default configurations of the code and after fixing that it worked like charm.

Configuring the Popup Calendar Widget


Can someone help me understand what type of problem I am looking at? Not sure if this classifies as hypothesis-testing

Question: Please pardon me if this question is not clear. I am not sure if I am using the right terminologies.
I have conducted an experiment in different environments multiple times. So my data looks something like this:
<code>Environment1  1.2  2.1  1.1  1.5  1.6
Environment2  4.2  2.6  3.5  2.5  2.9
Environment3  7.2  4.6  5.3  4.5  1.6
Environment4  0.0  0.0  1.2  15.0 0.0
Environment5  3.2  2.4  7.2  5.5  6.6
Environment6  23.2  32.1  18.1  1.5  19.6
</code>
I can clearly see (or maybe my intuition says) that the experiment was not conducted properly in Environment4 (too low and fluctuating a lot) and Environment5 (way too high) but am not sure how to prove this. Am I supposed to rely on hypothesis-testing with the hypothesis:

The experiment was not conducted properly in Environments 4 and 6.

and then use some procedure to prove this? Or is there a standard way of showing this? Can someone please help me how to approach this kind of problems? I am using R.
Comment: Nice question, its a good example to expose to different procedures, because we basically know without any maths or formality, that Environment 4 and 6 are different to the rest (and Environment 1 is a little different from 2, 3, and 5).  Thus any good procedure should be able to produce the obvious result, only difference coming from quantifying *how different* in a mathematical sense.  The obvious question is "is there any other way the experiment could have actually produce these results, besides an error?"
Comment: @probabilityislogic: Thank You. What you say is useful: if I can somehow quantify the effectiveness of the experiment in each environment, then may be I can say something but am still not sure what to say or how to say. Ah.. (...feeling stupid typing in puzzles) :) Regarding your question: the experiment was quite controlled in the sense that, it was made sure that the environment did not change. However, the procedure could have gone wrong. May be the procedure was not executed properly according to the guidelines (perhaps?)
Comment: I'm talking more along the lines of "is $32.1$ a physically meaningful quantity?  What would happen in the real world if this were correct."  It may also be useful to speak to someone who actually did the experiment 4 or 6 (preferably the person who recorded the data).
Comment: @probabilityislogic: I see. I get your point. The data is question is a response time variable. My take on your question would be that the value does make sense in a physical world but its just too unusual enough to be called a rare case. The person I talked to said he did not do anything differently. Actually, the data that I put here is just a sample from the entire data and there are some cases like this spread here and there.
Comment: so it would appear that the most likely result is an error, but interesting discoveries can be made if you "dig deeper" so to speak.  Could possibly be a new finding of some sort!  but don't get too excited, it probably is nothing, but it may be worthwhile to entertain the possibility, and see where it leads you.
Answer: You can do a student test to see if the mean is different between the group 4,6 and the rest. Even if your sample size is small you will conclude in a difference. Note that it will tell you that group 4,6 is significantly different in average from the rest but it won't tell you that "The experiment was not conducted properly in Environments 4 and 6" which can't be answered without a knowledge of what "properly" means in the observations.
Comment: girad: Actually, this question came up from someone over the testing team. Properly means that they were given a set of instructions to execute to get a final value. The experiment will complete even if one of the instructions is skipped but will result in an incorrect observation. I will check out the `student test` that you mentioned. But if the test relies on mean, isn't mean supposed to be a bad measure due to its sensitivity to change in the data values? Thank you for your time.
Comment: @Legend A test of difference of means may be inappropriate, but that is not the fault of @robin, as pointed out in the second half of his response, which is apt: the test to use is determined by which characteristic of a suite of results signals an "improper" experiment.  You could conduct an F-test for a difference of standard deviations; you could conduct multiple-outlier tests; you could conduct a Kruskal-Wallis test; etc., depending on what kind of differences you're looking for.
Comment: @Legend There is also another difficulty that is shadowed by your question because here you guessed that 4,6 was the different samples. But what if you don't know in advance... you will have to test all configuration and probably introduce a multiple hypothesis criterion. In this case this looks like outliers detection and many question have already dealt with that here.
Comment: @whuber: I did not intend to see it is anyone's fault. I am a novice here so I apologize if sounded so. @robin girard: That is a very interesting take. Thanks. I was just thinking about outlier detection. Will you be able to point me to some relevant material for this particular case? All I have used before are simple ones like k-means etc.


Is there any mapping of $N^3$ unique values to $N \times N \times N$ dots which underlie associative function(s) to next and prior dot, cyclic (SxSxS)

Question: Title in long:
Is there any mapping of $N^3$ unique values to $N \times N \times N$ elements which underlie associative function(s)/operator to next and previous element (and no more) for each dimension in a cyclic arrangement ($\mathbb{S^1}\times\mathbb{S^1}\times\mathbb{S^1}$)?
Problem by example
For a computer program I'm looking for some sort of three-dimensional matrix ($N \times N \times N$) with random elements. This matrix need to be bigger than storage allows but equal for each user (with same conditions).
To accomplish this the matrix elements should start at a random entry and compute the matrix out of this (using constants/functions/operators).
Each dimension has $N$ element but no start or end. Arrangement is cyclic like a 3-dimensional torus $\mathbb{S}\times\mathbb{S}\times\mathbb{S}$.
Every user has (in general) a different initial value. He should not know how to compute another user value out of his own.
The matrix is big but not big enough for common cryptographic methods like elliptic curves.
So to achieve this property only a function/operator for next and previous element is allowed (for each dimension). Computing e.g. the 2nd next requires the knowledge of the next.
So the computation complexity/time need to scale (about) linear with shift (next->1, 2nd next->2 times 'next',..., n'th next->n times computation time of 'next').
Furthermore complexity/time need to be (about) equal for each dimension.
Some more properties
-next of previous element is the element itself again
-independent of dimension order calculation (associative)
-after $N$ times 'next' the same element again (cyclic)
-there need to be some way to produce a (pseudo) random element without deriving the position in this matrix
-need to work at a computer
Weakening
(options to make problem less demanding)
-cycle size don't need to be $N$ in each dimension. Sizes can be different to each other but need to be close to a certain value of choice
-instead of just next/previous also some shortcuts for constant shifts are allowed (number $\ll N$), e.g. $N$'th next-> same again, $N$/2'th next -> ...
-shortcuts for each shift can be allowed if computation time much langer than for elliptic curves
-matrix elements don't need to be unique in matrix. Small amount of multiple usage of same value can be allowed
-values don't need to be in range of $[0,...,N^3]$, not all vales in range need to be part of it
-instead of equal matrices for every user also multiple which are different to each other are allowed (but total number need to be smaller than $2N$)
What doesn't work
-split in a value for each dimension (unless each of those is different after next/previous function). Finding another value would reduce of finding a equal value for each dimension. Target matrix size of one dimension ($N$) too small for this. Unless next/previous function need long computation time. Furthermore there should be no (effective) way to reduce an element to an index of each dimension.
-elliptic curve encryption and other methods which need more bit (at least those I know off)

Any ideas which might work? Problem has many properties but solution can be part of different topics. Mathematics not my major. Name of topics where this problem fit in also helpful.
Answer: One approach is to use a linear congruential generator in each direction.  In one dimension, if the current value is $n$ the next value is $an+c \pmod m$.  You choose $a,c$ for each direction and use a common $m$.  If $a$ is coprime to $m$ this is invertible, so you can go backwards as well.  It will be cyclic with period shorter than $m$.  If you choose $a,c$ properly I think you can get $m-1$ so you have the same period in all three axes.  All the values will be smaller than $m$, which means there will be many repeats, but maybe that is not a problem.  I think getting it cyclic and keeping the values distinct is difficult.  Also if the user has access to the numbers in the matrix he can derive $a,c,m$ with some work.  Is that a problem?  You could use some other seeded random number generator.  This one came to mind because you could go backwards easily.
Comment: ty for response. This approach splits the problem into one for each dimension. If a user want to compute another users value out of his own he only need to compute each dimension by itself. My wished target size is too small for this (written in 'what doesn't work' section). A PC could do that in some hours. For $N^3$ elements instead more than $10^{15}$ years needed.
Comment: many repeats not a problem unless this happen across dimensions. If elements calculated for each dimension over and over again there will be a cuboid of elements which repeats itself in all directions. This need to be as big as possible related to $N^3$. Best case would be just one number which changes according to next functions chosen.
Comment: both user have interest to compute the other user values out of their own. They share as many information they can. I'm looking for a way to make this as hard as possible while still being possible. (Or in case multiple different matrices exists, possible for those with same matrix)
Comment: How important is the cyclic aspect?  If you go upward from $N$ in one dimension do you have to get the number at $1$?  If it is not important, you can just make $m$ huge compared to $N$ and different in each dimension and repeats will be much rarer.  If you make $N$ large enough you will never roll over.
Comment: would be much better if cyclic. There can also be some settle in time, e.g. it starts at 1st element and after N'th element it continues at the 42th element (and to N again, next 42th again,..). If $m$ much greater the amount of different matrices (with size $N$ in each dim) will scale with dimensions. In 'weakening' I wrote that is possible but only up to about $2N$ of those. That would result in $\sqrt[3]{2N}$ for each dimension. This $m$ won't be much bigger than before. ...
Comment: ...Alternative for huge $m$ would be a limited amount of initial values. But if this number is too small the 'matrix-id' can be derived and it would be as hard as the small $m$ version. So for this multiple initial values need to map to the same 'matrix-id'. But how to generate those initial values without exposing the 'matrix-id'?


List Row smooth animation

Question: I have a list that I would like to make a view appear. The following code produces a jerky animation when I tap the row. I would like to modify to create a more smooth animation. Is there a way to smoothly animate changes to a List?
import SwiftUI

struct ContentView: View {
    var body: some View {
        List(0..<10){index in
             ListItem(title: index)
        }
    }
}

struct ListItem: View {
    @State var title: Int
    @State var bOpen = false

    var body: some View {
        VStack{
            Text("\(title+2) items")
            withAnimation{
                self.bOpen ? Options() : nil
            }
        }.onTapGesture {
            self.bOpen.toggle()
        }
    }
}

struct Options: View {
    var body: some View {
        HStack {
            Image(systemName:"circle.fill")
            Image(systemName:"star")
        }

    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Answer: Use .animation() modifier on the ListItem
like:
ListItem(title: index).animation(.default)

You can also apply it on the VStack itself (if you managed to not animate all ListItem changes).
And no need for withAnimation
Answer: If you have no other items, the other answer with listItem is good enough.
But specifically, you have some other animated items in the listItem, you may do the following:
 var body: some View {
    VStack{
        Text("\(title+2) items")
        self.bOpen ? Options().transition(AnyTransition.move(edge: .top)) : nil
    }.onTapGesture {
    withAnimation{
    self.bOpen.toggle()}
    }
}

correct the position where to place "withAnimation"
introduce a peaceful transtion action.
Comment: Thanks for the feedback. Still doesn't achieve the effect that I want. The animation appears jerky. The appearance and disappearance of the view is abrupt. Was going for something similar to what's in the app Overcast when you are viewing an episode.

List Row smooth animation


Prove that this element is nonzero in a tensor product

Question: I want to solve the following problem: show that the element $1\otimes (1,1,....)$ is not the zero element in $$\mathbb{Q}\otimes_{\mathbb{Z}} \prod^{\infty}_{n\geq 2}\mathbb{Z}/n\mathbb{Z}$$.
My approach would be to try to define a map from this tensor to a $\mathbb{Z}$-module such that the element in question is not mapped to zero. I tried to start defining a map from $\mathbb{Q}\times \prod^{\infty}_{n\geq 2}\mathbb{Z}/n\mathbb{Z}$. An idea I had was to send an element $(p/q,(x_1,x_2,...))$ to $(p/q)\sum (x_i/2^i)$. This is not well defined though. Is there a way to fix this? Or a better approach to the problem?
Comment: If you take any element of your tensor product which is only non-zero in a finite number of the terms in the product, then you can kill it by multiplying it by a large integer from the $\mathbb Q$.  Since these elements are zero in the tensor product, they are zero under any linear map, so whatever linear map you hope to define, it had better have any such element in its kernel.
Comment: Why exactly is it not well-defined?
Comment: I mean, maybe it is well defined, in that case my question is why is that so. I mean, do i get the same image changing representatives for the $x_i$s? Also, it is not well behaved with the linearity I need.
Comment: well, you could try to answer those questions :-)
Answer: If you consider any $\mathbb{Z}$-module $M$ and its torsion part $t(M)$, we have the exact sequence
$$
0\to t(M)\to M\to M/t(M)\to0
$$
that, tensored with $\mathbb{Q}$, says
$$
\mathbb{Q}\otimes_{\mathbb{Z}}M\cong\mathbb{Q}\otimes_{\mathbb{Z}}M/t(M)
$$
So, if $1\otimes x=0$ in $\mathbb{Q}\otimes_{\mathbb{Z}}M$ (for some $x\in M$), then also $1\otimes\pi(x)=0$ in $\mathbb{Q}\otimes_{\mathbb{Z}}M/t(M)$ (for $\pi\colon M\to M/t(M)$ the canonical map).
Now, if $N$ is torsion-free and $y\in N$, $y\ne0$, then $1\otimes y\ne0$ in $\mathbb{Q}\otimes_{\mathbb{Z}}N$, because the map
$$
N\to\mathbb{Q}\otimes_{\mathbb{Z}}N,\qquad y\mapsto 1\otimes y
$$
is injective.
Note that the first part uses the fact that $\mathbb{Q}$ is divisible (so tensoring with it kills the torsion part); the second part uses that $N$ is torsionfree, so flat over $\mathbb{Z}$.
In your case, the element $(1,1,\dotsc)$ has infinite order in $M=\prod_{n>0}\mathbb{Z}/n\mathbb{Z}$, so it goes to a nonzero element in the quotient $M/t(M)$.
Comment: If you use flatness of $ℚ$, then it already suffices to say $ℤ → \prod_{n ∈ ℕ} ℤ/nℤ$ has trivial kernel for $\bigcap_{n ∈ ℕ} nℤ = 0$, so tensoring by $ℚ$ we get an injective map $ℚ \otimes_ℤ ℤ → ℚ \otimes_ℤ \prod_{n ∈ ℕ} ℤ/nℤ$.
Comment: @k.stm I added a note for future readers.
Comment: @Khoata Actually it should be $N$ is torsionfree, hence flat.
Comment: @k.stm I treated a more general case.
Comment: Just mentioning it because I needed a moment to see exactly how your answer applies to the question.
Comment: @egreg Sorry to dig up an old answer, but I was wondering how you concluded that $$\mathbb{Q} \otimes M \cong \mathbb{Q} \otimes M/t(M)$$ I think it has to do with the $D \otimes -$ functor preserving exact sequences...
Comment: @Alex If $N$ is torsion, then $\mathbb{Q}\otimes N=0$; since $\mathbb{Q}$ is flat, tensoring $0\to t(M)\to M\to M/t(M)\to 0$ with it gives an exact sequence and so the required isomorphism.
Comment: @egreg Hi egreg,  I know $\mathbb{Q}$ is flat over $\mathbb{Z}$ so if $f: M \to N$ is an injective map of $\mathbb{Z}$-modules, then $Id_{\mathbb{Q}} \otimes f: \mathbb{Q} \otimes_{\mathbb{Z}} M \to \mathbb{Q} \otimes_{\mathbb{Z}} N$ is also injective, but I'm not sure how that implies the map $N  \to \mathbb{Q} \otimes_{\mathbb{Z}} N, ~~y \mapsto 1 \otimes y$ is injective? I meant, like what original injective map did we tensor with $\mathbb{Q}$ to get that map?  Thank you.
Comment: @egreg Thank you, that makes more sense now.
Answer: Here is an alternative approach which however only works for tensor products that can be considered as localizations: If $R$ is a commutative ring and $S\subset R$ is a multiplicative subset of $R$, then given any $R$-module $M$ the $R_S$-module $R_S\otimes_R M$ together with the map $M\to R_S\otimes_R M$, $m\mapsto 1\otimes m$, is a localization of $M$ at $S$. However, you know that the localization can also be defined as $S^{-1} M$ by taking as elements the equivalence classes of formal fractions $\frac{m}{s}$ with $s\in S$ and $m\in M$ under the relation $\frac{m_0}{s_0} = \frac{m_1}{s_1}:\Leftrightarrow t s_1 m_0 = t s_0 m_1$ for some $t\in S$, together with the map $M\to S^{-1}M$ sending $m$ to $\frac{m}{1}$. By uniqueness of localization, these two approaches are uniquely isomorphic over $R_S$ in a way compatible with the morphisms from $M$ - in particular, given $m\in M$, we have $1\otimes m=0$ in $R_S\otimes_R M$ if and only if there exists some $t\in S$ such that $tm=0$.
This applies to $R := {\mathbb Z}$, $S := {\mathbb Z}\setminus\{0\}$ (so that $R_S = {\mathbb Q}$), proving that the kernel of $M\to M\otimes_{\mathbb Z}{\mathbb Q}$ is precisely the torsion subgroup of $M$. Since in your example the element $(1,1,...)\in\prod\limits_{n\geq 2}{\mathbb Z}/n{\mathbb Z}$ is not torsion, it does therefore not vanish under the localization map to ${\mathbb Q}\otimes_{\mathbb Z}\prod\limits_{n\geq 2}{\mathbb Z}/n{\mathbb Z}$.
Answer: (This answer might be difficult.)
Let $U$ be a nonprincipal ultrafilter over the set of natural numbers which contains subsets of $\Bbb{N}$ of the form $n\Bbb{N}+1$ for each $n\in \Bbb{N}$. Consider the ultraproduct $A=\prod_{n\in \Bbb{N}} (\Bbb{Z}/n\Bbb{Z})/U$. You can check that $A$ is a $\Bbb{Z}$-module under pointwise operation. We will represent the elements of $A$ of the form $[x]_U$. More precisely, $[x]_U$ is defined as
$$[x]_U=\left\{x\in\prod_{n\in \Bbb{N}} (\Bbb{Z}/n\Bbb{Z}) : \{k\in \Bbb{N}: x_k=y_k\}\in U\right\}$$
where $x=(x_1,x_2,\cdots)$ and $y=(y_1,y_2,\cdots)$
We will define a function $\phi:\Bbb{Q}\times \prod_{n\in \Bbb{N}} (\Bbb{Z}/n\Bbb{Z})\to A$, $\phi(a/b,(x_n)_{n\in\Bbb{N}})=[(ab^{-1}x_n)_{n\in \Bbb{N}}]_U$. If it is well-defined, then it gives the bilinear function and it sends $(1,(1,1,1,\cdots))$ to nonzero element of $A$.
We must check that $\phi$ is well defined since $b^{-1}$ is not well-defined unless $\gcd(b,n)=1$. However for given $b$, the set of all $n$ such that $\gcd(b,n)>1$ can be ignored because $b\Bbb{N}+1\in U$ and $\gcd(bk+1,b)=1$ for every $k$ so $b^{-1}$ is well-defined for almost all $n$ (i.e. set of all $n$ with $(b,n)=1$ is an element of $U$.)
Answer: I come a bit late but wouldn't it be easier to just say that the map :
$$ \mathbb{Q} \times \prod_{n \in \mathbb{N}} \frac{\mathbb{Z}}{n\mathbb{Z}}  \longrightarrow \prod_{n \in \mathbb{N}} \mathbb{Q}$$
and say that it is a $\mathbb{Z}$-bilinear map between $\mathbb{Z}$ modules that send the wanted element to a non zero element?
Comment: Sorry if I put it as an answer instead of a post, don´t know if I can change it... I think that what I proposed is slightly different from what the author wrote (I'm just multiplying the elements of the product). Plus this seems to be simpler (if correct) so you could consider it as an alternative method.
Comment: Fair enough${}$.


Laurent series of $\dfrac{\sin(z)}{z\log(z+1)}$

Question: I want to calculate the Laurent series of $f(z)=\dfrac{\sin(z)}{z \cdot \log(z+1)}$ about $z=0$.
I know $\lim_{z \to 0} \dfrac{\sin(z)}{\log(1+z)}=1$ so f has a pole of order $1$ at $z=0$. Then $a_{-1}=1$ and $a_{-k}=0$ for $k\geq2$
¿What should I do next? I was thinking about multipling $x^{n}f(z)$ and taking  derivatives so I can get $a_{0}, a_{1}, a_{2}...$ but I'm not sure that's a good aproach. Any suggestion? Thanks.
Comment: Use `\sin` and `\log` for $\sin$ and $\log$.
Answer: Write $\frac{\sin z}{z\ln(1+z)}=\sum_{k\ge0}c_kz^{k-1}$ so $\sum_{k,\,l\ge0}c_k\frac{(-1)^{l+1}}{l+1}z^{k+l}=\frac{\sin z}{z}$ has $z^{2m}$ coefficient $\frac{(-1)^m}{(2m+1)!}$. This gives simultaneous equations in the first few coefficients. The Laurent series begins $\tfrac1z+\tfrac12-\tfrac14z+\tfrac{z^3}{240}+\tfrac{23z^5}{1440}$. I'm not sure if a closed form for the $z^{2n-1}$ coefficient with $n\ge0$ is obtainable.


Golang: protect source code

Question: Go/Golang in general at the moment is a hard thing to search for, nor did I find what I was looking for here. I know there some level of encryption that can be done during compilation of an app in several languages. Can anyone give me a quick rundown of the security of Go source code after being compile to an exe? If it can be read, at least in part, is there anything out there to increase security of the source code?
Comment: Don't hardcode credentials, If your security model depends on assuming that your user cannot find out what your application does, you're not doing it right. There's always a way to extract these credentials from your software, regardless of the language you use.
Comment: kwolfe: Design a security model that does not depend on anything hardcoded. Store credentials in configuration files. Give every user different credentials.
Comment: @kwolfe Then generate API keys for the clients and hand them to them - via email/upon purchase, or alternatively implement something like OAuth that authorizes your client on first run and provides them a unique key that the application saves in a config file alongside it or in a suitable location for that operating system.

It honestly sounds like you're getting ahead of yourself though.
Comment: What do you want to do? Are you afraid of other people stealing your source code?
Comment: Yes. I do not have the skill level with Go to do so yet, but I do have several ideas that I would like to market in a distributable application. Additionally, I'm wondering the security of say, hard coding db credentials.
Comment: Have an upvote. Maybe code security shouldn't be a high priority for me, though how might you handle db authentication in a distributed executable?
Comment: The problem with this is that you are assuming that I want to give every user an account, I might be referring to a logging db, or perhaps it is a read only db the I wish to retrieve info from, maybe stream info from.
Comment: If all users share the same authentification, why not totally drop the authentification?
Comment: I want to ensure that the connection is coming from my application.
Comment: I am getting ahead of myself, but this is something I was curious about.
Answer: Distribute only the binary (per platform/architecture). That's the best you can get with any language. There's no way how to distribute a program while being safe of reverse engineering it. Anyone telling you something different is probably just trying to sell you a "protection" scheme. No such thing really exists.
On the other hand: 99.9% of your potential users probably have no idea how to reverse engineer your program.
On the yet another hand: It's enough if 0.01 of your potential users have the ability to reverse engineer your program and you're doomed.
IOW, try to find out a business model which relies on anything else but security by obscurity. Actually, even open source code can generate profit - if the value of it is not only in having access to the source code per se.
Comment: Would stripping the debug info also be recommended? Go automatically builds with debug flags. Obviously the security gain is probably minimal, but for a commercially released executable it's probably worth it anyway (especially since, as I understand it, debug info can cause very slight performance hiccups and regardless).
Comment: @Jsor Go binaries are not designed to be stripped ATM - it's not recommended. There's been some discussion on the golang-nuts mailing list around this.
Comment: Even with go build -ldflags "-s"?

Golang: protect source code


condição hyperlink click

Question: Quero que quando clica-se no hyperlink pela segunda vez executa-se outro codigo.
$lib_nom

//ordena dados do array ASC
array_multisort( $affiche_ord, SORT_ASC, $affiche_tab );

//ordena dados do array DESC
array_multisort( $affiche_ord, SORT_DESC, $affiche_tab );

Se click uma vez fazer o ASC se for a segunda vez DESC, e assim sucessivamente.
Comment: Pode explicar melhor o que quer fazer? Como está não faz muito sentido... Quer fazer isso do lado do cliente ou servidor? Explique um pouco do contexto pf.
Comment: Tenho um link. Quando clico a primeira vez, quero que execute este codigo array_multisort( $affiche_ord, SORT_ASC, $affiche_tab ); e quando voltar a clicar executar array_multisort( $affiche_ord, SORT_DESC, $affiche_tab );
Comment: Ok, e quer que o click seja no lado do cliente e que corra o `sort` no PHP/servidor... porque não fazer isso no JavaScript? Quer recarregar a página ou fazer isso via AJAX?
Comment: é um link que recarrega a pagina. Sim do lado do cliente.
Answer: Pode fazer da seguinte maneira, alternando entre um parâmetro e outro, capturando
a variável ordem com $_GET e aplicando na função de acordo com o parâmetro enviado pelo link:
<?php
$ordem = $_GET['ordem'];
$nova_ordem = empty($ordem) || $ordem == 'SORT_DESC' ? 'SORT_ASC' : 'SORT_DESC';

echo '$lib_nom';

array_multisort( $affiche_ord, $ordem, $affiche_tab );
?>

Se o parâmetro ordem for vazio, será incluído no link o valor ?ordem=SORT_ASC, e depois vai alternando com ?ordem=SORT_DESC conforme o link for sendo clicado.

condição hyperlink click


SonarLint and "common-java" analyzers

Question: Using Sonar 6.7 with SonarLint in InteliJ the rule "Source files should have a sufficient density of comment lines" pops-up during Sonar analysis. But since this is not a Sonar rule ("squid:") but a "common-java" then SonarLint won't report it.
Is there a way to apply such a rule(s) before commit?
Thanks
Comment: You can't. As far as I know these rules are executed on the server-side and their results cannot be displayed with SonarLint...
Answer: After some more googling around SonarQube plugin (https://github.com/sonar-intellij-plugin/sonar-intellij-plugin) could be used and works perfectly. Connects to Sonar server, performs LOCAL analysis (issues are not created on server) based on server configuration, reports only new issues and its possible to hook this to auto-analysis done before commit.

SonarLint and "common-java" analyzers


Prove bipartite graphs have a perfect matching of $X$ into $Y$ if $\deg(x)\ge \deg(y)$ for all $x\in X$ and $y\in Y$

Question: I have an exercise from here involving Hall's Theorem:

Let G be a bipartite graph on the parts $X$ and $Y$, and
suppose that the inequality $\deg(x)\ge \deg(y)\ge 1$ holds for all $x\in X$ and $y\in Y$. Prove that $X$ has a perfect matching into $Y$.

I'm thinking about proving that $\deg(x) \ge \deg(y)\implies |N(S)|\ge |S|$ for all subsets $S\subseteq X$ and then Hall's Theorem applies. I'm having trouble thinking about it this way.
Another possibility might be to suppose our condition $\deg(x) \ge \deg(y)$ does not have a perfect matching and find a contradiction. I know there's some $S\subseteq X$ s.t. $|N(S)|\lt |S|$ by Hall's Theorem under this assumption. If I let $D(S)$ be the sum of all the degrees of each $x\in S$, this equals the number of edges from $S$ which are all in $N(S)$. Since $|N(S)|\lt |S|$, we have fewer vertices in $N(S)$ than in $S$. So some vertex $y\in N(S)$ has $\deg(y)>\deg(x)$ because we have $D(S)$ edges coming from $S$ and fewer vertices to connect them to in $N(S)$. Is this a proof? Could it be clearer or am I missing something?
Comment: Note that the statement of the exercise is not quite correct. What if all vertices have degree $0$?
Comment: @bof I will specify $\deg(x)\ge \deg(y)\ge 1$
Answer: Assume that $\deg(x)\ge\deg(y)$ whenever $x\in X$ and $y\in N(x)$, and assume also that $\deg(x)\gt0$ for all $x\in X$. Then for $S\subseteq X$ we have
$$|S|=\sum_{x\in S}1=\sum_{x\in S}\sum_{y\in N(x)}\frac1{\deg(x)}\le\sum_{x\in S}\sum_{y\in N(x)}\frac1{\deg(y)}$$$$=\sum_{y\in N(S)}\sum_{x\in N(y)\cap X}\frac1{\deg(y)}\le\sum_{y\in N(S)}\sum_{x\in N(y)}\frac1{\deg(y)}=\sum_{y\in N(S)}1=|N(S)|.$$
That is, Hall's condition is satisfied, so there is a matching which covers every vertex in $X$.
Comment: How is $|S|=\sum_{(x,y)\in A(S)}\frac1{\deg(x)}$ true?
Comment: $$\sum_{(x,y)\in A(S)}\frac1{\deg(x)}=\sum_{x\in S}\sum_{y\in N(S)}\frac1{\deg(x)}=\sum_{x\in S}1=|S|$$
Comment: $\sum_{y\in N(S)}\frac1{\deg(x)}=1$ why? What happens if the degree of every vertex $x\in S$ is $1$? That can't add to $1$, I'm still a bit confused
Comment: In my comment, $y\in N(S)$ is a typo for $y\in N(x)$. Forget about the comment, look at my (revised) answer. Does it make sense now, or does it still have typos?
Comment: Why does $\sum_{y\in N(x)}\frac1{\deg(x)}$ equal $1$? Couldn't $\deg(x)=1$ for all $x$ and the sum is $\frac{1}{1}+\frac{1}{1}+\frac{1}{1}+\frac{1}{1}+...$?
Comment: If $\deg(x)=1$ then $N(x)$ has just one element, so the sum $\sum_{y\in N(x)}$ has just one term. If $\deg(x)=2$ then $N(y)$ has two elements so the sum is $\frac12+\frac12$.
Comment: $$\sum_{y\in N(x)}\frac1{\deg(x)}=\frac{|N(x)|}{\deg(x)}=1$$
Comment: That makes sense, thanks
Answer: I assume vertices of $X$ have positive degrees. Let me write $\deg_A (x):=d_A(x)$, which is the degree of $x$ relative to a subgraph $A$ of $G$ if $x\in V(A)$. I am not sure if this is overkill, but:
Take any $S\subseteq X$ and suppose that $|N(S)|<|S|$.
Let $A$ be the graph induced by $S$ (meaning we include all of their edges and neighbours tied to these edges). Hence, $V(A) = S \bigcup N(S)$.
Note that $E(A)=\sum_{s\in S} d_A(s)=\sum_{v\in N(S)} d_A(v)$ by counting (or handshaking!) and bipartiteness.
We have $\sum_{v\in N(S)} d_A(v)\leq \sum_{v\in N(S)} d_G(v)\leq \sum_{v\in N(S)} d_G(w)\leq |N(S)|d_G(w)<|S|d_G(w)$, where we let $w$ be the vertex of maximum degree in $N(S)$.
On the other hand, $\sum_{s\in S} d_A(s)=\sum_{s\in S} d_G(s)\geq \sum_{s\in S} d_G(w)=|S|d_G(w)$, where the inequality holds by the problem assumption.
Putting everything together, $|S|>|S|$, a contradiction.
Improvement/suggestion is much appreciated!


How to edit a node programatically after it has been created?

Question: My articles have a field 'Ranking' and I'd like to give a value to this field after a node has been created. The value depends on the node's ranking in a view called 'Top 3'. I tried the following in my custom module 'Top', but it doesn't work.
function top_node_insert($node) {
  $top = views_get_view_result('top_3');

  $found = false;
  foreach($top as $key => $value) {
    if ($value->nid == $node->nid) {
        $found = true;
        break;
    }
  }

  if ($found) $ranking = $key + 1;
  $node->field_hoogste_ranking[LANGUAGE_NONE][0]['value'] = $ranking;
}

What did I do wrong and what's the correct version?
Comment: AFAIK, there is no `hook_node_save`. If you wish to do something after a node has been created, use `hook_node_insert`.
Comment: @AjitS: I've tried the same code with `hook_node_insert`, but it doesn't work either.
Answer: If you look at the Node API Hooks description here, you will see that hook_node_insert is called after field_attach_insert. That means that at the point hook_node_insert is called the fields for the node are already written to the database. If you keep your code in top_node_insert, then add field_attach_update('node', $node) to update the fields with the new data. It might look something like this:
function top_node_insert($node) {
  $top = views_get_view_result('top_3');

  $found = false;
  foreach($top as $key => $value) {
    if ($value->nid == $node->nid) {
        $found = true;
        break;
    }
  }

  if ($found) {
    $ranking = $key + 1;
    $node->field_hoogste_ranking[LANGUAGE_NONE][0]['value'] = $ranking;
    field_attach_update('node', $node);
  }
}

Alternatively, you can try and use hook_node_presave.
Comment: $value->nid == $node->nid should be wrong as node has yet not been written into the DB and the View couldn't have got the nid using node_load.
Comment: @AgA: It does work, because `hook_node_insert` is activated after the node has been saved to the database.
Comment: There's only a `;` missing at the end of the last code line. Perhaps you can  change it for future users.
Comment: No problem. I'm the one who should thank you. It's works perfectly!
Answer: You have to use hook_node_presave()
if you use hook_node_insert() then the value will not be saved in $node object
Comment: Yes.. you are right .. I wrote that by mistake .. Yesterday I faced the problem if hook_node_insert.. which is not saving field value associated with $node object... while node_presave solved my problem..

Note: I have updated my answer.. thanks
Comment: hook_node_presave() is invoked before node is actually created while hook_node_insert() is invoked after nodes get created, so you will find nid in case of hook_node_insert() but in case of hook_node_presave().


Conversion CSV to XLSX with VB.NET : Wrong delimiter

Question: I would like to convert an .CSV file to a .XLSX.
So far i have this code
    Public Sub CreateExcelFromCsvFile(ByVal strFolderPath As String)
       Dim oExcelFile As ObjectOpen Excel application object
       Try
          oExcelFile = GetObject(, "Excel.Application")
       Catch
          oExcelFile = CreateObject("Excel.Application")
       End Try

       oExcelFile.Visible = False
       oExcelFile.Workbooks.Open(strFolderPath)

       ' Turn off message box so that we do not get any messages
       oExcelFile.DisplayAlerts = False

       ' Save the file as XLS file
       Dim adr As String = ""
       For i = 0 To btn_chemin_source.Tag.ToString.Split("\").Count - 2
          adr += btn_chemin_source.Tag.ToString.Split("\")(i) & "\"
       Next
       With oExcelFile.ActiveWorkbook
          .SaveAs(Filename:=adr & "RD.xlsx", FileFormat:=Excel.XlFileFormat.xlOpenXMLWorkbook, CreateBackup:=False, Local:=True)
          .Close(False)
       End With

       ' Close the workbook
       'oExcelFile.ActiveWorkbook.Close(SaveChanges:=False)

       ' Turn the messages back on
       oExcelFile.DisplayAlerts = True

       ' Quit from Excel
       oExcelFile.Quit()

       ' Kill the variable
       oExcelFile = Nothing

End Sub

My problem is that even i searched some clues on google to choose the delimiter in "Panel Control > region" and use local=True in SaveAs method, VB still keep using the comma as the delimiter instead of a semicolon, and so my Excel file is unusable.
Do you have any hints about how to pick a chosen delimiter while saving an CSV to xlsx ? :)
Thank you very much for your time!
Comment: You are going from CSV to xlsx, right? So your issue is when you open the csv file? Then look into OpenText method: `oExcelFile.Workbooks.OpenText(Filename:=strFolderPath, Local:=True, Semicolon:=True)`. Maybe don't need both Local & Semicolon but worth a go. See what happens
Comment: I'm having trouble understanding. It looks like you open the file and then save it as Excel XML. I don't think Excel XML uses delimiters, it uses XML. Do you mean delimiters for the CSV input, or are you intending to save it as CSV instead of XML?
Comment: Hello tgolisch, and sorry for my bad english; yes I'm trying to convert a CSV files with demicolon delimiter to a .xlsx, but the problem is that vb.net pick the coma as delimiter to fill in the cells instead of the semicolon whatever I tried with the SaveAs method.

@MacroMarc Thank you very much it worked perfectly well !
After looking individually the parameters, it appears that semicolon doesn't do anything, but Local solve the problem with the OpenText Method !
Answer: So I don't know if there has to be an answer to mark the subject as solved but in case here is the solution found my MacroMarc in the comments :
Instead of saving the csv file as an excel with the saveAs function, use OpenText method with Local:=True; and finally SaveAs an xlsx with no specific parameters :
Instead of :
oExcelFile.Workbooks.Open(strFolderPath)
oExcelFile.ActiveWorkbook.SaveAs(Filename:=path, FileFormat:=Excel.XlFileFormat.xlOpenXMLWorkbook, CreateBackup:=False, Local:=True)

Use this :
oExcelFile.Workbooks.OpenText(Filename:=strFolderPath, Local:=True)
oExcelFile.ActiveWorkbook.SaveAs(Filename:=path, FileFormat:=Excel.XlFileFormat.xlOpenXMLWorkbook, CreateBackup:=False)

Thank you once more for your help ! :)


AngularJS  directive inside the  doesn't work in chrome browser

Question: I am trying to create a simple tags-input field in AngularJS, using ngTagsInput directive. I have some tag names in tags.json, which I want to be displayed as suggestions while entering the tag names in input field, for which I am trying to use auto-complete directive, inside tags-input.
Here is the index.html :
<!DOCTYPE html>

    <meta charset="utf-8" />
    <title>AngularJS Plunker</title>

    <link rel="stylesheet" href="http://mbenford.github.io/ngTagsInput/css/ng-tags-input.min.css" />

    <tags-input ng-model="tags" add-on-paste="true">
      <auto-complete source="loadTags($query)"></auto-complete>
    </tags-input>

Model: {{tags}}

Here is the tags.json :
[
  { "text": "Tag1" },
  { "text": "Tag2" },
  { "text": "Tag3" },
  { "text": "Tag4" },
  { "text": "Tag5" },
  { "text": "Tag6" },
  { "text": "Tag7" },
  { "text": "Tag8" },
  { "text": "Tag9" },
  { "text": "Tag10" }
]

The code works fine in firefox and displays the suggestions in a dropdown manner once you type 'Tag' in the input field. However in chrome it does not display the suggestions, but the rest of the things work fine.
Here is the screenshot of the app in chrome:

Any idea how to accomplish this in chrome?
Comment: can you show a demo with above mentioned issue?
Comment: i've added a screenshot of the app in chrome
Comment: in firefox when I click on the print-screen button, the dropdown goes away, so it looks the same as chrome
Comment: m not sure if it has something to do with my chrome settings or else
Answer: So yea, after digging a little, I figured out that chrome has some security issues which doesn't allow files to be loaded from the local machine, in this case tags.json.
Solution: You can host the file on some server or even on WAMP, should work fine.


drush aegir and drupal

Question: I have created a platform on my aegir dev server and I found myself wondering once the platform in drupal7 is installed is there a way to create websites using that platform via the commandline.
Answer: Yes there is: it's a two or three step process, but automatable.
Step 1) Create a Drush alias, or in Aegir terminology, 'context' for the site using drush provision-save (arguments)
Step 2) Install the site using drush @(site context name goes here) provision-install
Step 3) (optional but recommended) Verify the platform in the Aegir interface to have it automatically detect the site and 'import' it into the frontend so that you can do other things to it later via the web interface. You can also run this verification from the command-line with drush @hostmaster hosting-task @(platform context name goes here) verify
For specifics on the syntax of provision-save etc, see my article, "Manage your Aegir system from the command line": http://mig5.net/content/manage-your-aegir-system-command-line.

drush aegir and drupal


What can we say about behavior of $\sum_{p |n} \frac{p}{\log p}$?

Question: We want to estimate $\displaystyle \sum_{p|n} \frac{\log p}{p}$. It's well known that $\displaystyle \sum_{p \le n} \frac{\log p}{ p} = \log n + O(1)$.
Of course the former series should be smaller than second one, but what's the behavior? I think it should be $\log \log n$ (like instead of $n$ we should consider $\log n$, because of number of elements in this sum). Also I thought about Moebius function, but it doesn't work here. Any hints?
Comment: You can maximize the number of terms by taking $n$ as a primorial.
Comment: @ajotatxe then I'll find the upper bound?
Comment: Your question doesn't make **sense**,  with the PNT we can estimate $\sum_{n \le x}\sum_{p|n}{\frac{p}{\log p}}$ but not $\sum_{p|n}{\frac{p}{\log p}}$ which oscillates a lot (try with $n=2^m$ and $n+a$ prime). Also $$\sum_{p \le x} 1 \sim \sum_{k \le x} \frac1{\log k} \implies\qquad \sum_{p \le x} \frac{p}{\log p} \sim \sum_{k \le x} \frac{k}{\log^2 k} \sim\frac1{\log^2 x}\sum_{k \le x} k\sim \frac{x^2}{2\log^2 x}$$
Comment: I suppose it should be log p / p, and not p / log p.
Comment: It doesn't change my comment that we can estimate $\sum_{n \le x}\sum_{p|n}\frac{\log p}{p}$ but $\sum_{p|n}\frac{\log p}{p}$ oscillates @gnasher729
Comment: @gnasher729 Edited , sorry!
Answer: Let $n \in \mathbb{N}^{*}$:
$$\displaystyle \frac{\log n}{n} \leq \sum_{\substack{p|n \\ \text{p prime}}} \frac{\log p}{p}$$
And we have equality iff $n$ is prime.
Let $n = \displaystyle{\small \prod_{\substack{p \leq m \\ \text{p premier}}} {\normalsize p}}$. Then :
$$
\begin{array}{rcl}
\displaystyle\sum_{\substack{p|n \\ \text{p prime}}} \frac{\log p}{p} & = & \displaystyle\sum_{\substack{p \leq m \\ \text{p prime}}} \frac{\log p}{p} \\ \\
 & = & \log m + O(1) \\ \\
 & = & \log\Big((1+o(1))\log(n)\Big)\,\, , \quad (\text{prime number theorem})\end{array}$$
Then we have for all $n \in \mathbb{N}^{*}$:
$$\displaystyle \frac{\log n}{n} \leq \sum_{\substack{p|n \\ \text{p prime}}} \frac{\log p}{p} \leq \log\Big((1+o(1))\log n\Big)$$
You can see that $\displaystyle\sum_{\substack{p|n \\ \text{p prime}}} \frac{\log p}{p}$ haven't an equivalent whene $n \to +\infty$.


Total size of all subsets of a set is $n\cdot2^{n-1}$

Question: So I'm supposed to show that the total size of all subsets of a set is $n\cdot2^{n-1}$. I've noted that $2^{n-1}$ is the size of the power set of an $n-1$ element set, and I think it's that every element of $P(X)$ where $|X|=n-1$ will contribute $n$ to the size of the subsets of $P(X')$ where $|X'| = n$ but I don't know why or how. Can anyone help?
Thanks!
Comment: You want $\sum_{k=1}^n k\binom{n}{k}$. There are many questions on MSE in which it is shown the sum is $n2^{n-1}$.
Comment: 1 subset of size 0, 3 subsets of size 1, 3 subsets of size 2, and 1 subset of size 3... oh wow. That's awesome. I think I see it now! EDIT: Oh wait I think that's just a result of the binomial theorem...
Comment: What do you mean by "the total size of all subsets"?
Comment: Like for the subsets of {1,2}, you add up 1 subset of size 0, the empty set, 2 subsets of size 1, and 1 subset of size 2, you get 4, which is 2*2^1 = 4.
Comment: How does that work for $\{1,2,3\}$?
Answer: Each subset and its complement together have exactly $n$ elements.
Comment: This is just a hint--but a very good one. +1.
Comment: Nice pairing argument.
Answer: Imagine we have a list of all the subsets of the $n$-element set $A=\{a_1,a_2,\dots,a_n\}$.  We find the sum of their sizes in a funny way.
Look first at $a_1$, and make a tick mark for every one of the subsets of $A$ that $a_1$ occurs in. We will make $2^{n-1}$ tick marks, since $2^{n-1}$ subsets of $A$ contain $a_1$.
Do the same for all the $a_i$. The total number of tick marks is the sum of the sizes of the subsets of $A$. For given any subset $S$ of $A$, our procedure produces a tick mark for every member of $S$.
The total number of tick marks is $n2^{n-1}$.
Remark: We are evaluating the sum $\sum_{k=1}^n k\binom{n}{k}$. There are a number of proofs on MSE that this sum is $n2^{n-1}$. We described a counting argument specifically suited to the "sum of sizes" version.
Comment: Nice explanation
Comment: Sorry, can you explain why each element will appear 2^(n-1) times? Is it because that's the size of the powers set of a set of n-1 elements, and a1 will appear in every subset of the n-1 element set in the power set of the n element set? Hopefully that made sense.
Comment: To make a subset of $A$ that contains $a_1$, we take the union of $\{a_1\}$ with **any** subset of $A\setminus\{a_1\}$. There are $2^{n-1}$ subsets of this set. More informally, half of the $2^n$ subsets of $A$ contain $a_1$, and half don't.
Comment: Taking the derivative of $(1+x)^n$, and plugging in $x=1$ would be another way.
Comment: @i707107: Yes, that is a nice way to do it, please consider giving it as an answer. I wanted to give a "pure counting" argument.
Answer: The other answers are more elegant.  But the most straightforward way is
$$
\sum_{i=0}^n {n \choose i} i
= \sum_{i=0}^n \frac{n! \cdot i}{i!(n-i)!}
= n \sum_{i=1}^n {n-1 \choose i-1}
= n 2^{n-1}
$$
Answer: $$f(x)=(1+x)^n=\sum_{k=0}^n{n\choose k}x^k\iff f'(x)=n\,(1+x)^{n-1}=\sum_{k=0}^nk{n\choose k}x^{k-1}$$
$$f'(1)=n\cdot2^{n-1}=\sum_{k=0}^nk{n\choose k}$$
Answer: The total size is $\#\{\,(x,S)\in X\times\mathcal P(X)\mid x\in S\,\}$ if you count by fixing each$~S\subseteq X$ first. But counting fixing each $x\in X$ first, it contributes $\#\mathcal P(X\setminus\{x\})=2^{n-1}$ to this size, for a total of $n2^{n-1}$.


Zend Framework - Zend_Loader_PluginLoader

Question: I'm just really starting with the Zend Framework, and currently I'm having a problem with the Zend_Loader_PluginLoader.
I managed to get a module specific plugin working easily enough using the following code:
class Api_Bootstrap extends Zend_Application_Module_Bootstrap
{
    protected function _initPlugins()
    {
        $loader = new Zend_Loader_PluginLoader(array(
            'Api_Plugin' => 'application/modules/api/plugins',
        ));

        $front = Zend_Controller_Front::getInstance();
        $front->registerPlugin(new Api_Plugin_ErrorControllerSelectorPlugin());
    }
}

Edit: The class file is located at application/modules/api/plugins/ErrorControllerSelectorPlugin.php
I then tried to adapt this to get a plugin loaded for the whole application using:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAppAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'App',
            'basePath' => dirname(__FILE__),
        ));

        return $autoloader;
    }

    protected function _initPlugins()
    {
        $loader = new Zend_Loader_PluginLoader(array(
            'My_Plugin' => 'application/plugins',
        ));

        $front = Zend_Controller_Front::getInstance();
        $front->registerPlugin(new My_Plugin_ModuleConfigLoaderPlugin());
    }
}

But I'm getting errors:
Fatal error: Class 'My_Plugin_ModuleConfigLoaderPlugin' not found in /var/www/localhost/application/Bootstrap.php on line 22

Edit: The class file is located at application/plugins/ModuleConfigLoaderPlugin.php
So - since the files are where I would expect them to be as far as the prefix/path pairs sent to Zend_Loader_PluginLoader() and the code in both cases are the same, what's the difference?
How do I get it to recognise my application-level plugins?
Comment: And where `My_Plugin_ModuleConfigLoaderPlugin` locate?
Answer: If you want the app-level plugin to reside within the namespace My_, you either need to put the My folder out in the library folder or declare the app-level namespace to be My_.
Assuming that you already have other stuff within your top-level app that uses the App_ namespace, then the easiest thing would be the former: move your My folder out into the library.
So, the plugin would reside in:
library/My/Plugins/ModuleConfigLoaderPlugin.php.
Then make sure that your configs/application.ini registers the My_ namespace:
autoloaderNamespaces[] = "My_"
Then the app-level Bootstrap could contain something like:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAppAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'App',
            'basePath' => dirname(__FILE__),
        ));

        return $autoloader;
    }

    protected function _initPlugins()
    {
        $front = Zend_Controller_Front::getInstance();
        $front->registerPlugin(new My_Plugin_ModuleConfigLoaderPlugin());
    }
}

Alternatively, since your plugin does not sem to require any params, you could instantiate it via configs/application.ini using:
resources.frontcontroller.plugins[] = "My_Plugin_ModuleConfigLoaderPlugin"


What effect do wood and body mass have on electric guitar tone?

Question: Most articles on tone state that electric guitar pickups have a major - or even the greatest- influence on tone.
It is also typically said that tonewoods make a small difference in tone.
So why is it that a Les Paul and SG sound substantially different? (For this purpose, let's assume both are equipped with the same pickups, wiring, bridge, strings, neck, fretboard material, are non-chambered, etc.)
If tonewood makes a minor contribution, the maple cap on a Les Paul should not matter much.
Shape and mass are otherwise obvious differences between the Les Paul and SG. Do one or both of these explain the differences in tone?
Suppose the answer is mass. Non-chambered Les Paul Standards typically range from 8-10 lbs, yet - when the electronics, etc., are all identical - they generally sound very similar.
How does all this factor into the conventional wisdom about the most influential contributions to tone?
Comment: This is the _hot button_ topic for guitar fans. No two guitarists agree. It all makes _some_ difference. **I** think that the pickups make the most difference, but I don't have the strongest evidence to back it up. But that question is **_far_** more valuable as a hand-grenade to throw into musician conversations than it is as a guide for your tone quest.
Comment: Also, the pickup placement on the two models is different, so we're back to the "#1 influence" on tone.
Comment: The maple cap definitely makes a difference. Some might disagree, but **I** can hear the difference.
Comment: "For this purpose, let's assume both are equipped with the same pickups, wiring, bridge, strings, neck, fretboard material, are non-chambered, etc."  Are there two guitars for which this is true, so we could hear this comparison?
Comment: You are assuming too much. All kinds of factors influence the sound of an electric guitar, including manufacturing variations in the pickups, the electronics, the fretwork and the setup. So even if you equipped an SG and a Les Paul with the same pickups and electronics, and you could tell a difference (which you haven't demonstrated yet!), you would have to take, let's say, five SGs and LPs each and show that you can tell them apart. THEN you can read https://www.gitec-forum-eng.de/the-book/ and start investigating the relevant differences; and they're probably not in the wood, or the shape.
Comment: Never owned an LP but had 4 different Strats. The best sang like a bird, acoustically & electrically. The worst sounded like it was made of plasticine. The lightest was the best, the heaviest the worst. The best was made of traditionally dried wood, the worst was cheap kiln-dried. The pickups simply could not have been the deciding factor.
Comment: Related: https://www.youtube.com/watch?v=EM7wDZENKEM&list=PLZUa0lj5U66B1xxQ0dRRHo7J1dpVFqTcR&index=2
Comment: The wood should affect the sound only in terms of dampening. The major factors here are pickup position, pickup height and pickup design. And I don't know if you'll find a guitar where these three things are all the same.
Comment: I feel compelled to chime in, even though I'm not a guitarist. Let's accept that the imaginary scenario of two "identical-wiring" guitars is impossible. How about this instead: what if you took a single guitar, and consider its initial tone, and then for some reason hacked its body up. What if you cut away everything but the central chunk? What if you turn it into a hollow-body with a giant cavity inside? The pickups, wiring, etc are still the same—has the tone changed? How much? @Guitarsr if this strikes your fancy as a hypothetical, feel free to edit it into the original question.
Comment: @AndyBonner check out the video I linked above. The builder has made a neck-through-body setup with pickup installed to it and tries it on bodies made of different tonewoods and particle board. I'd say it's pretty close to the supposedly impossible "identical-wiring" scenario.
Comment: Ok, one more comment: This question has some close-votes as opinion-based. If you're listening, guitarsr: I believe the core of your question could be put as: "Sure, pickups and placement are a big component of tone. But **how much do tonewood and mass affect the sound**?" IMO, that's a more focused question that's easier to answer objectively. Maybe edit to highlight that, and not dwell on "conventional wisdom."
Comment: There are three questions here.  This post does not meet the standards of this exchange.  It is fishing for a discussion forum.
Answer: Pickup placement has a massive effect on tone. Moving a bridge or neck pickup just a few millimeters causes an audible difference.  Mass of the body also has an effect.  Both are at play here.  The former will only effect the plugged in tone, but differences in physical construction (body mass, woods, construction etc.) will also be audible when played acoustically.
Short answer, but sometimes it is just that simple.

edit, to expand a little:
Were you to find (or build) a les Paul made of the same wood, with exactly the same pickups, strings, scale length, electronics, the same bridge etc., and exactly the same pickup height and placement (in mm from the bridge), the differences in tone you were hearing would be primarily due to the heavier body of the les paul.
This does in fact make a difference; when you strum a chord and let it ring, the strings and the body and coupled and resonate together; in layman's terms, one vibrates the other and vice versa, and they "feed into" each other.  This means that the construction of the body affects things like sustain, and tone (as different frequencies are emphasised by a different resonating body).
(and indeed not just the body, the entire guitar, but SGs and LPs have the same style neck joint and similar necks, so that's not really relevant here)
Comment: They both have glued necks, but the joint isn't really the same. In LP neck goes much deeper into the body.
Comment: good point. In that case, it may well also have a non-negligible effect too
Comment: Technically it's not so much about mass, but about density, then also about hardness, grain structure, shape... The primary effect the wood has on the tone that certain frequencies get dampened. But this can stem from many different sources, such as soft joints, the nut and the bridge, &c.
Comment: Actually, in an electric guitar, the string and the body don't really resonate with each other. The body is something like 1000 times heavier than the string, so the amplitude at which the body vibrates is also minuscule compared to that of the string. Also, the body dampens vibrations, rather than resonating - if you tap an electric guitar's body, you get a "tok", not a "tschhhh". So the body is more like a sink for the vibrational energy of the string - once it leaves the string, it is essentially lost to the amplified tone (which is generated only by the movement of the string).
Comment: If you think about the physics, the mass difference doesn't mean that the body and neck don't resonate, just that the resonance must happen at higher modes. And if you tap a body with Stratocaster-style vibrato, it makes a definite "sproing" sound in addition to the "tok".


PHP classes error

Question: I have three files: one called sql.php witch has a class db that I use to ease the get results operation from MySQL; one called session.class.php that has class session (extending class db) witch I use to make my basic operations as functions... like check_login function witch I use to check if user is logged in; and another one called main.class.php that I have from a login module posted on a forum. At first it used another file as MySQL wrapper called mysql.class.php that I didn't like and replaced it with my sql.php. Now, I get an error in my main.class.php file like this:
"Warning:  Missing argument 2 for db::db(), called in C:\wamp\www\extlogin\inc\main.class.php on
 line 14 and defined in C:\wamp\www\extlogin\inc\sql.php on line 33

Warning:  Missing argument 3 for db::db(), called in C:\wamp\www\extlogin\inc\main.class.php on
 line 14 and defined in C:\wamp\www\extlogin\inc\sql.php on line 33

Warning:  Missing argument 4 for db::db(), called in C:\wamp\www\extlogin\inc\main.class.php on
 line 14 and defined in C:\wamp\www\extlogin\inc\sql.php on line 33"
My main.class.php file looks like this:
<?php
    require_once("sql.php");
    require_once("session.class.php");
    class main extends db {
        public function __construct() {
            header('Content-Type: text/html; charset=iso-8859-1');
            session_start();
            if (class_exists('db')) {

            } else {
                die("Database class does not exist!");
            }
            if (class_exists('session')) {
                $this->session = new session($this);
            } else {
                die("Session class does not exist!");
            }

        }
    }
?>

Where line 14 in my main.class.php file has this: $this->session = new session($this);
and line 33 in my sql.php file has the function db for connection defined like this:
function db($dbuser, $dbpassword, $dbname, $dbhost)

Can anybody tell my how to fix this error ? I could give you more details if you need them.
Thanks.
Answer: On line 33 you are initializing the db class without satisfying its last three parameters. The error is pretty straightforward...
Answer: The error is in sql.php. Check that file, db:db() seems to need some parameters.
As best practice:

you should not display the errors in the generated html file
set error level to warning, or lower
monitor the log file for errors
Answer: Are you sure you need to extend class 'db'?
Take a look at session.class.php in the constructor. It seems that it is trying to create an instance of a 'db' class, which requires some input parameters. You may need to pass some additional parameters to the session class or perhaps have a db instance initialized beforehand.

PHP classes error


Windows 2003, SQL 2005 - What is server tasking and where do I find it?

Question: I've been reading up on how to tune SQL Server 2005 for a machine in a test environment. I came across this article on technet which suggests how to configure "server tasking" and says I should refer to the Windows 2003 docs for more info.
I have googled Windows 2003 "server tasking" (with and without the quotes) but all I can find is more similar articles on SQL server telling me that it should be configured, not how/where you do it.
I know I'm probably searching for the wrong thing - can someone please tell me how to configure it in Windows or SQL server, whichever it is?
Answer: Whoever wrote that used the wrong (or an uncommon) term. It's "processor scheduling."
Comment: Lol - In that case I know exactly what it is! The line "When you run SQL Server Setup, server tasking is set to none in Windows Server 2003" confused me, because there is no "none" in the processor scheduling settings. I take it this is wrong?
Comment: It's also called server tasking: http://technet.microsoft.com/en-us/library/ms176012(SQL.90).aspx
Comment: But is it called that anywhere outside of the SQL documentation? I only ask because I've never heard that term until reading this question and the linked docs.
Comment: Like you, I've never seen it referenced anywhere outside of SQL.
Comment: And they all look like different revisions of the same document. I bet the person who first wrote this SQL doc in the NT 4.0 days translated something into English incorrectly, and the term was never corrected.
Answer: I can't really answer your question directly but when I use Help and Support on one a Server 2003 machine and search for server tasking it locates 25 Knowledge Base articles, so I'm guessing some of those might have your answers.
The following 24 KB articles were found through Help and Support (the 25th was about Win98). I don't know how many are really relevant but I'll leave that up to you to determine.

KB121594
KB102061
KB101709
KB970821
KB118677
KB109228
KB111405
KB107245
KB2272146
KB103810
KB124838
KB101781
KB102987
KB140372
KB135899
KB293513
KB86290
KB90227
KB103435
KB72182
KB71300
KB85394
KB85419
KB96418
Comment: Unfortunately my test rig is not allowed to have any connection to the internet at present (not my rules). Is it possible you could figure out the links to a couple of these and post them?
Comment: @simon, I'll have a look in the morning (it's 11:06PM here), although by then someone else may already have answered you question.
Comment: @Simon, answer updated.
Comment: Come on man - this site can't be linkdump-and-run :-)
Comment: @mfinni, if I understood the problem (not my area) and had the time to delve deeply into those articles I would do so. As it is I'm merely trying to offer a pointer in a direction that *might* be useful. It's not like this question has been overwhelmed with better answers.


pip install multiple packages listed in file with sources from local directory

Question: I am unable to install multiple packages listed in a file using single command line, I know that we can install multiple packages listed in a file using -r switch and we can use local sources to install using --no-index --find-links switches, but I am not sure if we can combine these two, I tried but its not working, so pls suggest, below is my exact requirement.
I have two packages pkg1-1.1.tar.gz and pkg2-2.2.tar.gz in directory
    /home/rafiq/newpkgs
    Need to install them using pip command and the package names are listed in pkglist.txt.
    phglist.txt contents:
    pkg1==1.1
    pkg2==2.2
please help me with pip command to install list of packages listed  in pkglist.txt with sources present in newpkgs directory.
Answer: According to pip install manual your command should be:
pip install --no-index --find-links=newpkgs -r pkglist.txt

--no-index ignore pip index and looks for packages only where explicitly told to.
--find-links finds packages in a directory listing or parses an html file for links (can be shortened to -f)
Edit:
OP had a different problem after pip command was successful, but the actual build wasn't. For more information see this thread: How to install psycopg2 with "pip" on Python?
Comment: i am using centos need to yum install python-devel and postgresql-devel for the above exception. I actually have many more packages in original list so may be the dependencies are causing the issue let me resolve individual exceptions for respective packages, if all goes well confirm its working
Comment: That works, actually the issue was with prerequisites , we can install all with one command given all yum install dependencies are installed
Comment: Thanks, Thats what i tried before posting, if you are sure it should work, I m getting error like 'Command python setup.py egg_info failed with error code 1 in /install/dir/build/psycopg2'. Not really sure what is wrong.
Comment: Try this if you're on ubuntu/debian: `sudo apt-get install libpq-dev python-dev` seems like these are prerequisites for the package (from this answer: http://stackoverflow.com/a/5450183/948550 )
Answer: I don't know how long the following solution has been around for, but I found you can simply run
pip install my_compressed_package.tar.gz
and pip will know what to do. All done locally, no network access needed.


Guqin construction and physics

Question: I am a physicist building a Guqin, an old Chinese zither.
I try to understand its construction, how it vibrates, what are the key features to obtain a good sound.

I found only one paper on the subject, Vibroacoustic of the Guqin, but it is only scratching the surface. Can somebody with playing / building experience give me suggestions? More specifically, I am trying to understand:

What is the main drive mechanism? In guitars and violins we have the strings attached to a light bridge and thin soundboard, while for the guqin the head is massive! How is the vibration of the strings transmitted to the body?
Are there some "cheap tricks" to change its sound, like closing the soundholes, that can help understand what affects the sound?
Tonewood choice. I am now using Larch as the main wood material, because of its availability, and I like the color. Officially, I should use Pawlonia wood that is much lighter, but I can't find it here. I have seen an instrument for sale made of Fir wood. Is there a difference?
Comment: I doubt a player would be able to answer that better than you.  You may have to dissect one carefully, or mount some accelerators to the device and take some measurements.  As a physicist how familiar are you with musical acoustics?  You might benefit from looking at the texts by Fletcher and Rossing on instrument construction (though mostly Western).  At the very least you may find more articles in the reference sections, or be able to do a search for new papers that cite Fletcher and Rossing as they are the well known.
Comment: The vibration is still transferred to the body through the bridge. Just because the bridge is massive doesn't mean it won't transfer energy. A bridge with more mass will have two effects: 1) It will damp higher frequencies more than lower ones, so it will make the tone less bright, and 2) it will increase sustain, because more energy will be reflected back into the string instead of transferred to the top.
Comment: There's some background information here: http://guqinreflections.com/making-a-qin-design-considerations/ For instance, it says the traditional top wood has the highest strength to weight ratio of any wood. A very high strength to weight ratio is also a hallmark of spruce, which is why it is popular for guitar tops. That suggests the top wood is meant to be sensitive to picking up and amplifying the vibration of the strings. High strength and low weight means it may be carved thin to make it have as little mass as possible, therefore less inertia and therefore easier to set into motion.
Comment: There's a lot of black magic involved in producing any acoustic stringed instrument. There's also a lot of math - I've seen the sketches and equations a local luthier uses when designing the dimensions of a violin body.  The type **and** quality of wood uses has a small effect, but you won't know until you've built a few.   That said, since it is in the zither family, try researching zither fabrication in general.
Answer:
The string vibrations are transferred at the point where they contact the body, like all other stringed instruments. As one commentator pointed out (and I concur from personal experience) the sustain will be improved by higher density wood, and/or more mass at the contact point. The nut on the left (photo) seems to resemble a guitar nut, so I would recommend graphite for improved intonation and playability (allows the strings to slip and vibrate easily).
Everything you change will affect the sound in some way. Closing a sound hole will definitely make a noticeable difference. Take any acoustic guitar and cover the sound hole to hear an example. The string vibrations echo and resonate in the body chamber (and throughout the instrument) and emerge amplified from the sound hole. If you plug the hole, it will be quieter (less projection). Additionally, if there is a soundboard, touching it or dampening it will also have a big impact.
Wood has a major impact on the sound of an acoustic instrument, not a small impact. If you want something lightweight, try Chinese Basswood (aka Linden). It is light, easy to work with, flexible, and very affordable (which is why so many modern guitars are made from it). It is also widely available.
Comment: Thanks for the contribution! Yes on the left it's a nut, graphite may be a nice try. The tuning pegs are actually under the bridge on the right (the bridge may then be coated with graphite). In the meanwhile I built the instrument out of larch (no graphite, ebony nut). The basswood idea is nice, it's a bit on the heavy side, but if i can get good large planks  it may be ok
Comment: @patta Basswood is NOT "a bit on the heavy side" ... it is widely known as being light and comparable to Ash. Swamp Ash was famously used for Fender guitars for many years due to it's light weight and low density. Basswood is now used. Ebony is great for fingerboards because the extreme hardness reflects [notes] well, but I would not recommend it as a nut. The slipperiness of graphite is ideal for a nut (or bridge) because the strings need to be able to slide easily. I didn't comment on the tuning pegs but thanks I guess for confirming what the photo shows. Reminds me of Steinberger's design.

Guqin construction and physics


Why is this not a matroid?

Question: If I recall correctly both of these definitions are equivalent:

$(E,I)$ is an independence system and satisfies the augmentation property.
$(E,I)$ is an independence system and all maximal independent sets in I have the same size.

However I would say that the following system satisfies the second definition but not the first:
$(\{1,2,3,4\},\{A|$ all numbers in A have equal parity$\})$
The maximal independent sets are $\{1,3\}$ and $\{2,4\}$, but at the same time if we take $A_1=\{1\}$ and $A_2=\{2,4\}$ we can't find any $a \in \{2,4\} \setminus \{1\}$ so that $(\{1\} \cup a) \in I$.
What am I missing here?
Answer: Note: The term "(abstract) simplicial complex" is a common synonym for "independence system", and I'll use the former term here.
Your first definition is one way to define a matroid. Your second definition defines a class of objects called pure simplicial complexes. As you point out in your question, there are pure simplicial complexes that are not matroids.
But what about the converse?
The fact that every basis of a matroid has the same size (equal to the rank of the matroid) follows directly from the augmentation property. It follows that the independent sets of any matroid form a pure simplicial complex. So we have the following chain of strict inclusions:
$$ \mathrm{Matroids} \subsetneq \mathrm{Pure~Simplicial~Complexes} \subsetneq \mathrm{Simplicial~Complexes}$$

Why is this not a matroid?