Collect Bluetooth Low Energy Data

Question: I like to analyze bluetooth low energy advertising packages on an Arduino Uno. This tasks poses me problem because the BLE modules I have found only work in device mode (Adafruit, RedBearLab, and other nRF51822 and nRF8001 based) and can't collect data. Does anyone know about such projects or have experiences with this?
Comment: NRF51 devices do support central role. Just use the correct softdevice (S120/S130).
Comment: Are there tutorials for reprogramming? I have a JLink and a nRF51 but I'm unsure about the wiring.
Answer: Adafruit has the Bluefruit Sniffer requires a host PC instead of an arduino UNO (http://www.adafruit.com/product/2269) it basically has a nrf51822 module which talks to the PC over a UART using the FTDI usb to Serial converter chip. I suspect that you could probably get a similar nrf51822 module and flash the sniffer firmware( found here: https://github.com/adafruit/Adafruit_BluefruitLE_Firmware/tree/master/sniffer/1.0.1)use the Jlink to flash the firmware onto the BLE module and use that to communicate with the arduino UNO over a uart connection. Hope that helps, Good luck!
you can try using one of these modules maybe:
http://www.seeedstudio.com/depot/MDBT40P%C2%A0%C2%A0nRF51822%C2%A0based%C2%A0BLE%C2%A0module-p-2503.html
https://www.adafruit.com/products/2479

Collect Bluetooth Low Energy Data


html helpers text input and line break

Question: public string BannerText {get;set;}

public void SetBanner()
{
  BannerText = "This is line 1. \nThis is line 2."
}

in the aspx page I am setting it like this:

<%: Model.BannerText %>

However, the text still shows up in a single line. I have tried
 and
 as well but that doesn't seem to work.  I am sure it has to be something simple, but need SO help :)
EDIT:Kirk Woll and Mike suggestion worked!
use:
<%= Model.BannerText %>

Comment: That looks fine to me...  In your real code (assuming that is simplified) are you sure ClientName is set when you assign BannerText?
Answer: First, \n will absolutely not work.  This is HTML.   You do need to use
 (or wrap them in
, etc.).  However, the purpose of <%: (as opposed to <%=) is to HTML-encode your string.  So presumably your line breaks (
) are being encoded.   You should try <%= instead and see if that fixes your issue.
Answer: What is "<%:"?  I haven't seen that before.  Have you tried "<%="?  That will use an HTMLTextWriter to pass the string to render.  Then just use HTML (
) in your string.

html helpers text input and line break


"Show In Playlist" CatalinaOS

Question: I've created a custom keyboard shortcut for the "Show In Playlist" command in the Music app. When I use the shortcut, I can see the menu bar is selected, but it does not open a menu showing the playlists. I am aware this is possible by right/cmd-clicking on a song in the library, but this is a tedious process for a large library. Thanks!
Answer: You would normally need a nested menu command Show in Playlist->ListName but this doesn't seem to work in the instance. It shows the key command in the right place but doesn't act on it.

I thought at one point that if you could find the correct symbol for the gear icon  then it might work, but best I can find is ⚙ which doesn't seem to have any effect. The key command appears to be correctly registered without it anyway.

"Show In Playlist" CatalinaOS


Is "to have a mind as sharp as a thumbtack" a valid idiom in American English?

