Handling missing data in logistic regression

Question: I'm trying to do logistic regression, but I can't seem to get the results I want. I have 6 columns of data (one dependent and 5 independent binary variables) and about 100 rows. The problem with my dataset is that I have a lot of missing ness in the data (NA's) which I think is the reason why I can't do the regression. Is there any way to tackle the situation? I think removing the rows with NA's in them not a good idea because ill have very less data left.
Comment: 100 observations in logistic regression is very little, not expect to much! Also, this is a FAQ: https://stats.stackexchange.com/questions/108686/how-to-cope-with-missing-data-in-logistic-regression https://stats.stackexchange.com/questions/448523/how-to-deal-with-missing-data-in-logistic-regression https://stats.stackexchange.com/questions/322229/missing-data-in-a-logistic-regression-analysis https://stats.stackexchange.com/questions/176327/safe-to-include-high-missing-percentage-variables
Comment: Please consider marking one of the answers as the accepted answer.
Answer: Even with only 100 observations, then assuming that the data are missing at random or missing completely at random, it is likely that a pricipled approach to missing data such as multiple imputation will provide much better resuts that removing rows/columns or any kind of single value imputation. The general approach to multiple imputation is:

create several complete datasets, let's say $m$, using whatever multiple imputation alogorithm you choose. A common rule of thumb is that you set $m$ to be the average percentage of missing values in the dataset.

perform the glm model on each complete dataset. That is, you would run $m$ models.

pool the results of the analyses. With a glm regression model you would simply average all the estimates of interest to find the pooled estimate and use Rubin's rules, which incorporate uncertainty both within, and between, imputations to compute standard errors.
Answer: Without much more information we can't give you guaranteed advice here.

You can remove rows of data. However, this will cause problems if they are not randomly missing. For instance, the fact that they are missing may indicate something about them (such as they are not an engaged customer).
You can impute values if you have a means to do so.
You can remove columns of data with missing values.
You can bin your data. Example: Answer1, Answer2, MissingValue.
Other.
You can determine that you do not have enough data in the sample to adequately represent the population you are trying to estimate and you can go get more data.


"Reducing degeneracies of/from/in FKK transmitter"

Question: As stated in the title, I'm trying to get correct preposition — of/from/in. The sentence corresponds to the title of my work that addresses degeneracies that occur in FKK transmitter. However, this "in" somehow does not sound correct, and I just wanted to consult someone, since this is a title, and should be correct. I suppose that "from" would work, right?
Comment: The answer depends much on why you suppose "'*in*' somehow does not sound correct" and "'*from*' would work."
Answer: Your title has problems other than  preposition selection; but with or without those problems corrected, the preposition to use in the title is in. Neither of the other two is suitable.
Problems with the title "Reducing degeneracies in FKK transmitter" stem from lack of an article, or from use of singular rather than plural, or from incorrect reference to a transmitter instead of to its transfer function or response curve, or from degeneracies (specific instances of degeneracy) vs degeneracy in general.  Thus, one might write

Reducing degeneracy in FKK transmitters
  Reducing degeneracy in an FKK transmitter

but perhaps more properly (if I understand correctly) should say

Reducing degeneracy in FKK transmitter transfer functions


How to answer clients / supervisors when they ask "Are there any other errors?"

Question: In a scenario where it's near impossible / too difficult for me to guarantee that there will be no errors, how do I answer that question without making my clients/supervisors anxious?
Comment: Software with no errors hasn't been tested enough.
Comment: "From my knowledge"
Comment: I think you guys are missing Simon's point. If you don't find errors, you clearly didn't test.
Comment: @Simon It is impractical to test general purpose software 100%.  To do so would require having access to the combined resources of all the users of the software, and to test against every individual use case that they execute.
Comment: @Simon As a professional software QA, I can assure you **there's no such thing as bug-free code.**  Bugs aren't planned; nobody knows they're there until they're found out.  No matter how long you test it, all you can really say is "I haven't found any new bugs recently."  Even if you do somehow find all the bugs in your program, new ones can surface after *some other software* gets updated (like the OS, or a third party web source.)  When I say there's no such thing as bug-free, understand this isn't about being lazy or negligent in testing.  It's just not possible to be 100% sure, ever.
Comment: Almost every comment and answer assumes that the question is about computer software.  I find that amusing as there was no mention of software in the question or tags.  Maybe the OP is worried about misspellings in a client's restaurant menus.   ... But yeah, it's probably software.
Comment: Stability is a measure of velocity, not position. It is not whether you do not know about any new bugs, it is that bug reports are infrequent.
Answer: You find errors by testing. (Errors may be bugs, in software. Defects, or other labels, as appropriate, in other settings). You test by measuring fitness against requirements. You answer the question "are there errors?" based on results of testing against known requirements: It's equivalent to saying, "Does the work product do what we asked of it?"
I point that out, because it's a flat question at first (are there unresolved failed tests) but has an implication (did we define the requirements well enough to know what the end product is supposed to be).
The conclusion is, in order to answer the question, you need to know if you and the person(s) asking it agree on the requirements, first of all, and then you need to understand if your testing was thorough enough to inspire confidence.
Personally, when answering questions like this, I tie the answer back to the requirements where possible. Some equivalent "well, when I press this button, this is what happens, which matches what you asked for." This lets you demonstrate that you know the functional purpose for your work, and by repeating it out loud, it gives the other party a chance to reflect on how your work was defined.
Answer: You can never guarantee that there will be no errors. Based on the level of testing that has been done, you should have a general idea.
If it was tested thoroughly, you can tell them something like:

While it is impossible to say there are no errors, I am confident in
  the testing that was done. At this point in time, I have no reason
  to believe there are any more errors.

On the flip side, if there was not enough testing done, you can't really feel confident at all and you should be honest about that and tell them.
Comment: Years ago I had an epiphany when I saw a paper on software testing that plotted the discovery/fixing of bugs against time.  it was a wonderful asymptotic plot that initially rose steeply and then slowly flattened out as fewer and fewer bugs were discovered.  So from such a plot you could say that you are X% sure that bugs had been eliminated - but you could never say 100% sure.
Comment: @PeterM You can only know that you found and fixed X% of the bugs that your tester, or your test methods will ever find.
Answer: From my experience, you could say something like

We have tested the software, fixed the bugs we found and we think we have a very stable program.

Anyway, it's important to let know that there always be bug chances, and that is not possible to reproduce EVERY production situation, BUT immediately after that to ensure that you will be available to fix them if the occur, and that those bugs should not make the software unusable to them.
So, you can add something like

There's no way we can cover every possible situation that can happen in production, but we are sure that any bug won't stop you from working with the software. Also, if you have any problem you can report it, and we will try to find a solution and fix it as soon as possible. You can count on us for that.

So, with something like this, you make them feel that even if a bug appear they have someone to help them. Even if later you can't help them, the important thing here is to give them that feeling.


Is ChatGPT allowed for solving puzzles?

Question: My question got an answer that used ChatGPT but still got 22 upvotes. Is this usage allowed on Puzzling Stack Exchange?
Comment: Hi. Please don't keep updating the number of votes that answer got so far. It adds nothing valuable to the post, but unnecessarily bumps the question.
Comment: So, all the answers to your question used an online tool to solve it, and you do not like one of them because it has "ai" in the URL?
Comment: As someone who's been playing around with ChatGPT a bit, this definitely should be addressed early, and should be expanded to AI in general. We're going to see rapid improvements in AI very soon and it'll have a big impact on everything
Comment: Thanks. I would stop.
Comment: Really, please stop editing the question to change the number of votes. You could just do ">20" if the out-of-datedness bothers you.
Answer: Why ChatGPT and AI answers should be banned... mostly
It is my opinion that pasting an answer from an AI model should not be allowed in general as it goes against the spirit of puzzling.
(Note this is more general, I think the use of ChatGPT in the linked question is fine and would fall under 'exceptions' below)

Why AI answers go against the nature of PSE
When we boil it down, the true nature of this site is for users to create puzzles for others to solve. While the quickest answer is rewarded with a checkmark, the purpose of setting the puzzle is not to get the quickest answer, but to challenge another human being with your creation.
Using AI to solve a puzzle, and then just copying and pasting the answer, takes away all the human aspect of puzzling, and defies the purpose of setting the puzzle in the first place. Puzzle setters aren't trying to create something that is difficult for an AI to solve, but for another human.

Exceptions
It may sometime be appropriate to use AI to either help with, or indeed answer, a question. Not every question on PSE is a typical puzzle, and there are other question types where it would be completely appropriate to use AI.
Such examples might be the linked question, where the user is just looking for a list of answers to a problem, or where a user is stuck on a puzzle, such as a Sudoku or wooden block game, and can't find the next step, in which case it is already common practice to research how to help.
It may also be appropriate to use it for research, similar to how a normal search engine would be used, to help deduce a part of the puzzle. From my experience of ChatGPT, it already can give better and more useful information to certain questions than a normal google search.

How can we know?
At the end of the day, it won't be possible to know if AI has been used to solve the puzzle, so any ban won't be able to be enforced.
Stack Overflow have already banned ChatGPT answers for coding questions, more on the basis that it can generate wrong information, and the issue of enforcement has been brought up there too.
This is an issue that already affects PSE however, so there will be little difference. There is no way to know whether a user has 'cheated' to solve your puzzle, by using online tools or code to answer the question.

Does it matter too much?
Right now, AI will struggle to solve the majority of puzzles on the site anyway.
It is possible to potentially solve short letter and number games, but good luck asking it to approach the door...
AI will obviously see some major improvements, and its capabilities will increase drastically - but I still don't see it being able to solve a lot of the current puzzles on the site anyway.
There is also the fact that the vast majority of users wouldn't want to use AI to solve a puzzle anyway. They are here for fun, for a challenge, and at the end of the day cheating with AI for a couple of extra internet points is not really worth it.

A summary
AI answers should be banned, or at least heavily discouraged, unless it is an appropriate scenario. This won't be enforceable, but for the most part it won't need to be - few users will want to use it to cheat and it (at least currently) won't be capable of solving the majority of puzzles on the site.
Comment: @FranckDernoncourt yep pretty much. You have to bear in mind that PSE and SO are very very different sites - SO doesn't want wrong answers which is understandable and PSE just doesn't want people using computers to solve the puzzles for them. I think both are fair
Comment: The "challenging another human" aspect may not be all that relevant to the puzzle that's linked in the question. The question explicitly allows computer answers and the currently accepted answer is just typing a regex into a computer tool and looking at what output it gives.
Comment: SO banned ChatGPT on the basis that it can generate a wrong answer, and Puzzling SE banned ChatGPT on the basis that it can generate a correct answer.
Comment: @Jafe oh I completely agree for the linked question, should probably clarify that in the answer - this answers more general. The linked question IMO would fall under the exception category, as the question is just looking for a list of answers
Answer: Well I think if you couldn't use AI then using Google search is out. Also no auto correct for spelling or grammar. That doesn't seem reasonable.
What is the purpose? The fear is that it spoils it for other people. Surely that is already against the spirit if what we are doing here and there are other rules against it.
ChatGPT might challenge us to come up with more original puzzles as essentially all it does is mash together stuff it's already read.

Is ChatGPT allowed for solving puzzles?


What is the Mechanical advantage provided by mechanical disc brake caliper

Question: I'm designing a tricycle and I wish to put mechanical disc brake calipers but I only got leverage of brake lever, I'm also searching mechanical advantage/leverage  provided by mechanical brake caliper
Also please tell what is the piston diameter provided by major mechanical calipers in the market
Comment: Piston diameter for mechanical brakes?????
Comment: Welcome, I suggest taking the [tour] and recommend to generally ask just one question per post.
Answer: I assume that you're asking because you want to find mechanical disc brakes calipers that are compatible with your levers.
Generally, these brakes are simply marketed as MTB or road (also known as long-pull or short-pull). Typically long-pull levers are found on MTBs or bikes with flat handlebars and short-pull levers are on road bikes with drop handlebars. As long as the pull of the caliper matches that of the lever, it should work fine.
For example, Avid BB7s are available as MTB or road versions. The MTB version is long-pull and will work with any long pull lever. The road version is short pull and will work with any short-pull lever.


Is it When or where in this sentence?

Question: We all have a moment in our life where something happens and that change the course of our life.
Comment: "where" is fine.  When we think of life as a journey, then "where" evokes that sense of traveling along through life and so makes sense.  Nevertheless it's a somewhat idiosyncratic usage.
Comment: "A moment **when**... and that **changes**" etc.
Answer: As I'm sure everyone here is aware, Einstein told us that we're living in a four-dimensional, smooth, connected Lorentzian manifold called spacetime, a combination of three dimensions of what we perceive as volumes of space and one dimension of what we perceive as unidirectional time. Our perceptions lead us to consider a moment as a point in time and a place as a point in space. And the Ngram viewer backs this up: writers prefer moment when to moment where by about thirty to one.
But English does accommodate the Einsteinian notion of a moment as a place in a metaphorical sense, perhaps involving abstractions such as emotions and personal relationships. Here is an excerpt from Temporality in Life As Seen Through Literature about the work of Virginia Woolf:

Woolf also refers to moments of pain, whether it is the moment where the presence of someone does not mean anything for us, to that moment where it is suffering to recall the inadequate character of human relations....

(internal references removed)
Comment: +1.  As for smooth, are you ignoring gravity?
Comment: @ab2 Smooth in this context means infinitely differentiable. I find that one ignores gravity at one's peril.
Answer: "We all have a moment when something happens..." is correct because moment is a point in time, and when describes a point in time.
Where would describe a location, "We all have a place where we go..."

Is it When or where in this sentence?


My Gmail is lost and I can't find it anywhere

Question: I literally lost my Gmail account. When I go to Gmail, only my daughter's pops up and mine is nowhere to be found.
Answer: It sounds like you're sharing a browser and aren't using multiple accounts with Google Multi-Login.
If you want to continue sharing the browser:

Click your daughter's profile photo in the upper right
Click "Add Account"
Sign in to your account

Now you can switch between Google Accounts by clicking the profile photo and choosing the account you want to use.
If you don't with to continue sharing the browser:

Click your daughter's profile photo in the upper right
Click "Sign Out"
Sign in to your account

Now your account should be the only one logged in, so when you go to gmail.com your email should be available to you.
Comment: If both your accounts were showing as options to sign in at one point, then the browser's history (or at least cookies) were cleared causing the screen to default back to Google's original sign in screen, at which point your daughter would have signed in and stored the cookie to keep her account listed.  Besides sharing a browser with multi-login enabled, you may also want to consider having separate user accounts on the computer itself.


Shell Script to parse/retrieve a string found after another string/match

Question: The shell script will be passed a string of arguments. The position of the key/value I am looking to parse out may change over time, i.e. it may come before or after another key at any time so parsing between two keys wouldn't be an option.
I am looking to parse the domain key out of a string like this:
maxpark 0 maxsub n domain sample.foo maxlst n max_defer_fail_percentage user oli force no_cache_update 0 maxpop n maxaddon 0 locale en contactemail

The key would be "domain" the value would be "sample.foo". The domain key could have more than one '.' in it so I would need to grab the entire domain key.
I am not the best with regular expressions but I imagine using 'sed' is what I'm going to need to do.
I am accessing this full string using $*, if I could simply reference the key by accessing $DOMAIN that would be great, but since my only option is to access based on position, $3, and the position could change, that isn't an option
Answer: Solved the problem using PERL.
#!/usr/bin/perl -w

use strict;

my %OPTS = @ARGV;

open(FILE, "</var/named/$OPTS{'domain'}.db") || die "File not found";
my @lines = <FILE>;
close(FILE);

my @newlines;
foreach(@lines) {
   $_ =~ s/$LOCAL_IP/$PUBLIC_IP/g;
   push(@newlines,$_);
}

open(FILE, ">/var/named/$OPTS{'domain'}.db") || die "File not found";
print FILE @newlines;
close(FILE);

Answer: If you do have perl, just use this one-liner from your shell script.
domain=$( echo $* | perl -ne '/domain\s([^\s]+)\s/ and print "$1"' )

Or if you'd rather just do it with sed:
domain=$( echo $* | sed 's/.*\<domain \([^ ]\+\).*/\1/' )


Install VMware Tools on Cisco Virtual Wireless LAN Controller

Question: I was interested in installing VMware Tools on a Cisco vWLC (version 8.3.102). Is there anyway to access a Linux shell on the appliance, or would I have to do something hacky like mount the vmdk on another machine?
Comment: You can't install VMware tools in the WLC image.  If you can't get a shell you can't install the tools
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.
Answer: You'd probably have to do the later.  You'd need access to the underlying OS.  Since the way it operates I don't believe you actually need VMWare tools.  There isn't really any advantage to install it either.  If you need 10GB nics, look at VMware vsphere 6.0 and above.  10GB support is built in.
Comment: Yeah i've been trying. I've managed to modify the image, so long as the resultant image is smaller, and then pad the embedded gzip files with null bytes to make it the same size. The problem is that VMware tools pretty much doubles the size of the image. I havent been motivated enough to go through the kernel's source code to determine the offsets of the embedded file sizes. Instead I have a outstanding open source request with Cisco to get a copy of the kernel's source for the vWLC. Someday when I get it, i'll post a guide here.
Comment: @MuhFugen, "_I have a outstanding open source request with Cisco to get a copy of the kernel's source for the vWLC._" The Cisco code is a closed, proprietary application, and Cisco has successfully sued companies that have copied its code. They are not going to give you that.
Comment: @RonMaupin you may be surprised to find that when Cisco modifies and distributes a their copy of the Linux kernel, Cisco can be and *has been* sued if they refused to distribute the source code of the modifications.  It's a lovely consequence of GPLv2
Comment: @MikePennington, I'm aware of Cisco needing to give out the source of the Linux kernel that is used for some of the OSes, but people have been trying to sue to get the processes (e.g. IOS) run as an application on the kernel, but this has gone nowhere. You can get the source of the particular Linux kernel used, including Cisco modifications to the kernel, albeit with a lot of trouble in contravention of the GPL licensing, but the Cisco applications are still proprietary.
Comment: The WLC VM is  more than just an application


LLVM Issues with setting up a Function Pass - namespace issues

Question: I've been coming to this site off and on for a few years, and today I finally ask my first question.  I've been stuck for about a week on this, and am just not good enough at C++ (or have just gone in circles one too many times) to figure this out on my own.
I am using the LLVM compiler infrastructure, and am setting up a Function Pass.  I have done this all before, but I am trying to write it in such a way to enable AliasAnalysis, which has required me to restructure the pass.  This is where I'm getting stuck.
The pass calls upon a variety of methods and data structures located within 6 distinct files.  Each file corresponds to the contents of a struct listed in the header file.
The runOnFunction method for the pass is located in RelRecovery.cpp, the 'main' file for this pass, with other files providing supporting methods and data structures.  The issue is that I need to have the contents of RelRecovery spelled out in the header file so the other methods can use it, but doing so causes a previous definition of 'struct RelRecovery' error when I try to compile everything, since the struct is also defined within RelRecovery.cpp.
In addition, the macros I am using within RelRecovery.cpp to initialize my pass and allow it to use memory dependence profiling information are located at the very end of the file and call a pass-specific initialization method which I get an error of: 'void llvm::initializeRelRecoveryPass(llvm::PassRegistry&)' should have been declared inside 'llvm'.  When I modify the appropriate file in llvm and try to build, I get this error:
In file included from /x/grwright/llvm/llvm-2.9/tools/opt/opt.cpp:40:
/x/grwright/llvm/llvm-2.9/include/llvm/LinkAllPasses.h: In constructor '<unnamed>::ForcePassLinking::ForcePassLinking()':
/x/grwright/llvm/llvm-2.9/include/llvm/LinkAllPasses.h:152: error: 'createRelRecoveryPass' is not a member of 'llvm'

Here is a brief overview of how the project structure is laid out.
RelRecovery.h:
using namespace llvm;
//stuff
struct RelRecovery : public FunctionPass {
public:
  static char ID; // Pass identification, replacement for typeid
  RelRecovery() : FunctionPass(ID) {}

  virtual bool runOnFunction(Function &M);
  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
  virtual bool doInitialization(Module &M);

  //lots of statics for data structures, etc
};

struct RelTrace {
public:
  //struct variables and functions
  RelTrace();
};

//other structs here

RelRecovery.cpp:
using namespace llvm;
struct RelRecovery: public FunctionPass {
    static char ID;
    RelRecovery() : FunctionPass(ID){
            initializeRelRecoveryPass(*PassRegistry::getPassRegistry());
    }

    //global static variables
    //datastructures
    //methods
};
//static definitions such as:
double RelRecovery::totStaticInstrs = 0.0;

char RelRecovery::ID = 0;
FunctionPass *createRelRecoveryPass() {
    return new RelRecovery();
}

INITIALIZE_PASS_BEGIN(RelRecovery, "relRecovery", "...", false, false)
INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
INITIALIZE_PASS_END(RelRecovery, "relRecovery", "Reliability transformation for     lightweight recovery", false, false)

RelOTHER.cpp ...
//Constructors and methods and such...

So, while the LinkAppPasses.h file error is annoying, what I'd really like to solve first is this error:
RelRecovery.cpp:49: error: redefinition of 'struct RelRecovery'
/x/grwright/llvm/llvm-sfi/RelRecovery/include/RelRecovery.h:67: error: previous     definition of 'struct RelRecovery'

How do I maintain the proper functionality of my pass and all of its files while just defining struct RelRecovery in one place?  I realize I've likely made many, many, MANY stupid mistakes here, but I'm a hardware guy, and programming (especially C++) is not my strong suit.  Sorry, and thanks for the help!
Answer: This seems not to be related to LLVM in any way. You're definitely defining your class twice - one in .h and another one - inside .cpp.
So, inside .cpp you should provide out of line definition of all the methods declared in the .h. In your case for constructor it will be something like this:
RelRecovery::RelRecovery() : FunctionPass(ID) {
    initializeRelRecoveryPass(*PassRegistry::getPassRegistry());
}


Specific Shopping Cart Recommendations

Question: I'm trying to suggest a solution for a friend who owns an existing web shop.  The current solution isn't cutting it.
The new solution needs to have a few things that look like they're enterprise-only if I go with Magento, and $12k a year for a store with maybe $20k in stock just doesn't work.
The site should have items, which have one or more categories.  Each category may have a parent category.  Items have MSRP, and a discount rate by supplier, brand, and sometimes additional discount by product.
When a user buys something, it should automatically setup a shipping label with UPS or USPS, depending on user's choice, and build two invoices; one to go in the box, one to go into records.  This is crucial; it's low profit per item, so it needs to minimize labor here.
Need to be able to have sales (limited by time), discount codes/coupon codes.  Ideally would have private sales and/or members-only rates as well.
It needs a payment gateway; Paypal/GCheckout-only isn't going to fly.  Must be able to accept Visa/MC.
Suggestions?  I'm debating just building this myself in Java or PHP, but wanted to point my friend to a reasonable-cost solution that already exists if I can.  This all seems pretty straightforward to code, save working with the UPS/USPS/Visa/MC APIs, and doing CSS for it.
Comment: @Adam: Konakart wants $5k/year for Gift Certificates to be turned on, and I'm still digging to see how it works on the shipping end.  :-/
Comment: Yeah, that's expensive, and you need something sophisticated. More than http://www.opencart.com/ can handle?
Answer: You can suggest Magento shopping cart for your friend, It would be better and flexible to integrate it to any of the web server either in Linux or Unix
And, regarding the payment process i suggest you to integrate Sagepay.
please try this link...
http://www.sagepay.com/products_services/sage_pay_go/integration

Specific Shopping Cart Recommendations


Aligning shapefile to satellite imagery

Question: I have a line shapefile in ArcGIS 10.1 (road shapefile) in WGS datum but they are not exactly placed as in the Satellite image. Is there a way to adjust all those lines to places on Arial image?
Comment: Can you please supply more information such as what type of satellite data you are working with and how the vector data were derived?
Answer: Provided the Aerial Image is accurate to your project needs and you have re-projected the Line Shapefile to match the spatial reference of the Image, you can use the Spatial Adjustment Toolbar to get started with some semi-automated fixes to your line data.
Answer: Inacurracy is a way of life for the GIS professional. Depending on the source of your roads they could be many metres from their correct location; normally data comes with metadata which should contain a date and an approximate accuracy figure. For example 250k data will be mostly within 125 metres of its' correct location, conversely GPS tracklogs will usually be within 5 metres of the true location.
As the roads were probably drawn (digitized) from a different image at a different time or possibly even GPS recorded they will be different to what is on your satellite image, this is known as temporal change.
You have options:

Redraw the roads using the ones you've got as a reference (long time).

If you're sure the roads are accurate then transform the image to match your roads using GeoReference (not 100% match)

If you are sure the image is correct then warp the roads to match the image using Spatial adjustment toolbar (rubber sheet) (still not 100% match).

Accept that this is the way that it is and draw your roads with a thick line so map users can't tell that they're slightly off.

You have to make a decision based on how inaccurate the roads are, how much you trust each source and how much time/effort you are prepared to invest on getting the data to match.

Aligning shapefile to satellite imagery


Will emptying used coffee grounds into the sink drain damage my pipes?

Question: I've been using a French press and emptying the grounds into the sink afterwards The main reason for doing this is that I read somewhere that coffee grounds are a good way to deter pests like cockroaches. I figured washing the used grounds down the drain would keep them from setting up shop in the sink. It only recently occurred to me that this might not be such a good idea and I wanted to know from the more experienced coffee drinkers if I should stop doing this.
Answer: You don't need the advice of coffee drinkers, you need advice from a plumber (which I am admittedly not, but I have enough contacts in the industry) and a gardener to chime in.
In short: Don't do it.
Coffee grounds may smell nice and there is that persistent old wives' tale that will claim that it has [some random positive effect]. It's not true. Any plumber will tell you that it's best to pour nothing except liquids down the drains. Coffee grounds are particles that may

clump together
collect like sediment in traps
bind to other fatty residue
provide food to microorganisms that form that slimy and stinky biofilm in the pipes.

And yes, most plumbers will love you for the habit of washing down your grounds, because it keeps them in business.
Coffee grounds are lovely additions for compost, so either simply add them to your garden compost or treat them like you would any other plant-based kitchen waste.
Comment: You may not be a plumber but your advice is sound and I will heed it from here on out. Thank you.
Comment: I had read that it was good to put grounds down the drain because the grit helped break up deposits in the pipes. Today we had a $340 plumber bill of to snake out a long run of pipe after cutting out a section to gain access to it. It was totally blocked by an accumulation of coffee grounds that formed a solid plug (needed professional equipment to reach it and clear it). The plumber thanked me for the business, but offered the same advice as this answer. He said it's worse than putting sand down your pipes.
Comment: Consider making this thread faq to save people from bad Internet advice. I was going to post a self-answered question to share the experience, and this thread showed up in the similar questions.


Difference between fixed-to-variable length codes and variable-to-fixed length codes?

Question: I am a bit confused by the difference between the two. Can someone clarify the difference between the two?
Answer: A fixed-to-variable length code is a code that takes a string in $\cal X^*$, partitions it into chunks of fixed length $n$, and replaces each chunk $w$ by some codeword $C(w)$ whose length isn't fixed. The classical example is prefix codes. A prefix code such as Huffman's code replaces each symbol $\sigma \in \cal X$ by a codeword $C(\sigma)$, with the aim of minimizing $\mathbb{E}[|C(\sigma)|]$ with respect to some distribution on $\cal X$. We can obtain a better rate by applying Huffman coding on $k$-tuples of inputs. This corresponds to a fixed-to-variable length code that encodes each word $w$ of fixed length $k$ by a codeword $C(k)$.
A variable-to-fixed length code is a code that takes a string in $\cal X^*$, breaks it into pieces of variable length, and replaces each piece into a word of fixed length. The classical example is Lempel-Ziv encoding with fixed dictionary size. Lempel-Ziv breaks its input into chunks, where each chunk extends a word in the dictionary by one symbol. Each chunk is then encoded as an index into the dictionary together with the new symbol. The encoding thus has fixed length, but the chunks vary in length.
Comment: Thanks, that makes a lot of sense now. In a way, I will try to remember as follows: Fixed to variable, takes a fixed "chunk", and changes it a code word with variable length. Variable to fixed takes a variable "chunk", and changes it to a fixed code word with a fixed length.


Cohomology with compact support for coherent sheaves on a scheme

Question: Is there a notion (for schemes or just locally ringed spaces) of cohomology with compact support? I guess there is for algebraic schemes over $\mathbf{C}$, but what about schemes in general? Does anybody have a good reference?
Comment: If you really mean the word "coherent" in the title, then the answer is no. E.g., you would want a $j_!$ morphism for $j$ an open embedding, but one can see that there's no left adjoint to $j^*$ in this setting (since it would imply tensor products commute with infinite products).
Answer: Yes there is. Take $S$ a scheme and take $f \colon X \to S$ a compactifiable morphism of schemes. By definition this means that there exists a proper $S$-scheme Y which contains $X$ as an open subscheme. Then, given a compactification and a sheaf on $X$, you may define the cohomology with proper support of this sheaf as the cohomology of the pushforward of your sheaf to $Y$.
I think this works for many different cohomologies, but you need to check that the compact support cohomology does not depend on the chosen compactification. At least for etale sheaves I know this is so.
Answer: SGA 2 is the original reference. You can find it here
http://www.math.polytechnique.fr/~laszlo/sga2/sga2-smf.pdf
Answer: If X is a smooth scheme over complex numbers then you can consider $X_{an}$ as an complex analytic manifold and compute  singular/ deRham/ simplicial cohomology with compact supports (this will be different from usual cohomology if X is not proper)
On the Algebraic side there is etale cohomology with compact supports (which is defined by embedding X into a proper scheme...).
Comparison theorems tell you that etale cohomology with torsion coefficients agree with singular cohomology (with torsion coeff).
Any reference on etale cohomology will discuss this.
Ref:SGA 4.5, Milne: Etale Cohomology.
Comment: For a discussion of "Sheaf cohomology wih compact supports over any topological space" you may want to look up "Sheaf theory - Breadon" and " Sheaves in topology-A.Dimca".

It should be noted that: Etale cohomology with compact support requires the existence of proper embedding (one shows that result is independent of a chosen embedding), so it is not a straightforward generalization of
"Sheaf cohomology wih compact supports" to the etale site.


Allow multiple RDP sessions for specific users on a terminal server

Question: I know, that there's an option to allow all users to open multiple sessions to one terminal server. But is there also a way to allow it only for some specific users through Group Policies?
Answer: Yes, you can allow multiple sessions only to specific users using GPO in conjunction with Security Groups filtering.
You can create new or edit existing GPO to limit number of sessions per user.
I.e. Enable option specified below in Group Policy Management Console and in Security Filtering section of the Group Policy Management console specify users/groups who this limitation applies to (exclude Everyone) and then ONLY they will be limited to one session.
Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Connections\Restrict Remote Desktop users to a single Remote Desktop Services session
Just remove Authenticated Users and add users\groups who should be limited to one session.
Comment: Emphasis on GROUPS! If you remove _Authenticated Users_ & add a user security group & expect this to work you will get this
`The following GPOs were not applied because they were filtered out: SoAndSo :  Denied (Security)`
It's because _Authenticated Users_ includes all domain-joined Computers. So you will either have to include the Computers you need (which I had trouble with) or a security GROUP including those Computers
https://technet.microsoft.com/en-us/library/cc759506%28v=ws.10%29.aspx


What is the correct layer to configure your IoC container when using a service layer?

Question: I have a medium sized asp.net MVC app.  It consumes a service layer that handles all the repository use, calling domain services, etc.  My controller actions are very slim -- they basically call a service class, get a response and show that respose.  Most components are interface based with some poor man's DI.  The app is growing, needs better testing support, and starting to call out for an IoC container.
Everything I read (such as this SO question) states that I should configure the IoC at the application root.  This makes sense to me if I were using repositories right from my controller actions and needed DI at the controller level, but I'm not.  It seems like I'd want my composition root in my service layer.  I keep thinking that I don't want my web.config (or another config) at the UI layer even mentioning/seeing/hearing about a repository, credit card processor, etc.
Am I thinking about this the right way or do I just need to get over it?
Answer: I have the same situation as you and I tackle it as follows.
The general rule I use is what ever has a global.asax or something similar, it needs to execute the code that registers the IoC components. Another way of putting it is that you need to run it one for each different process that is running (i.e. the website is in one process and the service is in another).
In my case I do this once for the mvc website global.asax and again for the server. In this case the registrations that get made would be different between the service and the website.
In addition I do one more thing. Due to the fact that I reuse components between the mvc app and the service (i.e. logging) I have a third core component that registers the core IoC components for the system and this component is called by the both the website and services registrations. Hence I anything that is common between the service and the website go into the core registration and then anything that is different goes into the 'interface' specific registration.
Hope that helps.
Answer: You just need to get over it :)
Having your Composition Root in the application root doesn't require you to have a lot of DI Container stuff in web.config. You can if you will, but it's optional. What is not optional when putting the Composition Root in the application root is that you need to have some DI code in Global.asax.
You may find it irrelevant because your Controllers are so thin, but that's not the real point. The actual point is that you (the abstract 'you') want to postpone coupling classes until the last responsible moment. The earlier you couple types, the less flexibility you have.
If you couple classes in the service layer, you make an irreversible decision at that point. If it later turns out that you need to compose those services differently, you can't - not without recompiling, that is.
If there was a major benefit of doing it, I can understand why you would want to, but there isn't. You may as well wait composing all components untill you absolutely must do so - and that's in the application's entry point.
Answer: Coming from a Java perspective, I use the Spring framework for my IoC container.  With it, the container really is application-wide.  Although you can have different configuration files for different layers (a persistence config file, a services config file, a controller config file, etc), all of objects (beans in Java lingo) go into the container.
I think this still ok though because there is no coupling between classes as you mentioned.  A view does not need to know about a credit card processor, just because they are in the same IoC container.  These classes will receive (by injection) only the dependencies they need, and are not concerned with other objects in the container.


