How to align text horizontally & vertically in UITextView?

Question: How to align text horizontally & vertically in UITextView?
I want align text in UITextView with horizontal alignment & vertical alignment.
Is there any custom way?
Please help me out.....
Answer: This is a Swift solution and is different now since content insets and offsets have changed slightly. This solution works in Xcode 7 beta 6.
override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    textView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.New, context: nil)
}

override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated)
    textView.removeObserver(self, forKeyPath: "contentSize")
}

Apple has changed how content offsets and insets work this slightly modified solution is now required to set the top on the content inset instead of the offset.
/// Force the text in a UITextView to always center itself.
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
    let textView = object as! UITextView
    var topCorrect = (textView.bounds.size.height - textView.contentSize.height * textView.zoomScale) / 2
    topCorrect = topCorrect < 0.0 ? 0.0 : topCorrect;
    textView.contentInset.top = topCorrect
}

Comment: not working in Xcode 8. does anyone have any ideas how to do this?
Comment: This worked great for me with IOS 9/ Swift 2 thanks!
Comment: This worked but if I have more than one UITextField, it only applies to one of them
Comment: Anybody achieved this with iOS 10, Swift 3 & Xcode 8?
Comment: Working fine for me on iOS 10, Swift 3, Xcode 8. (Slight syntax changes needed)
Comment: In swift 4.2,
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
let textView = object as! UITextView
    var topCorrect = (textView.bounds.size.height - textView.contentSize.height * textView.zoomScale) / 2
    topCorrect = topCorrect < 0.0 ? 0.0 : topCorrect;
    textView.contentInset.top = topCorrect
}
Answer: As far as I know there is no built in method for vertical alignment of a UITextView. However, by updating the the contentOffset you can get vertically centered text:
[textView setTextAlignment:NSTextAlignmentCenter];

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [textView addObserver:self forKeyPath:@"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [textView removeObserver:self forKeyPath:@"contentSize"];
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    UITextView *tv = object;
    CGFloat topCorrect = ([tv bounds].size.height - [tv contentSize].height * [tv zoomScale])/2.0;
    topCorrect = ( topCorrect < 0.0 ? 0.0 : topCorrect );
    tv.contentOffset = (CGPoint){.x = 0, .y = -topCorrect};
}

Comment: Where does this code go?  (ViewController.m?)
Comment: @Cindeselia The way the code is currently written, you would need to add it where your text view is located.
Comment: Note that changing contentOffset only seems to work if the text view's "Selectable" flag is checked
Answer: Vertically aligning middle with Swift:
In viewDidLoad:
textField.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.New, context: nil)

Then somewhere else in your view controller:
override func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer<Void>) {

    var topCorrect : CGFloat = (textField.frame.height - textField.contentSize.height);
    topCorrect = topCorrect < 0.0 ? 0.0 : topCorrect / 2
    textField.contentOffset = CGPoint(x: 0, y: -topCorrect)

}

where textField is wired up to the actual text field in your view.
Comment: that works properly but somehow it doesn't work with an unwind segue... any idea why?
Answer: You should provide the context on what you mean to do when you want to change the horizontal and vertical alignment,
The UITextview has a container and a frame property that you can align with another UITextview/ Imageview, etc.   The frame property has an origin and a size that you can modify to align your views.
The text within the UITextview has a property called the textalignment which you can set to NSTextAlignmentLeft, NSTextAlignmentJustified, As suggested, you may also adjust the content offset property of the container but I find that adjusting the frame is more straight forward.


Genetic Algorithm - Premature Convergence

Question: I am trying to implement a Genetic Algorithm that solves a TSP. It works fine with a TSP of a small number of cities (say 10) and produces the optimal solution. However, when the number of cities is increased even to 50 cities, it converges prematurely. I tried changing the parameters (mutation prob, crossover prob, initial population size, number of generation), however it still does not converge to the optimal solution.
The algorithm I have implement is as following:
<code>Create an initial population randomly of size p
Calculate the fitness
Pick p/2 random individuals to the parents
While counter < p/2
     pick parent1 and parent2 by tournament selection
     child1, child2 = mutate and crossover parent1 and parent2
     add child1 and child2 to new population
pick p/2 distinct individuals from initial population and store in new population
</code>
Could any one tell me what I am doing wrong please?
Comment: Who said that genetic algorithms were bulletproof ?
Answer: Usually, you'll want to adjust the mutation rate over the course of the evolution, which I don't see you doing here.
Start with a high mutation to give it a chance to find a few possible "evolution paths" (although what's considered high will depend on the application, you'll need to play around), then have the mutation decrease over time to prevent sporadic changes from hindering progress.
You could make the mutation rate a function of the current generation, the current error, or both.
But as the commentor mentioned, GAs are in no way guaranteed to give you optimal results. They usually give you "acceptable" results when dealing with a giant solution space.


Simple 2D UV mapping problem in openGLES

Question: I'm fairly new to low level openGL coding and I have a problem that perhaps I'm just too tired to find a solution to. I'm sure the answer is simple and I'm doing something utterly stupid but here goes...
I have a texture of 1024 x 512,and I'm rendering a 2D quad which intends to use a portion of that texture. The quad is of the same size as the texture portion I am trying to render, eg 100 x 100 between vertices to render a 100 x 100 texture portion.
The texture pixels are from 0(s) and 104(t) assuming zero based pixel coords, and therefore the UV(st) is being calculated as 0 / 1024 and 104 / 512 to the extents of 100 / 1024 and 204 / 512.
However when I render the quad, I get a line from the pixel coords at 103(t), which is part of a different section of the image so it really stands out. I can get around the problem by setting the UV to 0 / 1024 and 105 / 512, but this seems very wrong to me.
I've been searching for a while and can't find what I'm doing wrong. I've tried GL_LINEAR, GL_NEAREST,clamping etc in glparams to no avail. Can someone please direct me to my error?
Answer: That is because texture coordinates don't address pixels, thus your assumption

and therefore the UV(st) is being
  calculated as 0 / 1024 and 104 / 512
  to the extents of 100 / 1024 and 204 /
  512

is wrong!
This is kind of a FAQ, I recently answered it in OpenGL Texture Coordinates in Pixel Space


Can I merge text into irregular shapes? Illustrator

Question: I've made irregular shapes by overlaying white squares over each-other randomly and now I want to make it so that my text fits perfectly within those irregular shapes as one whole continuous paragraph. Is it possible to do this without making multiple text boxes? This is in adobe illustrator. Thank you (:
Answer: This can be done with pretty much any closed shape/ path except "Compound Paths".
You can draw an irregular shape with the pen tool and as long as it is a closed path you can fill it with Area Type.
For your squares select them and open the Pathfinder Panel (Window> Pathfinder) and hit the Unite icon (upper left). This will create one shape from your different objects. Then choose the Type Tool (T) and click on the outline of the newly created path. This will place your cursor inside the shape and you can type into it or paste text into it.
You can also modify your Area Text Box shape after the text is inserted by moving line segments or anchor points.
Comment: You can do holes as well ([see here](https://www.dummies.com/software/adobe/illustrator/wrap-text-in-adobe-illustrator-cc/)) with text warp objects ([see example picture](https://i.stack.imgur.com/nBy0G.png))
Comment: Thank you @joojaa- of course- a text wrap object inside an area type box rather than a compound path- very good !
Comment: Sounds like the OP want's *constrained* text, as Kyle has outlined in this answer. That's *wrapped* text @joojaa Not the same thing.
Comment: @Scott yeah i just pointed out that the holes can be  done with wrap, so you dont actually need the compound path functionality. Also wraps can be used to constrain by flipping the side,  but thats a different thing


Who played iguana Spot in Genesis?

Question: Memory Alpha is quite helpful when learning about all the background actors on Star Trek, even including all of the cats that played Spot on The Next Generation. However, I can't seem to find the animal actor that played the lizard version of Data's cat Spot in the episode "Genesis." Are there any production notes that state which animal actor was chosen to play the role of Spot? What kind of iguana was it (assuming it was an iguana)?
Comment: It was Janeway.   She went warp 10 just to be able to take the role.
Comment: @BrianOrtiz - You just gotta know who to ask.
Comment: I don't believe this is known. It may be that the iguana was not named.
Answer: I had the opportunity to speak recently to Rob Bloch of Critters of the Cinema (who provided this green iguana, as well as various other animals seen in this and other seasons of TNG) and I am advised that its name was Willie.
You might also be interested to learn that this  multi-talented critter also played the part of the holographic iguana 'Leonard' in VOY: Life Line

Who played iguana Spot in Genesis?


Does the compiler generate intermediate assembler?

Question: My source files are *.ino, but after compilation there aren't any other files placed in the folder. Does the compiler generate intermediate assembler, and if so, where does it leave them? Or is the machine code available somewhere?
Comment: 1) If you switch to a Makefile build or in some other way can customize arguments then you can ask avr-gcc to produce assembler ouput.  2) Alternately you can use avr-objdump to disassemble binary (or with the aid of objcopy, hex) ouput back to assembly mnemonics.  With an original unstripped elf binary objdump may be able to print many symbols (the usual way of producing a list file), but with a raw binary or hex file those are permanently lost.
Comment: @ChrisStratton: Thanks. Can you elaborate on 1)? I know makefiles are commonly used by software developers, but I don't have any experience with them.
Comment: There are various stock Makefiles you can find online to build an Arduino project with greater control of the details.  Not able to dig one up for you right now.  There may also be ways to customize the IDE's commands, but the IDE has so many other problems I'm not sure it's worth the bother.
Comment: You can find Arduino compatible makefiles in the embedxcode repository at http://embedxcode.weebly.com You will probably look at the `arduino15avr.mk` file in particular. You can change this file to have assembler output save and place where you want it to be.
Answer:
My source files are *.ino, but after compilation there aren't any other files placed in the folder.

Correct. The Arduino IDE performs compilation in a separate temporary directory, whose location you can see if you enable verbose compilation in the IDE options.

Does the compiler generate intermediate assembler, and if so, where does it leave them?

By default GCC (which the Arduino IDE uses) does not leave intermediate assembly language files on disk. You must pass the --save-temps argument to have it leave them in the current directory, or --save-temps=obj to save them in the output directory.