Question: I have been doing a research on the subtitle translations of the American Tv show called "It's Always Sunny in Philedelphia" and faced an instant where Frank mentioned having a mind as sharp as a thumbtack. I know that there are idioms as "having a mind as sharp as a tack/razor/steel trap" along with the old ones like "as sharp as a needle or thorn". However, I have never heard "having a mind as sharp as a thumbtack". Although "as sharp as a thumbtack" and "as sharp as a tack" sound similar, if the native speakers have never heard of the idiom "as sharp as a tack", that would be an important detail to shape my work since it would suggest that Frank made up or changed that idiom.
Thank you in advance.
Comment: In that TV show, those characters play stooges who are always a little bit "off".  It's a kind of malapropism.
Comment: Well you're right since in that episode Dee makes fun of Frank for losing his mind due to old age and Frank tries to prove her wrong by saying "my mind is as sharp as a …", but he cannot remember the rest of the idiom. So, at a later moment of that episode he screams "thumbtack" out of the blue in an attempt to say the rest of the idiom. However, learning that native speakers never use the idiom "as sharp as a thumbtack" proves that he is losing it. So, this has been very helpful. Thank you.
Comment: (I'm a New Yorker) 'Sharp as a tack' is common; I have never heard 'sharp as a thumbtack'.
Answer: Most people would understand the meaning of the idiom (with some thought), but as Jeff comments the shortened form is more widespread and would likely be your better choice:

Sharp as a tack
Answer: The idiom is "sharp as a tack":

Very intelligent and perceptive

I would imagine "sharp as a thumbtack" would be heard as a minor variation, unless the context of the show made it clear they were flipping it from a compliment to an insult.
Although if they were trying to flip the meaning I'd expect something much more obviously not sharp, or maybe something absurd like "sharp as a marble".
Comment: In *my* understanding, a (carpet) "tack" is a small "cut nail" like [this](http://www.wilko.com/content/ebiz/wilkinsonplus/invt/0160965/0160965_l.jpg) with an extremely sharp point. A "thumbtack", on the other hand, looks like [this](http://thehtrc.com/wp-content/uploads/thumbtacks.png) (nowhere near as sharp, but the important thing is it has a large head you can push in with your thumb). Not that I believe anyone would specifically use *sharp as a thumbtack* to imply *not actually as sharp as a **real** carpet tack*. I'm sure it's just an uncommon / meaningless "copying error".


Avoiding AWPers

Question: I'm new to this game, just tried out playing on casual servers, and got my life ruined by AWPers. One-shot one-kill... too overpowered, in my opinion. Any advice on how to not spend more time in respawn then in-game because of AWPers?
Answer: I mostly play competitive modes and I know that AWPrs can be a pain.
So, learning the maps and where AWPrs play is probably the most important thing overall (as suggested by @Novarg). Aside from obvious reasons, you'll need that info for this next tip which is smokes and flashes. Knowing the map and where APWrs can be will tell you where to put those smokes and flashes.
When employed effectively, these completely neutralize an AWPer (albit it temporarily) putting them in a very bad spot (it completely turns the tables, in my opinion). The idea is to neutralize , and then take control of a bomb site. Even in casual games, this should be the goal (although teams are obviously less serious & organized).
Another tip is to stay with your team. A single enemy is an AWPr's wet dream - it's a low risk kill. A group can overwhelm an AWPr although a good AWPr will still take out one or two before you can get them (assuming no smokes or flashes for whatever reason.)
And my final tip is to know when an AWP can be bought by the enemy team. This is a tricky part of the metagame as it takes some experience. But when you think an AWP is on the field, adjust your play accordingly.
Comment: Good addition, I totally forgot about smokes/flashbangs. Probably because I almost never play competitive ^^
Comment: Thx this might help especially the last part about predicting when they will get an AWP... thx again.
Answer: If you don't want to wait to respawn for so long there are a few options for you:

Play other gamemodes(Deathmatch, Arms Race, Demolition)

In Deathmatch you respawn immediately on a random spot on the map
In Arms Race you respawn immediately on your base
In Demolition you respawn at the beginning of each round, but rounds are 90 seconds max and maps are small, so normally it takes 30-60 seconds per round

Play on Community Servers

There you can find other game modes too or some modified servers.

Learn the maps, learn where AWPers normally camp. And don't go there :)

Of course there will be people who run with AWP all over the map, but many of them just use a couple of spots that they like

Stay at the back, wait until your entire team is dead and then go for a suicide mission :)

You will only have to wait a couple of seconds before respawning

EDIT
Frank V posted a nice addition to my answer. And I will add a few more tricks you could use against AWPers:

Bunny hop! If you master it you can move much faster than normal which will make you a much more difficult target. In this video, there is a short explanation about bhop mechanics and speed. To get the speed faster start bhopping with your knife("fastest" weapon in the game, you move 250 units/second with it(in 1.6 you could reach 260 units/second with Steyr Scout)) and when you are in the air, switch to your main weapon. You will maintain your speed in the air, and after you land and jump again your speed will drop to +-285 units/second anyway(assuming you did a clean bhop).
Circle jump. If you expect and AWPer somewhere(you should know the map of course), you could try a circle jump. The idea is: you approach a corner behind which might be an AWPer. Right before you go out of the corner, strafe and jump(strafe left if you approach a right corner or strafe right if you approach a left corner). While in the air, keep strafing(don't forget to release forward button right before or at the moment of the jump) and move your mouse the same direction. Like that you will be able to make a circle jump(a jump that looks like a circle if you watch it from the top). Most AWPers will probably expect you to land away from the corner and will immediately move their mouse to the predicted location and shoot.
Timing! Timing is very important when facing AWPers. After the moment you hear AWP shot you have exactly 1.5 seconds(assuming there is only 1 AWPer) before he will be able to make another shot. Use it to your advantage! Run out, make a couple of shots and run back to cover. But don't forget, that AWP has incredible penetration power(in 1.6 you could kill an enemy through 2 ice blocks on fy_iceworld with a headshot). Alternatively, run out and start shooting, but do NOT stand still and do NOT run in a single line. Make random turns, zig-zags and jumps, everything to make you a difficult target for AWP. In close combat AWP is probably the most useless weapon.
Molotov's/Incendiary grenades. If you know that AWPer is not too far, you can throw a Molotov/Incendiary grenade to his place. If you throw it good, the AWPer will run out of cover making himself a (very) easy target. You can combine it with circle jump. Circle jump to force him to shoot and then use that 1.5 second window to throw a grenade.
Comment: @KimMinseo Look at the other answer, it gives you much more information.
Comment: Not exactly answering my question but... I think learning the maps may help...
Comment: This is a stupid answer, sorry. It does not answer it, it works around it. And waiting  until the team is dead and then suicide is not how CS works. Sorry, but please don't answer this question if you don't have expert knowledge and especially if you do not play competitive.
Answer: Another great way to maybe "out play" an AWPr is to shoulder peek. Lets say an AWPr is holding a close corner, the way i use to peak them is to get close to the wall and make it so my left or right shoulder barely peaks out( just for a second). The way to do this is to quickly press a or d. The AWPr should shoot, thinking that you are peeking. While he is falling back or trying to get in another shot, peek him and either get to another position or kill him. Most people in comp are pretty decent and know not to shoot, but it seems you are playing casual and they are most likely going take the bait. Gl man!

Avoiding AWPers


Blocking a sidewalk in a gated community

Question: My HOA has blocked the sidewalk which connects the gated part of our neighborhood from the ungated.  They have given the code to those living behind the gate, but now I can't walk my dog back to the nature area behind the gate.  The nature area is maintained by the CDD not the HOA, and the HOA administration company claims that I have no right to go back and see it even though I pay for it.  How can I get the sidewalk gates taken down?  I'm in Florida in an unincorporated part of the county.
Comment: CDD = Community Development District. Question: Is there access to the CDD area otherwise, or is it fully enclosed in the gated community, or is t fully enclosed by the gated area and natural barriers?
Comment: Which jurisdiction (country, province, principality, state etc) does your question relate to?
Comment: fully enclosed by the gate or lake.
Answer: In a case such as this one, the answer boils down almost entirely to the exact language of the easement recorded in the public records, sometimes in a separate instrument, sometimes as writing on a recorded plat map, and sometimes both (and if it is in both places but the language isn't the same, you've got a real mess).
No statute or case law principle can tell you the right answer in a vacuum in the absence of this information (although there are several common law circumstances in which easements can be implied in law based upon additional detailed historical property ownerships and extrinsic evidence not found in the public record like the history of when it was used by whom), and it is likely that the interpretation of the scope of the easement has to be inferred from multiple separate provisions in different parts of the recorded governing instruments related to the easement.
As a practical matter, however, if you did provide us with that level of detail that would constitute specific legal advice which we don't do at Law.SE.
As a practical matter then, you need to have someone, either a lawyer or a title company, obtain all of the relevant recorded documents, learn as much as you can about the history of use of the easement and the history of property ownership leading up to the creation of the easement in the vicinity, and then hire a lawyer to make sense of it.
You can control the legal fees that you incur by having the title company (or in some parts of the U.S. a legal paraprofessional known as a "land man") get copies of as many relevant documents as you can find from the public record for you, and by developing a summary of the situation including as detailed a set of facts as possible about the most recent developments and everything that you can learn about the history of the use of the easement (e.g. when was the nature area created and by whom and who owns it and how does that relate to the timing of the community in between being gated). A Google image of the area would also help a lawyer evaluate the facts more quickly and hence with fewer billable hours and smaller fees.


Does a California employer have to provide drinking water within a certain distance from your work area?

Question: Does your employer have to provide drinking water within a certain distance from your work area? I work in a different building from the nearest drinking fountain
Comment: How far, in terms of distance (roughly), time, and "outside your normal work area/routine" is the building with the nearest drinking fountain from your normal work area?
Comment: It's about 3 mins from my work area.. different building
Answer: Per T8CCR 3395(c):

The water shall be located as close as practicable to the areas where employees are working. Where drinking water is not plumbed or otherwise continuously supplied, it shall be provided in sufficient quantity at the beginning of the work shift to provide one quart per employee per hour for drinking for the entire shift.

The is (in my opinion intentionally) vague; it is to be determined by "facts on the ground". Strictly speaking, the fact that the water fountain is in another building is not necessarily against OSHA/California regulations (though it may be, and it certainly does raise eyebrows). The question is how frequently and easily can you access the water supply.
Note that "a drinking fountain" as such is not required; it is absolutely permissible to have a non-continuous water supply, e.g. water-cooler in an accessible location.
Sources:
https://www.dir.ca.gov/dosh/etools/08-006/EWP_water.htm
https://www.dir.ca.gov/title8/3363.html


Usage of a TV show transcript in my Thesis is under fair use exception?

Question: Can I use the data of Friends TV show transcript in my thesis for analysis and publish my paper/findings. Does the usage of TV show transcript data for analysis and construction of new script based on the original script come under fair use of exception in US copyright law ? Can you please advise me on how to proceed further.
Comment: Are you putting the script itself in the thesis?
Comment: No. I will be using the transcript data to produce new show script through machine learning computer program, That is my thesis.
Comment: Do note that the right to make derivative works is covered by U.S. copyright.  That's why Star Trek fans who've made their own films are at odds with CBS and Paramount.
Comment: Thank you. If I do buy the TV script made available on ebay, does it count that I can use them in producing a Thesis ?
Comment: IANAL, but you probably won't be taken to court over this. If you are, your school will probably defend you.
Comment: @RajeshThevar purchasing a script on Ebay only covers the physical copy you are purchasing, not any rights (unless SPECIFICALLY being sold on ebay).
Comment: There's probably some legal affairs office in the university that can address this matter.  You would need actual, professional legal advice for this.
Answer: The description of your activities that you have provided, using a 'script' from a popular TV show for research purposes in a machine learning algorithm is allowed within the 'fair use' description of copyright. It is my understanding that the following descriptions place the usage described within 'fair use':

Amount and substantiality of the portion used in relation to the copyrighted work as a whole.

Since you are using the script to train a machine algorithm, and not the video, audio, nor are you reproducing it for your audience, it seems to be well within fair use.

Effect of the use upon the potential market for or value of the copyrighted work.

Using a script to train a machine algorithm, it seems, would have virtually no effect on the 'potential market or value of copyrighted work'.
Highlighted portions from "More Information on Fair Use by Copyright.gov"
Another possible solution you could consider is to train your machine learning algorithm on a different humorous show whose copyright has expired and is therefore in the Public Domain. Here is a list of humorous televeision shows whose copyright has expired, including "The Beverly Hillbillies".
Comment: I went through the given link and I cannot make a conclusion. In 1st point, It is said we can use copyrighted work as it is for non-profit educational work. But in 2nd point, I can see that  "Thus, using a more creative or imaginative work (such as a novel, movie, or song) is less likely to support a claim of a fair use than using a factual work (such as a technical article or news item)." How can I make a conclusion ?
Comment: @RajeshThevar I edited original post and provided additional (helpful) info.
Answer: I wouldn't. Fair use is a defense in court to a claim of copyright infringement brought against you by the copyright holder. That means that you have to get sued, hire a lawyer who fails to convince them to drop the suit due to your use under the fair use principles, and then take your defense to trial before a judge or jury. This, while unlikely to happen, is likely to cost you more than $10k and maybe as much as $100k if you get sued. It's not worth it.
I'm not a lawyer, nor am I your lawyer, but I'd find a play or radio play that is now in the public domain and use that instead. The idioms and colloquialisms are likely to be dated and may mess up your algorithm, but that's better than getting sued and being out the money.


What are the spots on my lilac bush?

Question: I just had someone plant lilac bushes for me and this is what they look like.

They don't seem healthy.
Answer: This is likely just transplant shock. The roots have been cut, the tops probably left intact and the roots that are left have a problem keeping up with transpiration from the leaves, so the plant begins to prune itself and try to rebalance top and bottom.
Lilacs are very pH (acidity/basic) sensitive. "Lilacs love limestone" is a comment we often hear from gardeners. If the plants have been moved from a low acidity to a high acidity soil then there will be visible effects from the move and the most tender parts, the leaves, will be the first to show that the plant is not happy where it is. Possibly addition of lime would help but get a soil test done if the plants do not recover quickly.

What are the spots on my lilac bush?


Retrieve via javascript/jquery/ajax/ReST the category tree

Question: I was looking for a way to get the category tree via ReST API.
I looked here but it doesn't seem to show how to fetch the category tree (it has an entry point which lists a product's assigned categories list, and that's not what I'm looking for).
I'm using Magento 1.6.2 (cannot update - even if it's possible, the guy before me working at this project killed a lot of kittens and considering the time I have to do this, and my newbieness, I cannot resurrect them) and I need to access ReST API (I already know how to do this in SOAP API). How can I create such custom entry point for ReST API? (It seems to not exist). I don't expect a long explanation. Links with their contexts are also accepted.
My intention is to use such API via a regular AJAX call:
$.get('entry/point', {data:needed, for:this, entry:point, function(categTree){
    //process (and build/display) the tree
}, 'json' /*or xml. actually don't care*/});

Answer: Not sure if this is exactly what you are looking for but you could look into how the admin site does this in Mage_Adminhtml_Catalog_CategoryController::categoriesJsonAction. I know that it is not part of the api but will return a json response of the category tree.


Is it possible to have an F-test with a $p<.05$ even if there is an $R^2<.1$ for a least squares analysis in JMP?

Question: I've been working with JMP, and I have found that often I get a significant p value but a relatively small r. Is this supposed to happen?
Comment: Don't see why it would be impossible. With a large-enough sample size, any effect will be significantly different from 0.
Comment: just to clarify the sample size in this case was 99
Answer: Yup. Just like @PatrickCoulombe said, it's normal to encounter such a situation with weak effects in large samples. Here's a demonstration in R (I assume you could do something similar in JMP):
X=data.frame(IV=sort(rep(letters[1:3],1000)),DV=sort(rnorm(3000))*.1+rnorm(3000))