Can you create new orders using the /V1/orders/create rest API?

Question: I am trying to create a new order using the /V1/orders/create rest API but when I search on google or dev docs it shows me a different set of API to do the order process (https://devdocs.magento.com/guides/v2.3/rest/tutorials/orders/order-intro.html). So is there a way to create an order using /V1/orders/create? if none then what is the purpose of /V1/orders/create.
Answer: You can refer the Adobe commerce developer docs for the API reference
Just added below the Orders REST API endpoint for your reference.

orders/create

https://developer.adobe.com/commerce/webapi/rest/quick-reference/


What are the required permissions to view Delivery Reports in Exchange 2013?

Question: According to the Mail Flow Permissions page the following roles are required to do Message Tracking:

Organization Management
Records Management
Recipient Management

The domain admin has these roles assigned to it. Yet when I login to EAC I am still not able to view delivery reports for other users. On the other hand I can see the admin's reports and I can login to OWA with my own user and see reports for myself too.
Clearly this is a permissions issue but I don't know what more I need. I'm probably just not noticing the instructions somewhere in the docs.
Below is a screenshot:
Answer: The problem is user error. I discovered that I was looking at my permissions with the wrong cmdlet. I was using Get-ManagementRoleAssignment and should have been using:
<code>Get-RoleGroupMember "Organization Management"
Get-RoleGroupMember "Records Management"
Get-RoleGroupMember "Recipient Management"
</code>
I've corrected the missing permissions and, as expected, everything is working after a logout/login.
Answer: It is not necessary to add the administrator to Organization Management or Records Management.
The solution to the problem is to ensure that the administrator is Mailbox Enabled in Exchange.


Is it possible to install zoo-project in Ubuntu 18.04?

Question: I want to install zoo-project in Ubuntu 18.04 (bionic), but it seems there aren't any programs to do that, for example I have a problem with zoo-kernel install because there is not "ibmozjs185-dev" for bionic. Which version of Ubuntu (14, 16 or 18) is suitable for installing zoo-project?
Comment: It states here that the download source package is not found.  No version of Ubuntu will work.   https://packages.debian.org/sid/libmozjs185-dev
Comment: Thanks, that's right. Today I was forced to change my ubuntu from 18.04 to 16.04 and installed it without any error especially in "ibmozjs185-dev" installation.
Answer: nickan
You could use the ppa from the OSGeoLive project.  They have a libmozjs and zoo-project for 18.04.
PPA is at https://launchpad.net/~osgeolive/+archive/ubuntu/release-12.0
Their github formula is at https://github.com/OSGeo/OSGeoLive


Texas holdem question

Question: If the community cards are Q,,Q,10,10,2 and one players hold cards are a 2 how do you decide the winner if no other player can match any of the community cards?
Comment: just a hint 3 pair is a six card hand, only five cards count, so if the board has two pair, the best hand Q,,Q,10,10 X, X= the largest kicker a player may have, whom ever has the best kicker wins, if two player have the same best kicker the pot splits.
Answer: If no one else has a Q, 10, or pair higher than 10, then the player with the single highest fifth card wins. Poker hands have exactly five cards, no more, no less. So if player 1 has, for example, 9-2, the best five-card hand he can play is Q-Q-10-10-9, while player 2's K-5 wins with Q-Q-10-10-K. Under no circumstances do a sixth or seventh card come into play.
Answer: Insufficient information. The precise answer is winning kicker wins the hand, and if all kickers are void due to being under the board, then it becomes a chop.
Board: Q♥Q♣T♥T♣2♥
Hand: 2♣3⋄, best 5 cards makes Q♥Q♣T♥T♣3⋄, Two pair with kicker on 3
Hand: 4⋄6⋄, best 5 cards makes Q♥Q♣T♥T♣6⋄, Two pair with kicker on 6. This player wins!
As "three pair" is not possible with 5 cards, the best two pairs are kept, then the highest card as kicker.
Another example: Q♥Q♣2♥2♣T♥, this time anyone without a Q, 2 or 10 would either have flush (two hearts) or nothing but two pair, but T♣3♣ would beat A⋄K⋄ (Queen Ten two pair > Queen Deuces two pair)
Another example demonstrating the chop:
Board: Q♥Q♣T♥T♣9♥
Hand: 2♣9⋄, best 5 cards makes Q♥Q♣T♥T♣9⋄, Two pair with kicker on 9
Hand: 4⋄6⋄, best 5 cards makes Q♥Q♣T♥T♣9♥, Two pair with kicker on 9
Both players win and they chop the pot!

Texas holdem question


Adding SPFieldLookup to a list programmatically?

Question: I added a SPFieldLookup field to a list programmatically.
When I checked my list view I found that the lookup field is as if I added it from the user inerface without specifying that it is linked to item.
Is there a method to force the lookupfield to be linked to item programmatically?
Comment: Ok I found it

It cannot be acheived programmatically although it will be

available in sharepoint 2010

you can do it from the sharepoint interface

thanks
Answer: If you are provisioning both the list where the SPFieldLookup field is in, and the target list you will have a problem. Because the SPFieldLookup field needs to assign the target list by its GUID, which is created dynamically when the feature is activated.
And you can't define this value in your field definition, since it doesn't exists yet.
The solution to this problem is provisioning both the "source" list and the target list normally, except the SPFieldLookup field in the source list.
Then, in the feature activated event, you add this lookup field programmatically, which could now be done since you have (or at least can find out) the GUID for the target list.
Answer: This is a nice snippet I saw and will like to share
Let us assume we have two list aList and bList already created.
Requirement is to create a lookup column in aList which will look up values in bList.
 SPList aList = web.Lists["aList"];
 SPList bList = web.Lists["bList"];
 aList.Fields.AddLookup("Lookup", bList.ID, false);
 SPFieldLookup fldLookup = aList.Fields["Lookup"] as SPFieldLookup;
 fldLookup.LookupField = bList.Fields[SPBuiltInFieldId.Title].InternalName;
 fldLookup.Update();

Answer: Did you fill all the needed properties (LookupField, LookupWebId and maybe also LookupList) and Update() the field afterwards?
Perhaps http://www.alexbruett.net/?p=153 will help
Comment: The link is dead so this answer is not useful. This is why its good practise to summarise the key points when linking offsite.


Media purchase and download website that doesn't use proprietary software

Question: The thing I hate about Itunes is that you have to use proprietary software.  What website can you buy the same (mostly) commercial music, and just download mp3's or whatever through a web browser?
Answer: Amazon offers this, but only for music. Also, as GAThrawn said, you can only download your purchase without proprietary software if it's a single track and not an album.
Comment: That's optional.
Comment: @GAThrawn, there's a link at the bottom of the download page that you have to hit if you don't want to download the program, it's not real obvious, took me a minute to find it.
Comment: Ah, +1'd you both. The Amazon FAQ agrees with you, but only for single tracks, it says that for buying entire albums your only choice is using the downloader, or cancelling the purchase (on both .com and .co.uk anyway).
Comment: Amazon used a proprietary downloader app last time that I used it, though the whole of the rest of the buying experience and the file that comes out of the other end are all open for web browsers.
Comment: Really? Is that new? I looked around the first few times I used the service and I couldn't see any option to download MP3s without using their downloader.
Comment: @GAThrawn, thanks for the details.
Comment: @GAThrawn: Thanks, i've edited that into my answer.
Answer: Emusic is pretty good and cheap, too. The downside is that it does not have as large a selection as some of the others. Also, it is a subscription based model.
Comment: It appears that they have a Download Manager, so it seems like it'd be a proprietary interface, but they have a contact link for me to ask them if it's required.


Way to check if a channel exists

Question: module.exports.run = async (bot, message, args) => {

    let ticketreason = args[1];
    let ticketname = "ticket" + ticketreason;

    message.guild.createChannel("tickets",  "category")
    message.guild.createChannel(ticketname, "text");

}

So I've got this very simple and basic code here. I am trying to find a way to check if a channel exists before creating it. I've attempted to search around the discord.js documentation a few times for a solution, but I've had no luck so far. I need an explanation for how I can achieve this.
Answer: You can use <Guild>.channels, which returns a collection of GuildChannels, from this collection you can use <Colection>.exists() to check if the channel already exists in the guild.
So something like this:
if (message.guild.channels.exists('name', ticketname)) { //checks if there in an item in the channels collection that corresponds with the supplied parameters, returns a boolean
    message.reply(`The ${ticketname} channel already exists in this guild.`).catch(console.error);
    return; //prevents the rest of the code from being executed
}

// Code that creates the channel {ticketname}...

Answer: I do it in the following way, and I go through each of the channels.
let nameOfChannel = "lista-" + message.author.username.toLowerCase();

        // Check if channel exist
        if ((message.guild.channels.cache.find(c => c.name.toLowerCase() === nameOfChannel))) {

---- code continue here----

Answer: You can do this by checking for the id.
While this might not resolve this particular issue, it might help others with a similar issue.:

var chan_id;

if(message.guild.channels.cache.get(chan_id) === undefined)  {
    //checks if the channel doesn't exist
    //put the action to take here
}
//continue your code here

Way to check if a channel exists


Enhanced Star-Gazing with Special Glasses

Question: I watched a video yesterday on how telescopes not only magnify images but also increase the amount of light entering into your eye, allowing you to see things not normally visible with naked eye. Would it be possible to create a "telescope" with no magnification, a wide field of view... say ~190 degrees left/right, ~120 degrees up/down (the average human field of view), and small enough to wear? Essentially creating glasses that allow for better star gazing?
A side question is do night vision goggles let you see more stars? or does the increase in ambient light from earthly objects negate any increase.
Answer: Stereo Vision?
Optically, you'll need something like a couple big Fisheye lenses mounted on a helmet.
Looking straight through such optics yields horrible distortion, so you'd have to feed the lens' output into CCD/CMOS sensors, and massage that into flattened images your eyes can handle, on a video screen. Perhaps Google Cardboard?
Probably doable and light enough to wear.
A straight optical approach to correcting the fisheyes would probably end up too heavy to lift.
Answer: The closest I've seen to what you mention in your question are wide-angle binoculars, the like of Vixen SG 2.1x42. There are other similar instruments available, often of Russian or Chinese (like this one) production. They have low magnifications and are examples of Galilean binoculars.

They don't have a fixed-size exit pupil and you can gain about 1.8 mag above what you can see with a naked eye (based on a review from a Polish astronomy forum).
With the field of view of about 25 degrees, this is an experience somewhat (to put it mildly) different from what you describe. However, it's enough to see quite a large piece of the sky at the same time and is probably the closest you can get to star-gazing goggles.
To make it easier to picture, 25 degrees is approximately the angular size of the Big Dipper, from one end of the bowl to the tip of the handle.
Due to their size and wide FOV, these binos are also known to be used in the same manner as goggles. Pictured below is a pair of Kasai WideBino 28 in a wearable, rubber casing.

This thread on cloudynights provides a nice overview of this kind of binoculars.
Image sources:

vixenoptics.co.uk
kasai-trading.jp
Answer: Fisheye lenses. Sure, it's doable. But does it really lead to "better" stargazing? It's debatable. The human field of vision is already pretty wide as it is.
There are telescope eyepieces out there that operate on the principle of light amplification, and they do indeed raise the bar in terms of the faintest stars that can be seen in that telescope. They aren't cheap, though.
Answer: On Murdoch's Mysteries, the technophile detective at the end of the Victorian era made, in one episode, night vision goggles that used mirrors surrounding the eyes, essentially a pair of reflecting telescopes with no magnification.
It would not cover the same angle, though: just straight ahead. The naive design you might throw together would handle light arriving parallel to straight forward, so the actual field of view may or may not be useful. To purposfully make a field of view of a specific size and quality would require knowing something about it.
A common SLR photography lens has an enormous opening compared to your pupil, and high quality formerly pro lenses for pure mechanical film cameras can be found cheaply. Some designs even have a lens board for mounting, rather than a fixed camera enclosure.
In their original use, they project the image on a large (relative to your eye) screen, so produce an image dimmer than life.  However, if instead of making a projection 44mm in diameter (say), you added an objective lens made for telescopes or a handy jewler's loupe (any magnifying glass works, but for more than 5× you need a fancy compound lens), you could project all the light into your eye.
Update: using on-hand materials it takes 3 pieces, not 2, and is unacceptably long (unless you want it looking like an old seafarers telescope). To concentrate the entire collected light, the next lens needs to be very large around to scoop in all of it.  a hand-magnifier doesn't result in an image as large as the directly-observed target, and a powerful loupe is not large enough.


Magento 2.4: Hide and disable billing and shipping address from checkout

Question: I am using trust payments ad I want to hide and disable billing and shipping address from checkout(Place order without billing address).
I am able to hide the billing address by following this: https://bsscommerce.com/blog/magento-2-remove-billing-shipping-address-from-checkout/ but not able to place order without it.
Any help would be appreciated.
Comment: To place an order pass the billing address same as the shipping address.
Comment: I want to place an order without shipping and billing addresses
Answer: Ideally you do not want to remove billing address but best workaround would be to hide billing address using CSS and simply set the billing address value to default to the shipping address.
Copy file vendor/magento/module-checkout/view/frontend/web/js/model/checkout-data-resolver.js to app/code/Vendor/Module/view/frontend/web/js/checkout-data-resolver.js
Edit file app/code/Vendor/Module/view/frontend/web/js/checkout-data-resolver.js and comment out code and automatically set billing to match shipping around line 231:
applyBillingAddress: function () {
    var shippingAddress;

    if (quote.billingAddress()) {
        selectBillingAddress(quote.billingAddress());

        return;
    }
    shippingAddress = quote.shippingAddress();

    selectBillingAddress(quote.shippingAddress());

    /*if (shippingAddress &&
        shippingAddress.canUseForBilling() &&
        (shippingAddress.isDefaultShipping() || !quote.isVirtual())
    ) {
        selectBillingAddress(quote.shippingAddress());
    }*/
}

then we can just add a display:none to the billing class of .checkout-billing-address in your custom _payments.less class
If shipping is also needed to be removed then might I suggest reading this article as it might help https://bsscommerce.com/blog/magento-2-remove-billing-shipping-address-from-checkout/
Comment: I tried the link and was able to hide the addresses but place order is still not working.
Comment: Can you please update your question and provide screenshots of what you want to be done, and what it is currently doing? Unfortunately, I cant help without seeing what is going on.
Comment: Let's just say I want to place an order without filling in the shipping and billing addresses on checkout.
Comment: Then your best option is to populate your shipping form with customer data (such as name, address, zip, etc.), set billing info to default to what is in shipping and just hide the forms.

Removing these forms will not work mainly because there are a few core files using either shipping or billing details, so YOU DO NEED THEM.
Comment: Okay. I will try this. Thank you


How do I reveal the character identity from a first person point of view?

Question: I am writing a book, and I'm trying to figure out how to reveal the main character's identity. It is a crime book set in modern day and is a story told in the perspective of a serial killer. I plan for the reveal to come somewhat early in the book and display the main character's thoughts and mental process throughout the story. I have to get the story out by April 1rst to be a part of a book collection based on inspired songs by the band, Talking Heads. This will be inspired from the song, Psycho Killer.
Comment: By identity did you mean the name, or the fact that they are in fact the killer?
Answer: Have the character talk to themselves

"Oh, what have you gotten yourself into John", I asked myself. I'd worked in marketing for years, but had no clue how to spin this. The blood would wash off, but getting an alibi was harder.

Or have someone talk to the character

Peter called out to me, "Hey John, what are you up to?" I didn't really want to talk to him, but couldn't find an excuse. "Hey Peter. Not much, just killing random people. Haha." Peter laughed. I was such a kidder.

Or have the character read something referring to themselves

I looked at my business card, "John Doe, marketing director." The graphic design was awful. Whoever designed that was going on the list. It was probably Peter. The only reason I hired him was because he married my sister.
Answer: Just have the POV character be introduced to a new person by a mutual acquaintance, they have a short exchange ("what do you do?" kind of stuff), then fairly quickly, the POV serial killer traps and kills that new person they just met. Perhaps it was part of their plan to meet them socially, so the victim would let their guard down.
Perhaps the POV character picked up the victim in a bar, something like that.
Answer: In a First Person narration, the character is the narrator, and hence can say anything they want to say, directly to the audience.
In fact, everything is addressed to the audience.  Although, the "audience" to which the story is directed may or may not be your reader.  Digressions into any set of side details could be the rambling of a crazy person, or could be clever tie-ins showing off the character's intricate intellect.
The question is not how to reveal information, but why.
If a murderer is writing anonymously, filling in details of his crimes that might not fully have been appreciated, mocking the police who have failed to catch him, then it would be difficult to justify revealing the character's name, or other personal details.  (Unless he's supremely arrogant - "My name Johann Fiddle, and I grew up on [X] St of [Y]ville...  But you still don't know enough to catch me!")
On the other hand, if the character is boasting to a soon-to-be victim, any information is on the table.  Dead men tell no tales.  ("Yes, I engraved my name on the knives I use to kill my victims.  Don't worry, you'll got as close a look as you like soon enough.  Closer, probably, then you'd like.")
An unhappy confession would have a different flavor, but might naturally include an early self-identification.  ("My mother, Janine Fiddle, was a neglectful parent.  Not neglectful enough, I'm afraid, because I lived through my childhood to become the monster that I am...")
Answer: Based on the topic and main character, this might be a good premise for a nameless protagonist. He might tell his victims variations on a made-up name.
They might be someone whose 'ordinariness' in appearance or disposition makes them un-remarkable – which is maybe the fascination of serial killers? They could be anybody.
If he lies to his victims, we'd meet him again and again as he improvises and learns – the persona becoming more confidant as more details are woven into his 'story'.
Ted Bundy pretended to be a cop, to need help carrying books, to be taking interviews with a tape recorder, etc. Many of his intended victims walked away because his stories didn't add up.


Why did nobody complain about Gilderoy Lockhart's lessons?

Question: I think we can guess that Lockhart's lessons were not the lessons EVERY student enjoyed. Having tests about his books where he asks "When is Gilderoy Lockhart's birthday and what would his ideal gift be?'", might be an example of the quality Lockhart based his lessons on the whole year to all the students. My question is, why did no student complain about this to their Head of House for example? I'm quite sure there were students other than Harry and Ron not happy with Lockhart and his lessons after awhile.
Comment: Well I dunno about you, but when I was at secondary school in Britain, you didn't complain to higher-ups about teachers, you sucked it up. You might have winged to your friends, but it would never have occurred to us that there might be some way to launch a formal complaint. And anyway, I doubt anyone would've been bothered by the quality of the teaching, to most schoolchildren lessons are just boring chores to get through. The thought that one might benefit by learning something isn't very prominent. Most people would probably be grateful for the easy ride
Comment: My German teacher his first question at the first test was where in Germany he was born. :D Half the time he was telling stories. The class was more fun, not sure it applies to Lockhart's lessons that one. But no one ever really complained besides just saying to each other we didn't get to learn that much. Which 15 year old kids don't really mind after all :D
Comment: And the Hermiones will get on with things quietly on their own. (Hermione herself, of course, was busy fangirling, but that's another matter). There's a common trope, you may have heard of it, of PE teachers making people who forgot their kit do the lesson in their underwear ... Quite frankly, if something as egregious as that hasn't traditionally been complained about, then cruddy teaching wouldn't be ...
Comment: True, and that may be for second years at the time. However, I can imagine that as a 5th year student you start to worry more if you have to pass exams.
Comment: If nobody complained about Snape's lessons, why complain about Lockhart's?
Answer: They probably did.
Lockhart was clearly known to be a pretentious poser by the staff as well as the students: recall Snape's dismissive attitude at the Duelling Club, and most memorably towards the end when the rest of the staff told off Lockhart to 'go and deal with the basilisk, then' just to get him out of their hair while they dealt with the situation seriously.
But what could they do? He had the job of DADA teacher and couldn't be sacked unless they found a replacement. And finding DADA teachers was a very difficult task at the time (and indeed throughout the series), due to widespread rumours about the curse on the job. Dumbledore, as a great and knowledgeable wizard, may well have guessed that Lockhart was a fraud already, or at least that he'd be a rubbish teacher. But clearly he was the best the Headmaster had been able to find for the job that year.
And given that he couldn't be sacked, what other form of action could be taken against him? The other staff would have no influence on his teaching. The Headmaster might, but Lockhart is clearly far too 'up himself' to heed a request for him to pull his socks up and teach the students Defence Against the Dark Arts in a serious manner. I mean, how would it go?

McGonagall: Gilderoy, I've been hearing complaints from some of my students about your teaching.
Lockhart: Ah, nonsense - it's all in good fun, I can assure you. They all love me really, and my lessons are very instructive. I mean, I didn't defeat the Banshee of Blitheringidiot by not knowing my Defence Against the Dark Arts back to front, did I? [dazzling grin]
Dumbledore: I hired you to teach my students Defence Against the Dark Arts, not to induct them into your fan club!
Lockhart: But my dear fellow, they're all so eager to hear all about me! I do try to keep the topic firmly to the syllabus you provided, but I've never had such a keen group of fans. They're positively begging for my autograph. It's all I can do to teach them anything at all!
Comment: To add to this (but not enough to justify a unique answer) - the teachers also show a distinct habit of ignoring any the students try to tell them. Too many to count are the instances where one of the three could have stopped the McGuffin dead in its tracks if McGonngal or somebody else would have simply believed them for once.
Comment: Your Lockhart impression is spot-on!
Comment: dont forget all female students loved him so for every complaint from a male student they would get 2-3 complements from the female students


Whether an area contains finitely many lattice points

Question: Based on Finding the area between two regions in the plane I know that the area between $y>\sqrt{2}x - \frac{1}{4x}$ and $y< \sqrt{2}x + \frac{1}{4x}$ is infinite. However, I actually have a different question to ask. Are there only finitely many lattice points contained in the area? How could I show this? Looking at the graph presented in the link, it's clear that the infinitely many lattice points could only come from the area around the asymptote going off to the top right, so I would need to show that this section only contains finitely many lattice points.
Answer: There are no such lattice points at all.
The question is whether there are infinitely many pairs of positive integers $(x,y)$ such that $$\sqrt{2} x - \frac{1}{4x} < y < \sqrt{2} x + \frac{1}{4x}$$
or equivalently
  $$  \left| \sqrt{2} - \frac{y}{x}\right| < \frac{1}{4 x^2} $$
This is a question about Diophantine approximation.  The best Diophantine approximations of an irrational number $\alpha$ (and any where $|\alpha - x/y| < 1/(2 y^2)$) are convergents of the continued fraction.
The basic inequality is
$$ \frac{1}{x_n^2 (a_{n+1}+2)} < \left| \alpha - \frac{y_n}{x_n} \right| < \frac{1}{x_n^2 a_{n+1}}$$
where $y_n/x_n$ are the convergents and $a_n$ the elements of the continued fraction of $\alpha$.
Since $\sqrt{2}$ is a quadratic irrational, its continued fraction is eventually periodic:
in fact
$$ \sqrt{2} = [1; 2,2,2,\ldots]$$
Since the elements of the continued fraction are at most $2$,
 we get $$\left| \sqrt{2} - \frac{y_n}{x_n}\right| > \frac{1}{4 x_n^2}$$
On the other hand, if you replaced $4$ by $2$ you would get infinitely many lattice points.
Comment: I'm not really familiar with diophantine approximation or continued fractions. I am trying to do this problem in the context of the geometry of numbers. Given this, I don't really understand your solution.
Comment: +1 Nice answer.  Do you have any recommended references for your statements about the relationship between best Diophantine approximation and convergents?
Comment: A. Ya. Khinchin, [Continued Fractions](https://books.google.ca/books?id=R7Fp8vytgeAC).
Answer: There is an elementary argument (not using continued fractions) that shows $|\sqrt 2- \frac{y}{x}| \geq \frac{1}{3x^2}$ for all $x, y \in \mathbb{Z}, x \neq 0$
We start from $|2x^2-y^2| \geq 1$ under the above assumptions ($x \neq 0$), so $|\sqrt 2- \frac{y}{x}||\sqrt 2+ \frac{y}{x}| \geq \frac{1}{x^2}$.
But if $|x|=1, |\sqrt 2\pm y| \geq .4 \geq \frac{1}{3}$, while if $|x| \geq 2, \frac{1}{10} \geq \frac{1}{3x^2}$, so the inequality is automatically satisfied unless $|\sqrt 2- \frac{y}{x}| \leq \frac{1}{10}$, which means $1.3 \leq \frac{y}{x} \leq 1.52, |\sqrt 2+ \frac{y}{x}| \leq 3$, so $|\sqrt 2- \frac{y}{x}| \geq \frac{1}{|\sqrt 2+ \frac{y}{x}|x^2} \geq \frac{1}{3x^2}$ and we are done.


how to use iio on surface pro to access sensor data in Ubuntu 13.04

Question: I have Ubuntu 13.04 running on a Surface Pro.
One of the usb device (ID 045e:0794) has registered a number of hid sensor devices:

HID-SENSOR-200041.0: Light: Ambient Light
HID-SENSOR-200062.0: Mechanical: Boolean Switch Array
HID-SENSOR-200073.0: Motion: Accelerometer 3D
HID-SENSOR-200076.0: Motion: Gyrometer 3D
HID-SENSOR-200083.0: Orientation: Compass 3D
HID-SENSOR-200086.0: Orientation: Inclinometer 3D
HID-SENSOR-20008a.0: Orientation: Device Orientation

When loading hid-sensor-als a iio device is available in /sys/bus/iio/devices/iio:device0
and also /dev/iio:device0 is created.
New iio devices are also created when loading hid-sensor-accel-3d and hid-sensor-gyro-3d.
Now my question is how can i get and read out data from these sensors?
Answer: I went through the same exercise for a Yoga 2 Pro, under Fedora 20.  The problem is that the sensor hub sensor drivers don't expose a raw interface, so you have to use the buffered interface, which is not easy to set up.  To add to that, the drivers may not correctly initalize some sensors so that they hang.
There is a program called generic_buffer alluded to in the presentation mentioned above.  However, there are many problems with that program, at least the most readily available versions.
I have a fixed up version of generic_buffer in https://github.com/pfps/yoga-laptop under sensors.  I also have a program that monitors the accelerometer and rotates the screen accordingly.   Feel free to use and abuse them, and, if you can, please improve them.
Answer: quick google, I found this: https://archive.fosdem.org/2012/schedule/event/693/127_iio-a-new-subsystem.pdf
pages 22-24: Userspace API, has some shell commands accessing the device files in /sys.
In the linux kernel tree, "Documentation/ABI/testing/sysfs-bus-iio" has some info as well.
I'm not an expert, but maybe that could help get you some of the way?


DHCP server access problem

Question: What will stop a PC from receiving an IP address from a DHCP server? Is it STP, VTP, 802.1Q or DTP? What is the most preferable of these?
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
Comment: Hi is your DHCP configuration is on layer3 device or in Active director server or any third-party. If your DHCP pools configured on layer3 switch means onces clear DHCP conflict #clear ip DHCP conflict* This above command we clear if there is any conflict on DHCP allocation If your DHCP is on server check excluded address or check for clearing DHCP conflicts
Answer: Neither.
DHCP works by the server receiving the client's broadcast - so you need a working broadcast domain (aka L2 segment aka VLAN) in between, unless you're using a DHCP relay. As long as the network is functioning, DHCP will work.
xSTP, VTP, or DTP all help establishing and maintaining a working network. There are no 'most preferable' protocols in these - you use whatever is best in your situation which you haven't detailed. (Except that MSTP is preferable over RSTP which is generally preferable over obsolete classic STP.)

DHCP server access problem


How to stream pcap file to RTP/RTCP stream?

Question: I have captured three different stream as pcap file with meta datas. How can I stream back to RTP/RTCP stream?
Answer: If I understand correctly, you have the pcaps, but you want to get the RTP from them?
Wireshark UI
You could use Wireshark's UI to easily take the RTP from the pcap via the Menu: Telephony/RTP/ then show all streams... click a stream it lists, and then 'analyize.'
However, if you want to automate this, and avoid the UI... you can use tshark.  I found several tutorials online and used them to build a test harness that automatically rebuilds the audio/rtp on a pcap, then makes a wav and transcribes the audio on that wav to text.
Automated with Tshark
I was making a test call, and wanted to convert the pcap recorded to audio. To do this, I stripped the RTP out of the pcap, then converted the rtp file to raw audio, and then to a wav.
I do this all via the command line so it can be automated. So really I have a shell script that does this:
tshark -a duration:20 -w /jenkins/userContent/sip_1call.pcap

The above records a packet capture for 20 seconds (the duration of the call going on at the same time) and outputs the packets as sip_1call.pcap
ssrc=$(tshark -n -r /jenkins/userContent/sip_1call.pcap -R rtp -T fields -e rtp.ssrc -Eseparator=, | sort -u | awk 'FNR ==1 {print}')

I'm setting the variable ssrc to this action of using tshark to pull out the rtp ssrc value. What the ssrc is is, is an identifier of a RTP stream.  If you have one stream, you'd have one RTP ssrc value.  You would need to capture all the RTP.ssrc's and output them to a file and that can easily become raw audio again.
sudo tshark -n -r /jenkins/userContent/sip_1call.pcap -R rtp -R "rtp.ssrc == $ssrc" -T fields -e rtp.payload | tee payloads

At this point of my shell script, I'm running tshark again on the recorded pcap and taking that ssrc value and saying "find all of them as 'payload'"
for payload in `cat payloads`; do IFS=:; for byte in $payload; do printf "\\x$byte" >> /jenkins/userContent/sip_1call.raw; done; done

Now the script is setting those RTP.ssrc's to a output file, i'm calling sip_1call.raw
For my purpose I also wanted to convert that raw file to a wav, so I used sox:
sox -t raw -r 8000 -v 4 -c 1 -U /jenkins/userContent/sip_1call.raw /jenkins/userContent/sip_1call.wav

I did some more stuff in my automation framework (like transcribe the audio to text and compare against a known string)... but that's outside the scope of your question.
I hope that helps...
More on SSRc: http://en.wikipedia.org/wiki/Real-time_Transport_Protocol
More details on the full shell script I'm using:
http://www.continuous-qa.com/2013/04/automated-verification-of-voip-audio.html
Answer: There is a tool just for this purpose, as part of the SIPp sip testing package.
http://sipp.sourceforge.net/doc/reference.html#PCAP+Play
(disclaimer: I've never used it myself, though I did use SIPp itself, and was very fond of it)
Answer: You can replay all of your captured packets (including RTP) with this simple, free tool.
PlayCap - Playback for Wireshark Captures
Answer: Taking a pcap and (I assume) replaying it is a non-trivial thing to do; there are no packages that I know of to do it. It can be done, but requires very good knowledge both of SIP (I assume you're using SIP) and RTP.  You also have to be careful to replay the packets at the right times, not as fast as you can.
Someone who really knows what they're doing could write such a tool in 3-5 days.
Answer: If you just want to replay/listen the audio you can save the RTP payload in a raw audio file using wireshark, then you can resend it (or listen to it using an audio editor), but if you want to reproduce the exact RTP/RTCP stream it's more complicated
Comment: Its bit hard to stream, all the folks are saying like that only.. Any way thanks Mike
Answer:
How can i stream back to RTP/RTCP stream.

To achive your goal there is a specific tool (free) named rtpplay: http://www.cs.columbia.edu/irt/software/rtptools/
Answer: I banged my head on a wall for some time with this as well... But, I got a solution.  So first, make sure you can correctly get your call to a softphone/phone... if you can make that connection fine, the rest isn't so bad.
Here's my command line:
sudo sipp -s [my phone number] [ip of my proxy/softswitch] -sf /home/sipp-3.3/uac_pcap_g711.xml -m 2000 -mi [ip of my computer sending the load] -d 1200 -trace_rtt -trace_err -stat_delimiter ,
So I'm using my own scenario file, but the above params should work fine for you.  here's what I'm doing with SIPP:
sudo: Why sudo?  If you don't sudo this, it can't create the socket needed to send the audio/media.
mi: mi specifies your IP for sending media... I didn't need to specify the port.
d: I added 1200 ms to the pause
trace_rtt and trace_err: I output the log files and performance report
stat_delimiter: i change the default ; to ,
Anyway this worked for me.
Edit:
Also, note that I have this for 2000 calls, at the default rate (10CPS)... you might want to make that -m 1 for now so that you can verify it works. It should play the pcap audio, and then send a DTMF.
After I got this working, I imported this all in Jenkins CI and call sipp via Jenkins jobs, and convert the csv output to visual graphs, and also do some tshark captures during the load... all via Jenkins... if you're interested, check out my blog (mentioned in my profile) for details on how to set that stuff up.


How can I extract transfer function an unknown nonlinear system?

Question: I am trying to do PID control for my servo electronic motor system. This system uses SSI encoder output for feedback mechanism. I will calculate PID parameters according to ziegler nichols tuning methods. However I must know transfer function of this system while determining PID parameters. So how can I extract transfer function of my system? Is there any way by using MATLAB/SIMULINK or Labview? I think I need a methodology for this? I do not know how can I do. Can anyone explain clearly.
Comment: A good technique is to introduce a white-noise signal as an input to your system. The output can be thought as the impulse response, which can be manipulated the same way as the impulse response.
Answer: As I remember (learned it 15 yrs ago) You need to have an experimental data, which will help you to find "linear" sections and the their limits (with taking into account the things like hysteresis), so you will be able to find transfer function for each band.
P.S. Why do you think that the servo motor system is nonlinear? Please describe the the mechanism to which motor is connected? What parameter you want to control?


Efficiently map $2^n$ unique 64-bit vectors to $2^n$ $n$-bit vectors where $n < 64$?

Question: Is there an efficient way to map $2^n$ unique 64-bit vectors to $2^n$ $n$-bit vectors where $n < 64$?
Comment: I'll vote to close as well; but you might want to consider: "what properties do you want from your mapping?"  If you want just any mapping, just chopping off $64-n$ bits off the vectors works fine -- is there a reason why that isn't sufficient?
Comment: How are you going to represent the set of $2^n$ unique 64-bit vectors?  What does that set look like?  The answer is going to depend upon these details.  Depending upon what your set of $2^n$ 64-bit vectors looks like, the answer might be very different.  Therefore, we can't answer the question until you edit your question to give us that sort of information; I'm voting to close as "too broad".  You can fix the question by editing it. (Also, I suggest you edit it to tell us what you tried and what research you've done on your own.  You *did* do significant research before asking, right?)
Comment: This question appears to be off-topic because it is about compressing or encoding data, not cryptography.
Comment: Yes..Chopping bits will not create a one to one mapping
Answer: In general, no. There are:
$$ {2^{64} \choose 2^n} = \frac{2^{64}!}{2^{n}!(2^{64}-2^n)!} $$
possible ways of selecting $2^n$ distinct 64-bit vectors. This is a huge number; using Stirling's approximation of factorials, when $2^{n}$ is substantially smaller than $2^{64}$ (i.e. when $n$ is smaller than $55$ or so), this number of combinations is approximately equal to:
$$ \sqrt{\frac{1}{2\pi}} 2^{-n/2} 2^{(64-n)2^n} $$
Therefore, any generic method for doing the mapping you seek must, necessarily, use enough memory on average to accommodate that many possible combinations. For instance, if $n = 32$, then you will need a minimum of 137 gigabytes. In fact, the naive method of storing all $2^{32}$ 64-bit vectors in a sorted array, using a binary search to locate the index of a given value, will use twice as much, but if the values are sorted and more or less uniformly spread over the space of 64-bit vectors, then the difference between two successive vectors will fit in less bits (a bit more than 32) so you could, realistically, do your mapping with 160 gigabytes or so.
Of course, the argument above is for generic methods. If you know how the $2^n$ 64-bit vectors are generated, then a more efficient method may be possible. As an extreme case, if the 64-bit vectors all end with 32 bits of value 0, then simple truncation will work for your mapping.
Comment: I agree that there are too many mappings possible.Should that be a concern ? I can implement a cheap hash function to create a mapping `out=(in*rand1+rand2)mod2^n` with the risk of many collisions. I was wondering if it is theoretically impossible to create a function with almost no collisions.
Comment: @Jean You can always use a standard hash function, if the number of collisions is acceptable is for you to decide.
Comment: I have tried using many hash functions. When tried to map 64million 64bit vectors to 128million buckets I was getting 22% collision.
http://stackoverflow.com/questions/25221410/too-many-collisions-in-hash-function
Comment: @Jean, with 64 million vectors you need at least something like $2^{52}$ buckets to have a chance of avoiding collisions.
Comment: @otus - Is there some hashing function which can give me less than 1% collision without using prohibitive number of buckets ?
Comment: @Jean, for 1% collision rate with 64 million entries you need a ~30-bit hash. I.e. at least a billion buckets. That's the best you can do in general.
Comment: Is this some sort of theoretical limit ? Even if all possible (random)inputs are known apriori ?
Comment: If all possible inputs are known _a priori_ then you can put 64 million entries into exactly 64 million buckets with no collision -- _but_ the mapping will have to know the 64 million entries. And the gist of my answer is that this cannot, in general, be done without using enough ROM or RAM to actually encode the 64 million possible values one way or another.
Answer: I believe this can be reduced to a case of format-preserving encryption.
http://en.m.wikipedia.org/wiki/Format-preserving_encryption
Using one of the many algorithms for FPE, you should be able to do such a mapping.
EDIT: As Seth points out in the comments to my original answer, the "cycling" method of FPE doesn't work here, but the first method described by Black & Rogaway might be practical if n<30. But this is really no more efficient than a straightforward array mapping as described in Thomas's answer to the question. The Black-Rogaway paper on format preserving encryption is at http://www.cs.ucdavis.edu/~rogaway/papers/subset.pdf
Comment: The "cycle-walking" method wouldn't work here because your target space is not your source space. For example, you could have two inputs X1 and X2 in your source space such that AES_K(X1) = X2 (it would make slightly more sense to use DES here, but same thing would happen). In this case, X1 and X2 would then map to the same point in your target space, unless X2 was already in it.
Comment: @Seth, I think it would still work, as no two inputs would map to the same output. If you cycle until you have a value less than 2^n, unique inputs would never collide if a block cipher (DES or whatever 64-bit block cipher). A block cipher is not a hash function. I agree you could hit an input value after X iterations, but so long as every input gets at least one iteration by definition that is not a problem.
Comment: I'm not sure what you're arguing. For concreteness, let's use the example I gave earlier, and suppose that, say, n = 63, both x1 and x2 are at least 2^63, x2 = DES_K(x1), and suppose that y = DES_K(x2) < 2^63. My understanding of your proposal is that both x1 and x2 would map to y because this is the first value in [0, 2^63) we reach by repeated application of DES_K, regardless of whether we start from x1 or from x2. If this is incorrect, could you please clarify how the mapping is computed?
Comment: @Seth, I just re-read the major Black-Rogaway paper at http://www.cs.ucdavis.edu/~rogaway/papers/subset.pdf and realize you are correct. I was assuming their first method and the second method had the same properties; they clearly do not due to the large storage+sort required for the first method. If n<<2^64, the first method in the B-R paper might apply. So I now think you are right and I'm wrong; cycling won't work. What's the etiquette here, do I edit my answer or suck it up and take the pummeling of down-votes?


Scala game programming - between OOP and FP

Question: I am trying to write a tutorial game in Scala & Processing, intending to use as much FP as possible. However, I come to a conclusion that immutable-state game objects are not profitable in such application. If an object is big, it may result in quite intensive memory consumption in case of numerous such objects being constantly updated (therefore, making copies of itself each cycle), for example, using the copy() func. What is the default approach to resolute this? The only thing that I come up with - is to slice the object in tiny pieces-objects so that only those who need to be updated, are updated while leaving the "big" objects same.
Comment: possible duplicate of [scala game programming: advancing object position in a functional style](http://stackoverflow.com/questions/4709437/scala-game-programming-advancing-object-position-in-a-functional-style)
Comment: yah, thanks, Peter! I have been there, it is relevant and full of info, but does not take the same angle of approach.
Answer: A game engine is essentialy a (discrete) event simulation. Typically, these are implemented via mutable data structures such as heap for the events, quad/oct trees for spatial queries about objects and lots of hash tables.
For each of these data structures, mutable variants are faster. Furthermore, immutable data structures produce garbage which has to be collected, so the pressure on the GC is higher, and your application ends up being slower. Where real-time is a concern, GC pauses can be harmful (e.g. it may affect the framerate in your game), and this is particularly the case on platforms with less processing power, such as Android.
As for the copy() method - it doesn't have to copy the entire object to create the updated version. If your object is organized hierarchically in a tree-like manner (e.g. as a hierarchy of case classes), then changing one property of the object requires rewriting only one path in this tree - you won't need to rewrite everything. Still, it will be more costly than just having a mutable version and updating in-place.
Example:
case class World(map: Array[Item], players: Vector[Player])

case class Player(health: Int, speed: Int, weapon: Weapon, shield: Shield)

case class Weapon(strength: Int, ammo: Int)

To add more ammo to the weapon, you don't have to copy the entire World:
def setAmmo(playerNum: Int, newAmmo: Int, world: World): World = {
  val p = players(playerNum)
  world.copy(players = players.updated(playerNum, p.copy(weapon = p.weapon.copy(ammo = newAmmo))))
}

In this example, map, other players, and the shield of the modified Player stay the same in memory and are not eagerly copied.
I would advise going for a mutable data structure to represent the state - unless you have a concurrent game engine with (for example) a single writer that simulates the game state, and a range of readers which render output, handle sound, network and so on, the benefits of immutable data structures are close to none in this use case.
Comment: The `copy()` facility looks like it turns vals in a more expensive and somewhat safer variant of vars because it lets changing vals like mutable values (vars). Does it?
Comment: The `copy()` method on case classes creates a new case class instance with the value of the fields equal to those in the original instance, except for those fields for which you explicitly write ` = `. But it does not do a deep copy - if some of the fields is a case class, that case class instance is not copied via `copy()`, only the reference to it is copied.
Answer: First of all, don't do premature optimisations. Have you measured your code? Maybe there is some concrete bottlenecks?
Since most of the objects consist of smaller objects joined via data stuctures, I think you can get rid of this problem by using persistent data structures
.

persistent data structure is a data structure which always preserves
  the previous version of itself when it is modified; such data
  structures are effectively immutable, as their operations do not
  (visibly) update the structure in-place, but instead always yield a
  new updated structure

Here is wonderful talk about some of them by Daniel Spiewak. If you want more, take a look on Purely Functional Data Structures by Chris Okasaki.
Comment: Read that presentation by Daniel spiewak it will clear your 'copy' myths up. Functional data structures are quite fast question is , fast enough for your usecase?
Comment: @AndreasScheinert Thank youall, I find these references to be highly interesting. I will try to develop the information.
Answer: Just embrace the fact that game state is inherently mutable. Use immutable classes only for things that are conceptually values such as position, velocity etc. This might still produce a lot of garbage, but running with escape analysis turned on might help.


What is the difference bettween "Now I will stop check somethings" and "I will stop check somethings now"?

Question: What is the difference between the following two questions?

"Now I will stop check {somethings}."
"I will stop check {somethings} now."

I don't know the correct position of the word "now".
Comment: I meaning "to stop check something"@Jasper
Answer: I am not sure if the sentences sound right to native speakers, but I would change them to

Now, I will stop checking it.
I will stop checking it now.

Regarding the position of now: both are absolutely fine and, I believe, are equally used. To me, the former slightly emphasizes the time period (I also put a comma there).
Answer: Your sentence structure is wrong. These will be as below:

Now I will stop checking facebook statuses.

Or

I will stop checking facebook statuses now.

Check the grammar basic below:
Verbs followed by 'ing' or by 'to + infinitive' (2)
When one verb is followed by another, the second verb can either be an infinitive or an –ing form. Some verbs can be followed by either an infinitive, or an –ing form but with a change in meaning. These are some of the most common ones.

like
I like watching old films on TV.
  With an 'ing' form, 'like' means 'enjoy'
I like to wash up as soon as I finish eating.
  I might not enjoy washing up but I think it's the right thing to do.

Remember that 'would like' can only be followed by an infinitive.

I'd like to go to Japan next year if possible.-

-

try
I'm trying to learn Japanese but it's very difficult.
  Try + to + infinitive means that something is difficult and you make an attempt to do it.

Have you tried using butter instead of oil?
Try + 'ing' means make an experiment. It's not difficult – it might work, it might not.

stop

Stop + 'ing' tells us what has stopped. in this example, buying a newspaper.

I've stopped buying a newspaper every day to try to save money.
  Stop + to + infinitive tells us why something stopped. In this example, the reason that the bus stopped was to pick up the children.
The bus stopped to pick up the children.

-

remember /forget
Don't forget to post that letter to me.
  Did you remember to post that letter for me?
  Remember/forget + to + infinitive means that you remember something you have to do – a duty or a chore.
I'll always remember meeting you for the first time.
  I'll never forget meeting you for the first time.
  Remember/forget + 'ing' form means to remember something you did in the past – an event or an activity.

Examples are taken from the below link:
https://learnenglish.britishcouncil.org/intermediate-grammar/verbs-followed-ing-or-infinitive-2


Activity Unit Testing holding visual results

Question: I'm trying to test an Activity. This Activity houses a fragment which contains a listview. I am passing in a object (which is generated from the database) to be displayed within the listview.
I would like to perform this as a test so that I can fill the database with dummy data and just hand off the object to be displayed to the Activity. My problem is that Unit tests aren't really setup to let me play with and visually inspect my fragment with the dummy data. The tests just run and close the app right away.
Can anyone make any recommendations about how they would go about testing this? Or is my only option to create a test database and just use this database in the application, i.e. not using the testing framework.
Answer: I suggest that you look at a UI testing frameworks like Robotium which lets one test that UI elements have certain values - for example that a TextEdit contains certain text.