Or is the machine code available somewhere?

The machine code is available in the .elf and .hex files generated in the temprary directory.
Answer: Yes.
Arduino compilation is set up with link-time optimization (LTO), and the assembly files created during C compilation don't contain any assembly code - just the intermediate representation used later in the LTO stage to generate actual assembly code. We want the latter.
It so happens, rather nicely, that the very last time assembler is invoked in the entire compilation process, is to take the output from the LTO stage, and turn it into a whole-application object file.
To get at this assembly file, do the following (on Windows):

Open %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\1.8.3\platform.local.txt (create it if it doesn't exist). Add the following line
compiler.c.elf.extra_flags=-save-temps=obj -fverbose-asm

If there already is such a line there, just add the above options (to the right of =).
Note: If you can't find the folder, look for the following files: boards.txt, platform.txt, programmers.txt. If you find these files in multiple locations, the one you want should be inside your home directory (i.e. not in Program Files or /Applications or /usr), and should be correlated at least partially to the version of Arduino you're using (should you have multiple versions installed).

Build the sketch again.

Look for a file named %TEMP%\cc*.ltrans.s. Each build will create a new such file. If you sort them by timestamp, the newest one is for the most recent build.

Note: The environment variables, enclosed by % signs, are valid in the Windows dialog boxes. You can directly paste such a path into e.g. an Open or Save As... dialog box, and it'll work. Paths with globs (*) will act as filters (IIRC).
To know which exact cc*.s file was generated, add the verbose option to the final binary generator pass:
compiler.c.elf.extra_flags=-save-temps=obj -fverbose-asm -v

Rebuild, and copy-paste all the output from the compilation status window in Arduino to e.g. Notepad++, and search for ar.exe. The sole line that contains ar.exe ends with the name of this cc file:
 c:/users/[...omitted...]/avr/bin/as.exe -mmcu=avr6 -mno-skip-bug
    -o C:\Users\[...]\AppData\Local\Temp\cc3XhU2F.ltrans0.ltrans.o
    C:\Users\[...]\AppData\Local\Temp\cc3XhU2F.ltrans0.ltrans.s

How does the file look? This is a short extract, just to show that both the C source and the assembly are intermingled - and this represents exactly the binary embedded in the .hex file and sent to the target.
.LBE33:
.LBE32:
.LBB34:
.LBB35:
 ;  C:\Users\[...]\Documents\Arduino\sketch_jul01a\sketch_jul01a.ino:29:   pinMode(ledPin, OUTPUT);
    .file 4 "C:\\Users\\[...]\\Documents\\Arduino\\sketch_jul01a\\sketch_jul01a.ino"
    .loc 4 29 0
    ldi r22,lo8(1)   ; ,
    ldi r24,lo8(13)  ; ,
    call pinMode     ;
.LVL55:
 ;  C:\Users\[...]\Documents\Arduino\sketch_jul01a\sketch_jul01a.ino:30:   pinMode(relayPin, OUTPUT);
    .loc 4 30 0
    ldi r22,lo8(1)   ; ,
    ldi r24,lo8(12)  ; ,
    call pinMode     ;
.LVL56:
 ;  C:\Users\[...]\Documents\Arduino\sketch_jul01a\sketch_jul01a.ino:31:   pinMode(ldrPin, INPUT);
    .loc 4 31 0
    ldi r22,0    ;
    ldi r24,lo8(54)  ; ,
    call pinMode     ;
.LVL57:
.LBE35:
.LBE34:
.LBB36:
.LBB37:

This approach also works on Linux and MacOS, except that the paths are slightly different, and path expansion uses different syntax. The two files of concern still are platform.local.txt - a file you must create, since it doesn't exist at first, and the ${TEMP}/cc*.ltrans.s files.


Are there any bitcoin communities for women?

Question: Not to knock the guys, but it would be nice to talk to girls about this awesome virtual currency...partly to bring awareness to enable widespread adoption of bitcoin, as well as to try to get involved with other girls who may be working on bitcoin-related projects.
Comment: Might be a great opportunity to start one!
Comment: I'm trying to teach myself about Bitcoin .... unsure whether I'd start mining though ;-)
Comment: I don't know why this is being voted as "primarily opinion based" as it's fairly clear that a factual answer can be made.
Answer: There is a Meetup for Women in Bitcoin in San Francisco. It might be helpful to try to get in touch with them as they might be able to point out a meetup near you or recommend an online community, unless you happen to be near there anyway.
Answer: There is the Mädchenabend in Berlin for Bitcoin-ladies only.

If you are curious about Bitcoin or already in love with it > and if you are a woman, you're in the right place! Since May 2014 we meet once a month in Berlin to chat about Bitcoin, share our knowledge, connect and -most important- have a lot of fun together! ---Girls and Women only!--- The goal of this meetup is not to entirely separate us from the male community, but to once in a while gather in a smaller, more pinpointed group and provide a space for exchanging our ideas and Q&A in a relaxed atmosphere.
'Every woman using and teaching #bitcoin becomes a full node that forms a World Decentralized Women Bitcoin Network. Steadily we grow.' (@TrueBitcoinGirl)
To all our male supporters: Thank you in advance for acting as our ambassadors, spreading the word and inviting more women!


How can you integrate SharePoint 2019 with Hadoop distributed file system

Question: How can you integrate SharePoint 2019 with Hadoop distributed file system. We are storing and managing bulk data( about    >10 000 items )on the document library and  there are issues handling this large documents especially on retrieval.
Answer: There wouldn't be any integration point. You may be able to find a 3rd party solution (i.e. AvePoint used to offer one) that allows you to view content on a file share, but if you want the SharePoint features of version control, metadata, and so forth it needs to reside in SharePoint.
In general you shouldn't be having any issues with that number of documents even in a single library. You may need to configure index, filters, and views on the library but that isn't much content.
Manage large lists and libraries in SharePoint
Comment: we are not  decommissiong Sharepoint , the users will still manage and store documents there but we have issues with Search service application(separate site) and database query.
Comment: You should create a new post to t-shoot your search issues. 10K documents is very small (for reference, my farm has 2+ million documents and that is also considered small).
Answer: What you can do to improve performance on that document library:

Create indices on the columns used most for filtering.
Move the site collection that contains the document library into its own content database.
Implement Remote Blob storage for your SQL instance (in my experience that helps mostly if you have very large files in your library).

Besides, 10K items is not massive amount. Most probably something is wrongly set up with your SQL instance.
Look at this series (there are 3 videos) It is talking about SP2013 but all recommendations will largely apply to SP2019:
https://channel9.msdn.com/Series/Tuning-SQL-Server-2012-for-SharePoint-2013/Tuning-SQL-Server-2012-for-SharePoint-2013-01-Key-SQL-Server-and-SharePoint-Server-Integration-Conce


How to make gritty two color photo?

Question: Reducing colors with levels will give you very high contrast stencil-like results. Half-tone effect will be too "perfect", stamp effect gives too much contrast too. Any ideas how to make similar images? Diffusion Dither is different thing.
Comment: @BillyKerr, I'm voting to reopen this. The effect shown in the examples isn't *diffusion dither* as in the duplicate. There might be some *other* duplicate though.
Comment: @Wolff Yeah, I know how to convert image to Bitmap, this is different effect or maybe something over diffusion dither. I don't know, and that's why I'm asking. It looks like Stamp filter + Something though.
Comment: @Wolff - I've reopened it, but a dither pattern of some sort may be a start. The first image looks a bit like an old fashioned photocopy
Answer: There's a free plugin called G'MIC - which works on Photoshop, GIMP and Krita, and possibly some other image editors too.
The G'MIC Charcoal filter comes close. It's located under the Black & White filters in the plugin. The controls can be tweaked.
An example
Comment: Nice! That's more like it.
Comment: Yeah, this seems like will do the job. Thanks Bill!
Comment: Can you please post the proper link to the plugin?
Comment: @Rafael It can be found at gmic.eu
Answer: I propose using the Dissolve blend mode to create that gritty look.
As example I'll use this image which I've corrected to be pretty light without too large areas of black.

Photo by Paul Brennan, CC0 Public Domain

Closeup at 400%.

Copy image to clipboard.
Make a white layer.
Make a black layer.
Make a mask for the black layer, paste in the image and invert it.
Set the Blend Mode of the black layer to Dissolve.

The result looks great, but it's harsh 1-bit and the grains are smaller than what you are looking for:

Click image to see full size.

Closeup at 400%.
Merge the black and white layers (or turn them into an Smart Object) and apply a Gaussian Blur filter with a Radius of 0.5 px for a more appealing result:

Click image to see full size.

Closeup at 400%.
I really like this look. Grainy but smoothened a bit. Perhaps it could be of use to you.
To make the grains coarser like in your examples, apply a Dust & Scratches filter  with Radius set to 1 px before you apply the Gaussian Blur filter:

Click image to see full size.

Closeup at 400%.
All dithering methods like this are very dependent on the resolution of your image. If you feel you lose too much information, consider applying the effect at double size and then scaling down to half size afterwards. This will give you smaller and sharper grains:

Click image to see full size.

Closeup at 400%.
Comment: It also looks like OP's images have the typical HDR photo effect. It happens when we use HDR too much or something like that and it creates extra contrast.
Comment: @Vikas, true. One could apply a little exaggerated HDR effect before using this method. I also did manipulate the original image of the cat with Camera Raw Filter applying lots of Texture and Clarity.
Answer: Make a DIY-halftoning based on noise. Start from an RGB photo which contains black and white and there's also plenty of intermediate brightness levels. The photo can be as well colored as desaturated. It's pixel dimensions should be selected so that the actual pixels are about the same as the screen pixels. The next example is 1200 px wide:

Add a new layer. Fill it with 50% bright grey. Apply to it Filter > Noise > Add Noise > 100% Uniform Monochrome
Blur the noise. Apply Filters > Blur > Blur. Gaussian blur can be used if the radius is less than one pixel. Bigger radius makes the grains too big in next steps.
Adjust in the Layers panel the opacity of the blurred noise to 50%. Insert a tresholding adjustment layer and adjust the treshold. The half-toned greyscale is not especially linear, so you must adjust the treshold for good tones in important areas like on the face:

Inserting a curves layer just above the photo can help in some cases. In the next example the midtone contrast boost with a curves layer makes the tones in the face substantially better:

Tresholding should generate only black and white pixels, but you may see grey in the screenshots. That happens because the image is resampled at least when one watches it in the web browser.  In Photoshop it looks right when the zooming is set to "Actual pixels".
You may want less random grains but you do not want the same degree of regularity that one gets by converting the image to grayscale, then to bitmap mode and by applying "diffusion dithering". As a compromise you can make the noise pattern from flat 50% grey by applying in separate image to it diffusion dithering, Convert the result back to RGB, add some noise and blur. Use it as your blurred noise layer:

The mechanical looking diffusion dither pattern is much reduced by applying 50%  noise to it before blurring. But the grain size variation is smaller than in pure noise versions => the image looks cleaner.
The blurred noise layer can be also scaled to bigger size for bigger grains. In the on diffusion dither based version it doesn't render the resolution down as steeply as in the pure noise version.

How to make gritty two color photo?


Center of Circle given Apothem and 2 points

Question:
I am given 2 end points of the chord $AB$ as well as the apothem, the distance from the center point of the circle to the chord. I can easily find the radius circle and midpoint of the chord I'm just unsure where to go from there. My end goal is to get the coordinate pair for the center of the circle.
Comment: Technically, if all you have are two points $A$, $B$ and the length $a$ of the apothem, if $a\ne0$ there are exactly two circles (the centers of which are distinct) such that $AB$ is a chord and the distance of the center from $AB$ is $a$. Namely, a point $C\notin AB$ and its symmetrical $C'$ w.r.t. $AB$.
Comment: Isn't the center just the perpendicular "connector" of the chord of length of the apothem (which can go in two different directions as @G.Sassatelli stated).  This is much easier to figure out if you use "vectors"--specifically write a line parameterized--as $x(t) = x_0 + m_xt$ and $y(t) = y_0 + m_yt$.
Answer: The center of the line segment is
$C
=(\frac{x_1+x_2}{2}, \frac{y_1+y_2}{2})
$.
Since the line to the center
is perpendicular to
the line segment,
which has direction
$(x_2-x_1, y_2-y_1)
= (dx, dy)
$,
its direction
is
$D = (-dy, dx)$
(or
$(dy, -dx)$).
Therefore,
go from $C$
in that direction
by the specified length.
If that length is $L$,
the center is at
$C + L\frac{D}{|D|}
$.
(Added later)
Note that, depending on
which version of $D$ is used,
you get two possible centers,
one on each side of the line.


Multiple separate forms for searching up different apache solr indexes

Question: Mac_Weber in IRC gave me some great info in relation to this earlier, but I have a more indepth question: is it possible to have multiple separate forms for searching up different apache solr indexes? Say for example I had a separate indexes on rock stars, countries, and organic food suppliers. I want a drupal website that has literaly separate pages with a search box to search upon these indexes.
Answer: The the Search API is perfect for the job. This module provides a framework for easily creating searches on any entity known to Drupal, using any kind of search engine (including Solr). You can create multiple indexes with their own individual search pages/blocks and have granular control over what fields are searched and the relevancy.
Comment: Alright, this is pretty awesome. Could this work even if the solr indexes were on an external database? Aka, content not created by Drupal? It sounds like you can, for sure.
Comment: I think the index has to be created by the Search API, but I am not positive.
Comment: A very very good write-up on this here: http://zugec.com/73-how-setup-search-api-apache-solr


OM1 and OM3 Fiber Questions

Question: We are looking to install OM3 fiber to get a through put of 10 gig throughout our facility. I am looking at a chart and it states that the OM3 (50/125) which I am guessing is multi-mode fiber can produce 10 gig @ 300 meters (SR) and 1 Gig @ 550 meters (SX) what does the SX and SR mean and I am assuming that the OM3 is a multi-mode fiber.
Answer: Use OM4 please, seriously I've found it so much more stable at those speeds than OM3 and the price difference isn't so much.
Answer: SR refers to 10GBASE-SR, and SX to 1000BASE-SX.
With an OM3 fiber, you can do ~300 meters at 10Gbit/s or ~550 meters at 1Gbit/s.
Answer: Here's some information about Fiber Type vs. Speed and Distance:
Fiber Type vs. Speed and Distance
Comment: Please give a summary, the link might break any time.
Comment: Welcome to Server Fault! Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference.

OM1 and OM3 Fiber Questions


Who were the original Spears of the Church?

Question: In the Ringed City DLC, you will come across the Spears of the Church, protecting their Lady Filianore. A small boss fight ensues, in which you kill the guardian Halflight and a player NPC. However, when the game first released, there had to be players who did not fight a Spears of the Church covenant member in that battle. Who participated in the battle if there were no covenant members of the Spears of the Church?
Comment: You can test it yourself - just go into offline mode and reset fight at Purging Monument
Comment: @arghtype Why bother asking the question when I could just test everything for myself? There's other parts that are unknown about this that testing myself can't tell me.
Answer: It doesn't have to be a covenant member, I've been pulled into the fight when my (white) summon sign was down.
However, if the game has trouble summoning a person, the player black crystals out, or you're playing offline, then a NPC will be summoned instead.  This NPC has massively increased health over a regular player, and I believe they use a spear and shield.
Answer: The NPCs wearing the Painting Guardian set are not Halflight. They are, presumably, generic members of the covenant. As far as I know, we don't have any actual lore on them. EDIT my memory failed me but we actually have some info on them, from the Church Guardian Shiv, which they use:

This special throwing blade has a flat tip, and is wielded by
  guardians of the Church of Filianore.
Guardians of the Church, of whom few remain, watch over Princess
  Filianore's eternal slumber along with the Spears of the Church.

Halflight himself can be fought if you play offline or if the game cannot find a player to face you. He wears the anticated plain garb set and wields the Frayed Blade, a White Birch Bow and a Knight Shield, and he can use the Divine Spear fragment. You can read a bit of lore about him on the anticated plain garb items description:

Ordinary garb from an ancient land of sorcery. The gold embellishments
  betray a faint residue of magic, but this clothing was never intended
  for battle.
When a mission visited the Ringed City long ago, one of its younger
  missionaries elected to stay behind. It was he who became the last
  recorded Spear of the Church.

You can see more info as well as a screenshot of him on the wiki.
Comment: I thought Halflight was the respawning NPC that throws the magic shurikens at you? Huh...


How do interrupts work on the Intel 8080?

Question: How do interrupts work on the Intel 8080?  I have searched Google and in Intel's official documentation (197X), and I've found only a little description about this. I need a detailed explanation about it, to emulate this CPU.
Answer: The 8080 has an Interrupt line (pin 14).  All peripherals are wired to this pin, usually in a "wire-OR" configuration (meaning interrupt request outputs are open-collector and the interrupt pin is pulled high with a resistor).  Internally, the processor has an Interrupt Enable bit.  Two instructions, EI and DI, set and clear this bit.  The entire interrupt system is thus turned on or off, individual interrupts cannot be masked on the "bare" 8080.  When a device issues an interrupt, the processor responds with an "Interrupt Acknowledge" (~INTA) signal.  This signal has the same timing as the "Memory Read" (~MEMR) signal and it is intended to trigger the peripheral device to place a "Restart" instruction on the data bus.  The Interrupt Acknowledge signal is basically an instruction fetch cycle, it occurs only in response to an interrupt.
There are eight Restart instructions, RST 0 - RST 7.  RST 7 is opcode "0xFF".  The Restart instructions cause the processor to push the program counter on the stack and commence execution at a restart vector location.  RST 0 vectors to 0x0000, RST 1 vectors to 0x0008, RST 2 vectors to 0x0010 and so on.  Restart 7 vectors to 0x0038.  These vector addresses are intended to contain executable code, generally a jump instruction to an interrupt service routine.  The Interrupt Service Routine will stack all of the registers it uses, perform the necessary I/O functions, unstack all the registers and return to the main program via the same return instruction that ends subroutines (RET, opcode 0xC9).
Restart instructions are actual opcodes, meaning they will do the same thing if they are fetched from memory during program execution.  It was convenient to use Restart 7 as "warm restart" for a keyboard monitor / debugger program because early EPROMs generally contained 0xFF in each blank location.  If you were executing blank EPROM, that meant something had gone awry and you probably wanted to go back to the monitor anyway.
Note that RST 0 vectors to the same memory location as RESET, both start executing at 0x0000.  But RST 0 leaves a return address on the stack.  In a way, RESET can be thought of as the only non-maskable interrupt the 8080 had.
An interrupt signal will also clear the Interrupt bit so an Interrupt Service Routine will need to execute an EI instruction, generally immediately before the RET.  Otherwise, the system will respond to one and only one interrupt event.
CP/M reserved the first 256 bytes of memory for system use -- and that interrupt vector map used the first 64 bytes (8 bytes per Restart instruction).  On CP/M systems, RAM started at 0x0000 and any ROM lived at the top end of memory.  These systems used some form of clever bank switching to switch in an EPROM or something immediately after a RESET to provide a JUMP instruction to the system ROM so it could begin the boot sequence.  Systems that had ROM at the low end of the memory map programmed JUMP instructions to vectors located in RAM into the first 64 bytes.  These systems had to initialize those RAM vectors at startup.
Comment: *An interrupt signal will also clear the Interrupt bit so an Interrupt Service Routine will need to execute an EI instruction...*, that was what I'd really been wondering. Now I can see why a program used only `EI`s but any `DI`s.
Answer: The 8080 was dependent on external hardware to control its handling of interrupts, so it is impossible to generalize. Look for information on the Intel 8214 or 8259 interrupt controllers.
Answer: I finally found it!
I created a variable called bus where the interrupt opcode goes.
Then, I called a function to handle the interrupt:
void i8080::interrupt()
{
    // only for RST
    cycles -= cycles_table[bus];
    instruction[bus]();
    INT = false;
}

INT is true when an interrupt needs to be handled.
EI and DI are instructions that enable/disable INTE.
When INT and INTE are true, the interrupt is executed.
Comment: If it's a variable "where the opcode goes", why not call it "opcode"?
Comment: opcode is used as type of data, anyway, as I see, opcode of interruption goes to external bus of 8080, so I think it was OK.