This creates a data frame of 3000 observations organized into 3 categories (IV). DV is a randomly generated, standard normally distributed, continuous variable, to which I've added another such variable that's been sorted from low to high and had its variability scaled down to 10% of the original. This creates a weak signal in the otherwise random noise variation, such that the observations organized into the second and third groups will tend to be a little larger than the previous. Fitting a simple general linear model with ordinary least squares produces results more extreme than yours:
Call: summary(lm(DV~IV,X)). Results: multiple $R^2=.007, F_{(2,2997)}=10.22,p=.00004$.
Even with a smaller sample, this still works ($N=99$ isn't even all that small). In the following version, I'll just scale down the sorted component of DV to 20% instead of 10%, and produce only 99 cases:
set.seed(1);X=data.frame(IV=sort(rep(letters[1:3],33)),DV=sort(rnorm(99))*.4+rnorm(99))

Call: summary(lm(DV~IV,X)). Results: multiple $R^2=.079, F_{(2,96)}=4.15,p=.019$.
Seem familiar? With a smaller sample, it won't happen every time, so I set the random number generator's seed to 1 for reproducibility. With set.seed(2) for instance, $R^2=.006,p=.73$, somewhat more as you would expect, I imagine. In the case of a simple ANOVA, the $F$-test compares means across groups, and tests any evidence of differences in your sample against the null hypothesis of no differences in the population. The meaning of this test is therefore very different from the meaning of $R^2$, which represents how much outcome variation is related to the predictor(s). As in my first example, even 0.7% of the variation (let alone 10%!) can be "significantly" better than nothing.
Comment: +1, I agree that n=99 isn't that small.


Mixing liquid ingredients to "just combine" to dry ingredients for muffins

Question: When baking muffins and adding the liquid ingredients to the "well" in the dry ingredients, the recipe says "to just combine".  Does this mean not to add the whole liquid mixture, only enough to wet the dry ingredients?
Comment: Seems likely that it's a precaution against overmixing, to avoid toughening the finished product.
Answer: As Adele suggested in the comments, this is a common instruction to guard against overmixing. You mix everything in, and mix it until it's just barely combined. You just want to make sure there aren't any big pockets of dry ingredients; once all the wet and dry is combined, you're done.
If you're curious why you don't want to overmix, see a previous question: Over-stirring muffin mixtures.
Comment: It's because of the glutens in flour which develop when you stir or mix. It makes bread delicious but muffins not so much!


Does ultrasonic bath cleaning damage laboratory volumetric glassware calibration?

Question: As an analytical chemist, I'm always ensuring my glassware is thoroughly clean before I start an analysis. However, my supervisor always states that using ultrasonic bath to clean volumetric glassware damages its calibration, rendering it imprecise for analytical usage. Does that hold true, or is it okay to use an ultrasonic cleaner?
Comment: Unless it fractured the glassware I don't see the issue.
Comment: I sometimes sonicate volumetrics to help dissolution for a short period. However, I am actually curious about the following test, which I vaguely recall (and therefore could be wrong). If we make up the volume exactly to mark, and then sonicate, what happens to meniscus? It goes down slightly below the mark temporarily. This could be from local heating of the glass. Glass and solutions do heat up during sonication.
Comment: A temporary effect due to temperature is sure. But volumetric glassware is supposed to be used at about room T.
Answer: According to technical information for volumetric measurement provided by Brand, it is acceptable to use an ultrasonic bath.

Both glass and plastic labware may be cleaned in an ultrasonic bath. However, direct contact with the sonic membranes must be avoided.

Nevertheless,

For gentle treatment of labware, clean immediately after use – at low temperatures, with brief soaking times, and at low alkalinity. Glass volumetric instruments should not be exposed to prolonged immersion times in alkaline media above 70 °C, as such treatment causes volume changes through glass corrosion, and destruction of graduations.
Answer: If your supervisor is unconvinced by Brand's guidance on this (as supplied by Loong in his answer), you could always test the effect of ultrasonic cleaning directly:
Take, say, six volumetric flasks, and weigh the amount of water each holds when filled to the line.  Then subject three to several cycles of ultrasonic cleaning (the other three can be left to sit in the ultrasonic cleaning solution, but without turning the machine on), dry all six, and repeat the weighing measurement. Determine if the before-and-after difference for the ultrasonically cleaned flasks is significantly different from that seen in the control flasks.
While the control flasks do control for temperature differences between the before-and-after measurements, it would be cleaner if you could do the before-and-after measurements at the same temperature.  That way the only difference you see should be random experimental error plus any systematic differences due to cleaning.
[Or more simply, if your boss is unconvinced by Brand's guidance, you could ask Brand if they could supply their test data on the effect of sonication.]
EDIT, BASED ON COMMENTS: If cumulative damage is the concern, then one could always employ an accelerated wear technique.  In this case, one would increase the sonication time until it matched the total sonication time anticipated over the lifetime of a volumetric flask.  E.g., if  standard cleaning time is 20 minutes, and glassware is typically cleaned 600 times, then one could leave it in the sonicator continuously for 8 days (assuming the sonicator wouldn't be damaged by this).  If you don't have a spare sonicator, you could do this over four successive weekends.  Or perhaps one weekend would be sufficient to satisfy your manager.
Note that this accelerated wear technique is a standard method used in product testing -- e.g., if you have a part that over its, say, 10-year lifetime is expected to be flexed no more than 10,000 times, then you put it in a device that does those 10,000 flexes over a very short period of time (or does sufficient flexes on several parts to determine a mean time to failure).
Comment: @Karl - A beaker in the lab might get re-used thousands of times. Unless you can adequately model what happens after x thousand cleanings, your results will be worthless. Cleaning a table with a too-harsh cleaner once won't usually harm it in any measurable way. Cleaning it hundreds of times will result in the patina coming off.
Comment: @Karl It's not "repeating the same experiment a thousand times." It's possible that one ultrasonic wash doesn't make a large enough difference to measure, but that, over the life of a flask, the damage will add up to something significant. How many washes would a weekend correspond to?If it's something like a lifetime of washing, fine; if it's not, then it's not enough.
Comment: Can anyone propose a mechanism that _could_ impair a flask's calibration with repeated sonication? Does the advisor think cavitation will erode the flask's interior?
Comment: I suspect his adviser's objection is to repeated cleanings, not a single (or even short cycle) event. For the experiment to hold true, you'd need to perform potentially hundreds of cleanings.
Comment: @Valorum No. Put it in the ultrasonicator over the weekend and be done with it. Of course the result will be the same, glass does not yield to ultrasound. Repeating the same experiment a thousand times just in the hope it will one day give a different result is not good scientific practice.


Can you un-enroll from 401k at any time?

Question: Can you un-enroll from 401k at any time? Or is it like health insurance where you are locked into it until open enrollment periods?
Comment: @user102008 that's true if it's a personal/family plan, but not if the insurance is through your employer, and OP obviously has health insurance through his employer.
Comment: If it's a health insurance plan you are paying the premium for, you can also un-enroll at any time by not paying the premium. You just cannot enroll outside the enrollment period.
Comment: It all depends on your plan.  I have heard of plans that have limited times on when you can join and when you can change your contributions.  So check with your plan administrator.
Answer: You can stop contributing or change your contribution at any time, but there are some restrictions on taking the money out that you should be aware of. For example, you can't cash out the 401k while you are still employed by the company that hosts the 401k.
Also, even when you can, you will be penalized for withdrawing funds before you turn 59 1/2.
FYI: On insurance you aren't "locked in" so much as you are paying for a fixed amount of time (like a lease on an apartment). You can get out of health insurance when that runs out by just not paying for another period.


What is difference between attention mechanism and cognitive function?

Question: How are attention mechanism used in different deep learning algorithms different from the cognitive function attention?
Answer: Are you reffering to biological "cognitive function attention"?
If yes than it could be argued its different.
TL;DR
Fixed-length Context vector in the encoder decoder architecture could not remember long term dependencies. Attention could learn  these long term dependencies, hence have a long-term memory. If we speak about human attention it is usually short spaned (relative).
On the other hand I believe it was Yoshua who first talked in the terms of attention and one could argue that we could implicitly focus (our attention) on some older parts of text and hence extract deeper meaning.
TL;DR TL;DR One can make a case its actually more natural to talk about long-term memory when discussing attention-ML-mechanism
Comment: As I said I like to think about it more in terms of cognitive "long-term-memory" rather than attention. But one can make case for both. Also I highly doubt that they were having biological models infront of them and then they tried to model them. Its rather solving one problem after another WHILE trying to take influence from biology. If they match they match.
Comment: Yes it is the biological cognitive attention but is it this attention which has been implemented in neural networks or the attention function is altogether different
Comment: What is the meaning of "**TL;DR**" to you?
Comment: too long; didn't read- summarization


How can I create a near-future artifical general intelligence that doesn't violate contemporary ideas in computer science?

Question: In my novel, twenty years from now, a physicist/computer scientist has created a machine version of himself, an artificial general intelligence that integrates the physicist's personality, memory and consciousness. This concept doesn't sit well with computer scientists. One objection is that an AGI is almost a blank slate, a learning machine (perhaps an artificial neural network) that doesn't have lines of programming. I'm not writing hard science-fiction, but I want the concept to approach scientific possibility.
Comment: I have a feeling you question needs to migrate to another stackexchange to get the answer you're looking for. Worldbuilding comes to mind, but it's currently too broad and to story-based for that. Something with computers? Sorry my answer wasn't what you wanted.
Comment: Having worked on developing AIs I have an issue that disrupts any suspension of disbelief: no single developer would be able to create an AI. It's a task for a team effort. A large number of teams actually. Especially an AGI.
Comment: On a practical/realistic level, you're quite right.
Answer: If you're avoiding the hard science, then I'd focus on the dimensions of the AGI, as in how would it be different to the human intelligence it's integrating with, and how those two intelligences would be out of alignment.
As an example, consider the perceptual differences between them, and how the AGI would be coming to terms with having direct access to the physical world, emotional states, and perhaps basal functions.
But then there's the option to explore what the human would have access to and experience, such as enhanced logical thinking, and problem solving on a massive scale.
Answer: Do What Feels Right:
It's the future. Scientists haven't made real AI, so they can't object to your version of it. Just because they think it has to be one way doesn't mean it will. Intelligence is a murky concept. You can do what you want. Read any of a number of science fiction books with AI and they all use colorful reasoning that's short on detail but feels right. It reminds me of my favorite AI joke about humans. The AI asked the human how he ever thought the crazy hacking scheme would work. The human said it felt logical.
Comment: Thanks. I do use that strategy, but it's only 20 years in the future, and it's only one scientist that creates the AGI version of himself. I realize that once you establish the AGI's existence, anything can be said of it, but it's the efforts to create that AGI that I want to make more believable.
Answer: It's probably unlikely that we'll be able to create an intelligence on par with a human in 20 years. (Musk et al be damned! :)
What we have today is the equivalent of a digital parrot... or in fact, that may be condescending to parrots. A digital dog that can fetch and sit... it just fetches words and images and we think it's so clever for doing that...
But as @DWKraus says, we don't know what the future will hold.
I first misread your question as the scientist having created a digital clone of himself (or has he?) This could then involve some scanning and cloning of the brain into digital form (think OpenWorm but with brain scanning + digital cloning).
Extrapolate 20 years from that... OpenMouse? OpenDollyTheSheep?
If he used the technology on a human brain he'd be way past the fringe... and that cloning may have been more or less successful. (And a glitchy AI might be an easier sell.)
Some of my favorite AI:s (HAL for instance) aren't as good as they seem to be from the start. And a malfunctioning AI can be used to make a nice comment on society, psychology, and/or technology (it's after all what some of the best SciFi do...)
And it could also be used for comical effect, if that's what you're after (or hey, whatever story you're writing, comical relief can always have a place...)
One such glitch could be that the AI takes things too literally:

Scientist: We're gonna blow their minds!
AI: I'll get the C4!

Has low or zero ability to navigate social situations... Understanding instructions but requiring them to be precise or there will be unexpected results. etc. etc.
You could blame the AI for being as annoying as a Smartphone... :)
And then you might add fixes for the issues. Reboots, reindexing, resets, or something similar.
However, check out the great masters in SciFi. I'm willing to bet very few of them explain things.
You could just say, it's an AI and it has the scientist's personality, memory, and consciousness. Something huge will happen in AI tomorrow! Period!
Comment: Yeah. I don't think we'll ever "code" a personality. However, everything else being equal, the speed of signals through a neuron is 120 m/s, the speed of light is about 2.5 million times faster so maybe an AI can mature that much faster? A back of the envelope calculation suggests 18 human years might translate to 0.28 seconds! (Shit! We're really doomed if we ever manage to create an AI like that :O )
Comment: Good points. There is satire, which I'm counting on to blur some of the technical shortcomings.But I want the protagonist to be uncertain if he's dealing with the real thing: An AGI that does think like a human or just cleverly programmed AI that has no self-awareness. One reader with a computer science background holds that true AGI wouldn't even have programming, so that no aspects of personality could be coded into the machine.
Answer: The core problem with digitizing the information on a human brain is that for all the advancements in computer processing power, the human brain is still better.   It's estimated that the human brain could store 2.5 million gigabytes of digital information (or the equivelent of digital recording a television station every day for the next 300 years).   By comparison, the IRS has a storage capacity 150,00 gigabytes, and yahoo's 2.0 petrabyte data warehouse is only 80% capacity of a human brain.   The amount of data space alone for something like this is insanely massive an while computer's were predicted to double memory every 2 years and has largely kept pace with that (Moore's law) we may be approaching the upper limits of that from a physical standpoint, as of the 2020s (that is, to keep pace, we are appoaching the miniturization of transistors to atomic sizes... it's impossible to go smaller than this).
That said, there are some reasonably life like programs that exist out there that occasionally pass the Turing Test (i.e. sit at a computer and have a conversation with a person in another room who you cannot see.   If you cannot tell that the person is in fact a computer, the computer passes the Turing Test), but these are hardly digitized human brains, but rather text (or speech) parsing programs that have very good predictive models for returning expected responses to comunicated stimuli... they aren't going to learn.
Comment: Right. I've read a lot of the literature, but as you point out it doesn't hold much hope. But is it possible that someone could simply see the problem in a new way, and come up with a solution. Darwin: Evolution. Einstein: Space and Time.


Setting View Filter Operator to "Greater Than Or Equal To"?

Question: I have a view for which I've set different exposed filters and users can search for objects of different criteria. However, I want some fields to be searched by "Less than/Greater than or equal to" what the user types. I don't have those options in the operator field. Some people seem to have them however.
Comment: I figured it out. My field was set to text so then obviously I couldn't do GT/LT. I switched the field to a CCK one (Integer) and it worked.
Comment: Answering your own question is encouraged: if you leave that as an answer and accept it, others will be able to vote on it and use it as a future resource.
Answer: The operators you get in a Views exposed form depends on the type of data that is stored. If you store a text string you can't use GT or LT, instead you can use starts with or ends with.
Most likely your problem is that you are storing numbers as text in the database instead of storing them as numbers.
Comment: Thanks for the answer, I have list (integer) how can i get GT/LT in the few ?


No rec letters from subject area of master's application

Question: I have a minor in the subject I want to get a master's in (CS). Core courses, all excellent grades. I have a major in math. If I get all 3 of my recommendation letters from math people (or possibly 2 solid math letters and 1 stellar letter in a totally unrelated subject), will that look bad to the CS admissions committee? As core courses, the CS classes were all massive lecture halls and I didn't develop personal relationships with the profs.
Answer: Oh, it doesn't really matter.
If it is course-based CS master, not researched-based CS master, then a recommendation letter only takes a very very small portion of it, so whether it is from a math professor or a CS professor doesn't differ too much.
GPA is the most important.
One of my friends who worked in the admission process before told me that the first admission step is to filter out students whose GPA is lower than 3.5 no matter which university they were in.


Domination problem is NPC

Question: I call the problem as DOM. Given a graph $G$ and an integer $d$, Decision problem DOM - "Does there exists a dominating set of size less than or equal to 'd' in G? " DOM is NP Complete problem.
But, if we specify some class of graphs $G'$ and if we ask the same question, then DOM might be solved in polynomial time.
(Eg : Given $C_n$, and an integer $d$ , you can verify DOM in polynomial time )
 Till date , for which all classes of graphs, DOM problem can be solved in polynomial time ?
[Let me know where I can find research papers worked on this topic]
Answer: I guess that related Wikipedia article is a rather complete and up to date source.  According to it, a minimum dominating set can be found in linear time in series-parallel graphs. On the other hand, even for planar graphs the problem remains NP-hard, but it admits a polynomial-time approximation scheme (PTAS) and a fixed-parameter algorithm is known.

Domination problem is NPC


Why use if function_exists?

Question: I noticed a lot of developers of WordPress themes would use this in functions.php
if (function_exists('register_nav_menus')) {
    register_nav_menus (array('primary' => 'Header Navigation'));
}

For me, I alwayse use add_action for every function I am using in functions.php
So, the above would be written as:
add_action('init', 'my_register_nav_menus');

function my_register_nav_menus() {
    register_nav_menus (array('primary' => 'Header Navigation'));
}

I have two questions:

Why use the if statement in the first method?
Which one is the correct way?
Answer: Checking to see if built in WordPress functions exist before calling them is for backward compatibility which IMHO is not needed.
So if you see if ( function_exists( 'register_nav_menus' ) ) the theme author is supporting versions earlier than 3.0.
You still sometimes see if ( function_exists( 'dynamic_sidebar' ) ) Why? I couldn't tell you because dynamic_sidebar was introduced in 2.2.
Another reason to use it is to make your theme or plugin pluggable. A pluggable function is one that can be overridden in a child theme or another plugin.
This is done on the definition not the call and you use the ! operator to make sure it doesn't already exist before you define it.
if ( ! function_exists( 'my_awesome_function' ) ) {
/**
 * My Awesome function is awesome
 *
 * @param array $args
 * @return array
 */
function my_awesome_function( $args ) {
  //function stuff
  return array();
  }
}

When this is done a child theme or other plugin can override that function with there own.
Answer: The function_exists function is not an other way to load the function like add_action its for check your code to see that there are no other function with that same name so it will not break your code. From php.net:

Checks the list of defined functions, both built-in (internal) and
  user-defined, for function_name.

If you have the same function twice in your code it will break, thats why you prefix Your function with something else than wp_.
Read more: http://php.net/manual/en/function.function-exists.php
Answer: you can use http://php.net/function_exists
if(function_exists('my_function')){
   // my_function is defined
}

OR if you want to see the all function available, so you also print all,
echo "
"; print_r(get_defined_functions());

print on page and you can search that function if it is not found on list means it is not available to use.
you may need to activate extension for particular library.
Answer: function_exists should be used after the function name in a theme not before.
add_action( 'loop_start', 'add_slider' );

function add_slider() {

if ( function_exists( 'soliloquy' ) ) {

soliloquy( 'slider', 'slug' );

    }

}

This checks to make sure the plugin is active before outputting a function and/or markup otherwise you might get a error like call to undefined function.
Answer: php.net defines this as

(PHP 4, PHP 5, PHP 7) function_exists — Return TRUE if the given function has been defined

I have to agree with Michelle in usage in that you [sh]ould only use the check for something similar to type cast checking; so you would be looking for if a function existed (on that page or from anything called on that page/file reference) so then you would know if is safe to run another function or parse some template HTML possibly.
As someone mentioned it is used commonly to check if your file/theme (using WordPress) is able to run your needed request. I have used it for checking if a theme has a specific template part.
if ( function_exists( 'register_sidebar' ) ) {
    get_sidebar();
}

Why use if function_exists?


Why do some musicians count "un, two, three, four"?

Question: I've seen and heard, in particular jazz musicians, count in using "un" instead of the regular pronunciation of the word "one". It seems unlikely there's a technical or practical reason for this, but I'd love to find out why it's done. Thank you.
Comment: Which ones?  I have literally never head that in my life and I've been a work jazz musician for 30 years.
Answer: When playing jazz, I will often count in by calling attention to "the one" with a propulsive or percussive syllable: "mmm", "uhh", "nnn", etc. Sometimes it's to emphasize the one; sometimes it's to communicate the primacy of beats two and four; sometimes it's a concession to being a trumpet player and needing to prep for the first notes.
Overall, though, it's more a stylistic convention, an idiom, than having any specific technical or practical reason. One band leader I've heard often counts in "a-one  a-two  a-you know what to do".
Answer: Un just happens to be French for 'one', but it's doubtful that's a reason it's used. It matters not what gets used. Billy Joel used 'uno dos tres quattro', a band I work with uses 'un deux, trois, quatre'. One band I used to work with simply grunted: 'ugh,   ugh,  ugh ugh ugh ugh' in place of '1,  2,  1 2 3 4'.
As long as everyone knows what the count in means, that's sufficient. In fact, whole orchestras manage to come in on time with nothing like that. Simply an upbeat (usually) of the conductor's baton. So why a 4 piece band needs two whole bars, I've yet to find out..!
Answer: There's a military tradition of counting beat one, or the lead off step, differently - most people are familiar with "HUP two three four". The difference emphasizes the first beat, and uses a syllable that can easily be said loudly (similar to the way Ten-Hut! has replaced Attention! in the US).
The use of drums in popular music derives partly from the way they are used in military marching, so it's possible that part of the reason is that the tradition has carried over.


glXSwapBuffers() blocks until vblank

Question: While trying to make a compositing window manager for X11 using OpenGL as backend, I'm caught in a nasty situation where glXSwapBuffers() blocks until vblank rendering the compositor irresponsive to X events which causes windows being dragged around to lag behind the cursor by roughly one frame. I've tried multithreading but it didn't work well, so I decide the only proper solution is to make glXSwapBuffers() asynchronous. It would be desirable to send drawing commands to GPU and return immediately without waiting for the operations to actually finish, and AFAIK this is possible under modern Linux with DRI2. So what should I do?
Answer: Actually glXSwapBuffers should return immediately. What's blocking however is the very next OpenGL command that introduces a so called synchronization point. Usually this is the next glClear that follows the call of glXSwapBuffers.
Note that it's actually desireable to somehow synchronize with the V-Blank, otherwise nasty tearing artifacts happen. But you're right, that in a naive implementation this introduces about one display refresh interval of latency.
The big problem here is, that double buffered windows redirected to an off-screen surface may still subjected to the active swap interval (i.e. V-Sync setting); and of course double buffering itself doesn't make a lot of sense in a composited setting.
So here's what you can do: Use a swap interval extension to set your compositor's swap interval to 0 (no V-Sync); depending on your system's settings this choice may actually not be honored (user configured all applications are forced to V-Sync). Unfortunately there are several swap interval extensions and what works with one display driver doesn't work with another. I suggest you look at the swap interval example programs of Mesa and the sources of glxgears of Mesa, which contain code that deals with pretty much every situation you may encounter.
It's also desireable to somehow turn off V-Sync in the clients too. I don't see better way than injecting a shared object into them, hooking glXSwapBuffers, glXCreateContext and the swap interval extensions to override them.
Finally you must use one of the available video synchronization GLX extensions to implement a timed buffer swap in your compositor (i.e. call an "unsynchronized" glXSwapBuffers at just the right moment when the V-Blank happens). With a direct OpenGL context and a realtime scheduling policy applied to the compositor process you can do that.
Note that all these issues are shortcomings in the existing X11 protocol. But if you think Wayland would get rid of these issues, think again. While Wayland was originally intended to make "every frame perfect" and do away with the synchronization issues, in practice I encountered many of the problems, again. In this blog post the creator of Wayland talks about roundtrips and overhead, but he completely avoids the point of pipeline synchronization and buffer swap latency. The problems are inherent to the concept of stacked composition and buffer swap based V-Sync. To really solve the issue there must be some kind of screen associated V-Sync event that's independent from graphics operations and can be applied an arbitrary phase offset, so that applications can synchronize their rendering loops with display refresh. And there should be an additional "framebuffer commit" function that makes the whole composition chain consider the newly arrived frame. This would allow the compositor to sync applications to a few 100µs before the V-Blank happens, so that composition can happen in that margin between framebuffer commit and V-Blank.
Answer: As @datenwork says, I don't think it's glxSwapBuffers that's blocking. But something is. I solved the issue inspired by this blog post.
Specifically, on my platform (Ubuntu 14 + Nvidia driver + Nvidia OpenGL implementation), the following code works:
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT");  // Set the glxSwapInterval to 0, ie. disable vsync!  khronos.org/opengl/wiki/Swap_Interval
glXSwapIntervalEXT(x11_display, glx_window, 0);  // glXSwapIntervalEXT(0);

where x11_display is built as
Display* x11_display = XOpenDisplay(0);

and glx_window is built as
GLXWindow glx_window  = glXCreateWindow(x11_display, fb_config, window, 0);

and fb_config is a suitable GLXFBConfig, that I, specifically, get as follows:
int visual, n_fb_configs;
GLXFBConfig* fb_configs = glXGetFBConfigs(x11_display, screen_number, &n_fb_configs);
GLXFBConfig fb_config   = fb_configs[2];  // Select 3rd FB config! Many others work!
glXGetFBConfigAttrib(x11_display, fb_config, GLX_VISUAL_ID, &visual);  //  Query visual?
printf("screen %x  fb_configs %d  fb_config %llx  visual %x\n", screen_number, n_fb_configs, (ull)fb_config, visual);

Note that I don't get any screen tearing that wasn't alread there with (the largely useless, imo) vsync enabled.
Also, depending on your GPU driver and OpenGL implementation (Is it Nvidia's? Is it Mesa's?), there's other glxSwapInteral*(...) functions that  you may have to use. Eg. there's a glXSwapIntervalMESA(...) and a glXSwapIntervalSGI(...).
Rant: As usual with X11 programming, there's very little documentation to hold your hand... Good luck! :)

Bonus. To quote the OpenGL documentation:

Your application's use of swap interval may be overridden by external, driver-specific configuration. For example, forcing Vsync Off in a driver's control panel will prevent Vsync, even if swap interval is set to 1 in your application.

glXSwapBuffers() blocks until vblank


Looking for an animated movie where Superman is in a coffin sent to the sun

Question: I watched an animation where Superman is in a black coffin and gets sent into the sun. My question is, does anyone know what animation this is from?
Also there was another character who looks like Superman with longer hair, also I think Beast Boy was there too.
Answer: While the other answer has some great suggestions, I'm afraid it's not entirely correct. What you're thinking of is an episode from the 1980's Super Friends. Specifically, the ninth and final season: The Super Powers Team: Galactic Guardians episode 7: "The Death of Superman."
Comment: Hi, welcome to SF&F!  I took the liberty of adding some links to your answer; if you could find and add an image of the coffin, that would be really great.
Comment: This is definitely the episode that the question made me think of.
Answer: As far as I know, it might be one of these:
Superman: Doomsday - There is a Superman clone in there, long-haired Supes fights him. Coffin sent to the sun to recharge Supes. No Beast Boy though.
Justice League vs Teen Titans - Beast Boy fights Supermen there.
There is also the episode of the Justice League TV show called "Hereafter II", with long-haired bearded Superman:

There is also a movie called All-Star Superman, where he also flies into our star:
Comment: That's what I'd do, then you can add more detail into each answer for why it matches the OPs description, see [How to write a good story-ID answer?](https://scifi.meta.stackexchange.com/q/9444/58193) Though you should beware that some people may downvote you thinking you are truing to farm rep or something. Posting one solution per answer helps voters know what they are actually voting on.
Comment: So, am I supposed to make 3 answers, one for each possibility?
Comment: One answer per answer please otherwise how do we know what we're voting on for the Id and how do we know which story the OP accepts (if they do).
Comment: @jo1storm - Yes, that's precisely what you should do if you think there are multiple distinct possibilities. The only time you'd go for a multi-answer spread is if the question isn't clear and you just want to dump off some indistinct possibilities. In this case the "black coffin" should be the uniquely defining feature that allows you to post a single answer.
Comment: @Valorum There is black coffin in two of them and beast boy in one of them. All of them fly into the sun. Not clear enough, sorry.


Just downloaded Minecraft no bin folder or minecraft.jar

Question: I've just downloaded Minecraft and I wanted to install Minecraft Forge, but it said I needed to go to bin folder than to minecraft.jar.  I don't have minecraft.jar, only having  versions, magic, launcher, launcher.pack.izma and launcher_profiles.json
Comment: As far as I am aware there is no Minecraft Forge for 1.7.4 yet and the folder as well as file structure changed drastically since 1.6.4 which the latest version was for.
Answer: The new Minecraft launcher and all versions that it supports exclusively (1.6 and up) have no bin folder/minecraft.jar. Also, it seems that Minecraft Forge has not yet been released for Minecraft 1.7.4.
When it does come out, you can either install mods the recommended new way using the new launcher, or you can directly edit the jar files.


If a diesel truck has been run dry of coolant and has then been refilled and then overheats and now has a blown head gasket when was the damage done

Question: Only problem is with head gasket. No leaking hoses and truck was serviced two weeks prior.
Comment: Damage was done, or started, as soon as the fluid level was too low to provide the correct cooling.
Answer: I would recommend a proper engine evaluation to ensure you're made aware of all possible damage however, most likely cause is warped head/s. Of course, the head/s could also be cracked in which case you're up for a decent amount of cash to fix.
Not sure if you have the know how or tools but just remove the head and send it in for assessment. If warped, they can resurface the head/s, reseat the valves etc. and hopefully its nothing more serious than that. Then all you need is a new gasket, new head bolts and chuck it back in. (yes there is more to it but these are the broad brush strokes).
Comment: What causes warped heads?
Comment: @SolarMike Looking at the many responses you've posted to this community, its clear you are knowledgeable about vehicles.
So to ask me such a simple question which I'm sure you already know the answer to...what are you trying to achieve?
If you disagree with something I've said, just be honest and get to the point.


How to ignore certain folders while using TAB button

Question: I usually press TAB to select directories on Windows, how do I ask it not consider internal svn folders (e.g. .svn)
Answer: You can't; the filename completion key cycles through all files/directories, including hidden ones. There is no special provision for selecting only certain file/foldernames. You may be able to find a third-party command-prompt shell (eg 4NT, Console2) that has the ability, but I have not seen any that actually do.


How can I leverage machine learning for log analysis?

Question: I am new to data science and trying to find possibilities of using datascience in tasks. I have a set of logs which I want to convert to json. The logs are more or less of same format and I can write a script which parse them or aggregate them but instead of doing it manually I want to use help of machine learning. This thought is also inspired by the fact that at sometime some new log line may come. I guess pre-trained LLM models can identify the context and information from logs. But I am not sure how exactly can ML be used for for this purpose? The question may sound stupid but please pardon.
Answer: this question is not stupid, it's great that you want to extract knowledge from logs. However, if you are at the very beginning of this journey, I wouldn't recommend not pondering over LLM but starting from simpler stuff. If I were you, I would start by parsing these logs and organizing an infrastructure for doing that regularly (in a real-time best). Having done that you can consider your first NLP analysis, but for me, the key would be to do something hands-on with this data like visualizing on the Grafana dashboard or creating an alerting. When you trudge along this data, you will see what has potential.


Servers can't find each other

Question: I had originally posted this on Superuser, but for some reason it got marked off-topic, so this seems like the only reasonable place left to post this.
I have a web server, which hosts my website (https://thijs365.com/) and my Nextcloud server (https://cloud.thijs365.com). That Nextcloud server is configured to use a OnlyOffice document server (https://docservice.thijs365.com/). However, the Nextcloud install can't reach the document server. After some digging around, I found that I also wasn't able to curl -L my website; it just times out. Nginx is configured to proxy-pass to the document server. I have split up my config into multiple files; you can find my config for thijs365.com here, the docservice config can be found here, the ssl config here, the nextcloud config here, and the php config here. My web server runs Ubuntu 18.04, and my document server runs CentOS 7.
Update:
I have found that curling from my laptop does work, which means that the servers can't reach each other internally.
Answer: I ended up fixing it by giving the document server a certificate. I then added the internal IP, followed by the hostname in the /etc/hosts file. This worked. It's quite sketchy, but with problems like this you don't have much choice.

Servers can't find each other


Connect to "gold plate" connectors of existing PCB

Question: I got a Bluetooth heating thermostat that I want to modify. The board has an ATmega 169PA, and I identified JTAG and ISP "connectors". They all look like those five round golden plates in the upper right of picture. Their distance is about 2.54 mm (0.1 inch) between each.
Is there a name for those gold plates?
How do you commonly connect a programmer (e.g. bus pirate) to those "plates"? (Preferably without soldering)
Comment: Usually those are called test points and "connected" to via bed of nails in manufacturing testing/loading.
Comment: If they are a sensible spacing you can use veroboard, 0.1" headers  and some bluetack.  Then solder to the veroboard instead.
Answer: The way they are supposed to be used is with "pogo pins" (sharp spring loaded pins) mounted in a test fixture that holds the board in place against the pins. Such a fixture is known as a "bed of nails".
Great for production but kinda sucks for development. Building such a fixture for one-off use would be a lot of effort and may make access to the board for test probes difficult. Especially as those pads are nowhere near the mounting holes.
Solding wires to the pads is an option and probablly what I would do personally. I would go for 30AWG wirewrap wire, if the wires get accidently stressed you want it to be the wire or the solder joint that fails (as those are easy to replace), not the pad.
Depending on the physical constraints an option can be to glue a connector to an empty part of the board with hot glue or silicone rubber and then solder your wires between that connector and the pads.
Answer: You need to use pogo pins. You'll have to build some sort of holder or fixture to keep the spacing and possibly maintain tension.
If you are only trying to program it once, you can probably use your hand to hold it in place, but you'll need to use a piece of perf board, or drill your own plate to hold the pins in the correct spacing.
Another approach that I have seen used is to measure out all the alignments, then put the results in a 3D printer.
If you want the best solution, you'll need to measure your board and determine a way to clamp the programmer to the PCB in a way that is self-aligning.
This is sometimes referred to as a "bed of nails" like @PlasmaHH mentioned.
Comment: (1) [Related thread](http://electronics.stackexchange.com/a/79226/7036) about bed-of-nails (pogo pins).  (2) With some care, you can solder wires to these pads.  For a one-off hack, that's probably a more sensible option than building a bed-of-nails.  (There was a discussion [here](http://electronics.stackexchange.com/a/96812/7036).)
Comment: @NickAlexeev The pink clothes pin is hilarious and awesome


Can a voltmeter itself disturb the electrochemical potential of battery?

Question: I'm trying to understand the effect on a system when a voltage of a system is measured by connecting a voltmeter.
For example let's say we are trying to measure the voltage of a Li-ion battery. The junction is as follows:
Lead(Nickel alloy) | Current collector(Copper) | Anode active material(Lithium-intercalated graphite) | Electrolyte | Cathode active material(Lithium transition metal oxide) | Current collector(Aluminium) | Lead(Nickel alloy)
Lead, current collector and active material would be in thermodynamic equilibrium(Fermi level(a.k.a electrochemical potential) alignment) at each side and the electrolyte works as a border(electrically insulated).
To measure the voltage of the battery, we must connect the voltmeter to both leads of the battery. Each probe will be connected to each side of the battery (anode and cathode lead.)
Assume this voltmeter is a high-end one, there is almost zero current flowing through the voltmeter (infinite input impedance.)
Although it is, I'm concerned that this behavior itself could disturb the voltage of the battery because the Fermi level of each side of the battery will change.
In the situation of anode side when the probe of voltmeter is connected, this makes another metal-metal junction:
Voltmeter | Probe(Stainless steel(?)) | Lead(Nickel alloy) | Current collector(Copper) | Anode active material(Lithium-intercalated graphite) |...
And this would also happen in cathode side when the other probe of the voltmeter is connected to the cathode lead.
So the voltage displayed in the voltmeter would be somewhat distorted because this is the result after some electrons from the voltmeter flow into or out of the lead of the battery since voltmeter measures Fermi level difference between two probes.
For summary, my questions are:

If composition of probes are different from that of a system we want to measure voltage, would the result be somewhat distorted because of Fermi level alignment? If it is, can we calculate how much the Fermi level changes?

Along with question 1, if the two probes of voltmeter are the same material and have dimension, does this effect cancel out so we can measure exact voltage of the system?

Along with question 2, if we have to use additional wire material of which is different from the original one to measure voltage, can we calculate the actual voltage of the system by compensating some constant value?

In the same spirit, does the material of current collector also affect the Fermi level of active material which we actually want to measure?

I've never seen or heard this kind of effect discussed. Is it because the contribution of the effect mentioned above is negligible or am I just wrong?
Answer: although you broke the rules by putting four questions into your post, I think all of them can be answered in one response, as follows:
Any dissimilar metal junction is going to develop a very small voltage (of order ~ millivolts) across it. In a context of measuring voltages of order ~ ten volts across a stack of cells, those millivolt signals will be utterly swamped out.
Furthermore, a sensitive voltmeter is always zeroed and calibrated before use against a precision voltage source, so as to null out contact voltages before taking measurements.
Comment: I'm very sorry to give four questions at a post. I wouldn't do that again. But could you give any references for why the voltage difference caused by metal junction would be in order of millivolts ?
Comment: Look up "thermocouple" on wikipedia. -Niels


Apple Watch 6 blood oxygen measurement said I had hypoxia when I in reality was fine. How to know if reading is taken in optimal conditions?

Question: TL;DR: How can I know if the SpO2 reading is in fact taken in optimal conditions ?
Comment: I'm voting to close this question because there doesn't seem to be a question here.
Comment: For example : "How can I know if the reading is in fact taken in optimal conditions ?"
Comment: I would say the question would work better if it's about three sentences long. You could then post an answer with all the backstory or how you come to your conclusion on what you do with the watch once you get an answer to how to determine if the results are properly calibrated. See [ask] and [tour] if no good answers surface in a week or so...
Answer: As much as I understand your frustration, Apple mentions the limits in the small print at the bottom of https://www.apple.com/watch/:

Blood Oxygen app measurements are not intended for medical use, including self-diagnosis or consultation with a doctor, and are only designed for general fitness and wellness purposes.
Comment: Yes, I am aware of that, but that doesn't answer the question at all
Comment: @user1511956 You are expecting something from Blood Oxygen measurements for which the functionality hasn't been designed. So even under (unknown) best conditions the result will not provide medical value.
Comment: Yes, exactly, it should be more explicit that the feature doesn't really work. It is easy to think that it does.
Answer: I have had similar conversations with people about other aspects of Apple Watch - heart rate not matching expectations, people comparing their activity with another and feeling the calories or heart rate or distance travelled aren't the same, so hopefully some of that perspective can help you and others.
I find the largest value for my health data is longitudinal tracking of my stats with my watch and my band. Yes - an instant value is nice when perfect, but over time, those measurements are easier to trust as you see how they vary.
Each of us has different mechanics, melanin pigmentation, and bone structure. The watch is a sensor and it surely aims to get a good result, but your results will naturally be different from mine. What doesn't change is your results day after day and week after week with the same sensor will give you good information how your body is changing.
Specifically, pulse rate and SpO2 are visual sensors, so band tightness, interference due to body hair, transdermal fat content, skin pigmentation, current moisture levels, and your specific capillary structure and location of anterior arteries and veins on your watch bearing wrist should affect the readings. I'm sure Apple tried to control for this, but the variation in humans is going to make some people have larger error than others. Hopefully you are able to get decent results once you control for the elements you have control over.
This error and confirmation of accuracy happens all the time in physiological labs for any medical measurement. The instruments are almost always very precise (measuring temperature to a tenth of a degree) but not always accurate - three devices all read 37.2° (or 99.0° in a few countries).
Same with estimating your stride length - if you are training against yourself - it doesn't matter if the reality is your steps are 1.4m and it's measures 1.2m if you're just looking at how far you go compared to yesterday and if you went further or faster than you did in the workout yesterday. Basically, don't overlook the value in longitudinal data even if it's not absolutely perfect.
My hunch is nailing the calibration is what's expensive and pricey (like building several redundant sensors). Many instruments that are cleared for medical use have formal calibration procedures, which is one reason the Apple Watch isn't cleared for that level of diagnosis. It lacks the ability to perform a calibration step if you determine it's not precise and accurate enough for you.
Also, this assumes the watch is perfect and the sensors are perfect. If over time you can't get a good pulse read / SpO2 read - maybe Apple would exchange it, but I'd hate for you to go through a swap if the device is working as designed and it's just not what you need where your body and Apple's design meet.
Comment: Well, the problem with "longitudinal tracking" is that my daily range of SpO2 values are usually always down to 90, or even less sometimes (which is wrong). Thus, that makes the feature useless. It is basically saying that my range is between "possibly seriously sick to perfectly all right". Simple measurements are often 10 percent off when comparing to a real oximeter. A couple of percentages in difference in SpO2 is significant.You cannot play around with that. That is completely different than a step length of 1.2 m vs 1.4 m, or a couple of BPM in heart rate for example.
Comment: If those are your results, I can see how you're disappointed @user1511956 I'm not saying you're wrong - just what I value from the watch. Using it for some time so I can know the confidence I place in any of it's health / fitness / environmental measurements.


Where can I get CloudVPN? It's installed on all my servers but I can barely find any info about it

Question: I recently became responsible for looking after a group of servers, and am now trying to add a new one.  The existing servers all have CloudVPN running, but I can find almost no information about it.  Does anyone know where it is available, or what a good alternative would be (that would not require any/much downtime)?  Thanks.
Answer: Maybe have a look at wikipedia regarding CloudVPN (http://en.wikipedia.org/wiki/Cloudvpn).
If you need some VPN solution you can use OpenVPN (http://openvpn.net/)
Comment: The wiki page says the project was last updated 4 years ago, and links to an external page which does not exist any more.  That (and a lot of other searching) is why I said "I can find almost no information".
Comment: IMHO it's time to change your vpn solution and give OpenVPN a chance. Have you seen the Link from wikipedia? If yes... have you done some research on the site? -> http://repos.e-x-a.org/view.cgi/cloudvpn/
Comment: Yes, I am ready to change - but only if I have to - I don't want to take the whole website offline while re-configuring the VPN if it is not necessary.  I did not see that specific page on e-x-a.org - I only saw either commentary, or links that did not work, so thank you for that.  Is OpenVPN what people really use?  At a minimum of $60/year?  I only need to connect the servers to each other, not tunnel into them privately.


Are USB ports in laptops protected against short circuits?

Question: I accidentally plugged in a mobile phone which shorted out. The USB port is still working fine, but could such events make my USB port or the motherboard fail?
Comment: My current laptop has short-circuit-protected USB ports, but not every computer is well-behaved under these conditions. My old laptop once shut down abruptly when the power lines were shorted on a USB port.
Comment: Knowing your laptop's model might help a little. Once you create an account here, you can [edit] your question.
Comment: "could the event make my USB port or the motherboard fail soon" this will draw opinions rather than answers, no way anyone can know what will happen in the future.
Answer: Generally a host USB port will have ESD protection on the data lines, and power will be supplied through a current limiting power-switch like the TI TPS2557. These devices will limit current to a programmed amount (generally 500mA for standard USB ports), and have output signals in event of a power fault that go back to the USB controller informing it of an over-current event.
Did your event degrade long-term reliability of the part in question? Unknown without further information about the event and ICs involved. I think you are probably fine though -- any reasonable laptop design would have that current limiting device there, and those devices themselves generally have thermal protection to keep them inside their SOA.
Answer: Many motherboards uses PTC thermal cutout as the short circuit protection for the USB ports. This device go into high impedance state when its temperature goes above certain limit during short circuit. If this is what being used on yr laptop motherboard then you got nothing to worry.
Answer: You'll probably find a lot of requirements for short-circuit protection in the USB specifications (which probably vary depending on the USB port type you have on your laptop).  And your USB port manufacturer probably followed the specs when implementing the hardware and software aspects of this protection.  But there's no way to tell what the long-term effect of a short circuit might be.


Spontaneously symmetry breaking from QM perspective

Question: I am a bit confused about the idea of spontaneously symmetry breaking (SSB), from the point of view of QM. I am talking here about the energy plot looking like a mexican hat in 2D (not the general Higgs one in the complex plane). I am mostly thinking of it by making an analogy with the ammonia molecule problem. The 2 lowest energy states in the SSB case don't respect the symmetry of the interaction, hence they can't be stationary states. Which means that they are not eigenstates of the 2 level Hamiltonian of the problem. Assuming that the energy of these 2 lowest energy levels is
$E_0$
 and the off diagonal term is
$A$
 (please see the link to Feynman lectures for more details about the notation), then, the actual stationary states, obtained by diagonalizing the hamiltonian (and which explicitly manifest the symmetry of the physical interaction) will have energies of
$E_0
±
A$
. But this implies that there is an even lower in energy level,
$E_0
−
A$
, than the 2 equal ones. Yet in the plot I mentioned above there is no lower energy than the 2 equal ones. Can someone explain to me what is wrong with my reasoning. Why don't we have that lower energy level? Thank you!
Comment: "Yet in the plot I mentioned above there is no lower energy than the 2 equal ones." Potential energy or total energy?
Comment: I don't think it's useful to think about SSB from a QM perspective. If I am not mistaken SSB is impossible in QM.
Answer: Like you mentioned, the eigenstates are the ones that respect symmetry. Thus the two SSB states are a linear combination of them. This means that the energy expectation in the SSB states must naturally be greater than or equal to (in case of degeneracy) the energy eigenvalues. The lowest energy level is $E_0-A$.
Comment: Thank you for your reply! So now my confusion is this: in the normal Mexican hat plot, the 2 degenerate states (which are not stationary) appear to be the lowest energy states. But as you said (and I agree with), the lowest energy level is E-A, so shouldn't that plot have an even lower level displayed? Why isn't it there?


Would RSA make sense if we used no computers?

Question: I was recently wondering - would RSA be useful if we brought it to, say, medieval times? Could you choose the keys so that you could encrypt/decrypt messages quite easily, but factoring the private key would, say, take over 1000 days for 1000 people, provided that they used paper and pencil only and wouldn't make any mistakes?
Comment: Why wouldn't it be?
Comment: You probably would need a monastery full of monks to do the key generation - and then kill all the monks to keep the private key safe :P
Comment: It's not clear if asymmetric encryption would be useful for their use cases, even if we ignore performance.
Comment: I share this link describing what kind of cryptography they used at Medieval times: [cryptography at medieval times](http://www.astronomicum.com). Sounded like asymmetric cryptography would have been giant leap.
Answer: I thought about this and have done a bit of research, and the answer is no.
The problem is the gap between the difficulty of factorisation versus prime generation isn't really large enough at the scale of primes/moduli we can work with.
By 1588 the largest prime discovered was 524287, thanks to Pietro Cataldi. This was a prime generated by a single person's work. I don't know how much effort this took, but given that it was a world record at the time, I think we can assume it was a fair amount of effort.
In order to have a secure instance of RSA, we'd probably want to generate a modulus using two six-digit primes. That's already quite a bit of work.
However, a nation-state can draw on more resources. They could hire a team of people to try and break the message. One observation is that there aren't actually that many primes below 1,000,000: there are only 78,498! If we consider only the primes between 100,000 and 1,000,000, this number comes down to 68,906.
A nation-state could use the sieve of Eratosthenes to find all the primes below 1,000,000. This would be a one-off effort.  They would then need to attack any modulus which is the product of two six-digit primes.
Finally, to factor a particular spy's modulus they simply could give it to a pool of people who would work down through the list.
Let's say one person can try one division every five minutes. That seems like quite a long time given the size of the numbers. Nonetheless, in one eight-hour working day, they could try 96 divisions per day. Across a pool of 20 people it would take 35 days to run through the entire list.
In practice, most moduli would be solved much sooner than this because both primes will appear somewhere in the list.
This attack is entirely practical and thus makes RSA pretty useless for encryption in that historical period.
Comment: So, would fast prime tests actually make it feasible?
Comment: For number of RSA interest and where computing the private RSA function is done by hand, [Fermat factoring](http://en.wikipedia.org/wiki/Fermat%27s_factorization_method), known for about 350 years, is much more plausible than trial division, and quite so.
Comment: Thanks, didn't know that generating prime numbers is that hard! First thing I thought of is that there are fast tests for primality, but actually, if there's just 8% of primes in the below-million set, it sounds a bit hard.
Comment: The fast tests for probable primality were not known back then. Then again I would say that numbers between 10000 and 100000 would already be enough to get started. Why? Its already enough to illustrate the substantial amount of difference in effort adversary has to do compared to legitimate parties. Anyway, consider that in many cases adversaries did not even break basic substitution ciphers. Anyway, once algorithm like RSA is known to some parties, and its usability is acknowledged then related problems (like finding primes) could get more research.
Comment: To enforce the above point I could mention Pascal. Mathematical theory of probability was studied during 1600's by Blaise Pascal because there was practical problem involved: making money in gamble. But then again. I would not expect inventing RSA without first understanding all the foundations of mathematics and probability we know.
Comment: No they would not. My answer took the approach that I assumed that in addition to RSA they have had more mathematical knowhow than they do. If they just had RSAEP and RSADP there would be little they could do with it. It would be like receiving a electric car from future via a time machine. In medieval times you'd do almost nothing with an electric car as you cannot charge it at all. Modern inventions have dependencies on other previously existing technologies, this is true even for innovations that are mostly documentation and know-how instead of tangible property.
Comment: In addition, the proof Fermat had for the Last Theorem Fermat. If it would have fit within the margin, merely the know-how in that proof may have significantly advanced fields of mathematics which are today important foundations for asymmetric cryptography.
Comment: If you _believe_ that every prime has a primitive root, and someone gives you a hint about one-way functions, then someone like Gauss could have developed RSA.
Comment: Generating a prime is not that difficult. You could take, say, $M = 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 = 6,469,693,230$, choose a random $a$ coprime with $M$, e.g. a prime that is smaller than M, and a small $b$, say, up to 1000. Then try $p=a+bM$. The probability that it's a prime is larger than 20%! And you get a 12-digit prime. Of course you'd need to tweak the process to increase the key space.
Comment: It does not make sense to assume that primality tests were not "known". Knowing that RSA works they could simply test a prime by checking that encryption+decryption modulo say, $3p$, works.
Answer: I'm answering to this a bit with "tongue in cheek" attitude because I like the question. Thanks d33tah. I try to make a few useful points. Maybe somebody contributes more via comments.
The term RSA in itself is ambiguous. I've assumed that entire RSA as defined in PKCS#1 + key generation stuff from FIPS 186-4 was known back then (maybe they also knew DSA and ECDSA and made wise decision to only use RSA as it is the most convenient).
Thus, I'm assuming that RSA means RSA sign/verify, padding, RSA encrypt, verify, key generation mechanisms, ... The other answer about primes is indeed completely true. There is no reason to expect that very large prime numbers were known back then. But if these things have been known...

There is are three laws from Clarke regarding technology. One of them is: "Any sufficiently advanced technology is indistinguishable from magic."
The medieval methodology to rubber-hose cryptoanalysis XKCD: Security was harsher that it is now (nobody expects The Spanish Inquisition). Back then somebody having skills indistinguishability from magic would have been most probably reasonable basis for witch trial.
Early forms of steganography and cryptography (think e.g. Caesar cipher) date much further back than medieval times. Therefore, it can be easily thought that some more asymmetric cryptography back then would have been possibly beneficial for faster progress in mathematics and natural sciences. Maybe renaissance would have been earlier. And, quite probably, modern computers would be something totally different.
Cryptography made certainly sense before computers, and problems related to confidentiality, integrity and authenticity existed back then.
BTW, alone RSA had been next to useless. It is too slow. For fast execution hybrid encryption is needed. Authenticity/integrity on the other hand likely needs strong hash functions.
Comment: Witch trials were actually extremely rare. If someone demonstrated extreme mathematical ability, they would not be regarded as dangerous, just as very smart. Now, if they could shoot fire out of their hands and mind-controlling people, that might be grounds for assuming they are in league with the Devil...
Comment: Strong (large and random) padding would not be necessary as Coppersmith attacks would be too complicated.
Answer: Security is based on the difference in effort for encryption/decryption and for cracking. With RSA, the difference grows exponentially with the key size. So for small key sizes, the difference isn't too bad.
To crack RSA, we need to factor the product of two large primes. There is an algorithm that should be accessible to a very talented mathematician in medieval times which solves this in O(n^(1/3)). So for two primes up to a million it takes about 10,000 steps.
So for a normal person to keep their secrets safe from a nation state, RSA won't work.
Comment: "With RSA, the difference grows exponentially with the key size"; actually, no, it grows superpolynomially (with the currently known algorithms)
Comment: @poncho did you mean "subexponentially"?
Comment: @Fractalic: either; it grows faster than any polynomial function (hence "superpolynomial" but slower than any exponential function (with positive increasing exponents), hence "subexponential".
Answer: I think you could implement the Enigma encryption with pen and paper. And that was barely breakable in the 1940's. It wouldn't be efficient enough for thousands of messages, but for one 100 character message a day it would be fine. Replacing the wheels with two strips of paper should work.


Riemann Lebesgue Lemma Clarification

Question: If $f$ is continuous real-valued function, does the Riemann Lebesgue Lemma give us that  $\int_{m}^k f(x) e^{-inx}\,dx \rightarrow 0\text{ as } n\rightarrow \infty$ for all $m\le k$? Specifically, is this true for any continuous function, whether it's periodic or not?
Edited.
Comment: yes, and yes.${}$
Comment: How about when f is only continuous on the interval $[m,k]$?
Answer: If $f$ is Lebesgue integrable on $[r,s]$, then the result is still true. You can show it by approximation. For $\epsilon > 0$, there exists a continuously differentiable function $g$ on $[r,s]$ such that $\int_{m}^{k}|f-g|dx < \epsilon/2$. And, as $n\rightarrow\pm\infty$,
$$
       \int_{r}^{s}e^{-inx}g(x)dx = \left.\frac{e^{-inx}}{-in}g(x)\right|_{x=r}^{s}-\int_{r}^{s}\frac{e^{-inx}}{-in}g'(x)dx \rightarrow 0
$$
This really has nothing to do with integers. You can assume $m,k,n$ are all real if you like, and you get the same result:
$$
         \left|\int_{r}^{s}e^{-inx}f(x)dx\right| \le \int_{r}^{s}|f(x)-g(x)|dx + \left|\int_{r}^{s}e^{-inx}g(x)dx\right| < \epsilon
$$
if $|n|$ is chosen large enough that the second integral on the right is bounded by $\epsilon/2$.

Riemann Lebesgue Lemma Clarification


Are there any metrics for cohesion inside a single function?

Question: There are metrics for class and module cohesion and coupling, but I didn't find anything yet for a single function. Some functions are obviously doing too much, like doThisAndThat (should be doThat(doThis())) or getDataForThis (should be convertForThis(getData())), and it would be very nice if there were an automatic way to detect such cases, to increase composability and testability of functions, which in turn will increase code reuse. Maybe this is the same as a metric for potential code reuse in the code-base?
Comment: What you're looking at is how well decomposed the algorithm is. doThisAndThat() is decomposed into doThat() doThis() which is good. This relates to "Stepwise Refinement" which was a big topic in the 70s (?). Here is a link https://web.stanford.edu/class/cs106j/lectures/03-Stepwise-Refinement/03-Stepwise-Refinement.pdf. The metric for this can be calculated depending on what language you use, for example cflow can help see how functions are connected using a flow chart. https://www.gnu.org/software/cflow/
Answer: Cohesion inside a single function might simply be called code duplication.
There's also algorithms for automatic procedure extraction. Here's one thesis about it: https://research.cs.wisc.edu/areas/pl/theses/raghavan.thesis.pdf
One could say that a function has "cohesion" if the procedure extraction algorithm is unable to extract anything from it further (give and take the tuning of that algorithm).


Foolproof Strategy to Beat Civilization 2 on Any Level?

Question: I'm curious to know if there is a foolproof way of beating Civ 2 everytime I play. I can do this on the first level and usually the second, but what about Deity level? Assume we're talking about conquest and not the space race.
Comment: Its worth clarifying, you are talking about Civilization2(1996) and not Civilization5(2010).
Comment: @Akusete - Yes, I'm talking about Civilization 2.
Comment: I, a "hardcore" player can USUALLY beat Civ II up to the King level. Sometimes at the Emperor level, for certain games that play like "king" (or if I'm lucky with resources etc.) Deity? Forget it, at least for me. Someone who knew all the game mechanics AND got lucky might beat Deity. Not me.(Except in some scenario games). Otherwise, the AI gets too far ahead.) It's all I can do to "get lucky" at the Emperor level.
Answer:
Expand, expand, expand. Upside to this you get a lot of cities and can make a lot of units to keep attacking/guarding. Downside is your economy isn't the greatest, and you have to rely on continuing to attack/pressure the enemy into giving you money/resources.

OR

Turtle till you got large army and slowly expand taking over cities slowly, the downside to this is that you stay at war for forever which sucks. If you go this route try to only be at war with 1 race at a time, even if you have to pay tribute to someone. And make sure to destroy them completely, take over any good cities, and destroy the others as it hurts your economy and a weak city is just saying attack me please.

I am referring mainly to Civ 2 here, but this works in Civ 4 mostly as well. I haven't gotten 5 yet so unsure of that.
EDIT:
Oh in Civ 2 my very favorite unit was stealth bombers once you got them, just bomb the hell out of the enemy, there is nothing they can do when you send 50+ bombers at one city, then wait 1 turn to repair and go against another city. It got to the point I always had half my bombers repairing (i.e waiting a couple of turns) and the rest attacking.
Once you get normal bombers things are all uphill from there.
Comment: Interesting answer: these two different approaches remind me of what real-world empires (such as the Roman Empire) did, and the problems they had
Comment: I'm used to the turtle strategy, but on higher dificulties the computer grows so fast that I get overrun easily. I'm trying the expand-fast strategy now.
Comment: The only problem with bombers is that it requires flight, which cancels your Colossus. If you were playing with a MSC, your science output probably drops by about 20-25% without the trade bonus from Colossus.
Answer: As someone who easily managed Civ2 on Deity level (unlike Civ3 and Civ4, where the AI already beat me up on King) I would like to add a little aspect that I remeber from the good old days in addition to Vipers answer : The Artillery unit in Civ2 is incredibly powerful. I remember stomping over several enemy cities in one round with one artillery (railroads available).
Comment: Yep very true .