Is there a notion of integration over the algebraic numbers?

Question: For reasons which are hard to articulate (due to they not being very clear in my mind), but having to do with the eprint From Matrix Models and quantum fields to Hurwitz space and the absolute Galois group by  Robert de Mello Koch and Sanjaye Ramgoolam, I have been wondering whether there is a notion of integration over the algebraic numbers $\overline{\mathbb{Q}}$, as there is over the p-adic completions of the rationals.
Comment: Reading the comments below, it seems that people would like the algebraic numbers to have a nice topology first, and do measure theory compatibly with this topology then. Why don't we just look for a way to assign to each algebraic number a certain "weight" (perhaps somehow related to some Galois theoretic property of that algebraic number) and then just sum the series?
Comment: This is essentially what the Weil height (and other similar "height functions") on algebraic numbers does.
Answer: You can definitely talk about integration on $\overline{\mathbb{Q}}$. The question is "with respect to what measure?" The reason integration theory works so well over a completion of $\mathbb{Q}$ is that such a field is, as an additive group, locally compact, and so possesses a Haar measure (a non-zero, translation invariant Radon measure) which is in fact regular because any $p$-adic field is second countable (think of Lebesgue measure on $\mathbb{R}$). In less technical language, the completion has a canonical "nice" measure against which to integrate. The (additive) group of algebraic numbers is definitely not complete in any of its (many) valuations (obtained by embedding it into the algebraic closure of some $\mathbb{Q}_p$ or into $\mathbb{C}$), and therefore is not locally compact. The main tool for constructing interesting measures on topological spaces (that interact nicely with the topology) is the Riesz representation theorem, but this is specifically for locally compact Hausdorff spaces, so doesn't apply to the algebraic numbers. Really the reason people care about completions of $\mathbb{Q}$ and of number fields in general, is because the completions are amenable to lots of tools for analysis, whereas $\mathbb{Q}$ (and I guess also $\overline{\mathbb{Q}}$) just isn't. Completing fields allows one to bring analysis to the study of, say, number-theoretic problems.
Now, in another direction, integration definitely works on the Galois group of $\mathbb{Q}$, $Gal(\overline{\mathbb{Q}}/\mathbb{Q})$. This is a profinite group (meaning it is compact and totally disconnected) in its natural topology, and so, like the completions of number fields, admits a Haar measure.
In yet another direction, one can view the multiplicative group of algebraic numbers, $\overline{\mathbb{Q}}^\times$, modulo torsion (roots of unity) as a (multiplicative) vector space over $\mathbb{Q}$. J. Vaaler and D. Allcock sort of initiated the study of this group (as such) and worked out its completion as a certain subspace of $L^1(Y,\mu)$, where $Y$ is a totally disconnected, locally compact Hausdorff space whose underlying set is related to the places of $\mathbb{Q}$ and where $\mu$ is a Radon measure (got using the theorem I mentioned above) that satisfies some kind of relative invariance with respect to the absolute Galois group of $\mathbb{Q}$.
I guess maybe I went way off topic with this. My point is that interesting measures on $\overline{\mathbb{Q}}$ are maybe difficult to come by, and without an interesting measure, there's no reason to do integration.
Comment: Here's a link with the paper of Vaaler and Allcock:

http://www.ma.utexas.edu/users/allcock/