Thanks to all!
Answer: Function pointers to the interrupt handlers are stored in the low memory.
Some 32 or so of the first addresses are hardware interrupts: hardware triggered.
The next 32 or so address are user-triggerable, these are called software interrupts. They are triggered by an INT instruction.
The parameter to INT is the software interrupt vector number, which will be the interrupt called.
You will need to use the IRET instruction to return from interrupts.
It's likely you should also disable interrupts as the first thing you do when entering an interrupt.
For further detail, you should refer to the documentation for your specific processor model, it tends to vary widely.
Comment: This describes the 8086, not the 8080.
Answer: An interrupt is a way of interrupting the cpu with a notification to handle something else, I am not certain of the Intel 8080 chip, but from my experience, the best way to describe an interrupt is this:
The CS:IP (Code Segment:Instruction Pointer) is on this instruction at memory address 0x0000:0020, as an example for the sake of explaining it using the Intel 8086 instructions, the assembler is gibberish and has no real meaning...the instructions are imaginative

0x0000:001C   MOV AH, 07
0x0000:001D   CMP AH, 0
0x0000:001E   JNZ 0x0020
0x0000:001F   MOV BX, 20
0x0000:0020   MOV CH, 10   ; CS:IP is pointing here
0x0000:0021   INT 0x15

When the CS:IP points to the next line and an INTerrupt 15 hexadecimal is issued, this is what happens, the CPU pushes the registers and flags onto the stack and then execute code at 0x1000:0100, which services the INT 15 as an example

0x1000:0100   PUSH AX
0x1000:0101   PUSH BX
0x1000:0102   PUSH CX
0x1000:0103   PUSH DX
0x1000:0104   PUSHF
0x1000:0105   MOV ES, CS
0x1000:0106   INC AX
0x1000:0107   ....
0x1000:014B   IRET

Then when the CS:IP hits on the instruction 0x1000:014B, an IRET (Interrupt RETurn), which pops off ALL registers and restore the state, is issued and when it gets executed the CPU's CS:IP points back to here, after the instruction at 0x0000:0021.

0x0000:0022   CMP AX, 0
0x0000:0023   ....

How the CPU knows where to jump to a particular offset is based on the Interrupt Vector table, this interrupt vector table is set by the BIOS at a particular location in the BIOS, it would look like this:

INT    BIOS's LOCATION OF INSTRUCTION POINTER
---    --------------------------------------
0      0x3000
1      0x2000
..      ....
15     0x1000    <--- THIS IS HOW THE CPU KNOWS WHERE TO JUMP TO

That table is stored in the BIOS and when the INT 15 is executed, the BIOS, will reroute the CS:IP to the location in the BIOS to execute the service code that handles the interrupt.
Back in the old days, under Turbo C, there was a means to override the interrupt vector table routines with your own interrupt handling functions using the functions setvect and getvect in which the actual interrupt handlers were re-routed to your own code.
I hope I have explained it well enough, ok, it is not Intel 8080, but that is my understanding, and would be sure the concept is the same for that chip as the Intel x86 family of chips came from that.
Comment: this is for the 8086, not the 080


Is there more money in pockets or in banks?

Question: In America, or the world at large, is there more money in people's pockets---i.e., not within banks or institutions, etc.---or in banks or institutions, etc? Provide evidence and reasoning.
Comment: How on earth is this a question even remotely related to _personal_ finance?
Answer: In banks and institutions where you could look at the money supply of M1 which is the physical currency in circulation compared to M2 which would be all the deposits that tend to be valued much more. http://www.federalreserve.gov/releases/h6/current/ would be the link where as of Nov. 2014 the figures are
M1 - 2,849.8
M2 - 11,588.7
Footnotes from that:

M1 consists of (1) currency outside the U.S. Treasury, Federal Reserve
Banks, and the vaults of depository institutions; (2) traveler's
checks of nonbank issuers; (3) demand deposits at commercial banks
(excluding those amounts held by depository institutions, the U.S.
government, and foreign banks and official institutions) less cash
items in the process of collection and Federal Reserve float; and (4)
other checkable deposits (OCDs), consisting of negotiable order of
withdrawal (NOW) and automatic transfer service (ATS) accounts at
depository institutions, credit union share draft accounts, and demand
deposits at thrift institutions. Seasonally adjusted M1 is constructed
by summing currency, traveler's checks, demand deposits, and OCDs,
each seasonally adjusted separately.
M2 consists of M1 plus (1)
savings deposits (including money market deposit accounts); (2)
small-denomination time deposits (time deposits in amounts of less
than $100,000), less individual retirement account (IRA) and Keogh
balances at depository institutions; and (3) balances in retail money
market mutual funds, less IRA and Keogh balances at money market
mutual funds. Seasonally adjusted M2 is constructed by summing savings
deposits, small-denomination time deposits, and retail money funds,
each seasonally adjusted separately, and adding this result to
seasonally adjusted M1.

Where M1 sounds like the physical money outside the banks and M2 is the money inside the banks. Did you mean something more specific here?
http://en.wikipedia.org/wiki/Gross_domestic_product would be a link about GDP in terms of economic output that has more than a few pieces to it that I'm sure whole courses in college are devoted to understanding this measurement.
Comment: So we're talking 33% or about 1/3 is out and about. What can be said about this "out and about" metric; that is, vis-a-vis the nation's economy.
Comment: The economy of a nation is usually measured in GDP and wouldn't be what I'd consider money since the same dollar could be recycled over numerous transactions, e.g. the dollar I give to McDonald's for dinner that is used to pay an employee that gets used at a store to another employee and so on and so on.
Comment: I'm sure that this metric varies across nations. What could be said at all about it---as far as variability goes?


Samsung Galaxy note 3 SM-N9005 cannot boot due to Power down

Question: I have Samsung galaxy note 3 SM-N9005 and I wanted to make hard reset but I accidental did Power down. And now, my phone does not fully switch on. When I turn on the phone it stops at the Samsung sign. I waited for several minutes but nothing further happened.
Comment: Not sure if Galaxt note 3 comes with an unlocked bootloader by default, but try booting into Recovery, and doing something like a re-install (stock recovery should do in that case). You could technically go to download mode and install a custom recovery, but that voids warranty
Comment: when I switch on Adroid system recovery it offers me:
1.reboot system now
2.apply update from ADB
3.APPLY UPDATE FROM EXTERNAL SORAGE 4.apply update from cache 5.wipe data/factory reset 6.wipe cache partition 7.reboot to bootloader 8.Power down 9.voew recoveru logs 10.Enable cp logging 11.Disable cp logging
Comment: Did you mean you accidentally turned off the phone while doing hard reset?
Comment: I took the phone for repair and found out the  problem,they said that the need to reinstall the entire phone again.
Answer: The OP stated (in a comment),

I took the phone for repair and found out the problem, they said that they need to reinstall the entire phone again.


which is better for makeup videos and portrait; canon 50mm f/1.8 or a 55-200mm f/4.5-5.6 , and why?

Question: I make makeup videos for youtube and recently got the canon rebel T5i as well as the  50mm f/1.8 and 55-200mm f/4.5-5.6 lenses. I am not sure which is better for taking photos and which is better for video. I'll appreciate answers. Thank you.
Comment: Did you also get the EF-S 18-55mm kit lens?
Answer: Either lens will work for shooting still and cinema. I think the issue here is the glass and what you are trying to do. The 50mm lens is great for lower light situations, but you have to physically move the camera to change the field of view you are shooting. If the camera is sitting on a tripod, the 50mm is great.
The 55-200/4.5-5.6 zoom lens is going to be better for outside use. The aperture is really small on this lens, so inside shooting quality is going to be much lower. Plus this is a 200mm telephoto, so unless you are zooming on small parts, this is not real useful.
I personally like using a 28-105 zoom lens as my general purpose lens. I would also get the largest aperture I can afford. If you can find a used or budget f/2.8-4.0 I think you would be much happier with the results.
I would go to the local camera store and try them out before buying.
Comment: Good answer. I would like to add though, that I think she already owns both lenses. And for me personally, I'd recommend the 50mm 1.8 for Makeup videos, due to the fact that you'll get more light, as well as the possibility to get rid of nonsense that goes on in the background, with the shallow depth of field that f/1.8 gives you. Be careful though, with f/1.8, keeping focus will be more of a challange if you're on your feet.


What is the difference between complete statistics and complete family of distributions?

Question: I fail to understand when we call a family of distribution is complete and when a statistic is complete. What is the difference between both?, Is there a relation between them? Please provide examples along with your answer.
Answer: Suppose $X_1,\ldots,X_n \sim \text{i.i.d. } N(\mu,\sigma^2).$
The family of distributions is $$\left\{ N_n\left(\begin{bmatrix} \mu \\ \vdots \\  \mu \end{bmatrix},\sigma^2 \begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{bmatrix}\right) \quad : \quad \mu\in \mathbb R \right\}$$ (so $\sigma$ is fixed, so that the only difference between one distribution and another in this family is a different value of $\mu$). This is the family of $n$-dimensional normal distributions in which the expected value is that column of $\mu$s and the matrix of covariances is $\sigma^2$ times the $n\times n$ identity matrix. This family of distributions of $n$-tuples is not complete since it admits nontrivial unbiased estimators of $0$; for example $X_1-X_2$ is such an estimator.
Now suppose $T = T(X_1,\ldots,X_n) = X_1+\cdots+X_n.$ It follows that $T\sim N(n\mu,n\sigma^2).$ The family of distributions of $T$ is $\{ N(n\mu,n\sigma^2) : \mu \in\mathbb R\},$ so again $\sigma$ is fixed, so the difference between two members of this family is a different value of $\mu$. This family is complete since it admits no nontrivial unbiased estimators of $0$. The fact that this family of distributions is complete is also expressed by saying that the statistic $T$ is complete. Any time you define a statistic that is a function of $(X_1,\ldots,X_n),$ having already defined a family of distributions for that $n$-tuple, that definition induces another family of distributions for the statistic you have defined. To say that that statistic is complete merely means that that induced family of distributions is complete.
Comment: I was having a note in which there was an example on whether the family of Bernoulli distribution with parameter  p is complete or not. In notes the solution started by taking n sample points from Bernoulli distribution and a statistic T was defined as T=X1+X2+...+Xn, then T follows binomial distribution with n trials and parameter p. Then it worked out and checked for the completeness of T and at last it concluded that since T is a complete statistics so family of Bernoulli distribution with parameter p is also complete.
I think this conclusion is wrong. Am I right?


What is the difference between \relax and {}?

Question: As I understand it, the point of \relax is to stop a macro from swallowing up subsequent material (such as whitespace). But {} (\bgroup\egroup) serves the same function. Why do we need both?
Comment: Try starting TeX from the terminal without any file name and type `{}` at the `**` prompt you get. ;-) Kill the process and retry typing `\relax`, this time. :)
Answer: It's hard to answer the question as the two constructs are different in almost all respects so it's a matter of where to start.
\relax is a single token, an unexpandable TeX primitive that does nothing when executed.
 {} is two tokens which (assuming the standard catcodes) mark a TeX group or non delimited macro argument.

\baselineskip =13pt\relax the \relax stops the length parser looking ahead for plus and minus components, but does nothing else. \baselineskip =13pt{} would define baselineskip the same way but then open and close a group which could have several effects, most notably in math mode where it will generate an empty math atom and affect the spacing of surrounding atoms.
{\let\section\relax...\immediate\write\@auxout{..   \section}} makes a command such as \section locally inert and safe to write (as itself) to an auxiliary file. {\let\section{}...\immediate\write\@auxout{..   \section}} does something but is unlikely to do what anyone wants:-)
\relax is the definition given to a new control name generated by \csname  hence the common idiom \expandafter\ifx\csname foo\endcsname\relax to test if a macro is defined. This clearly has no analogue using {}
$a+{}$ produces infix spacing as the {} generates a mathord atom. $a+\relax$ is like $a+$ and not produce infix spacing for +.
Comment: Instead of saying that `\relax` "does nothing", might it be more informative to state that `\relax` tells TeX to "stop doing whatever you're doing right now (whatever 'whatever' may be)"? E.g., in the statement `\baselineskip =13pt\relax`, `\relax` tells TeX to stop scanning ahead for `plus` and `minus` items. That's not the same as "doing nothing", right?
Comment: @Mico I think the form that I gave is more correct. (although it was of course not the whole truth) `\relax` only stops scanning for a length as it's an unexpandable primitive that isn't part of a length, `X` or `\def` would do the same, it's just that unlike `\def` when it is re-evaluated after the length assignment has completed, it does nothing.
Comment: @Mico the bit that I didn't include in the above description is the use of `\relax` as __  in `\toks0 = \relax{aa}\showthe\toks0` `\relax` isn't playing the part of a general unexpandable token (as it is when it terminates a length) it is part of the syntax of a toks assignment and absorbed along with the `=` sign and white space so the token register gets the tokens `aa`. (I have never seen a case where this is useful, but still:-)
Answer: Try the following couple examples:
\documentclass{article}

\begin{document}

\[
\begin{array}{rl}
+9mm   & +9m^2 \\
[+9mm] & [+3m]^2 \\{}
+9mm   & +9m^2 \\{}
[+9mm] & [+3m]^2 \\\relax
+9mm   & +9m^2 \\\relax
[+9mm] & [+3m]^2
\end{array}
\]

\end{document}

If you leave there \\ alone, the [+9mm] is interpreted as an optional argument to \\ and transformed into a vertical space.
If you use {}, then it inserts an "empty thing" into the formula and the + is improperly spaced.
Only the variant with \relax works correctly here, because it really does nothing.