I should have said that one gets a norm on $\overline{\mathbb{Q}}^\times/\text{torsion}$ from the Weil height...then it makes sense to ask about its completion.
Comment: Interesting.  Thanks for the detailed answer the link to the paper.  Perhaps when I've a clearer idea of what it is that I'd like to do with this, I will post a more detailed and hopefully better motivated question.
Answer: Pick an algebraic number at random.  What is its expected degree?  As noted, since the set is countable, we cannot expect to do conventional integrals on it.  But we still have things like this:  pick a natural number at random---then it is square-free with probability $6/\pi^2$.
So, maybe the question is:  What are "natural" Folner sets for the algebraic numbers?  The usual Folner sets for $\{1,2,3,\dots\}$  are the sets $\{1,2,\dots,n\}$, which define the "density" (not an actual measure)
$$
\delta(A) = \lim_{n\to\infty}\frac{\\#(A \cap \{1,\dots,n\})}{n}
$$
for sets $A \subseteq \{1,2,\cdots\}$.  See, for example, http://en.wikipedia.org/wiki/F%F8lner%5Fsequence for information on Folner sequences.
Comment: The fact that the set of algebraic numbers is countable is not what precludes applying the usual integration machinery to it. The additive group of integers is a perfectly good (countable) locally compact group and people do Fourier analysis on it all the time. The problem with $\overline{\mathbb{Q}}$ is that it fails to be locally compact in any of its usual topologies.
Comment: @KK: As with the integers, you could put the discrete norm on $\overline{\mathbb{Q}}$ and then it becomes locally compact and complete, with natural (Haar) measure being the counting measure.  This feels like a rather trivial answer, but I can't tell from the question exactly what Jose has in mind.
Comment: @Pete Yeah, I thought about that as soon as I posted my response. I'm also not really sure what Jose has in mind, but it's good to point this out, that there is one obvious locally compact topology on $\overline{\mathbb{Q}}$.


Running Spock unit test along with TestNG in Spring boot maven based project

Question: I'm working with IntelliJ, Spring Boot 1.3, java8 and maven.
We were using TestNG for our unit but when I started using Spock for unit test, I really liked writing test using Spock in Groovy. Here is the folder structure:
src->test->java -> All java based TestNG test lives here
src->test->groovy -> All groovy based Spock test lives here. All test have a suffix of Spec and that's how I've configured surefire plugin to look at those test.
Now when I run these individual test they work just fine. But when I run maven lifecycle command like mvn test or mvn clean install, Spock test does not run even though I have enabled maven compiler and appropriate library.
This is how my pom looks like:
 <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${version.surefire}</version>
                <configuration>
                    <skipTests>false</skipTests>
                    <useFile>false</useFile>
                    <includes>
                        <include>**/*Spec.*</include>
                        <include>**/*Test.java</include>
                    </includes>
                </configuration>

            </plugin>

            <dependency>
        <groupId>org.spockframework</groupId>
        <artifactId>spock-core</artifactId>
        <version>1.0-groovy-2.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib-nodep</artifactId>
        <version>RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.objenesis</groupId>
        <artifactId>objenesis</artifactId>
        <version>2.1</version>
        <scope>test</scope>
    </dependency>

I think I'm missing something in plugin which would let maven run Spock test along with TestNG during maven lifecycle command. I think I'm missing trivial thing here. Can can someone give me some pointers here on what should I add in pom or if someone has a sample skeleton project in github which I can look at. Thanks.
Comment: What is you use `**/*Spec.java` like in the sample: https://github.com/spockframework/spock-example/blob/master/pom.xml
Answer: I was able to get this working. Here is my updated pom.
I had two problems:
-One to run TestNG and Groovy test as a part of maven test lifecycle. This was made possible by adding dependency in surefire plugin. See below pom.
-After fixing that I had a problem another problem with Intellij where it was complaining about class already exists for my groovy based test. This was due to generated stubs in target folder. For this I had to provide configuration to override those directories as suggested by below link.
<plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>addTestSources</goal>
                        <goal>testGenerateStubs</goal>
                        <goal>testCompile</goal>
                        <goal>removeTestStubs</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>

                <stubsOutputDirectory>${project.build.directory}/generated-groovy-stubs</stubsOutputDirectory>
                <testStubsOutputDirectory>${project.build.directory}/generated-groovy-test-stubs</testStubsOutputDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${version.surefire}</version>
            <configuration>
                <includes>
                    <include>**/*Spec*.groovy</include>
                    <include>**/*Test*.java</include>
                </includes>
                <properties>
                    <property>
                        <name>junit</name>
                        <value>false</value>
                    </property>
                </properties>
                <threadCount>1</threadCount>
            </configuration>

            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>${version.surefire}</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-testng</artifactId>
                    <version>${version.surefire}</version>
                </dependency>
            </dependencies>
        </plugin>

I hope this helps other folks who are trying to run TestNG and Spock test together.


Any way to save highlights or annotations within MHT file?

Question: I've seen tools that let you highlight and/or annotate webpages and save those annotations online. I'm interested in finding a tool that will allow me to do the same thing on a webpage and save the highlights or invitations with the webpage inside a single MHT file so that I can reopen the file locally and retain my notes. Is this possible? It can be a browser add-on or a standalone separate program.
Answer: I don't think so in general. This is something we should have had long ago (including SVG-based freehand annotation), but we still don't have decent solutions. There are some things you could use for highlighting or adding notes to the end of a page/section, which can be saved as MAFF (with the Firefox "Mozilla Archive Format" extension). They should work with MHT as well, although I can't say for sure. MHT is a weird proprietary format. If you use FF, MAFF is probably a better way to save websites, it's basically just a zip archive of the webpage and its resources (so you can just unzip it and view it with anything).

The markit highlighter bookmarket copies a page to the markit website and then lets you highlight it. It doesn't require registration and it's fairly lightweight. You can save the page as MAFF and it will be saved with the annotations
If you want to add some notes to the end of a page (or in the middle, although they'll be styled normally), you could use a bookmarklet. If you save the following as the location in a bookmark, with a name like "edit current page", it will let you edit a webpage when you click it:
<code>javascript:document.body.contentEditable='true';document.designMode='on';void(0)
</code>
Note: any keys that perform functions in your browser will still be intercepted and perform those functions. In particular, if the space bar does a page down, it will still do so rather than entering a space. In this case, the easiest solution would be to copy a space and then Ctrl-v paste it for spaces. (Otherwise, you could use an extension or setting that lets you disable that keybinding.)
If you want to use it together with markit, you need to use markit first, since it won't copy your changes. Also, it's highly unreliably trying to edit directly after using markit, so highlight, then click the markit icon to go to your markit page and click the link that takes you back to your highlighted page. Then you can edit the page.
There are plenty of screenshot and annotation bookmarklets/webapps/extensions that let you make an image of a page and draw/type over it. Those are of limited use for text-based content, though.
Keep in mind you could always convert a page to another format (eg. PDF) and annotate that.


Second monitor's resolution not on maximum with micro HDMI

Question: I got a Samsung NP900X3A Ultrabook (http://www.samsung.com/de/support/model/NP900X3A-A01DE) with Intel® HD Graphics 3000 and an external Samsung SyncMaster SA450 24" screen.
I plug the external screen into the micro HDMI with a VGA adapter. My problem is, that I can only set up the screen to run with 1440x900 resolution. I installed drivers etc. but no change. Is there anything I can do to get the full resolution the screen is capable of? Do I need to buy a HDMI to Micro HDMI cable?
Comment: You will need to use an HDMI cable more then likely to get any higher resolution.  Have you verified your Ultrabook even supports a higher resolution then 1440x900?
Comment: The ultrabook itself has a 1366x768 screen. But I've seen x1024 resolutions as well.
Answer: Ramhound was right. The Micro HDMI to HDMI connector (from the MS Surface) fixed the issue with the resolution. I wonder why samsung doesnt offer such a connector.


Filter-amplifier circuit for low-voltage I/P circuitry

Question: I'm designing my first ever circuit for a hobby project. I have a sensor that outputs in mV (1 to 2) and a controller with ADC. The ADC is 16 bits, VDDA = 3.0 V, Temp = 25°C, fADCK = 1.0 MHz. Since the sensor voltage that is fed is to the controller is low I'm in a predicament! Should I use a low pass filter or a band pass filter in this application? Do you have a circuit that I can relate to? I've attached an example plot.
Comment: Are you sure your sensor is working? What kind of sensor is it?
Answer: Your signal has too much noise to be useful.
I eyeballed a mean signal that might be a high order LPF and although there is correlation in some cycles , not in every cycle.  The results are almost meaningless for position sensing.

I suggest there are a few problems that can be improved greatly with much more disclosure on details.
Suggestions

Provide details on design,sensor,cabling, layout and sources of EMI for improvement on EMI reduction. This includes radiated noise and conducted noise.
Improvements needed may range from higher gain at sensor, shielding, balancing, and filtering both the noise source and the sensor signal and averaging results.
Note that motor noise is likely and ADC noise at Fadc=3MHz reduces accuracy on ARMs from 12 bits to <9 bits without quiet mode etc so 1mV is too low a signal

There are lots of free filter design tools if you know what you need.
This must be defined 1st.
<code>- gain
- Passband (PB) freq. ( eg 1Hz or 10Hz)
- PB ripple ( <1dB)
- Stopband (SB) freq. ( eg  10 Hz or 100 Hz)
- SB reject @ above f (-40dB ) 2nd order is 40dB /decade
</code>
eg free from TI

Large caps can be scaled down by 100 while R increased x100 so if you use Rail to rail OA's rated for 10K load, you do not need lower values. Also use 1M ~10M max depending on bias offset.  This is not a final design just a starting point.  If you use single supply 0~3V then use Vcc/2 as your ground ref with Resistors and cap.
Comment: Hi, @tony thank you. The sensor is piezoelectric and I'm using nxp's KW40Z as the Uc and Alligator Test Leads for cabling. I am thinking of designing a circuit with a low pass filter (2nd order), instrumentation amplifier and then to the Uc's ADC. Since the voltage is too low I am thinking of a gain of 100 or even 150. sounds good or would you advise against this? Let me know :)
Comment: Maximize your gain such that output does not saturate even with noise. Use Rail-Rail type OA's and follow warnings on load R's. Consider Null offset pot with CM range sensing below ground, otherwise must bias to Vcc/2
Comment: Piezoelectrics are really high impedance. I would think a coaxial connection is required. Or better yet, coax with the shield not grounded, but driven at the detector end and NOT connected at the amplifier/ADC end. Better yet, an amplifier at the piezo. If you have to use test leads, make them a twisted pair. That can work wonders. Or the probe from a scope.
Answer: It looks like the sensor may have insufficient signal to noise ratio over the frequency range of valid signals.  You also have a secondary problem in that the sensor signal of 1 to 2 mV is way too small for the 0 to 3 V A/D range.  That can be solved with amplification.
It looks like your signal period is a bit over 20 s.  It's not a sine, so some harmonic content looks to be important.  You haven't given response time or frequency range requirements, but let's say anything past 2 Hz is noise.
Since 2 Hz is very slow for any microcontroller, you can use a rough analog low pass filter, sample much faster than you need the data, then low pass filter in the firmware.
For example, let's say you can sample at 10 kHz.  That's 100 µs per sample, which is a long time even for cheap and small micros.  Two poles of R-C low pass filtering at 500 Hz won't matter to the signal at all, but will squash signals above the aliasing limit of 5 kHz.  For example:

The two poles are actually nominally at 480 Hz with these part values.  This filter would go between the sensor and the amplifier that drives the A/D input.  It's purpose is not make the final filtered signal, but just to ensure that there is no aliasing when the signal is sampled at 10 kHz.
In the micro, you then run a low pass filter that squashes frequencies above 2 Hz.  This digital filter can be more complicated if needed, and won't suffer from analog part tolerances.  I'd start with two poles of low pass filtering at 2 Hz.
It is unclear from your graph what signal to noise ratio you will get this way, but try that and see.  If you substantially reduce frequencies past the valid signal and still don't have enough signal to noise ratio, then you need a better sensor, or you need to reduce the bandwidth requirements.
Comment: Could you elaborate on why you would use both an analog lowpass filter and a digital lowpass filter? I don't quite understand it. Is the analog filter just used to prevent aliasing?
Answer: Using Signal Chain Explorer, with numerous Efield and Hfield aggressors active under the Gargoyles mode, with 159Hz LPF before the single-stage gain, and 1.59Hz after that gain stage, we see 8.8 bits ENOB/55dB SNR. Notice the FOI frequency of interest is 10Hz; this should be 2Hz or 1Hz. (also, click on the topright I/C InterconnectsModel, so EFI/HFI have targets for their fields.)

Here are the active Efield and Hfield aggressors.

Reducing FOI (top right) to 1Hz produces 69.6dB SNR
How can we trust predictions of Signal Chain Explorer, regarding interference?
Examine this diagram of the PCB trace: 14mm long, 1.5mm above the plane, 1mm wide. The Hfield aggressors couple into the Loop: 14mm*1.5mm; the Efield aggressors couple into the trace area: 14mm*1mm. However, the Efield math needs to account for the HighPassFilter behavior of capacitive charge injection, using the vulnerable node(s) impedances.
Answer: You need an amplifier. Your signal is so low that the ADC is having trouble reading. That might be why it just looks like noise. Or it's because you're unshielded. You need to use a shielded coax and maybe balanced cable to a +40dB amp. A simple op amp circuit would be fine but you might get significantly better results if you consider the source impedance of the sensor and select a part that matches that impedance and possibly at the right frequencies. If you post a link to a datasheet for the sensor, you'll get better answers.


Why do my point lights have red X's on them in the Unreal editor?

Question: I've noticed through the first two tutorials I've done that Point Lights begin entering the viewport with red x's on them. When I build those don't turn on. It seems to be implying some limit to the number of Point Lights in a given space. Is that space the lightmass importance volume, or a given scene? I checked the Point Light tutorial explanation to no avail.
Answer: You can only have 4 overlapping point lights. I guess your radii must overlap. You can read more about standard issues with lights in the  lighting troubleshooting guide.


Is there a way to see tags that have no wiki?

Question: Tags are often more useful with WIKIs attached. Is there  a way to see only the tags that are not defined?
Answer: Here is a query that produces tags with no wiki from the Stack Exchange data dump. These are sorted descendingly by the number of questions that have that tag, hence tags that need wiki's and are used the most. I include the length as a potential indicator that a wiki, even if it has some text, can be potentially expanded upon.
Unfortunately the data dump can not keep up with your recent work! But hopefully this is useful enough to see potential candidates.
Note that a tag wiki and a tag wiki excerpt are different, and you can have wiki excerpt without a full tag wiki (it appears all tags with wiki's have an excerpt, I assume this is by design). Included in the query are the tag wiki excerpts, so you can filter them out as well. I include length so one can also see short wiki's that are potentially candidates to be expanded upon.
Answer: I appreciate the work you've been doing making sure that tags have at least a wiki excerpt.  I agree that that makes them more useful.
One way to see which tags don't have wiki's is to click on the gray TAGS button at the top of the page.  You can see the top 36 most used tags ever on CV; you can also sort alphabetically or by recently added.  Below the tags a portion of the wiki excerpt is displayed.  On the first page, all the tags have wiki's, but those are also the most important to have wiki's.  If you keep going through the pages to less frequently used tags, you will start to see some that don't have a wiki excerpt. At the time of this writing, 'experiment-design' is the most frequently used tag without a wiki excerpt; it's on the second page.
I don't know of a way to determine which tags don't have full wiki's, other than clicking on them & navigating to it, but I also think the full wiki's are less important than the wiki excerpts.
Comment: Hi @gung. Thanks. But what I wanted was a filter that identified all the un-wikied tags.
Comment: I don't know of one. There may well be a way via the SE data site. I believe it uses MS SQL server, if you know that.


geometry node: mesh as curve profile

Question: I'm learning about hair for games, I created some hair cards and to modify them I'm using the curve modifier.
At first everything was fine, but soon the scene was a mess, full of curves and meshes. I wanted to know if there was a way to use hair cards as a curve profile, so I would only have the mesh profiles and the rest would be curves and I could still easily edit the profile and change the curves that use it,and I would have the same UV as the profile.
for comparison purposes, while I was researching this I found the Hair tools addon which has a tool that works as I mentioned(strands filter), but I'm just learning about hair for games and I didn't want to buy an addon for now(after all I don't do this often).
Comment: I found a geo node very close to what I really wanted although it still has a defect, I don't know much about geometry nodes but from what I've read the Blender geo nodes system itself still doesn't support changing the curve radius manually (alt+s in edit mode) , but I managed to work around this problem while Blender doesn't add this support
Answer: If the profile shape you want to use is a Mesh object, you can convert it to Curve object to be able to choose it, while selecting the other Curve used for the hair strand length, in Properties panel > Objet Data Properties > Bevel > Object.

But if you really want your profile shape to remain a Mesh object, you can also do this conversion to curve "virtually" within a Geometry Nodes modifier, using the "Mesh to Curve" node:
Comment: Sorry, I don't think I explained it well. I think profile wasn't quite the right word to use, it would be more the idea of instantiating the mesh on the curve and using it as a control. https://youtu.be/vYXeqwqauzE?si=Oh9MQeJkn1gjXGa7 In this video I found something very close to what I wanted, I don't know much about geometry nodes but from what I researched it still doesn't support editing the mesh radius manually, so this is probably the closest I can find

geometry node: mesh as curve profile


Can a sub array be passed to another page as array with checkbox?

Question: I'm new to php so please pardon me if I'm asking something which is basic and asked before. I have googled for this for a few days now and esp. this forum where I found most of my previous answers but I can't find anything for this problem so I must ask. This is my first question.
// this array is coming from MySQL db as a result. It's a list of user's friends and it could contain dozens or hundreds of friends. Now he wants to put them in different groups.

$array = array(
       array("John", "Doe", "1"),
       array("Peter", "Citizen", "2")
       ...
      );

// a page is created with the result. Each record has a checkbox that the user can select.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<?php

foreach($array as $item){
$nItem = $item;

?>

<input type="text" name="fname" value="<?php if(isset($nItem)){echo $nItem[0];} ?>" readonly="readonly" />
<input type="text" name="lname" value="<?php if(isset($nItem)){echo $nItem[1];} ?>" readonly="readonly" />
<input type="text" name="uid" value="<?php if(isset($nItem)){echo $nItem[2];} ?>" readonly="readonly" />
<input type="checkbox" name="val[]" value="<?php if(isset($nItem)){echo $nItem;} ?>" /> // I want to send this $nItem array as it is to the action page and read its keys and values there.

<?php
}
?>

<input type="submit" name="submit" value="Submit">
</form>

<?php

// if I tick both checkboxes and submit I get the following:

if(isset($_POST['val'])){

$val = $_POST['val'];

echo var_dump($val), '
'; // array(2) { [0]=> string(5) "Array" [1]=> string(5) "Array" }

echo count($val), '
';    // 2

print_r($val);                 // Array ( [0] => Array [1] => Array )

echo("val is {$val[0]}");      // val is Array

foreach($val as $key => $value){
    echo "Key and Value are: ".$key." ".$value, '
'; // Key and Value are: 0 Array
}                                                         // Key and Value are: 1 Array

}

?>

It just returns a string "Array" instead of actual array that I can read the velues from. If I put individual values in checkbox value such as --
if(isset($nItem)){echo "".$nItem[0]." ".$nItem[1]." ".$nItem[2]."";}

-- then I get --
0 John Doe 1

-- but that's not what I want. I want the actual array on the action page that I can iterate through. I thought since it was already an array it wouldn't be difficult but I was wrong.
Could anyone please show me how to do it?
Many thanks in advance.
Answer: <?php foreach($array as $item): ?>
    <input type="text" name="fname" value="<?php echo $item[0]; ?>" readonly="readonly" />
    <input type="text" name="lname" value="<?php echo $item[1]; ?>" readonly="readonly" />
    <input type="text" name="uid" value="<?php echo $item[2]; ?>" readonly="readonly" />
    <input type="checkbox" name="val" value="<?php echo htmlentities(serialize($item)); ?>" />

<?php endforeach; ?>

After submitting, unserialize array $_POST['val'].
Depending on what you do with this array, this method is not very save to use with an eye on injections.
Instead of working with arrays containing all info, you'd better use id's for each record.
The checkbox named "val" has a value of the corresponding id then.
<input type="checkbox" name="val" value="<?php echo $item['id']; ?>" />

After submitting, query the record belonging to the id and use the returned array to work with.


Why in mercury barometer pressure inside the glass tube at a point is same as the pressure outside the glass tube at the same height?

Question: I am quite familiar with the pascal's law but i still think that being on the same points still they should have different pressures as above on one point is atmosphere and on the other is only the column of mercury can anyone give physical explanation for this and also if the pressure inside the torricelli vacuum is only due to mercury vapours which is quite low than why the vacuum does not get crushed under the atmospheric pressure?
Comment: Atmospheric pressure is $1~kg/cm^2$. If the tube's surface area is $1cm^2$, it needs to be strong enough to not break when you put $1kg$ over it's *entire* surface.
Answer: The pressure inside the tube at height is not equal to the pressure outside. It is a vacuum, or partial vacuum created by the weight of the column of mercury in the tube. Higher atmospheric pressure at the open pool of mercury at the base of the tube will push the column of mercury higher in the tube. Lower atmospheric pressure at the base pool will let the pool level rise, making the column of mercury drop. So the pressures equal at the surface of the mercury pool at the bottom, not at height inside the tube. see https://en.wikipedia.org/wiki/Barometer#/media/File:MercuryBarometer.svg
Comment: Where the tube is under the surface of the pool the pressure is equal inside and out, it has to be, the tube is open to the pool. Just as pressure increases with depth in liquids, because the weight of the liquid above pressing down, raising liquid above the surface lowers pressure from the weight of the liquid pulling down. Once the weight of the liquid pulling down equals atmospheric pressure, it starts forming a vacuum above the liquid.
Comment: No what i meant to say was pressure of mercury inside the tube at any point should not be equal to the pressure of mercury in the trough at the same levels
Answer:
Let understand this by the figure, if we notice that pressure at surface of mercury would be the atmospheric pressure. And same pressure at the bottom of the mercury tube and if we go a height h above.
Now the pressure in the space above the mercury is less than atmospheric pressure and equilibrium is attained when $ Mg$ (where M is the new mass of mercury which is less than initial mass in the mercury column) + P*A (where P is less than atmospheric pressure) = (Atmospheric pressure) $ A$ where A is area of cross section of tube. Or as  $ρ g h$ (where h is the new height of column) = P + Atmospheric pressure
So we get. $$ \rho g h = P_\text{atm} - P $$
where $\rho$ is the density of the mercury.


Find fantasy novel involving fairies, magic and tattoos that harm humans

Question: I have been trying to remember the title of a book I read a while back and hope someone can help. The story involved a woman who was magical, I believe she was a fairy herself who had been exiled, and there was a male fairy who operated a tattoo shop and his tattoos harmed or took energy from the humans. Any ideas anyone?
Answer: This sounds a bit like "Ink Exchange" by Melissa Marr

*Seventeen-year-old Leslie knows nothing of faeries or their intrigues. When she is attracted to an eerily beautiful tattoo of eyes
  and wings, all she knows is that she has to have it, convinced it is a
  tangible symbol of changes she desperately craves for her own life.
The tattoo does bring changes—not the kind Leslie has dreamed of, but
  sinister, compelling changes that are more than symbolic. Those
  changes will bind Leslie and Irial together, drawing Leslie deeper and
  deeper into the faery world, unable to resist its allures, and
  helpless to withstand its perils. . . .*
Answer: Don't know if this what you're looking for but Robin McKinley's Sunshine novel involves a female protagonist and magical tattoos. Great book in any case.
Comment: No fairies there, great book indeed.


Python equivalent for ordertrack function in matlab

Question: I'm looking for a Python (numpy/scipy) equivalent of the ordertrack function in matlab. With this functionality i want to be able to perform order-tracking analysis with vibration measurements on slow rotating machinery. I searched extensively for examples on Google/Stackexchange, but I could not find anything. Although i found enough examples with regular FFT spectra analysis.
More information on the function can be found here: https://nl.mathworks.com/help/signal/ref/ordertrack.htm
Comment: Please explain the downvoting or possible improvements to the question
Comment: This question probably belongs to a different site: https://dsp.stackexchange.com/. Is it possible to move the entire question?
Answer: You could use the vibration-toolbox package. More precise, the class vibration-toolbox.vibesystem.VibeSystem.
It is set up a little bit differently than the python function, but such an instance
from vibration-toolbox.vibesystem import VibeSystem
sys = VibeSystem(M=your_signal_mass, C=your_signal_damping, K=your_signal_stiffness)

is basically a vibration signal instance with a specific mass, damping and stiffness, which would correspond to the signal x in MATLABs ordertrack function.
The method VibeSystem.freq_response would then be able to calcuate the magnitudes you want.
omega, magdb, phase = sys.freq_response(omega=your_signal_rpm, modes=your_signal_orderlist)

magdb should then contain the magnitudes you are looking for.
Unfortunately, I do not have the Signal Processing Toolbox in MATLAB, so I cannot compare the code and show an example.
Comment: I think this might be a bit different, than what i'm looking for. I do not know beforehand what the exact characteristics (i.e. Mass, stiffness or damping matrix) are of the system what is being measured.


Limit involving a hypergeometric function

Question: I am new to hypergeometric function and am interested in evaluating the following limit:
$$L(m,n,r)=\lim_{x\rightarrow 0^+} x^m\times {}_2F_1\left(-m,-n,-(m+n);1-\frac{r}{x}\right)$$
where $n$ and $m$ are non-negative integers, and $r$ is a positive real constant.
However, I don't know where to start.  I did have Wolfram Mathematica symbolically evaluate this limit for various values of $m$, and the patters seems to suggest the following expression for $L(m,n,r)$:
$$L(m,n,r)=r^m\prod_{i=1}^m\frac{n-i+1}{n+i}$$
which one can re-write using the Pochhammer symbol notation as follows:
$$L(m,n,r)=r^mn\frac{(n)_m}{n^{(m)}}$$
If the above is in fact correct, I am interested in learning how to derive it using "first principles" as opposed to the black box that is Wolfram Mathematica.  I am really confused by the definition of hypergeometric function ${}_2F_1(a,b,c;z)$, as the defition that uses the Pochhammer symbol in the wikipedia page excludes the case that I have where $c$ is a non-positive integer.  Any help would be appreciated.
Answer: OK, let's start with an integral representation of that hypergeometric:
$$_2F_1\left(-m,-n,-(m+n);1-\frac{r}{z}\right) \\= \frac{1}{B(-n,-m)} \int_0^1 dx \: x^{-(n+1)} (1-x)^{-(m+1)} \left[1-\left(1-\frac{r}{z}\right)x\right]^m$$
where $B$ is the beta function.  Please do not concern yourself with poles involved in gamma functions of negative numbers for now: I will address this below.
As $z \rightarrow 0^+$, we find that
$$\begin{align}\lim_{z \rightarrow 0^+} z^m\ _2F_1\left(-m,-n,-(m+n);1-\frac{r}{z}\right) &= \frac{r^m}{B(-n,-m)} \int_0^1 dx \: x^{-(n-m+1)} (1-x)^{-(m+1)}\\ &= r^m \frac{B(-(n-m),-m)}{B(-n,-m)}\\ &= r^m \lim_{\epsilon \rightarrow 0^+} \frac{\Gamma(-n+m+\epsilon) \Gamma(-n-m+\epsilon)}{\Gamma(-n+\epsilon)^2} \end{align} $$
Note that, in that last line, I used the definition of the Beta function, along with a cautionary treatment of the Gamma function near negative integers, which are poles.  (I am assuming that $n>m$.)  The nice thing is that we have ratios of these Gamma function values, so the singularities will cancel and leave us with something useful.
I use the following property of the Gamma function (see Equation (41) of this reference):
$$\Gamma(x) \Gamma(-x) = -\frac{\pi}{x \sin{\pi x}}$$
Also note that, for small $\epsilon$
$$\sin{\pi (n-\epsilon)} \approx (-1)^{n+1} \pi \epsilon$$
Putting this all together (I leave the algebra as an exercise for the reader), I get that
$$\lim_{z \rightarrow 0^+} z^m \ _2F_1\left(-m,-n,-(m+n);1-\frac{r}{z}\right) = r^m \frac{n!^2}{(n+m)! (n-m)!}$$
which I believe is equivalent to the stated result.
That last statement is readily seen from writing out the product above:
$$\prod_{i=1}^m \frac{n-(i-1)}{n+1} = \frac{n}{n+1} \frac{n-1}{n+2}\frac{n-2}{n+3}\ldots\frac{n-(m-1)}{n+m}$$
The numerator of the above product is
$$\frac{n!}{(n-m)!}$$
and the denominator is
$$\frac{(n+m)!}{n!}$$
The result follows.
Comment: @M.B.M.: thanks for the catch!  I made a mistake in writing down the integral representation, so it all works out.
Comment: Thanks for the derivation!  I have a question: in your first step you bring $z^m$ into the integral and multiply $(1-rx/z)^m$ by it.  This results in $(z-rx)^m$, which goes to $(-rx)^m$ as $z\rightarrow 0$ and $r^m$ comes out of the integral. What happens to the negative sign in $(-x)^m$ in that step then?  Perhaps I am misunderstanding the Beta function...
Comment: @Ror Gordon: no problem!  Another question: what happens when $n=m$?  I think your approach still works, unless one needs to treat the pole of the gamma function at zero differently from its poles at negative numbers.
Comment: @M.B.M.: I think it works out OK; the pole at $0$ in this case is the same as the others.  Just take the limit as $\epsilon \rightarrow 0$ through positive values.
Comment: It turns out that I used the Pochhammer notation incorrectly in the last line of my question, so I fixed that.  Thanks for your help!
Comment: just want to draw your attention to a [related question](http://math.stackexchange.com/questions/506337/evaluating-limit-involving-hypergeometric-function-lim-z-rightarrow1-2f?lq=1) I posted not long ago.  Any help would be greatly appreciated...  Thanks!


pricing in the case where payment currency and collateral currency are different?

Question: I'm asking for the curve construction of the discount curve in the case where payment currency and collateral currency are different.
If I refer to BBG, in the case of a USD swap collateralized in EUR, they use the curve N°400 (MBB EUR Coll For USD). How do they construct this curve ?
Comment: Bloomberg - ICVS - Help Page (F1) - White Papers: direct link: {LPHP ICVS:0:1 2894955 } It explains how the CSA curves are constructed in some detail on several pages. If you press F1F1, you can also ask the help desk. They will likely only give you the white paper but it is explaining all relevant details anyways.
Comment: Is the collateral necessarily EUR, or does the CDA include a cheapest to deliver option, allowing sometimes USD and sometimes EUR? Bloomberg probably has documentation, but take a look at https://quant.stackexchange.com/questions/39886
Comment: Yes is necessarily EUR. the link you provide is a more complex example than what I'm looking for. My question is simple: If I have a USD cash-flow  in 5Y but the posted collateral is in EUR. How do I discount this cash-flow ?
Comment: Apologies foe the typo above, CSA (Credit Support Annex), no "CDA".
Comment: In the new documentation I have prepared for `rateslib` there is example of a curve construction process which systematically creates EUR and USD curves and finally as the last step on the page uses multi-currency derivatives (in this case cross currency swaps, but FX swaps can also be used) to construct cash-collateral curves as the final step: link https://rateslib.readthedocs.io/en/latest/c_solver.html
Answer: TO answer the question in the comment.  Suppose you have a USD cash flow receivable in 5yrs and you are trying to calculate the PV.  You need to know the interest rate that you are paying on the EUR cash collateral.  Suppose this is Eonia flat.  Then you execute a 5yr currency basis swap where you lend the Euro collateral out at Eonia flat, against borrowing USD on which you pay Fed funds + X, where X is determined by the basis swap market.  Then you discount the USD receivable at Fed Funds + X (by which I mean, you construct a new USD curve X bp higher in rate than the standard Fed Funds curve).
Comment: The explanation is good, A side remark, EONIA itself was [discontinued on 3 January 2022](https://www.emmi-benchmarks.eu/benchmarks/eonia/).
Comment: Good point.  ESTR.
Comment: would the swap or fx fwd you use to construct the discount curves also be a function of collateral currencies?
Answer: If I recall Cooking with collateral by Piterbarg (https://www.risk.net/derivatives/2194249/cooking-collateral) has the details but you effectively need to use FX swaps to get the basis adjust discount rate you want.
Answer: In an arbitrage free framework you may be interested to know that a USD cashflow payable in 5y collateralised in EUR can either be valued (in USD) by discounting the cashflows with a USD-EUR discount curve (that is a discount curve for discounting USD cashflows under a EUR CSA).
Or, you can convert the USD cashflow to EUR with the 5y EURUSD FX forward rate, then discount the converted EUR cashflow to the present day with the EUR-EUR discount curve (that is the discount curve for EUR cashflows under a EUR CSA) and then convert the resultant EUR PV to USD with the immediate EURUSD FX rate.
The EURUSD FX Forward rate is essentially determined from the USD-EUR discount curve or vice versa within an arbitrage free framework, so this may practically not be helpful, but it may help with the concept.


Is there a tool for creating animation with HTML?

Question: Is there a tool for creating animation with HTML, or just any other language that can be added with HTML?
Answer: There are many languages that can aid in 'animation' behavior.  Depending on what type/level of animation you want, will point you in the right direction.  If you want just mouse-over animation, javascript and CSS are your friends.  If you want something more sophisticated you'll want to look at Flash (but that's a beast of its own).  For the most part, HTML5 (canvas) has some nice 'animation' behaviors that you can easily invoke with JavaScript.  You might want to start there.  Furthermore, if you want a more specific answer you might clarify what type of animation behavior you are after (examples included).
Comment: I've found jQuery (a javascript "library") quite useful for moving, fading, and coloring blocks of HTML (divs or spans).
Comment: Yes jQuery is def the buzz word these days.  For cross-browser support and application building I'd recommend dojo.  There are others, but I know jQuery and Dojo seem to be pretty dominant.


Extracting intensity from density plot image given color bar

Question: I have an image showing a density plot from a paper, as well as the corresponding color bar. I am trying to convert this back to a 2D array of intensities.

Here's what I did, which works but seems to be imperfect.
imagedata = ImageData[plotimage]
colordata = ImageData[colorimage][[row]]

where row is a number which selects a single row out of the center of the color bar. imagedata is a rank 2 array of {R,G,B} values, while colordata is a rank 1 array of {R,G,B} values (between 0 and 1). I assume the color bar goes from 2 to 7. I then sample a number of colors from the bar with equal spacings,
colorbar = colordata[[1;;-1;;step]]
for some integer step such as step = Round[Length@colordata/30.]. Let ncols = Length@colorbar, the number of color samples. This looks like
cols = RGBColor@@#&/@colordata[[2 ;;]]

Since the image has a lot of white space which I want to differentiate, I add a single white element as the first element: colorbar = Prepend[colorbar,{1,1,1}].
Now my basic strategy is to get each pixel's {R,G,B} (I downsample the image to make this process not take forever because it's rather inefficient) and associate it to a single element of colorbar. I don't know the best way to do this, but my strategy right now is to minimize Norm[{R,G,B}-{R',G',B'}], to find the {R',G',B'} in colorbar which is "closest" by this metric to the color of the pixel, I don't know if this is a good method of color matching though. I define a function
f[c_] := Module[{n},
  n = First@First@Position[colordata,#]&@First@MinimalBy[colordata,Norm[c-#]&]-1;
  If[n==0, 0, 2. + 5 n/ncols]
]

which takes an {R,G,B} vector, uses MinimalBy to find the element of colorbar for which the Norm of the difference is minimal, and returns its index minus one. Since white was the first index, if the result it zero I return 0 while for non-white colors I scale the output between 2 and 5 like the original color scale.
Defining a color function from the sampled colors,
colorf[x_] := Blend[cols,(x-2)/5]

the plotted result looks like this:
imagedataConverted = ParallelTable[
   f[imagedata[[j, i]]],
   {j, 1, Dimensions[imagedata][[1]], 1},
   {i, 1, Dimensions[imagedata][[2]], 1}
];

ListDensityPlot[imagedataConverted,
 ColorFunction -> colorf,
 ColorFunctionScaling -> False,
 InterpolationOrder -> 0,
 PlotLegends -> Placed[BarLegend[{colorf, {2, 7}}], Above],
 PlotRange -> {2, 7},
 ImageSize -> Small]

This seems to work, but there are some subtle differences in the output. Overall it seems to me that the output is on average a bit lighter, and especially so near the edges. This is causing me some issues because I want the match to be as close as possible, and I cannot find a way to improve the accuracy of this method. Is there a simpler/more accurate way to do this? Bonus for efficiency.
Comment: I think it's also flipped compared to the source. Try `Reverse`-ing your data at level 1, 2, or both?
Comment: @thorimur it is but I'm not worried about that
Answer: My method seems to work, the only thing I needed to change is the color norm. Using ColorDistance improved the results significantly.
f[c_] := Module[{n},
  n = First@First@Position[colordata,#]&@First@MinimalBy[colordata,ColorDistance[RGBColor@c,RGBColor@#]&]-1;
  If[n==0, 0, 2.+5n/ncols]
]


Adding a quadratic term: should I use the squared original (and not the squared standardized?)

Question: In a multiple logistic regression I need to standardize one of the variables because I need to add a quadratic term. Whether I add the quadratic term as the squared original or the squared standardized, I get very similar models, same AIC. Why? The estimates of the linear term change.
When I square a standardized variable, I get positive numbers after squaring half of the data (which are negative) and that should completely mess up my data. Why does it not? Can someone please explain the mathematical reason behind it and tell me if I definitely should use the squared original and if I can use the squared standardized, why does it work?
I notice this is a mathematics question rather than anything but I searched and could not find anything related to this.
Answer: Let the variable be $x$, its mean be $\mu$, and its standard deviation $\sigma$, so that the standardized variable is $z = (x-\mu)/\sigma$.  By expanding $z^2$ and collecting like powers of $x$ you can rewrite your model as
$$\eqalign{
y &= \beta_0 + \beta_1 x + \beta_2 z^2 + \varepsilon \\
&= \beta_0 + \beta_1 x + \beta_2 \left(\frac{x-\mu}{\sigma}\right)^2 + \varepsilon\\
&= \left(\beta_0 + \beta_2\frac{\mu^2}{\sigma^2}\right) + \left(\beta_1 + \beta_2\left(-2\frac{\mu}{\sigma}\right)\right)x + \left(\frac{\beta_2}{\sigma^2}\right)x^2 + \varepsilon \\
&= \alpha_0 + \alpha_1 x + \alpha_2 x^2 + \varepsilon
}$$
where the $\alpha_i$ are functions of the parameters $\beta_i$ depending on the constants $\mu$ and $\sigma$ and the error terms $\varepsilon$ are the same as before. (Other multivariate regression terms would be unchanged and are not shown.)  This means that one model will fit the data exactly as well as the other: any differences can be attributable to floating point rounding errors.  (If they are not really tiny, you likely have huge collinearity problems.)  Moreover, the parameter estimates obtained with one model can be converted to corresponding estimates with the other model, provided the estimation procedure is invariant under linear changes of parameters (which is the case with Maximum Likelihood, which is what is being used when an AIC is reported).
In short, you don't have to standardize the variable when squaring it: you get an equivalent model even when it is not standardized.  Because the software will automatically standardize all variables when solving, you are free to write the model in whatever form you find most interpretable.
Comment: One note: You mention collinearity problems. I'd say these are pretty common when dealing with quadratic terms, especially if the original variable never gets close to 0. I've frequently seen it recommended to always *mean center* a variable before squaring it (it doesn't matter if you divide by the sd or not).
Comment: @Peter That's a very good point. Perhaps the best way to deal with this issue is to use orthogonal polynomials--but that can create problems with interpretation. Ultimately, being able to carry out the algebraic manipulations illustrated here will give one the ability to perform numerically stable calculations *and* derive interpretable coefficients.
Comment: Although the questions in your last two comments are related to your original question, they are genuinely different and require a different explanation. (However, if you would just graph the data as a scatterplot matrix, everything should become clear.) Consider posting them as a new question: that will also give you an opportunity to post your information in a readable form.
Comment: Thank you for your answers. The variable in question is indeed one that does not reach zero in this dataset (it is latitude from 22-65 degrees). I am trying to include a correlation table below                               Latitude     Latitude     Latitude_sq     stLat   stLat_sq
Latitude     1.0000000   0.9956874  1.0000000 -0.2520726
Latitude_sq  0.9956874   1.0000000  0.9956874 -0.1612099
stLat        1.0000000   0.9956874  1.0000000 -0.2520726
stLat_sq    -0.2520726  -0.1612099 -0.2520726  1.0000000
Using stLat and Latitude_sq: beta=1.7 for stLat. With stLat and stLat_sq that beta is0.22
Comment: Sorry, try again: The pearson corr coeff between the original latitude variable and the squared standardized latitude is -0.2520726, same as between the standardized latitude variable and its squared form. Between standardized Latitude and the squared original it is (shock for me): 0.9956874. I do not yet understand this, thank you in advance for some more elaboration on this problem. The beta estimates in the model are 1.69 for stLat when the original squared is used inaddition, and 0.22 when the squared standardized is used, so the first must be completely off. ??


Adding new field to feature class?

Question: I'm using one of the esri model sewer system geodatabases. It includes empty feature classes and a geometric network.  i need to add a field to one of the pre-made feature classes, but it won't let me. I've tried adding it in ArcGIS Pro, ArcGIS Desktop and in ArcCatalog, but all of them won't let me update or add any fields.
Answer: I just needed an Advanced or Standard License, then I was able to add the field!

Adding new field to feature class?


Copy/paste stops working in gnome-terminal over VNC session

Question: I have been clumsily working around a strange clipboard issue on a Linux system over VNC. I recently noted a fix and want to document it here. An alternate title for this post might be: VNC client/host clipboard sharing may impact copy/paste behavior in certain Linux programs.
For reference, the VNC session in question is a TigerVNC (version 1.1.0-24.el6) on a CentOS 6 Linux system. I connect to this remote session from Mac OS (Mojave 10.14.6) with the TigerVNC client and run in fullscreen mode.
This setup worked without issue for a long time (session uptime is ~300 days as of this writing). Recently, the selection-based copy/paste functionality ceased to work in gnome-terminal windows. Middle-click was still able to paste text but I was unable to update that text by selecting text in the terminal. Further, the Ctrl-Shift-C method also failed for gnome-terminal. Oddly, I was able to paste text when copied from GUI programs such as Firefox or gedit. This led to extremely clunky workarounds such as redirecting terminal output to files so that could be opened with gedit and pasted elsewhere.
So how do I resolve this odd copy/paste behavior? Numerous solutions (such as manual use of xclip) have been reported around the internet for related issues. None of these worked for me. In my case, even manual use of xclip proved unable to update the stored text for paste with middle click (I suspect this is a clue but am not quite sure what it points to).
I was preparing to shut down the session entirely when I stumbled upon a fix: unchecking "Accept clipboard from viewers" and "Send clipboard to viewers" in the VNC config window completely resolved the issue. I have been working with the session for several hours now and normal behavior is restored. To be clear, after the config adjustment, I can now copy/paste from/to terminal windows that were previously uncooperative without any need to close and reopen.
The nature of the fix suggests that some clipobard issues on the Linux side are affected or even caused by the client VNC program and/or the client's OS. I have muddled through similar clipboard issues for years but never came across this particular solution to 'recover' normal behavior in a running session. Given how irritating the problem was and the ease of the solution, I thought it would be worth noting the finding here for other folks with VNC and clipboard issues.
Answer: As noted in the body above, I was able to resolve the copy/paste issues in gnome-terminal by disabling clipboard sharing between the VNC client and server. Specifically, I found the "VNC config" window inside the running CentOS 6/Gnome session and unchecked both "Accept clipboard from viewers" and "Send clipboard to viewers" options. At this point, normal copy and paste behavior was restored throughout the Linux session.


Regenerate Geowebcache Tiles on PostGIS change

Question: I am using Geoserver with Geocache to get WMS tiles and a PostGIS backend. There are 2 systems using the PostGIS database: one that is with Geoserver and one that is an old system that just uses the database. All changes made to the geometry using either system need to cause the tiles to be recreated, and we can't change the code in the old system. I think I need to use a trigger in PostGIS. I understand how to create the trigger, but how do I make it regenerate the tiles that include the point that was changed?
Answer: One option is create trigger into postgis table which uses "NOTIFY channel_name message" when something happens. Then create software which connects to postgresql and executes "LISTEN channel_name" and when something happens on channel it executes command which re-creates tiles. You can forward needed coordinates with in message
Comment: I understand the trigger part and the notify part but what do I use to make the second part - the software that connects to postgresql and executes the Listen?
Comment: as I undestand it, you use external program to compile tile, not postgis. So you code program that connects to postgis and LISTENs channel_name. When it hears somethign , it executes re-tiling. see http://email@example.com .. http://www.postgresql.org/docs/9.2/interactive/plperl-trusted.html gives you idea howto do it straight from trigeer, but it has more problems that listen notify design


Different color cubes in one city

Question: If we had a blue city with one black disease cube due to an outbreak and we pull that blue city card during epidemic infection phase, is it an outbreak?
We thought that 3 was the max #of cubes one city can have (even if they are of different colors), but I just read one of the thread here that mentioned a city with 2 red cubes and 2 black cubes, total of 4 cubes in one city.
Answer: An outbreak only occurs due to cubes of a single color:

If the city already has 3 cubes of this color, do not place a 4th cube. Instead, an outbreak of this disease occurs in the city (see Outbreaks below).

And therefore a city can have up to three cubes of each color, not just three cubes overall:

As a result of outbreaks, a city may have disease cubes of multiple colors on it; up to 3 cubes of each color. This does not affect infections.
Comment: Thanks Jefromi!! This should help our win% (currently at 20%) lol
Comment: 20%? Ouch! How many Epidemic cards are you putting in the player deck? You might want to take one out just to give you more of a sense of accomplishment :)

Different color cubes in one city


Automatically sort functions alphabetically in C++ code

Question: I am aware of a similar question for C#. I downloaded and tried NArrange and UniversalIndentGUI but both do not sort functions of C++ code per name. Does anyone know a non-commercial tool that does this job?
Comment: Out of interest: Why do you want to do this?  Usually, you want to have related functions together, not functions whose names happen to be similar.
Comment: I have to deal with code which I want to structure better. Related functions are all in the same file and those shall be sorted alphabetically.
Comment: @OliverCharlesworth Another reason to do this: I have some python code that generates C++ headers based on some protocol reference information... I want to diff an old generated C++ header with one generated now off the new protocol reference, but there's probably an extra message or two - and/or a difference in the way the python interpreter I'm using this time hashes or chooses bucket counts, such that iteration to print the functions now produces a different pseudo-random ordering.  If I could sort new and old generated headers, I could get a nice clean diff.
Answer: Unless you're under orders to rearrange the code to conform to an arbitrary coding standard, my advice is do not do this.  I've seen people do it before, and the results are not pretty.  The file will look completely different after you're done, and you'll have effectively trashed all of the edit history in source control.  Any diffs between this version and any version that came before it will look like a jumbled mess.  In the long run, having a clear diff history is worth more to you and your team than some measure of code cleanliness.
Comment: Agreed doesn't answer the question
Comment: And so I am "under orders to rearrange the code to conform to an arbitrary coding standard" how do I do this? (This is the actual case, not just hypothetical)


Miners do not obey certains orders

Question: I've started my fortress and dug one level down and cleared it out without a problem but created stairway on third level and unable to dig the tile under it?  I can see it and designate to be mined but miners aren't doing the task.  They are sitting inactive and if I designate anything on the current levels to mine they do it without issue.
The mineral below is white sand so they should be able to dig that up right?
Comment: Can you provide a picture of the z-level with the designation, and the z-level above that?
Comment: From your brief description, its sounds like you don't have a matching up or up/down stair designated on the level "below". Stairs work in pairs. A down stair and an up stair on the z level below it. Up/Down stair lets a stair act as an up stair for any down stairs on the level directly above it, and a down stairs to go with an up stairs directly below it.
Raven Dreamer♦ has provided an excellent answer. Please look at that to see why you stairs are needed in pairs to allow dwarves to travel between z levels.
Answer: It sounds like you may be having trouble, not with your miners per se, but rather, how Dwarf Fortress Handles elevation changes.
Each Z-level (the map at a given height) has both a "wall" and a "floor" tile. Stairs in Dwarf Fortress need to account for both of these - the wall must be an "up stairs" tile, and the floor must be a "down stairs" tile.
The Dwarf Fortress Wiki has a great visual example of this, as a side view:
Comment: Thanks guys- I understand it better now and able to work with it properly
Comment: I've found a work around (or maybe the way it's supposed to work) is to create the downstair, then a channel next to it and build the upstair once I'm down there (removing the channel afterwards). I can best describe the problem I was having by the third picture (the downstairs).  I was able to place the stairs as shown, but isn't a miner supposed to be able to clear the tile immediately below a downstair once it is placed and the tile is designated to be mined?
Comment: @Mendetus No, digging `d` can only take place horizontally. To dig downwards, you must either designate an up stair or an up/down stair. Once you have an up or up/down stair on the level below, your dwarf can move down and begin mining horizontally.

Miners do not obey certains orders


keeping an SSH connection alive

Question: Here is a situation which I noticed.  I have a server to which I login via SSH and when I do it from lan then things work perfectly and I have noticed that even if the connection is idle (i.e. I am not doing any thing on SSH session just logged in) the connection is alive for a long time, but if I do an SSH on  same server from internet then the connection after some time dies.The server is a Ubuntu 10.04 server edition server.What can be possible reason for this?
Answer: Enable keepalives in your ssh client, your firewall/router is killing the idle connection.
I have ServerAliveInterval 59 in ~/.ssh/config for openssh client.
Comment: Ok I do not have any such line as you mentioned since the server is in a corporate data centre is it possible for the sysadmin to detect an idle connection in this situation given the fact that to this server I am the only person who has SSH access to it.
Comment: Just as clarification; consumer grade hardware with little memory kills connections that haven't been active for a while. TCP keepalives can cause disconnects, so you can also, if you use something like screen or tmux, put a clock in your status bar so you have trafic all the time :)
Answer: You could look at the TCPKeepAlive option in sshd_config on the server.  It looks like if this is enabled you will see more disconnections (which seems a bit counter intuitive until you read the doc) as any route changes between you and the server will result in a disconnection.  That is unlikely to happen on the LAN, but fairly likely across the internet.

keeping an SSH connection alive


Recovery HD mounts on startup

Question: Recently I was messing around with Backtrack 4r2, and created a USB "live CD" and started from it. I normally run the live CD in a VM, but wanted to see if I could install it on the USB as a separate HDD. Normally, I experiment on VMs as well, but decided to go against my better judgement. This corrupted my startup disk, and for a little bit I had the folder with the question mark. The internal SSD was there untouched, but the starting sequenced was affected. I tried using rEFIt to get back into it, but the system did not recognize the SSD. Finally, I went in with GParted on the live CD, and made the Mac Book Air boot from the "Recovery HD". I used the terminal in the "Recovery HD" to correct my permission, and made the correct area of the SSD my boot disk. I am running Lion 10.7.1, so trying to build a "Recovery USB" was impossible since the app store would only let me access Lion 10.7. Onto the question:
Lion now mounts the "Recovery HD" upon start up, and it didn't before. How can I make it to where it doesn't? As stated, I tried repairing the install, but the App Store only has 10.7, so Lion blocks it as an "older" version.
Comment: Would superuser be a better place for this question? It is most likely a boot loader problem.
Answer: this hint suggests
asr adjust --target /dev/disk0s3 -settype "Apple_Boot"
P.S. use diskutil list to confirm that your "Recovery HD" is disk0s3: it should show like this:
$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            499.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

Recovery HD mounts on startup


Help, can I still fix this?

Question:
A few weeks ago, the door knob started to become loose with greyish wood/sand chunks falling out of the gap between the doorknob and the door. Currently thinking of getting a handyman in to have a look but just want some opinions on whether it's still fixable and if it's worth it. TIA
Comment: It looks like the screws are loose can you find them and tighten them they may be on the other side of the door
Comment: Does the round back plate on the knob assembly actually fit inside the hole drilled in the door? From looking at the picture this seems to be the case but please confirm because this will have an impact on a proper answer.
Answer: Yes, this can be remedied by using a "goof plate" pictured below.  If the outer diameter of the lockset is 2" or larger this plate will work.  I do believe they make smaller ones if the lockset is smaller.  The UPC for this product is 049793095244- Model # U-9524.  Package includes 2 pieces-One for each side.
Answer: The knob hole looks larger than the knob.  I want to know if the hole is 2-1/8" (54mm) diameter.   If it is, then you have a standard doorknob hole, but the wrong doorknob assembly.
If it is larger than 2-1/8", then have the landlord or home insurer fix it, because this is a big, big mistake! What were they thinking? There is no reason I know of to drill a knob hole oversize.  If it is oversize, then decide if you're in love with the door.  If not, just replace the door - it will be easier than trying to glue a plug in there, and a lot more secure if it's an outside door.
How to get the knob off
The screws are covered by a vanity plate, because people don't like seeing screws and because they want to be able to change vanity plates for different knob colors.  The vanity plate is the pretty cylinder up against the door.
Look for a latch or a catch to release it from the actual backing plate. Also, look for a small tuck-under" maybe 3/16" long, pinch the disc at the points 90 degrees around from there and try to pull it or slide it toward or away.
With a normal knob, you typically need to remove the doorknob, but with that type of handle it may just slide over.
With the vanity plate gone, you should be looking at a steel plate and two screw heads. It's straightforward from there.
Answer: I'm guessing the outer ring of the back-plate unscrews to reveal the two machine screws that hold the handles on the door.
It looks like the face of the door was drilled too big for the chosen handle.
The proper fix is to replace the handles with ones designed for that size of hole or to replace the door.
it may be possible to cut a ledge around the aperature with a router
and then fit a plywood cover that spans the opening, drill the cover for the latch axle and the handle bolts, fill the cracks sand and paint
The lazy fix is to put some sort of metal plate to span the gap, you might find a flat stainless plumbing escutcheon that does the job.
To do it almost-right remove the handles, clean the surface of the void then fill the edges of the void with 2 part plastic filler, you can use cardboard tubes or drinking straws etc to keep the filler from blocking the screw-holes etc, this filler has a strong chemical smell for a few days, so you you may want to remove the door first. This is basically the same stuff as automotive body filler. it sets hard, but before it's fully cured it can be trimmed with a knife etc. when it is cured sand, paint, and re-fit the handles.

Help, can I still fix this?


AE: Character Offset to Randomize Specific Pairs of Letters

Question: I'd like the bottom left text to do the same as the top right, but the randomized text should be limited to "ATCG" in pairs (e.g. "AATTCCGG), instead of numbers. Is there a way to do this with expressions? Preserve Case &  Digits seems to keep the random text to pairs, but I'm not sure how to make an expression so that the pairs are limited to As, Ts, Cs, and Gs. Thanks!
Answer:
Here's my updated way of doing it.
A couple of points:

This method will only work with fixed width fonts
Make sure you have an even number of characters in your plain text layer.  Add a space on the end if you don't.

Make two identical text layers. In my example, they are labelled "AGCT text" and "plain text".
In the "ACGT text" layer, put the following expression into the Source Text control:
<code>n = 4; // how many pairs of characters (starting from zero, so 0 to 4 is 5 pairs, so 10 characters).
letters = ["A","T","C","G"]; // array of possible characters to use
str = ""; // string we will print

for (i = 0; i <= n; i++){  // start a loop, repeat it n times

    var m = Math.round(random(3)); // pick a number between 0 and 3
    j = letters[m]; // make a variable using one of the characters
    str += (i > 0 ? "" : "") + j + j; // append that character to the string twice
}

str // print the string
</code>
Add a text animator to both layers.
Set the opacity on both text animators to 0%.
In the Advanced settings of the text animator, set the Shape to Square.
Animate the "plain text" animator so that the "Range Selector 1" Start control is 0% at the beginning of the animation, and 100% at the end.  Make sure the "Range Selector 1" End control is set to 100% throughout.
Now animate the "ATCG text" layer:
Set the "Range Selector 1" Start and End controls to 0% at the beginning of the animation.  Set the End control to 100% at the end of the animation. Make sure the Start control is 0% throughout.
Comment: Change the "j+j" bit to only one j
Comment: I'm not!  Googling around and trying out snippets of other people's code!  http://motionscript.com/ and  https://creativecow.net/forums/forum/adobe-after-effects-expressions/ are both v useful (and this site obvs)
Comment: Thank you! I have to use Source Sans Pro Bold for the font, but it seems to work even though I'm not sure if it's fixed width. Sorry for the confusion, I've been told it should actually not be pairs, but instead just a random assortment of As, Cs, Gs, and Ts. I thought maybe getting rid of the "n=4" might do the trick, but that breaks the expression. Is there a way to do this?
Comment: Thanks @tomh! That did the trick. Like you said, the font needs to be fixed width so that the ATCG layer takes up the same amount of width as the plain layer. It's not completely clean the way I have it, but I think it will work. I'm curious, how did you get so good at expressions?
Comment: This is super helpful. I'll definitely be using these resources going forward. Thanks!


Half-duplex serial communications in Python

Question: I have a device with a built-in USB/Serial adapter (shows up as a Prolific PL2303).  The device documentation provides full details on how to communicate with it, and provides a sample Windows app.  However, I need to use it on Linux - ideally with Python but I'm not too precious about that.
The device docs state the device runs at 9600, 8N1 with half duplex.  The Windows app works fine - device works fine (so I know it's not a device problem).  However, I can't communicate with it using Python on Linux.  I'm using pySerial, and I've tried a similar (full duplex, also PL2303) device which works fine.
I've tried several combinations of setting xonxoff, rtscts etc.  I've also tried RTS toggling using setRTS(True) and checking for CTS and DSR etc - gets all return False.  I can successfully open the device using pySerial (I can see activity light flashing - simple but effective test) and pySerial complains if you unplug it during reads/writes.
Doesn't seem to matter what flags/lines I set or what data I send, always get the same result.
<code>>>> s=serial.Serial()
>>> s.port('/dev/ttyUSB1')
>>> s.open()
>>> s
Serial<id=0x7fe94b533b50, open=True>(port='/dev/ttyUSB1', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=3, xonxoff=0, rtscts=0, dsrdtr=0)
>>> s.write('\2CMD2292\r')
>>> s.inWaiting()
0
>>> s.setRTS(True)
>>> s.getCTS()
False
(several iterations of above with different flags).
</code>
Ignore the data in the write command - that's just a status check command.  Doesn't matter what goes there, the device should either respond with an answer or an error.
I've even resorted to closing and re-opening the device in between setting various ctsrts flags etc., and unplugging / replugging it to force resets.  As above it continues to work fine using the Windows test app.  I can't use Portmon etc. to sniff the Windows port traffic as it's a 64bit Win7 install and I don't currently have time to build an XP machine.
Any thoughts?
UPDATE: I've also tried all of the above using Python on the same Windows box that the demo app works on.  It definitely opens the port and communicates, but again no info back regardless of what's written.
UPDATE2: It looks like it might be device-driver related.  Some additional background research suggests that some PL2303 chips have functionality to support half-duplex, but this isn't supported by the Linux drivers.  The Windows demo app comes with a dedicated device driver and the app doesn't work on a clean test machine using default Windows drivers.  This makes me think that while I can connect to it successfully through Python, I can't control the duplex comms (e.g. even in an STX/ETX way) and therefore this might be a hopeless case.  sigh.
UPDATE3: Thanks for the comments below.  However, I couldn't find any way round this.  I tried a USB protocol analyser, and I tried disassembling the driver but it just became rather time-consuming, so in the end I took the device apart and after some tinkering I managed to replace the existing usb-serial adapter with a proper PL2303 part - on the device side, it was just a basic 2-wire serial interface so it didn't care what was talking to it. I can't seem to close this question so I'll leave it as-is.
Comment: Have you tried using a serial comm program, minicom, for instance to talk to the device on your Linux box? That should allow you to verify the device works on Linux before diving into a Python implementation.
Comment: Yes - I've tried using minicom to talk to it, but I don't get any response - however I can't find any way to manually to RTS toggling in minicom which is why I tried Python.  I know pySerial is connecting  to the device and sending data (see above ref. flashy lights:) ).
Comment: Where did you get the driver? is it part of your distro or did you build it by hand? Are you root?
Comment: Driver is part of kernel since ~2.4 AFAIK. Have also tried the same on two different distros (Debian and Fedora) and it's the same driver.  Have tried as root (user has permissions to device as well) and no difference in behaviour.
Comment: Do you know some command that the device should respond to? Could you tell what device it is?
Comment: Did you try to send `\r\n`? Maybe it is somehow different on windows. You can also try wiresharking or usbmonitoring the usb under linux.
Answer: Try
<code>s.flush()
</code>
just after your s.write call


CQWP image rendering as HTML for certain users

Question: I have what I can only presume is a security related problem but comparing it to other site collections (which are pretty much a carbon copy of the site with a problem) there seems to be nothing different in regards to security. The attached image displays the div tags + html for what should actually be rendered but doesn't for a regular staff user, site collection admin sees the CQWP as the image which is correct and a staff user / student gets the div html.. any leads appreciated.
Answer: Can you show your code?
you can try:
<xsl:value-of select="@Value" disable-output-escaping="yes" />

or
<xsl:value-of select="@Value" disable-output-escaping="no" />

Answer: As silly as this sounds the actual problem was the fact that the itemstyle.xsl file was not 'checked in' and as such no user other than the site collection admin was seeing the html styles properly


Did Kylo Ren take students from the academy or not?

Question: In The Last Jedi in 2017, it is stated that Kylo Ren took students from the academy with him when he destroyed it and fled.  In the 2019-2020 comic The Rise of Kylo Ren, however, his destruction of the academy is shown, but he doesn't take any students with him.  Normally, I thought that SW canon followed the law of movies and TV shows over books - if information in a movie and in a book contradict one another, the movie is taken as canon.  But in this specific case, the retcon came out after TLJ.  So which is canon?  Does TLJ still hold, or does the graphic novel have a greater sway because it came out later?
Comment: Generally, the movies/shows seem to be regarded as more canon than novelizations, companion books, comic series, etc. However, that's not to say that it is the case here. Great question
Answer: In this case there's no canon discontinuity. It's stated by an in-universe character (in this case, Luke) that...

"He had vanished with a handful of my students. And slaughtered the rest."

... which leave us well open to the possibility that Luke is simply mistaken.
In Rise of Kylo Ren #001, we see several of the Temple's students (who'd been offworld at the time of the attack) return to the temple shortly after the attack, then leave to try to catch up with Ben Solo, ultimately doing so in #004. They also make a comment about wanting to deal with Solo before speaking to his mother.
It's very plausible that Luke, having found evidence of their landing or simply noting that they didn't return to the Temple subsequently, would assume that those students were involved with Ben (noting that they were evidently still alive but hadn't made contact with him or Leia), rather than that they were adversarial to him.
Answer: It's possible that he took students with him and the comic just didn't show it.
Speaking more broadly, Star Wars "canon" is on much shakier ground than it was ten years ago.  Aside from the obvious (i.e. the sale to Disney, the EU being retconned out), the policies on what is and isn't canon are subject to change without notice (in practice, if not explicitly).  People who controlled canon five years ago - people who in 2017 could say "this is canon now" and make it so - are now out of the picture with no authority over canon, and the stories they told are subject to retcon or expulsion if the next person wants to tell something else.
If I may digress for a moment, this is one of the problems with legally disconnecting ownership and authorship to the extent that Star Wars has done.  The old EU worked - it was (mostly) self-consistent within its own canon - because while it had multiple authors, all those authors worked under the auspices of Star Wars.  They couldn't just add anything willy-nilly - the various EU novels and comics and video games were made under the assumption that they had to fit with what had come before in order to get George Lucas's stamp of approval.  This was mostly a fiction, but it worked - partly because George Lucas was staying out of the Star Wars storytelling and showed no signs of returning to it, and partly because, up until TCW and the Disney sale, nobody had written a new story that explicitly retconned or contradicted someone else's previously-canonical story.  As long as that unbroken standard held - as long as every new author worked within the confines of those that had gone before them - there was no need for a hierarchy of canon-authority.  There was no need for readers to interrupt their reading to check what authority a particular work had to contradict some other particular work, because you could take it as gospel that the greater Star Wars story - weird and idiosyncratic as it might be - would not contradict itself.
That standard is broken.  Canon is broken.  And from that follows this and every other confusion you will ever have about Star Wars.
(Sorry if that turned into a rant.)
Comment: Hi, welcome to SF&F.  Yeah, there's probably a bit too much rant here; while it might be reasonable to discuss that the canonicity of older works is always up for re-evaluation, you might want to [edit] this to dwell less on it.  Your point about the comics simply not showing other students might be valid, but it would be better if you could show there was some space in which that could have happened.
Comment: This doesn't really answer the question at hand and is little more than a rant about canon standards.


In Exploding Kittens, how do you know that another player got the exploding kitten?

Question: In Exploding Kittens, how do you know that another player got the exploding kitten?  I mean what's to say if I draw it I don't reveal it.  Is it like "go fish" where you have to trust your opponent?
Answer: There's certainly nothing stopping a player from cheating and not revealing a drawn Exploding Kitten, but since (at least in the base game) there's no way to put a card from your hand back into the deck you will eventually reach a point where the draw pile is exhausted but more than one player is left in the game, at which point you can look at each player's hands to see who cheated.
Comment: But you can wait until you have a matched pair, steal a card from an opponent, and then reveal the Exploding Kitten and claim that that was the card that you stole, and claim that your opponent cheated. Or, conversely, wait until an opponent steals a card from you and hope they steal the Exploding Kitten (or, if they use a Favor, hand them the Exploding Kitten).
Answer: It is nowhere stated in the rules, but our group has always played the game with the variant where the currently drawn card is briefly revealed for everyone to see and announced by name. This lets everyone confirm that the card is not in fact an Exploding Kitten and lets players have an estimation about the hands of other players ("Hey, don't steal from me, she has already drawn 3 Defuses, pick her instead!"). With even moderately many players it quickly gets infeasible to know each player's hand, in addition to the uncertainty caused by the initial deal and all the stolen cards, so nobody knows exactly what the others have and cheating (at least by holding an Exploding Kitten) is nipped in the bud.
Comment: That sounds like you don't trust each other to play honestly and allows you to target people based on knowing information that you should not know.
Comment: @JoeW yes, it does - and indeed, our group was always engaging in a friendly competition in finding creative ways to cheat and staying on our toes in order to catch the cheaters. It is a way of playing, admittedly not for everyone but quite fun for us. Independently, the additional information does not unbalance the game, as everyone gets the same amount, while opening up new dimensions in strategizing and diplomacy, as detailed in my answer.
Comment: Personally I wouldn't play with a group that cheated on a regular basis like that. Your answer is based on people knowingly cheating which isn't helpful at all in my mind.
Comment: @JoeW my answer, as clearly stated, reflects a personal decision and experience. It offers one possible solution to the problem described by OP, which can be adopted, adapted or ignored by anyone as they see fit.
Comment: And I am pointing out that if you are changing the rules because you can't trust people to not cheat and actually expect them to cheat that isn't a good basis for suggesting how others should be playing.
Comment: I actually like this variant to the game.


Why do we say "shelo asani isha" everyday?

Question: Why is it that we say shelo asani isha/sheasani kirtzono every day? Presumably we would only need to thank Hashem once for making us the gender he made us.
Answer: According to the Zohar, the soul leave the body during sleep every night. In fact, there is actually a small chance that the wrong soul returns in the morning. Thus, there is the possibility of receiving the wrong "gendered" soul, and so we thank Hashem every day.
Comment: If anyone can find the actual source in the Zohar that would be great! I just heard it at a shabbat table.
Comment: This is also kind of an answer to trans-gender people min hatorah minayin....


What's the critical temperature of the XY model on a triangular lattice

Question: I've been looking deeply into many bibliographic references without finding the answer. I would be interested in knowing the numerical value of the critical 2d XY spin model on triangular lattice. Being derived analytically (if possible) or from Monte-Carlo doesn't matter.
Answer: This may be the relevant paper that would answer your question:
http://journals.aps.org/prb/abstract/10.1103/PhysRevB.57.8472
Comment: Yes, indeed they do locate the critical temperature using the 4th Binder cumulant, though my simulations are giving me different results on the x and y axis, I definitely need to look deeper into that. Many thanks ;)


SQL Server 2005 Merge Replication

Question: I've a large Db and most of tables have relationship with each other.
I wanna make Merge replication with another SQL Server. The problem is that when i create Merge replication it gives error "tblItem couled not be dropped, it has some foriegn key constraints". How can i avoid this problem and is there way to do it without dropping any article.
Answer: You can change the properties of the article (or of all the articles) when you create the publication.  You can also change this after the fact by editing the publication.  You can setup the replication to drop the tables (the default), truncate the data, delete the data, or do nothing.  IF you need to load the data on the subscriber from scratch you'll need to setup the articles to delete the data.  This means it will take a lot longer to apply the snapshot.  It would be best to make sure that all the foreign keys exist in the publisher so that the publisher knows in what order to drop and recreate the tables on the subscriber.

SQL Server 2005 Merge Replication


Composting: what is the ratio of volume of material in to compost out?

Question: Say you've got a compost heap, 1 full metre cube, with about 1 part green to 3 parts brown by volume. If this is left to break down, what volume of compost will be produced?
Answer: In my (extensive) experience, between a quarter and a third of the original volume, usually a quarter - and the ratio of green to brown should really be kept as close as possible to 50/50.
Comment: Oh I though the 50/50 was by weight, which is roughly 25/75 by volume due to the greens' water content.


Check to see if a user has came from a 'forward' page

Question: I am currently working on a form which posts to a web service. The form validation is done at the web service and if a validation error occurs the user is presented with an error and a back button.
The form contains a number of default values which I am auto populating. These values then overwrite any values that the user has inserted when the back button is pressed.
Is there a way I can detect to see if the user has pressed the back button and prevent the auto population?
Comment: Have you tried checking whether there is already something in those forms before filling them?
Answer: My guess would be you are filling these post load via JS? Because the value attribute should not override new values. If you are, I would just do a check to see if the field is empty before loading in the text.
Also, I would look into the placeholder attribute.
Answer: Pass a parameter as part of the URL that your back button sends the user to, then check to see if that parameter is part of the URL of the current page in your Javascript. If it's present simply don't populate with the default values.


Assessing water damage to wood beneath bathroom

Question: Some tiles are coming up from our bathroom floor. I haven't yet taken off the thinset mortar to assess if there's any damage but I went beneath the house and found a good bit of wet wood. How bad does this look from first glance?
Answer: I've seen a lot worse. There doesn't appear to be any mold. I'd rip the thinset up to the extent of the loose tiles and the water staining below as soon as possible and start the drying out process. When the drying is complete, you'll be in a better position to judge for damage. If you caught it fast, you'll probably be OK. Once dried, you might think about spraying some white vinegar on the wood to kill any mold/mildew that might be thinking about growing.
Comment: Looks like there's a bit of green around the edges of the moisture on the joists and subfloor. Looks a bit like mold to me, but not the scary black stuff and nothing to worry about. There's no signs of rot, at least from below, so it looks good structurally.
Comment: Thanks all - I upvoted but it won't show as I don't have enough rep yet - just bought a house, so that will likely change soon. :) I chiseled out the thinset and am going to monitor the moisture/rent something to apply heat and dry the wood. Appreciate the feedback.


Clipping TIN layers to pit shells

Question: I have two TIN surfaces, one being a pit shell and a second being a horizontal layer which intersects the shell on all sides. I need to find out the volume between the intersection horizontal layer and the base of the pit, but I'm having trouble clipping the layer to the pit edges in order to do so,
Comment: What software are you using for the analysis?
Comment: Hi,ArcScene 10.2
Comment: have you tried using the [Cut and Fill tool](http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000tz000000)? The section [How Cut and Fill works](http://resources.arcgis.com/en/help/main/10.1/index.html#/How_Cut_Fill_works/009z000000vt000000/) gives a good explanation. When you said "_I'm having trouble clipping the layer to the pit edges_" what did you mean, do you have gaps between the surfaces?
Comment: Previously I have worked with a software package called Micromine, where in this situation I would be able to form a completely new closed multipatch, which would encompass the entire pit from the green layer, shown above, down to the current pit floor, hence providing me with the volumetric I am after.   Is this possible in ArcScene?
Answer: The tools that you need are located within ArcToolbox which can be accessed in ArcScene's tool bar or ArcGIS desktop. Look for this icon. Some of the tools that will allow you to calculate volume are as follows:

Surface Volume (3D Analyst)
Polygon Volume (3D Analyst)
Cut and Fill, here is a link to another question regarding this tool

If your horizontal layer has a fixed height/elevation, then Surface Volume (3D Analyst) should get you the results that you are after. Just make sure the processing extent is just for the pit.
Answer: If you can export the two surfaces to (STL PLY) to CloudCompare ten Cork plugins in CloudCompare can generate intersection between two meshes.
Then use the mesh volume tool.

Clipping TIN layers to pit shells


How to use a Polyglot book in C# with a chess engine

Question: I would like, if possible, for someone to provide a code snippet of a basic logic to access a Polyglot book file. I'm having trouble finding the file format documentation, so I don't know how to access it and use it in the code. I'm making a chess game and would like to use the books to support features in the game. If not too much trouble, I would rather have a c# code sample, since it's the language I'm fluent with right now.
Answer: Sorry, I don't have C# code. Can we do it in C++?

https://github.com/Warpten/Fruit-2.1/blob/master/src/book.cpp

Polyglot book is defined like:
<code>struct entry_t {
   uint64 key;
   uint16 move;
   uint16 count;
   uint16 n;
   uint16 sum;
};
</code>
You may want to wrap the C++ code inside your C#. How to do that is out of scope here.
Comment: Thanks a lot for your reply! I understand that wrapping is out of scope. Well I'm learning C++, so this can be a good learn as you go exercise.

So my plan is:

import book file
do method to find position on book (parsing moves string, comparing accessing boards list?)
if found board similar to parsed position, create my own variant format to parse
to my move manager so variant can be played out.
Comment: I didn't want to make my first comment too long, so here are a couple extra questions:

So Polyglot file is just a collection of entry_t objects? I saw in your git link, you have a board class, so you then construct on your own reading the entry_t collection properties the board you need to find the variant? I thought  in the book file you would have like a lot of positions defined as objects, so you can compare to them, am I wrong on this? Thanks for the help btw :)!


How to change width of TAB character in a Flex TextArea?

Question: Is it possible to change the width of an insert TAB character in a Flex TextArea?
I'm capturing FocusEvent.KEY_FOCUS_CHANGE events and manually inserting a "\t" into a text area styled with an embedded monospace font. By default, the TABs are being displayed two and a half monospace characters wide... I need them to display five monospace characters wide.
Any ideas on how to do this?
Comment: Is using a Flex4 RichEditableText an option?
Comment: Wouldn't this be an operating system specific thing? Or possibly font related.  I wouldn't expect any Flash APIs allow you to change this.
Comment: @Marty - Thanks for the suggestion. Unfortunately I'm on a tight schedule and thus tied to Flex 3.
@www.Flextras.com - I tried creating a custom font glyph that was 5 characters wide, but the text area didn't seem to like that. I'm hoping to achieve a work around in AS.
Answer: What about something like this?
<mx:Canvas>
    <mx:Script>
        [Bindable]
        public var myText:String;
    </mx:Script>
    <mx:TextArea id="textArea" text="{TabUtil.expand(myText)}" valueCommit="myText = TabUtil.contract(myText))" />
 </mx:Canvas>

  public class TabUtil
  {
       public static const SPACE:String = "     "; // Five spaces;
       public static function expand(text:String):String
       {
            return text.replace("\t",SPACE);
       }
       public static function contract(text:String):String
       {
            return text.replace(SPACE,"\t");
        }
   }

I forget the params of replace, but I think it may take a RegEx, in which case you'd need to tweak the above.  But it should work.
Answer: The tabStops property of textFormat is what you are looking for. You can set the pixel values of where you want each tab to be placed.

var tf:TextFormat = new TextFormat();
tf.tabStops = [100, 200, 300, 400];
myTextArea.mx_internal::getTextField().defaultTextFormat = tf;


Should I always hibernate instead of shutting down?

Question: I'm using Windows XP and I hate the long start up time when I shut down and then turn on my laptop. However if I hibernate instead of shutting down it starts up much faster. Are there any harmful effects / disadvantages if I always hibernate whenever I'm done for the day instead of shutting down?
Answer: Hibernation is a good thing, as long as you have the disk space to accomodate for the hiberfil.sys that gets created in the process.  You can find it in the root of your C: drive if you are curious how big it is.  You will need to have all hidden and system files visible.
Shutting down every now and again and restarting is still recommended.  Not only will it allow those pesky (but required) updates to be installed, but will keep your system in tip top condition.
Answer: There is nothing wrong with Hibernating, it is an option in windows for all of the reasons you have just listed! I have been using it for years.
Answer: Under XP, the OS will slow down over time, and eventually get unstable, but that can take upwards of a week depending on how much you use your OS. Reboot every so often, there's no real harm in hibernating over short periods. In a laptop, most components should be built with hibernation in mind, and HDD space is cheap, so the hibernation file shouldn't be a big deal (If it is, it's 2010! Get an external HDD, 1.5TB is the best GB/$ right now, and they're pretty cheap!)
In Vista/Win7, I can't honestly reccomend shutting down unless you have a good reason.
Comment: FWIW, in my case, your "upwards of a week" with Windows XP was actually no notable instabilities with at least 8 hours a day of use every workday, and rebooting every few months to install Windows updates.
Comment: @Brooks; Were you open/closing a lot of windows? XP had a known bug with window handles, it'd eventually run out and screw up the world. I could never keep an XP machine stable for more than a week or so, alas.
Comment: Huh -- I guess I wasn't; I do all my browsing in tabs, and mostly keep programs open.  I did have problems every so often that looked like my email program was running out of handles for its child windows, but that got fixed if I closed and reopened it.
Answer: In theory hibernation dumps the memory to the drive and allows "almost instant" powerup. I personally don't care for it. It is aimed primarily at laptops and will create a file that is the size of your physical memory that you cant delete.
I say if you arent having any problems with it and like what it does keep using it.