Very similar examples can be used to show that \relax is the correct terminator of \dimexpr and \numexpr expansion etc.
Comment: Thats not _my_ error, that's the StackExchange whatevet that eats backslashes. Sorry for that, but complain to them, not to me.
Comment: There is an error in your code, the first `\\` is just `\` so it doesn't compile... and could you explain why is there a small space between the + and 9? I don't get that part (I understands it inserts a 'nothing', but why does it appear there?)
Comment: I would make also this example: ```\[\relax-5\]``` and ```\[{}-5\]```. The 1st one prints just ```-5``` like a negative number. The 2nd one prints minus with a space like there is subtraction "empty string minus 5". So ```\relax``` really does nothing and ```{}``` makes an empty string and then does nothing like ```\relax```. I understand it in a way like this...
Answer: There is more than one reason.
I'll give an example where \relax is good and {} isn't:
\def\mysize{144pt\relax} % when expanding \mysize we won't trigger
                         % expansion of the next token
\hbox to \mysize{\hfil abc\hfil}

When TeX is processing the \hbox command, it expands the tokens after to in order to find the required <dimen>; it will find 144pt\relax and the syntax rules make this \relax disappear (in TeX's jargon it's a <filler>); with
\def\mysize{144pt{}}

TeX would find
\hbox to 144pt{}{\hfil abc\hfil}

which would be a disaster.
Of course one might as well define
\def\mysize{144pt }

but then \mysize could not be used in text without \unskip. A bit contrived example, perhaps.
In any case, \relax does really nothing, while {} opens and closes a group.
You mention \bgroup\egroup as equivalent to {}: it isn't; for instance, a macro with an argument that finds {} will absorb an empty argument, while \bgroup\egroup would absorb \bgroup as the argument, leaving \egroup in the stream. Again, if we use \relax it would be one token.


Making two classes work ambidextrously

Question: I've written some script in python following OOP guidelines. I've created two classes in my script in such a way so that both of them are able to make requests and produce flawless results. It can parse names, phone numbers and email addresses from yellowpage. I've already executed my script and found it working as I expected. Now it is able to parse the aforesaid category from any links from that site irrespective of how many pages it traverses. So far, I've used one class for making requests and the other for processing results. However, this time I intend to make a bridge between these two classes so that they can both be able to make requests and can do the same stuff if needed. I've tried my best to make a good class crawler. Any suggestions to make it more dynamic or improved will be highly appreciated.
from lxml import html
import requests

class web_parser:

    page_link = "https://www.yellowpages.com/search?search_terms=pizza&geo_location_terms=San%20Francisco%2C%20CA"
    main_url = "https://www.yellowpages.com"

    def __init__(self):
        self.direct_links = [self.page_link]
        self.vault = []

    def parser(self):
        for link in self.direct_links:
            self.get_link(link)
            self.processing_main_link(link)

    def processing_main_link(self, sub_links):
        page = requests.get(sub_links)
        tree = html.fromstring(page.text)
        page_links = tree.cssselect("div.pagination a")
        for page_link in page_links:
            if self.main_url + page_link.attrib["href"] not in self.direct_links:
                self.direct_links.append(self.main_url + page_link.attrib["href"])

    def get_link(self, url):
        page = requests.get(url)
        tree = html.fromstring(page.text)
        item_links = tree.cssselect('h2.n a:not([itemprop="name"]).business-name')
        for item_link in item_links:
            if self.main_url + item_link.attrib["href"] not in self.vault:
                self.vault.append(self.main_url + item_link.attrib["href"])

class get_docs(web_parser):

    def __init__(self):
        web_parser.__init__(self)

    def procuring_links(self):
        for link in self.vault:
            self.using_links(link)

    def using_links(self, newly_created_link):
        page = requests.get(newly_created_link)
        tree = html.fromstring(page.text)
        name = tree.cssselect('div.sales-info h1')[0]
        phone = tree.cssselect('p.phone')[0]
        try:
            email = tree.cssselect('div.business-card-footer a.email-business')[0].attrib["href"].replace("mailto:","")
        except IndexError:
            email = ""
        print(name.text, phone.text, email)

if __name__ == '__main__':

    crawl = get_docs()
    crawl.parser()
    crawl.procuring_links()

Answer:
Naming convention: classes should normally use PascalCase.
Requests best practices: if you want to use the requests library, you can see my answer about requests usage.
Speeding up your script:

Threading: you can use the threading standard library to get data from URLs and process that data.
Concurrent Futures: this approach exists from Python 3.2, there is a good example on the docs page. But you may have problems with using requests with the concurrent.futures library, so take a look at standard.
Scrapy: modern Python for scraping data from websites. It provides lots of built-in functionality: from scraping to storing results in a way you wish.

Logging: it is a good practice to use logging while doing any actions, e.g. scraping.
Exceptions: adding exception handlers is good practice. At the moment, if your script fails in any line, it stops all execution.

Making two classes work ambidextrously


VCS - Better way to change location than pushing to branch?

Question: I work from multiple locations quite frequently, and there's times (16:59 on a Friday for example) when I need to leave quickly with potentially unstable code. Right now I tend to commit and push the days work to my branch and work on it from home/elsewhere, but this feels a little dirty. Would others consider this acceptable? How else would you go about it?
Comment: Have you considered something like git flow, where the production branch is nearly never touched?
Answer: This is perfectly acceptible for me. In fact I've probably done this since I started using version control as I found it the most convenient way.. Other options like dropbox etc work but then you still have to wait for the sync and it does lead to conflicts sometimes which are a mess. I've even known people emailing themselves the temporary work, even messier.
I usually don't just push to the branch I'm working on though, but to a branch called work-in-progress for example: if you're in a hurry it's easy to just push all current changes to a branch as-is without having to properly lay out one or more commits with decent messages etc or without having to fix your messy commit afterwards.
Answer: There are two main reasons to use branches in a VCS:

To isolate unreleased features from each other and from released code. This is mainly what git flow is all about.
To share unfinished code with other developers without impacting the whole team. This is exactly your use-case, where you can read "other developers" as "myself sitting behind different computers".

So, yes, committing non-compiling, unfinished code to a branch is perfectly fine. The only consideration should be that others (including automated build setups) don't depend on that branch being stable/buildable.


Relationship between Alternating Least Squares and SVD

Question: I have been assuming that ALS is simply an alternative algorithm for doing matrix decomposition that is more efficient, but in the end produces the same $U$ & $V$ matrices that SVD does. Is this true?
Answer: Actually, ALS is generally less computationally efficient than directly computing the SVD solution, with some special cases.
An interesting results of the SVD decomposition is that one gets the complete nested set of low-rank approximations. So if you'd like a rank 5 approximation and a rank 10 approximation, you can just compute the full SVD, grab the top 5 components from that decomposition to form the rank 5 approximation with the lowest MSE and grab the top 10 components for the rank 10 approximation with the lowest MSE.
Meanwhile, ALS only gives you a single rank approximation. So if you wanted a rank 5 and rank 10 decomposition, you would need to run the ALS algorithm twice.
On the other hand, SVD requires that all entries of the matrix be observed. This is not the case for ALS. Similarly, ALS easily generalizes to higher order cases (i.e., tensors) while SVD does not.
Finally, resulting $U$ and $V$ between the two algorithms are not necessarily the same: for one, SVD results in $UDV^T$, while ALS results in only $UV^T$. What is true is that, assuming convergence to the global minimum by ALS, we should have that $UDV^T$ = $\tilde U \tilde V^T$, where $UDV^T$ is the SVD solution and $\tilde U \tilde V^T$ is the ALS solution.
In fact, there's no guarantees whatsoever about $\tilde U$ and $\tilde V$ as the solution from an ALS problem. Note that $( \tilde U \alpha) (\tilde V \alpha^{-1})^T$ = $\tilde U \tilde V^T$, which means that if $\tilde U \tilde V^T$ is the solution to an ALS problem, then so is $(\tilde U \alpha) (\tilde V \alpha^{-1})^T$. However, the constraints required for an SVD solution doesn't allow for this type of ambiguity.
Comment: Thanks! Two questions. First is could you cite a reference on this? Second question: if you were going to use U or V as latent features for, say, a classification problem, would the U and V from either model be expected to perform similarly? I guess what I'm asking essentially is whether one model or the other contains more information, say, holding the rank equal.
Comment: @thecity2: I'm afraid I don't have a reference for this; I just know it from the work I do. The ambiguity of $U$ and $V$ with ALS can be an issue in many cases, so it's not too uncommon to post-process $U$ in some method. In fact, you can just take the SVD of the $UV^T$ solution to impose structure. While at first that might seem like its pointless to use ALS in that case, it makes sense in the case of missing data: SVD can't give you the answer, but ALS can and you can then post process with SVD to impose structure on the solution.
Answer: A rank-1 solution by alternating least squares is a linear transformation of a rank-1 SVD.
A rank-2 solution by alternating least squares (WH) is related to SVD (UDV), where the second singular vector U_2 is a linear transformation of W_1 - W_2, similarly V_2 is a linear transformation of H_1 - H_2.
ALS is always the fastest method for solving a rank-2 SVD (based on my current work), significantly faster than lanczos bidiagonalization in irlba, for example.
At rank-3 the vectors in SVD and NMF are no longer directly relatable. This is because alternating least squares seeks factors that best describe the signal collectively, rather than SVD which seeks first one factor which best describes the signal, then an additional factor that describes the next most signal given the normalization of the first factor, and so on.
The above intuition immediately makes obvious how alternating least squares can be used to solve an SVD. We solve a k = 1 ALS solution, fix the first vector, randomly initialize a second vector, solve that vector while holding the first vector fixed by ALS, and repeat until reaching the desired rank. This works really well, in fact, it's less costly than Lanczos bidiagonalization (i.e. irlba) because it generally involves only 1-2 refinement iterations per rank addition.
The previously described intuition also highlights just how different SVD and ALS MF are in their objectives, and hence proper applications. They are not at all describing similar information. One way to think of SVD is that the first vector in SVD is a normalization of the data to a middle point, the second factor is a normalization of the data based on the preceding normalization, and so on. The result is that there are positive and negative vectors which account for prior local over- or under-normalization. Thus, the significance of an arbitrary nth vectors can only be determined given the preceding vectors and is not particularly intuitive. It is therefore useful for describing variance in signals, but not signals themselves, although it incidentally may extract recognizable signals at times.
Note that SVD solutions and ALS SVD solutions are linear transformations of one another, they describe the same relationships between data but are not on the same scale. In general, this is not a concern.
Because factors in NMF are dependent on one another during the alternating updates, it takes more alternating updates to converge on the minima. In SVD, because other factors are fixed with each update and there is only a single vector to be added, there are fewer alternating updates with each rank addition. Whether ALS MF or SVD is faster all depends on the condition of your dataset and the rank you're requiring.
As @Cliff AB pointed out, SVD is rank-indefinite, meaning you can run a 5-rank decomposition or a 10-rank decomposition and get the same first five vectors. This is attractive, but does not guarantee robustness between similar datasets. ALS MF does not have such a rank-definite guarantee, but in general can extract signals from two different datasets that are highly correlated. This means that cross-validation for rank determination is necessary for NMF, and in general for datasets with robust signal there will be a best rank. Now THIS is not fast, and so ALS MF, even if it's faster one-off than an SVD, becomes quite burdensome to do properly.


Batting right and left handed every alternate ball in cricket

Question: A switch hit is acceptable in cricket. But if a batsman wants to disturb the line of the bowler by playing right and left handed every alternate ball, would it be allowed.
Answer: There is nothing in the Laws of Cricket which explicitly prevents this, but I'd say that it very quickly becomes time wasting by the batting side and would be subject to the penalties detailed in Law 41.10.


How do I calculate prediction intervals for random forest predictions?

Question: In regression problems random forests yield a prediction for each case by averaging the results of each single tree in the forest. I would like to draw a 95% prediction interval around each prediction. There is a nice option interval="prediction" for the prediction method of linear models, but there's no such thing for random forests (at least in the R package randomForest). Can I presume that the casewise predictions of the single trees are normally distributed and apply the formula http://mathurl.com/bbvuvx9 or should I determine it by bootstrapping? If so, how can this be done?
Answer: I'm assuming you're talking about the continuous response case.  If so, I'd recommend the quantregForest package that layers on top of the basic randomForest package and gives conditional quantile predictions.  The documentation is quite good.  Instead of assuming a gaussian distribution, it build an empirical density function from the terminal nodes.
Comment: http://www.stats.ox.ac.uk/~meinshau/quantregforests.pdf describes the technique.
Comment: @Shea Parkes: I did not know this package, thanks for the hint.
Comment: @B_Miner: I already downloaded the pdf and shall dig into it... Certainly I'll come back with more questions ;-)
Answer: The ranger package supports quantile predictions and hence prediction intervals: predict(ranger_fit, type = "quantile", quantiles = c(0.025, 0.975)).


Sign actual current with mesh current for ac circuits

Question: Take a look at the following circuit, using mesh method, we can have the following two equations
$$
\begin{align}
(Z_1+Z_3) I_1 - Z_3I_2 &= V_1 \tag{1} \\
-Z_3 I_1 + (Z_2+Z_3)I_2 &= -V_2 \tag{2}
\end{align}
$$
where \$ Z_1=8,Z_2=j4,Z_3=-j2,V_1=40,V_2=j20 \$. Solving the two equations, I get \$ I_1=3+j4,I_2=-13-j4\$. Now how can I know that the mesh currents in the same/opposite directions of the actual currents that pass \$ V_1,V_2\$? For this circuit, we can see the actual currents direction by looking at the polarities of the sources but I'm asking in general. I need this for computing the power at each source.  In pure resistors circuits, obviously when the current is negative, it is opposite in direction with the actual current. The problem in ac circuits, current/voltage are complex numbers.
Comment: Doesn't matter...You can assume any direction and in the end up with a -ve sign for the computed current if your assumed direction was wrong.
Comment: I did. You assume it to be true only for 'Pure resistor' circuits. But it's true if it involves linear elements like capacitor and inductors as well.
Comment: @MituRaj, not sure if you've read my post properly.
Answer: Look at the following diagram:

simulate this circuit – Schematic created using CircuitLab
Above, I've labeled the polarities on the parts. The way I did this is to just "follow the current direction." The tail of the current is (+) and the head is (-). One way I remember reading about is that since a current through a dissipating device goes from the more positive end to the more negative end," you label the more positive end with (+), etc. If you examine the \$I_1\$ loop, you'll see that I followed this convention from the perspective of \$I_1\$. If you examine the \$I_2\$ loop, you'll see that I still followed this convention from the perspective of \$I_2\$, even when the signs disagree with the prior assignment made for \$I_1\$ (\$C_1\$ is the example, here.)
You found that \$I_1=3+4j\$ and that \$I_2=-13-4j\$. I agree with these.
It is easy to label two of the nodes, but the node (\$V_3\$) shared by \$R_1\$, \$L_1\$, and \$C_1\$ has to be computed. You can start from either end and work towards the middle.
For example, \$V_3=V_1-I_1\cdot R_1=40\:\text{V} -\left(3+4j\right)\:\text{A} \cdot 8\:\Omega=\left(16-32j\right)\:\text{V}\$.
Or, working it the other direction and noting the direction of the arrow on the diagram which is in the opposite direction so we must add the product term instead of subtracting it, find \$V_3=V_2+I_2\cdot L_1={+}20j\:\text{V} +\left(-13-4j\right)\:\text{A} \cdot 4j\:\Omega=\left(16-32j\right)\:\text{V}\$.
Same answer, either way.

Now for power.
I guess a general procedure is to use the voltage difference times the complex conjugate of the current for each component in the circuit. The voltage difference is found by subtracting the node voltage at the tip of the current arrow from the node voltage at the tail of the current arrow.

\$V_1\$: \$P_{V_1}=\Delta V_1\cdot I_1^{^*}=\left(0\:\text{V}-40\:\text{V}\right)\cdot \left(3-4j\right)\:\text{A}={-}120+160j\$.
\$V_2\$: \$P_{V_2}=\Delta V_2\cdot I_2^{^*}=\left(20j\:\text{V}-0\:\text{V}\right)\cdot \left(-13+4j\right)\:\text{A}={-}80-260j\$.
\$R_1\$: \$P_{R_1}=\Delta V_{R_1}\cdot I_1^{^*}=\left(40\:\text{V}-\left(16-32j\right)\:\text{V}\right)\cdot \left(3-4j\right)\:\text{A}=200+0j\$.
\$L_1\$: \$P_{L_1}=\Delta V_{L_1}\cdot I_2^{^*}=\left(\left(16-32j\right)\:\text{V}-20j\:\text{V}\right)\cdot \left(-13+4j\right)\:\text{A}=0+740j\$.
\$C_1\$: \$P_{C_1}=\Delta V_{C_1}\cdot \left(I_1-I_2\right)^{^*}=\left(\left(16-32j\right)\:\text{V}-0\:\text{V}\right)\cdot \left(16-8j\right):\text{A}=0-640j\$.

Tellegen's theorem says that the sum should always be zero:
$$\begin{align*}
{-}120&+160j
\\
{-}80&-260j
\\
200&+0j
\\
0&+740j
\\
0&-640j
\\\hline
0&+0j
\end{align*}$$
And so it is.

...but I'm asking in general

Asked and answered.
Answer: You already have the current coming out of the positive terminal of the source on the left-hand side, that is your \$I_1\$.
The current coming out of the positive terminal of your source on the right hand side is the negative of your \$I_2\$, thus \$13+j4\$.
You can just assume an element of your circuit is supplying power. The math will show you if it is absorbing from the circuit or providing to the circuit.
In the figure below you assume voltage, \$V\$, with polarity as shown and current, \$I\$, with direction as shown.  Then calculate complex power \$S=VI^*=P+jQ\$ from the actual values you found in your analysis.  As you see in Jonk's answer, your source may be providing or absorbing real power (\$P\$) and may be providing or absorbing reactive power (\$Q\$) from the circuit.
Comment: In my example, it is clear but I'm asking in general. For example, if we have multiple sources and impedances in series.
Comment: Hi @CroCo, it doesn't matter how complex the circuit.  The only complicating factor is the complex math - but same exact principles.  I've edited my answer to point out that in a circuit with complex elements (\$X_C, X_L\$) you use conjugate of current when calculating complex power \$S\$.  This same \$S=VI^*\$ holds true for a purely resistive circuit too, it just simplifies to \$VI\$ since complex term is zero and conjugation does nothing to the real part.
Answer: For a two-terminal device the rule for computing the power absorbed by the device is always:

simulate this circuit – Schematic created using CircuitLab
It turns out that for passive components (resistors, capacitors, inductors) the direction that you choose for the current arrow doesn't matter. That is, the formula you use won't change if you decide solve the problem with current arrow in the opposite direction.
However, for voltage sources you may have to use the negative of the voltage depending on which direction the current arrow is pointing relative to the voltage polarity. For instance, both of the following describe exactly the same situation but in the second case the A and B points are flipped because the current orientation has changed:

simulate this circuit
Note that we are calculating the power absorbed by the voltage source.
Comment: Not sure if you're addressing my problem. I'm not having a problem with power formula, the problem with detecting whether the source is absorbing or supplying energy based on the direction of current. This is obviously based on the sign convention.  In my example, both sources are supplying power to the circuit (i.e. negative values).


How to keep a process from running?

Question: I can kill a process. But how do I keep that process from being called up again without removing it from Linux? For example, if I run something like netstat to find the port associated with the process, then kill it I will see it again running with a different PID in just a few seconds.
Answer: Change its execute permission bits. As root, use the command:
chmod a-x path_to_process_binary

This basically denies execute permission to owner, group and others (as a = all).
This simple trick will prevent the process from running, but I believe you might have something more serious going on in your system.
If you actually need to run it yourself, check this answer.
Comment: Please note that if you're chmoding with -a a file that is part of an RPM/DEB package, you will probably lose your modifications when the package receives an update.
Answer: Maybe it's a bit too much, but probably the safest way would be to use AppArmor or SELINUX to block the execution of the binary. Modifying the file permissions will work until the package that provides that binary is updated (then, it will be set as executable again when updated).
In the other hand, if you're trying to protect an entire partition so that nothing can be directly executed in it (example, protect /var or /tmp so that nobody can unpack and execute binaries in that directories), you can mount the partitions with the "noexec" options flag:
root@server: ~ # grep noexec /etc/fstab
/dev/sda6    /tmp   ext4   defaults,noexec,nosuid,nodev  1 1

This way:
root@server: /tmp # cp /usr/bin/vim .
root@server: /tmp # ./vim
-bash: ./vim: Permission denied

Note that shell scripts can still be executed as /bin/sh /tmp/myscript.sh, but not directly with ./myscript.sh.
The "noexec" flag is useful for webservers, because you can avoid some attacks based on downloading, compiling and executing binaries from vulnerable PHP or CGI-based sites.

How to keep a process from running?


Given a mean and standard deviation how to find sample size?

Question: Given a mean of $5.60$ and a standard deviation of $0.13$ is there a way of finding out how many individual values produced this mean and what those values were?
Comment: Impossible, no.
Comment: Start with the mean of $56.0$.  That could come from $56/1, 560/10, 5600/100$ and many more. Knowing the SD too doesn't help determine between those possibilities,  and vice versa.
Comment: @Nickcox how about if we know that there were 2 values. Can we find those values then?
Comment: @MichaelMunta are you asking now if it's possible to determine the sampled values given that you had a sample size of 2 with a mean of 5.6 and a standard deviation of 0.13?
Comment: @jros yes, that is what I'm asking.
Answer: If you know there are two values, then you can figure out what they are.
$$
\bar x = \dfrac{1}{n}\sum_{i=1}^nx_i = \dfrac{1}{2}\big(x_1 + x_2\big)\\
s^2 = \dfrac{1}{n-1}\sum_{i = 1}^n\big(x_i - \bar x\big)^2 = (x_1 - \bar x)^2 + (x_2 - \bar x)^2
$$
Solve the system of equations. Wolfram Alpha gives two solutions, but the way of interpreting them is that the calculation does not know which value is $x_1$ (x) and which value is $x_2$ (y), and it is true that you do not know which value is which.
$$
x_1 = \dfrac{1}{2}\bigg(
2\bar x - \sqrt{2s^2}
\bigg)\\
x_2 = \dfrac{1}{2}\bigg(
2\bar x + \sqrt{2s^2}
\bigg)\\
$$
Let's do a quick check in software.
x1 <- 4
x2 <- 6
x <- sort(c(x1, x2))
xbar <- mean(c(x1, x2))
s2 <- var(c(x1, x2))
x1_solved <- (1/2) * (2*xbar - sqrt(2*s2))
x2_solved <- (1/2) * (2*xbar + sqrt(2*s2))
x_solved <- sort(c(x1_solved, x2_solved))
x == x_solved

This should reveal why it is problematic to figure out the original values from just the mean, standard deviation, and sample size, however. You wind up with two equations but more then two unknowns, so there are multiple solutions.
If you have two points where $\bar x = 5.6$ and $s = 0.13$, then you can apply my code to solve that the points are $5.50807611844575$ and $5.69192388155425$.
Comment: Let's make explicit that you are calculating the variance using sample size minus 1, hence just 1 here, so no division of the sum of squared deviations is needed.
Comment: In the case of numbers I provided, what would be the two values?
Comment: Your values have been edited into the answer, but it is important for you to understand how to use my code to calculate them. Are you able to get them on your own? // There's a wrinkle in this in that I assumed $0.13$ was the sample standard deviation. If that is, instead, the population standard deviation, do you see how to proceed? (You'll need to do some algebra, perhaps on Wolfram Alpha.)
Comment: @NickCox Good idea! // Michael, regarding not knowing which value is which, it also is true that we do not care which value is which. Do you see why?


How to make Adobe Reader the default PDF viewer in Winshell

Question: I am a Windows user. I use Winshell to edit Latex. In the Winshell toolbar, there is a magnifier sign labelled with PDF. When I click on it to view my document as PDF, it views it in GSView. I want to view it in Adobe Reader. I tried to set Adobe Reader as default program in my Windows Default Programs from the Control Panel, but this did not help. Can you help?
Comment: Well, you shouldn't use Acrobat Reader with LaTeX: it locks the pdf file, and when you recompile, you have to think of closing the .pdf first. The recommended viewer for Windows is SumatraPDF, which is ultra-light (4Mo, as opposed to Adobe's monster), ultra-fast, has a 64-bit version, does not lock pdfs, and has direct and inverse search capability.
Comment: Ok. How to make Winshell opens SumatraPDF instead of GSView. Because I have the same issue. I downloaded Sumatra and WinShell still uses GSView.
Answer: Go to the Options -> Program calls menu and select PDFView. In the exe -File fill form, select the path to SumatraPDF.exe, as in this image:

I don't know how to configure direct search for Winshell and SumatraPDF, but I think you must find the relevant information on the web.
For inverse search, there's an answer to this question.
Answer: For setting up WinShell for direct and inverse search, see the Winshell manual and the FAQ at WinShell's webside. This is direct cite from the web:

Sumatra PDF: Synchronization  « The setup is described in detail in
  the WinShell manual.
In short, please make sure, that the WinShell command line option for
  pdflatex looks like this:
-interaction=nonstopmode -synctex=-1 "%s.tex"

Now, please "browse..." in the WinShell options for pdfview for the
  sumatrapdf executable. The command line for pdfview will be set
  automatically.
In SumatraPDF... No settings at all which need to be changed
Now, in WinShell, press F10, F10, F11. SumtraPDF will open with your
  PDF.
In WinShell... If you move your text cursor to a specific position and
  press F11, SumtraPDF will jump to that specific position in the PDF
In SumatraPDF... If you double click your left mouse button somewhere
  in the text, WinShell will jump to that specific position in the tex
  file

The setup with Sumatra is described at page 12-13 in WinShell Manual. Remember to change the path to the program files to reflect the correct path on you computer:
-reuse-instance -inverse-search "\"C:\Program Files\WinShell\WinShell.exe\"     -c %f -l %l" "%s.pdf"

If you have installed WinShell in another path than C:\Program Files, change to where your winshell.exe is located.


How to get "Trace image to grease pencil" to work?

Question: The Problem
I have attempted to use the "Trace image to grease pencil" today and it seems to only return a black square for me, despite the image I want to trace not being a black square.
It seems like it's just not finding the image I want to sketch and is just returning a black nothingness, but I cannot see where I am going wrong as I have the image selected when applying this conversion.
It also a pretty simple feature to understand from some youtube videos, such as this one https://www.youtube.com/watch?v=yz7EZShDvq8&t=37s&ab_channel=StevenScott, as well the blender documentation for this. For which I have followed the very simple instructions to the dot.
Example of problem
I am using a pretty basic image as a test for this, it's a very simple black and white UFO type sketch. When I add this image and then attempt to use the conversion feature "Trace image to grease pencil", the black square arrives as you will see in the pictures below.

And here it famously is, the black square

Things I have attempted

I have attempted to use the same image with a transparent background, black square
I have attempted to use different image types such as png or jpg, black square
I have attempted to use different images, colourful images, detailed etc. Black square
I have attempted to change the image from a reference image to a background image, black square
I have fiddled with the trace image to grease pencil options window with every combination of settings that can be possibly imagined, black square

Maybe there is an issue here, or it could be that I'm missing something extremely obvious. Though the steps are quite simply to add an image to the scene and then apply this "Trace image to grease pencil" conversion.
Either way any pointers would be a great help
Comment: I had the same issue...I opened the image in affinity designer the resaved it as png...whole document no transparency....then traced it again in blender!...some images will just not work ..
Answer: In  *Trace Image to Grease Pencil * change the Turn Policy from Black to  White.
Answer: I got the answer, when you add the image, please choose the image as background, it will work.


Why was Amy not arrested?

Question: In Gone Girl, Detective Rhonda Boney knows that Amy has killed Desi deliberately. But still just because they are unable to find any clue they let her go. That is no justice in my opinion. If she believes that Amy killed Desi and tried to frame Nick for her disappearance then it is sufficient enough for FBI to investigate her case more closely. I mean its a murder not some robbery.
Comment: Also absurd that they wouldnt follow up after they almost arrested the wrong guy for murder. I mean I am pretty sure professional homicide detectives would recognize in hindsight that all the original clues had been supplied by Amy, and that pride would compel them to investigate her thoroughly.
Comment: @Shiz thats my point.
Comment: It was not so difficult to investigate.
Answer: First up, just to get it out of way, the FBI was never involved. The detectives were probably from the local PD. Now, back to the question of implicating Amy for the murder of Desi.
Even though Amy came clean with Nick and told him about killing Desi, there just wasn't any evidence for an investigation against Amy. The CCTV footage from Desi's lake house, the bruising that she gave herself, all were consistent with rape, abuse and unlawful confinement. She had brilliantly orchestrated and disguised the murder as her self-defence and escape, making the entire thing more or less an air-tight case in her favour. And whatever little doubt that people like Detective Boney had, was swept under the tide of emotions surrounding the abduction and subsequent homecoming of Amy. So much so that when Detective Boney tried to prod her on the weak links in her story, she was promptly snubbed by her senior.
There was no opening to force an investigation on Amy. And yes, there was no justice for Nick or Desi.
Comment: I've to agree with @NapoleonWilson, you can't accept every single movie to have a perfect happy ending which would make it completely predictable and boring. In the gone-girl universe Amy was a very famous celebrity and to make a case against her would be really stupid unless he had evidence of Amy's confession which clearly he didn't.
Comment: Technically no, fictitiously yes!
Comment: The whole movie was perfect until it is revealed that she gets  away with it so easily for everything she did.
Comment: @FaizanRabbani Haha, and that's unrealistic for you? I don't get it. Yes, she fooled them all, so what? Is it so hard to accept that the system has simply been outmaneuvered by *Amy*? Now I've seen people call stuff plot-inconsistencies, but that's a new record. ;-) But to each his own, of course.
Comment: Which technically means a woman clearly fooled all law enforcements. Nice to hear that. At this point it can be easily concluded that there are weak links enough for woman like Amy to exploit it so easily (Not once or twice but four times). Quite ridiculous.
Comment: In my opinion this movie narrows the gap between fiction and reality. :)
Comment: Yes it is hard to believe because it is simply not possible in today's world. Call it 17-18th century I might have actually believed this story.
Comment: To be clear, the FBI absolutely gets involved. They can be seen in the room after Amy returns and she's providing her story in the hospital. Additionally, detective Boney states that the case is being handled at the federal level close to the end of the movie.
Answer: The police not looking into the murder of Desi whatsoever actually made no sense whatsoever. I understand there were emotions, and KeyBrd's answer makes sense to a degree, but it completely falls apart due to the fact that tape footage does not add up to her orchestrated story at all. Like not even a little bit.

The footage of her entering Desi's house was WAY after her disappearance. 5 days, 2 weeks? I forget exactly, but her claim that he took her directly to his house and tied her up falls apart. Or at the very least there is no evidence.
She found out about the cameras and the recordings a little late. The existing footage of her entering Desi's house is 100% voluntary, as is any of her initial wanderings around his house. Pretty sure there's also footage of them eating ice cream together.
There absolutely had to have been bulletproof footage of Desi entering/leaving HIS OWN house THE NIGHT/DAY of Amy's disappearance. At the very least there had to have been a mad count of 100% bulletproof alibis of him being present wherever else (work, meetings, friends, family, etc etc etc) for a full week or two, during which he should have been busy kidnapping and raping her. Amy also specifically testified that HE (Desi) came over and kidnapped her, not someone "working for him" in case Desi's presence elsewhere could be negated in that manner -- now it can't.

Just trying to make a point that that last piece of the movie was taking the whole "hot girl tricks police" to a completely fictional level. Emotions and a nice ass go a distance, but looking at camera footage and checking for an alibi of a victim in a MURDER CASE is simple routine. It's just something police would do; they wouldn't "take your word for it." And when they did, there would be a case. Maybe she wouldn't go to prison for it by looking sad and innocent to the jury, but there would BE a case.
Comment: But that does not answer the question being asked here.
Answer: I think this is simply a weak point in the plot the movie makers accepted in order to tell the ending as it is. I totally agree with you that police/ FBI or other would investigate about the death of Desi and they surely would find inconsistencies in Amy`s version. Some of them are listed in the answer of Max A.
Personally I dislike inconsistencies but here I think they have their purpose in this story. Besides, the movie already has shown so many details how Amy plans her plausible fake story's. The movie makera could have also added more details on how Amy fakes her claims about Desi but then the movie would last another half hour longer. Therefore, in this case I simply accept the not very plasible killing with no investigation as it is.
Answer: The first and second halves of the movie were radically different.
The first half of the movie was perfectly logical and plausible. But the second half (after the big reveal that this was simply Amy's plot) was magical and fantastical.
This "first half logical, second half magical" split is very similar to that in Fight Club. Which makes sense, given that both Gone Girl and Fight Club were directed by the same guy: David Fincher.
So to answer your question: In the second magical half of the movie, Amy could simply do pretty much anything she wanted and get away with it. This included murder, artificially inseminating herself with her husband's sperm, and continuing to live happily ever after with a husband whom she tried to frame with murder. I don't think any of this was meant to be logical/believable/plausible.
Note: I haven't read the book and I don't know if the book has a similar thing, or if this was added by Fincher.

Why was Amy not arrested?


Visualize error logs from winston (node.js)

Question: [Update] It looks like there's Cubism which can use graphite as a source. It would be really nice if there was a project out there that uses mongo as a source.
I am using winston (node.js package) to do logging to a mongodb data store. What is a good tool to visualize mongodb data? The recommendations on mongo's website are include pentaho which is very enterprisey. I've seen Cube float around, but it doesn't seem to be what I need; I need a visualization tool so I can see counts of specific errors (stored in mongo) be updated every few minutes. Essentially what splunk does, but one that works with mongodb and is free.
Answer: Albeit limited, there is a free version of http://www.mongovue.com - I think it's Windows only though.


Not able to find peers to publish with. Will publishing alone affect the credibility of the paper?

Question: I am a Master's student, and I'm nearly done with my first paper draft. Although the paper I am currently working on will be published with my advisor, I want to work in research areas that my advisor is not interested in. I can publish on my own but most papers I have reviewed have multiple authors. Will submission of a paper with only my name on it affect the chances of the paper being accepted? How can I go about finding like-minded people to work with?
Comment: If you do succeed in publishing a single-author paper, this will be more impressive to future recruiters than a multiple-authors paper, so this may be worth the effort.
Answer:
Will submission of a paper with only my name on it affect the chances of the paper being accepted?

No.  Reputable journals do not intentionally make publication decisions based on who the author(s) are.
That said, getting feedback from colleagues can help you improve your work before you submit it.
Comment: *Reputable journals do not intentionally make publication decisions based on who the author(s) are.* That's what everyone wants to believe, but is not true in general. Most of the time it's subconscious bias, but there are even some journals that make it explicit that they're considering the author's identity, e.g. PNAS.
Comment: @Allure You may have missed the word "intentionally."  PNAS may be an exception, I haven't published there.
Comment: https://www.pnas.org/page/authors/journal-policies "A member of the National Academy of Sciences may contribute up to 4 of her or his own manuscripts for publication in PNAS each year ..." which isn't skipping peer review, but is a fast track. Also, there are definitely papers for which the editor thinks "I'm not sure about this, but if [big name scientist] is willing to put his/her name on this paper I'll err on the side of publication". Schon scandal papers are an example, the recent LB-1 paper probably falls into this category as well.


Design my Windows Store App in Portrait even when the device is tilted to Landscape

Question: I am a Windows Phone developer and just started with Windows Store Apps. I want my app to only work in Portrait Mode even when the device is tilted to Landscape (I don't want the app to change to landscape mode). How can I set my Windows Store app up to accomplish this?
Answer: In the app manifest, you can set the supported rotations:

That said you may have an issue in certification as a result, since snapped mode is a requirement.  Snapped mode applies to landscape orientation, so it would seem to be something you wouldn't need to do, but as this thread suggests, you may have an issue.  A possible workaround would be to provide a nominal landscape view that simply says the app runs only in portrait mode, but I would heavily document your rationale for supporting only portrait in the "Notes to Testers" when you submit your app to the store.
Comment: correct, it won't work in the simulator because the mechanism relies on the accelerometer on the device to indicate the orientation change.  There's more additional information in [this blog post](http://blogs.msdn.com/b/visualstudio/archive/2011/11/04/microsoft-windows-simulator-rotation-and-resolution-emulation.aspx) if you're keen on having it work in the simulator, but you'll be fine on the actual device.
Comment: Its not working in the simulator.While changing the orientation on simulator the App also changing its Orientations.Plz give a piece of code to set my application in Potrait mode default even the orientation changes in the device or simulator.