Hired but not happy

Question: I begun working for a company 2 months ago. It's my first job in a big enterprise. The problem is that in a lot of days I've nothing to do except having to read internal docs. And the main part of the coding tasks are modifying very small part of the already existing huge code-base, not rarely a single char in a line. Sometime I fell like I'm not good, because I can't find what it can be the required solution. I can do my solution of course, but it's not what they require. I had little or no support from senior members most of the time. I feel like I'm steeling my salary but... It isn't even high (19k per year in south EU). I think that I'm going to change my job, or at least my company. Hopefully before that they make the choice for me because I'm not adapting. But... What do you think? It's normal or I'm unlucky? Before this job I worked in small enterprises, and it was very different (always a lot of job, even too much, and a lot of freedom and "just it works" philosofy)
Comment: Someone needs to build an omnibus of all the "I am shocked, shocked, that my first software job is crap" questions on this site!
Comment: @Fattie I don't know where this sentiment is coming from that this is the norm, I haven't experienced it myself nor does it seem the general experience of the people I work with.
Answer: This is how big enterprise works. In so many cases, a person is hired and then the manager learns that there is a new person on the team. The manager doesn't have tasks ready for a new person. It takes a while for the organization to find the right work for this new person.
Some stories: A large Aerospace company in CA was known for hiring people and putting them in a trailer for 6-9 months while the security clearances came through. That gave the managers time to find what that new person could be assigned to.
A relative (with PhD and decades of experience) went to work for Chase in NYC. He endured weeks of reading corporate documents before getting to work on the stuff that they said they hired him for.
In short, this behavior is totally normal for huge corporations. It will change.
Comment: I had to change a word on a website for medium sized company's client (we had 400 employees across North America. Client was a province-wide electricity provider). Because we dealt with huge amount of money, I had to get so many signatures to add a single "s". On another project, I had to find out whether a specific FTP server was active or passive. That took 5 days of talking to dozens upon dozens of people. It's just how highly bureaucratic companies work, and large enterprises are steeped in bureaucracy.
Comment: It is totally sad and a waste of time, but it IS - exactly as the answer indicates - how many companies work. Heck, even having a computer can be something that takes months.
Answer: You might just be experiencing Imposter Syndrome. If you have 1-on-1 meetings with your boss, then that would be a good time to ask for feedback, be it positive or negative. If you don't have 1-on-1s, suggest it to your boss. You could also ask your boss for a mentor that could help you every so often.
Whenever you are left with nothing to do, ask your boss for tasks, and what to do when you run out of tasks (as @JoeStrazzere pointed out). Otherwise, do things to improve yourself (e.g. learning new technologies, reading industry articles) or to improve certain processes at the company.
Answer: I have been worked in a big company for many years, I can tell you, there is nothing strange in your case, big company more or less the same.
You would have your "formal" work to do after few months or even after probation. Similar case is very common.
Don't think about your salary, until your whole family rely on your salary. What you need to do is learning, learning your professional knowledge. Being working record in big company would great great help your career!
Answer: When I began my new job two years ago, I spend the better part of two weeks reading and cleaning out old files before I was trained to do what I do now.  My boss warned me, "be thankful for the occasional downtime...it doesn't happen all that often."
There are times where it does feel chaotic, but I do appreciate those times when I have a free moment or two to relax, take a breather, and then focus on what needs to be done.

Hired but not happy


Information on this rock, and identity?

Question: My aunt gave me this rock.  She has had for years.  She was given it by a relative who passed many years ago.  She said it was called a Tuffy (not sure which way it should be spelled) and that it came from Neveda.  I couldn't find any info on it.  Could you help.  Thank you.
Comment: You need at least one more photo from a different angle with coin or ruler to show scale. Also some idea of weight and hardness. Ideally some info on the site, but that seems impossible in this case. It didn't come from an old nuclear test site by any chance?
Comment: From what I understand, no it didn't come from a nuclear test site. I will get more pictures posted later today. It is very heavy. I can lift up to 50 lbs., and I can't even start to lift this one. Thank you for comments.
Answer: Typically we are not answering Rock Id questions, though this is a somewhat unique question because the rock is unique.  Your rock is likely a tufa (never heard it called tuffy).  It is a rock that is formed when water with high carbonate content is released to the surface.  Depending on the conditions at the surface the dissolved carbonate comes out of solution, this can be through cooling, depressurization and reduction of the partial pressure of CO2, or through biological precipitation by organisms such as blue-green algae.  There may also be other means that the deposition occurs but overall the water solution is initially oversaturated with the carbonate minerals.  These deposit out in the patterns shown on your sample.  If you were to perform an acid test your rock should show a strong reaction.  The area around the California Nevada boundary has a large number of locations with this type of deposit both active, Mono Lake, and inactive like the Trona Pinnacles.  Nevada itself has some of these deposits in the Black Rock Desert, Pyramid Lake and Fly Ranch areas.  Deposits are likely found world wide but these are the ones I am familiar with.  The pattern of deposition on your rock suggests to me an association with algae when it was deposited.  See the following sites:
https://en.wikipedia.org/wiki/Tufa
https://www.blackrockdesert.org/wiki/index.php?title=Geology

Information on this rock, and identity?


PubMed RSS Feeds

Question: I would like to be up to date with published articles on my research topic. I saw that pubmed allow to subscribe to a research (there is an RSS link just below the research box), so I added the RSS to my Outlook account. The problem is the new feeds seem not very frequent, and the articles are not  even recent! (I added the RSS feed in November, today I got an update with a paper published in September 2012, which by the way I had already read).
Do you subscribe to this kind of RSS? Is it a problem of Pubmed, or maybe of Outlook?
Answer: In this case, it's a PubMed issue, but it's actually an issue that most of the online aggregators and literature databases share: for some reason, which I have never managed to understand, databases update is slow.
If I take a given journal indexed in PubMed, Phys. Rev. Lett., let's see what are the most recently added articles:

You see that they are two months old (dating November 21, while I write this answer on January 25). Both the web search front-end and the RSS use the same database, which is not fast to pick up papers from some journals. Your mileage may vary, however: the most recently added PLOS One articles are dated January 16, a mere 10-days old:

I say that most databases I know have the same issue. From experience, Web of Science has the slowest update, while both PubMed and Google Scholar are better. For my field (chemistry), SciFinder has the fastest update speed.
Comment: @laika look at the RSS feed in another viewer, like Google Reader or Firefox. I doubt it's an Outlook issue.
Comment: Thank you for the reply. What puzzles me is that if I make a research today, sorting by newest added, from the website, with the same words, I get much more recent papers (like 20 papers from January 2013). That's why I was wondering if it was also an Outlook issue.
Comment: Sorry, I had to check again my exact research terms and now I see that the paper I received today is just the second newest article according to Pubmed (so it's not sooo bad as I was thinking). I'll give a look to SciFinder too!

PubMed RSS Feeds


How can I see my skill abilities?

Question: I've just started playing The Secret World. In the game you have room to place skill points and ability points. It seems that if you place a skill point you get a small passive bonus. But it went away too fast and I didn't actually see what bonus I got. Is there a way for me to see what the future skills give, and what the previous skills have given me?
Answer: Expand the particular skill bar in question (hit the +) and mouse over the little tick marks instead of the button to allocate skill points.  It'll display what the current tier gives you, and also what the next tier will give you (at the low levels I've hit, always just seems to be a slightly upgraded version of the same effect).
Comment: I've noticed occasionally that tooltips in this game will misbehave (often in mission results screens, oddly enough).  Probably just some bugs to work out!
Comment: Hmm, very strange i was doing that 2 days ago but it didn't work, tried yesterday and it did work. Thanks!

How can I see my skill abilities?


Minecraft 1.13.2: changing LAN hosts without using intial hosts playerdata?

Question: When I take a single player world from a friend who was hosting the LAN server I have their player data instead of my UI. Is it possible to start with mine and then host?
Also, in a way in which the friend doesn't lose their data when they rejoin?
Comment: Hm, I think there should be a "how to migrate player data" FAQ, there are many questions like "make LAN world into server and keep my data" or "move data from one server player to singleplayer" or like this.
Answer: re Kyle Yee's answer, the solution did not work for me initially. Turned out because I'd already loaded the save once, player B's playerdata had been overwritten by player A's. So deleting Player under level.data made no apparent difference.
Solution worked fine after I copied the save afresh and deleted Player before attempting to load the save. Don't know if it made any difference, but I did the same under level.dat_old.
As an aside, the following can be used to edit DAT files. NBTExplorer
Answer: You could try this solution that was posted in a couple of other places: https://gaming.stackexchange.com/a/197693/228410
But in cases like mine, this did not work. In which case, you would have to use a dedicated server to store playerdata for each player's UUID in the correct manner.


Request an extension for paper revision

Question: The deadline for submitting my revised paper for a journal is July 30th. I emailed the editor and asked for the deadline in two weeks, but the editor did not respond. Where is the problem? Why didn't the editor answer? Is this common? I'm afraid the deadline will come and my request will be ignored and the article will be rejected. I would like your help.
I am sure the email address is correct and sent.
Comment: Don't worry. I'm pretty sure the *worst case* scenario that can happen is the journal declining your manuscript with option to resubmit. That doesn't have any serious consequences. The editor would still send it to the same reviewers. If the journal declines it is because they care about their statistical benchmarks (time from submission to acceptance). They still would want to get the submission but prefer it as a new submission. But it's very likely that they will just grant the extension.
Comment: How long have you waited?  Editors are busy people.  I know of an Editor who only attends to his/her journal responsibilities one day a month.  You can try emailing the admin person for the journal.  In my experience, missing a deadline won't result in a rejection.  I had journals chase me after the deadline of my papers.
Comment: Thanks for your answer Prof. ...  Among a week. In his previous email, the editor himself suggested that I have this option to request an extension.
Comment: Thank you very much dear Ronald. Its alright. I'm not worried anymore.
Answer: First things first: we are all humans, and the editor is probably aware if this, too. Hence, I believe that missing a deadline (in most cases) wont cause immediate rejection of a paper even if you had not asked for an extension.
As editors are commonly very busy, you should not put that much weight on him/her not responding within a week's time. Furthermore, if you clearly requested an extension of the deadline to a new date X, you have fulfilled your obligation to request an extension. Therefore, under normal circumstances, I would assume that you are now on the safe side for the time being, although the editor did not yet respond.
Comment: Your answer was promising. So the reason for this is my inexperience. Thank you very much dear pbaer.

Request an extension for paper revision


Lessen the acidity of fruit shrub syrup

Question: I made a strawberry/cherry shrub for the first time with a 1:1 ratio of fruit juice to white wine vinegar, about 5 cups total, and it turned out just a little too strong for my taste. Is there anything I can add to lessen the vinegar flavor about 10-20%?
Answer: You could simply change the ratio by adding more fruit juice; otherwise you're into experimental territory by adding alkali almost at random.
Baking soda would reduce the pH, but I'm not hopeful for what it would do to the taste, or look.
Whatever you decide, I'd test it in small portions first.
You may end up just liking it mixed with tonic water... or gin... or...
Comment: Yeah, I figured this might be the only option, but I was hoping someone else would have an idea that didn't require a second batch. But, fair enough, I'll go with this. Thanks!

Lessen the acidity of fruit shrub syrup


How are some coins premined?

Question: Did the developers of the various premined coins have to wait for those coins to be mined first or did they change the code to first issue themselves the premined coins?
I'm referring to the list of coins at http://altcoins.com/scamcoins
Answer: Both options are possible. I don't know how most scamcoins do it but I believe it's more common to actually mine coins before the chain is released to the public.
Comment: They can mine with low difficulty first and then raise it.
Answer: There are various ways to premine coins, some are use for scam coins and others are used by experimental altcoins.
The premining made by scam coins are usually made with 3 methods:
1-At the first method the guy create the coin and start to mine it, after some amount of time he tell the internet the coin exist and promote it. At this moment he already have alot of coins. After it, he sell the coins he has to the public.
2-The second method involves the guy promoting the coin, but just creating a thread about the coin at some forum and not really advertising it, he just start to really advertise the coin after he has already mined alot of coins. The difference between this and number one is that this method will reduce the amount of people that will say the coin is a scam. After people start to mine the coins, he can see the coins to those who want.
3-The third involves selling all the coins to the public, everyone pay some amount of money and each person that gave money to the project get some % of the coins based at the amount of money they paid to the developers. After they receive the money, they gradually stop to work at the coin. Mining is made to get transaction fees.
Then there are the other premine method, used by experimental coins, some say some (or all) of those ideas are bad ones, but they aren't made by people trying really scam others, but by people that want to try the idea or think they can work.
1-The previous idea 3 can be used in a non scam coin. If that's the case, the developers will really continue to work at the coin, after they receive the money.
2-Another method include burning coins. People sent another altcoin (at some implementations a specific coin, at others various coins can be burned) to a place that will then (at the moment they sent the coins or at a specific date) burn their coins. The users that burned the coins will receive money from the new coin based at the amount of coins they burned. They can either receive X coins for every Y coins their burned, or Z% of the total amount of coins based at the % of total burned coins that came from him.
3-Other method includes, sharing the coin equally between everyone that ask. When the coin "start to run" everyone will have their own coin.
4-This fourth method involves people mining the coin as usual, but the coin is blocked, you can't use the coin until all coins are mined.
5-At the fifth method, people don't mine coins, but they mine numbers. People use their computers to mine numbers and after some amount of months or years the mining stop. After the mining stop, all coins are spread between the users, based at the amount of numbers they mined, if there are 100 coins and 3 users mined numbers, the first one mining 30 numbers, the second mining 50 numbers and the third 120. The first guy will get 15 coins, the second one will get 25 coins and the third one. will get 60 coins.
At method 3 of of scam premine and all the 5 method of non scam premine you can either have transaction fees, where people mine those fees, or demurrage, where the system get X coins (or X% of your coins) every Y months and give back to the system to be mined.

How are some coins premined?


Can my landlord legally not let me do my anmeldung in Germany?

Question: I really need to do my anmeldung so I can start working and get health insurance in Germany now (during corona). I moved out of a youth hostel once it shut down and me and two others found a room for rent which is sort of a hotel that had been converted to an apartment during corona, since they lost their customers. The landlord says anmeldung is not possible here, but I was wondering if that is fair, since we are paying to be here, and it is now basically impossible for us to get our anmeldung without moving and paying somewhere else (or even double paying). I can't generate income without my anmeldung.
Comment: "sort of a hotel that had been converted to an apartment during corona". This is the salient point. Has it actually been (legally) converted to an apartment or is merely that the hotel is offering extended accommodation periods. Do you have a rental contract?
Comment: anmeldung = residency registration, a distinctively Germany bureaucratic process. https://mag.n26.com/how-to-register-your-address-in-germany-aka-do-the-anmeldung-a62fad5d429
Comment: @MarkJohnson Fair enough. The primary purpose of the comment was to define the German language term for future readers, which is difficult because there isn't a good exact counterpart in English since it is far more of a big deal than, for example, a voter registration and most common law countries disaggregate the role it serves into multiple filings.
Comment: @ohwilleke Most European countries have such systems. It supplies the city important planing information ; simplifies a passport application ; automatic sending of a voters card before an election. So it has its benifits.
Answer: No, they can't. They are required by law to issue a Einzugsbestätigung when your indended stay is longer than 3 months when staying in a hostel or pension or another form of temporary accommodation.
The rule for temporary residence (up to 3 months) have many exceptions

Youth Hostel are exempted
Hotels, Pensions have a simplified registration (Hotel registration)

For long term residence in  Hostel, Pension etc.  (everything more than 3 months), the standard rules apply

registration after 3 months plus 14 days at the latest
may be done earlier, if the extended stay exceeds 3 months

This sample assumes the person is not registered elsewere in Germany.
For those who are registered elsewhere in Germany

6 months apply instead of 3 months

A Einzugsbestätigung (Confirmation of moving in) must be issued by the landlord when registering.
Should the landlord refuse to issue a Einzugsbestätigung, you are required to report this to registry office immediately to avoid paying a fine.
In pratical terms, you should go to the office personally and tell them that you want to register but landlord refuse to issue a Einzugsbestätigung.
When moving a permanent residence, registration within 14 days is required.

Die "Hotelmeldepflicht"
3. Abgrenzung zur allgemeinen Meldepflicht
...
Allerdings greift für eine Beherbergungsstätte diese allgemeine Meldepflicht lediglich dann ein, wenn eine der beiden folgenden Fallgruppen vorliegt:
Fallgruppe 1:
Die aufgenommene Person ist nicht für eine Wohnung im Inland gemeldet und ihr Aufenthalt überschreitet die Dauer von drei Monaten.
Dann muss sie sich bei der Meldebehörde ganz regulär anmelden und zwar binnen zwei Wochen, nachdem der Zeitraum von drei Monaten überschritten wurde. (Fall des § 29 Abs. 1 Satz 2 BMG). Eine Anmeldung schon vor Ablauf der genannten Zeitgrenzen ist möglich, sofern von vornherein ein darüber hinausgehender Aufenthalt beabsichtigt ist.
...

3. Differentiation from the general reporting obligation
...
However, this general reporting obligation only applies to an accommodation facility if one of the two following groups of cases applies:
Case group 1:
The admitted person is not registered for an apartment in Germany and their stay exceeds three months.
Then they have to register with the registration authority in the normal way, within two weeks after the period of three months has been exceeded.  (Case of Section 29 Paragraph 1 Sentence 2 BMG).  It is possible to register before the specified time limits have expired, provided that a longer stay is planned from the outset.
...

Meldegesetz – Einzugsbestätigung
Weigert sich Ihr Vermieter oder Wohnungsgeber, Ihnen die Bestätigung auszustellen, müssen Sie dies umgehend der zuständigen Meldebehörde mitteilen (§ 19 Abs. 2 BMG). Nur so laufen Sie nicht Gefahr, ein Bußgeld zahlen zu müssen. Denn wer seinen Pflichten nicht nachkommt, riskiert ein Bußgeld von bis zu 1.000 Euro (§ 54 Abs. 2 Nr. 1, Abs. 3 BMG).

If your landlord or the landlord refuses to issue you the confirmation, you must notify the competent registration authority immediately (Section 19 (2) BMG).  This is the only way you do not run the risk of having to pay a fine.  Because anyone who does not meet his obligations risks a fine of up to 1,000 euros (Section 54, Paragraph 2, No. 1, Paragraph 3 BMG).

Sources:

Die "Hotelmeldepflicht" | rehm. Beste Antwort

Section 29 - Special registration requirement for commercial accommodations

Meldegesetz – Muss ich dem Amt eine Einzugsbestätigung vorlegen? - Finanztip

Section 19 - Cooperation by the supplier of the residence
Section 54 - Provisions on administrative fines


Linux : Display a permanent text on the desktop

Question: I am looking for a way to display a permanent text on the desktop (xfce/gnome but if I found a way on another window manager, I catch).
I was asked to show a version number on the desktop in a permanent way, so I have to display it on opening session, and I have to update it if our software is updated.
How can I do this?
Answer: It should be possible to run any Xwindow application in the root window, however a simpler solution would be to use a wallpaper and set up a cron job to update the wallpaper file from a template using a script. You can add text (for example) using the imagemagick toolkit or using the GD extension with PHP.
It's possible to force XFCE to reload the wallpaper.
Answer: in gnome you can set a global background using
gconftool-2 --direct \
--config-source xml:readwrite:/etc/opt/gnome/gconf/gconf.xml.mandatory \
--type string --set /desktop/gnome/background/picture_filename
/usr/share/wallpapers/default-1600x1200.jpg

source
You could use convert to generate the wallpaper at login as explained here
Remove the option to change the wallpaper
You could then use a script like
version= `uname -a`
convert -pointsize 10 -fill blue -draw 'text 800,6000 "version" ' basewallpaper.jpg usr/share/wallpapers/default-1600x1200.jpg


Improving model training speed in caret (R)

Question: I have a dataset consisting of 20 features and roughly 300,000 observations.  I'm using caret to train model with doParallel and four cores.  Even training on 10% of my data takes well over eight hours for the methods I've tried (rf, nnet, adabag, svmPoly).  I'm resampling with with bootstrapping 3 times and my tuneLength is 5.  Is there anything I can do to speed up this agonizingly slow process?  Someone suggested using the underlying library can speed up my the process as much as 10x, but before I go down that route I'd like to make sure there is no other alternative.
Comment: I don't think you should be statistically altering your input data set.  I would be surprised if you can't take a smaller subset than what you have.  That being said, 300K observations is not that large in the grand scheme of things.
Comment: I agree, 300K is not that large which is what makes the performance so upsetting.
Comment: To ask the obvious: Would it be possible for you to work with a subset of the 300K observations?  You could show that a 30K subset behaves the same way as the full 300K set.
Comment: Hi Tim, sorry if I wasn't clear.  8 hours was for training 30k observations (10%).  Training on 1% takes a reasonable amount of time, but is not very predictive.  Here's a question for you: my outcome is a binary factor ('Yes'/'No') but 'Yes' only occurs in about 20% of my total dataset.  Do you think providing a test set with a more even split (say 50/50 'Yes'/'No') might allow me to train on a smaller sample size?
Comment: It's really that slow on 30k x 20?  That's really surprising.  How much RAM are you working with?
Comment: I've got 4GB.  random forests seem to take an incredible amount of time.
Answer: @phiver hits the nail on the head but, for this situation, there are a few things to suggest:

make sure that you are not exhausting your system memory by using parallel processing. You are making X extra copies of the data in memory when using X workers.
with a class imbalance, additional sampling can help. Downsampling might help improve performance and take less time.
use different libraries. ranger instead of randomForest, xgboost or C5.0 instead of gbm. You should realize that ensemble methods are fitting a ton of constituent models and a bound to take a while to fit.
the package has a racing-type algorithm for tuning parameters in less time
the development version on github has random search methods for the models with a lot of tuning parameters.

Max
Answer: What people forget when comparing the underlying model versus using caret is that caret has a lot of extra stuff going on.
Take for example your randomforest. so bootstrap, number 3, and tuneLength 5.
So you resample 3 times, and because of the tuneLength you try to find a good value for mtry. In total you run 15 random forests and comparing these to get the best one for the final model, versus only 1 if you use the basic random forest model.
Also you are running parallel on 4 cores and randomforest needs all the observations available, so all your training observations will be 4 times in memory. Probably not much memory left for training the model.
My advice is to start scaling down to see if you can speed things up, like setting the bootstrap number to 1 and tune length back to the default 3. Or even setting the traincontrol method to "none", just to get an idea on how fast the model is on the minimal settings and no resampling.
Comment: What "extra" stuff does caret have going on compared to the other methods?
Comment: Caret does a hyperparameter search. It searches the tuning parameters to find the best combination.
Answer: Great inputs by @phiver and @topepo. I will try to summarize and add some more points that I gathered from the little bit of SO posts searching that I did for a similar problem:

Yes, parallel processing takes more time, with lesser memory. With 8 cores and 64GB RAM, a rule of thumb could be to use 5-6 workers at best.
@topepo's page on caret pre-processing here is fantastic. It is step-wise instructive and helps to replace the manual work of pre-processing such as dummy variables, removing multi-collinear /linear combination variables and transformation.
One of the reasons the randomForest and other models become really slow is because of the number of factors in categorical variables. It is either advised to club factors or convert to ordinal/numeric transformation if possible.
Try using the Tunegrid feature in caret to the fullest for the ensemble models. Start with least values of mtry/ntree for a sample of data and see how it works out in terms of improvement in accuracy improvement.
I found out this SO page to be very useful where parRF is suggested primarily. I didn't a lot of improvement in my dataset by replacing RF with parRF but you can try out. The other suggestions there is to use data.table instead of dataframes and use predictor/response data instead of formula. It greatly improves the speed, believe me (But there is a caveat, the performance of predictor/response data (providing x=X, y=Y data.tables) also seems to somehow improve predictive accuracy somehow and change the Variable importance table from factor-wise break up while using formula (Y~.).


Drupal shows mobile theme on desktop

Question: I have drupal 6 with mobile-tools module and idrupal theme for iphones. sometimes my website starts displaying mobile theme (idrupal) for desktop, and the only way to return back to normal theme for desktop is to flush all caches.
is there a permanent solution to disallow idrupal theme from being used for desktop?
Answer: If you are using varnish in front of the your server, then it will completly cache you request, Mobile tools will not be able to determine the useragent is mobile or desktop to redirect the theme.
One of the solution is to determine at varnish level and redirect to a m.domain which always has a mobile theme attached to it.
Refer the following links

http://fangel.github.com/mobile-detection-varnish-drupal/
http://mobiledrupal.com/content/mobile-device-detection-varnish-0
Comment: @Alaa honestly, that's even worse - with page cache, memcache has no option to tell what should be served, it only knows what got cached. That's why modern themes are trying their best to solve this by CSS and JS, purely on browser's side.
Comment: Thanks Dinesh,,, but i am not using neither varnish,,,i am just using memcached and i flush it periodically (every one hour)

Drupal shows mobile theme on desktop


If $cor(X,\epsilon) \approx 0$ in linear regression, can we conclude $X$ is exogenous?

Question: Suppose that we run the simple linear regression $Y = \alpha + \beta X + \epsilon$.
I want to test whether the independent variable $X$ is exogenous.
If the correlation between the independent variable $X$ and the residual of linear regression $\epsilon$ is almost zero, i.e. $cor(X, \epsilon) \approx 0$,
can I then conclude that this simple test suggests that the independent variable $X$ is exogenous?
Comment: the issue is that in practice you don't observe $\epsilon$ (only $\hat{\epsilon}$) so you can never compute $\mbox{cor}(X,\epsilon)$
Comment: The correlation between regressors and residuals (not errors) in a linear regression model estimated by least squares _is_ always zero. You cannot test exogeneity (conditional uncorrelatedness) without instrumental variables.
Comment: As said above, $\epsilon$ is unobservable so you need to rely on your own knowledge and use the common sense to decide about exogeneity.
Comment: Thank you for your comments, as putting them all together answers my question. Is anyone willing to organize these together into an answer which I can accept?
Answer: The linear regression model is
$$
\boldsymbol{Y}  = \mathbf{X}\boldsymbol{\beta} + \boldsymbol{\varepsilon}
$$
together with the conditional uncorrelatedness assumption $\mathbb{E}( \mathbf{X}\boldsymbol{\varepsilon}) = \boldsymbol{0}$.
If estimation of the parameters $\boldsymbol{\beta}$ proceeds by least squares, then the first order conditions (normal equations) are
$$
\begin{align}
\mathbf{X}'\left(\boldsymbol{Y}  - \mathbf{X}\hat{\boldsymbol{\beta}} \right) &= \boldsymbol{0} \\
\mathbf{X}'\hat{\boldsymbol{\varepsilon}} &= \boldsymbol{0}
\end{align}
$$
where the last line indicates that the correlation between the residuals and the regressors is always zero for a linear regression model estimated by least squares. Thus this cannot form the basis of a test for the unconditional uncorrelatedness assumption in the linear regression model.
In order to test the exogeneity assumption, you will need access to instrumental variables. See the Durbin-Wu-Hausman test.


Help identifying my 2000s Specialized FSR Elite

Question: I'm trying to resuscitate my stumpjumper FSR ELITE.
I'VE SEARCHED the interwebz and it's just confused me. I need to have the shock rebuilt or replaced, and the forks need a rebuild or replace. I need to know the exact year to confirm several things. Most important is the rear shock length, something like 7.25x1.75. This will help me decide whether to rebuild if I can find parts or but a replacement. Same for the steerer tube. I think it's 1⅛ straight, but need to confirm.
The shock says Triad, and the fork says Talas RC 100-120-140. The model is stumpjumper elite, in M5 alloy. The specs for 2004 sj FSR elite refer to m4 alloy, but mine is M5. 2006 maybe? But according to this link https://www.bikeradar.com/reviews/bikes/mountain-bikes/specialized-stumpjumper-pro-fsr-06-review/ the '06 has
The 2005 was made in M4, so it's not that. The 2006 SJ FSR 'pro' has a brain rear shock, and different groupset. Despite that, I'm pretty sure it's a 2006. 2007 they changed the linkage completely. The specialized site is no help. . I have decent trails nearby, but the shock is leaking oil everywhere. I might just have to pull it off and send it to fox or S4 suspension in Montreal. If I still lived in Whistler I could visit them there dangit. But I'm nowhere near a specialized bike shop. I tried to find the serial number, supposedly it's stamped under the BB but I can't find it. I'm stumped  haha
Lots of pics in Google album. Note the very asym rear triangle. Xtr long cage, LX front bottom pull derailleurs, dt swiss wheels, and avid juicy 7s. Thanks!
Comment: Check the underside of the pivot link for cracks. I've just sent a 2006 FSR XC with same pivot design to art project land as pivot has cracked.
Comment: My 02 Stumpy ended it's life via a broken linkage as well. @Brandon Mount, that is a sweet looking Stumpjumper. Pretty clean looking as well. My builds consistently feature Shimano XT/XTR components and Fox suspension.
Comment: Thanks all! I think I can get a fox 32 with a straight steerer, from fox in burnaby, and a rebuild of the triad by S4 in Montreal. . Now to disassemble the bike... I'll get it done soon, just have many chores on my plate. I guess riding this fall is off the table sadly.
Answer: Matching the colour and decales on google search results, looks likely a 2007, However it does not matter that much, all the information you need can be found by looking at the parts.
2007 will be a 1 1/8" straight steerer fork. A quality replacement fork will likely be hard to find these days (recently went though it with my 2010 Scott Spark), aim for a full service if you can still get the parts needed, and consider a used fork if you need to replace.
The shock is a Fox Triad. If you find the shock serial number head over to Fox and use the serial number to find the details you need.   (https://www.ridefox.com/fox17/help.php?m=bike). Shock size is reported to be anything from 7.25 x 1.5 to 7.825x1.9. I suspect the stock shock is non-standard (not uncommon back then) and people have fitted various alternates with various degrees of success.
If you cannot get an exact match, aim for a shock that is no longer than the specified shock length when uncompressed, and has a compressed length no shorter than the specified shocks compressed length. If you still have choices of shocks, choose the longest.
Comment: Understood, that's pretty much where I'm at. I guess Specialized were evolving these bikes so quickly that there's a bit of overlap. 2007s that I can find have different shock linkage, but maybe it's a 2006.5 or something.
Comment: Be thankful, in 2007, shock length was about it, wheels were 26", tires 2.1", steerer 1 1/8", axles QR. BB standards were starting to play silly, but at least it was only matching BB and Crank.
Answer: Based on the components listed for this 2006 FSR Elite, which are identical to the kit you described on yours, I think we can confidently put yours in MY 2006.
Here is an online Owners Manual for the Fox Triad shock.  Within this document is a hotlink for authorized service centers.  It's pretty straight forward to obtain the critical measurements of your shock to find a replacement match size-wise. You need the eye to eye measurement and the stroke length, which is very close to the length of the exposed shock body minus 5mm.  Emailing Fox should get you some answers fairly quick in my experience.
The Talas is a decent fork for its time. I like the adjustable travel feature. It likely has an open bath damper, either an RL or RLC.  Replacement parts and even seal kits for these are scarce. At least in the online marketplace.  There is brisk used fork market and Fox forks from this era can sell for upwards of $300. Unfortunately, new straight steerer forks are not common any more and the most popular brands, Fox and Rockshox do not even offer straight steerers on their new products. Fox definitely doesn't. I'm fairly certain your head tube is 34mm inside diameter, and it's not possible to even adapt that via special headset cups to accept a tapered steerer fork.
One upgrade I did with my 2002 FSR was to put a Shimano Hollowtech2, 2x crankset on it. The external bearing system and the crank itself was much lighter than the 3x stock with cartridge bottom bracket.
Comment: Thanks Jeff, very helpful!


Can't connect to IIS Express using IP Address

Question: From what I understand, VS2012 comes with the IIS Express version by default.  And it allows you to connect to the development site using IP address.  Currently I can connect using http://localhost:22222.  But this would not connect using this http://xxx.xxx.xxx.xxx:22222 where xxx just a local IP of the development machine .  I have verified that the IIS Express is running and being used.  The IE error was http 400 bad request.
Comment: possible duplicate of [Browse Web Site With IP Address Rather than localhost](http://stackoverflow.com/questions/14881515/browse-web-site-with-ip-address-rather-than-localhost)
Comment: You can do this easily with our free extension 'Conveyor' which you can get from Tools->Extensions or https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
Answer: I know you have asked question since a long time. I have an answer to this question at this link.
Go to your IISExpress>Config folder, locate applicationhost.config. Change <bindings> as below:
<bindings>
      <binding protocol="http" bindingInformation="*:1407:YOUR_IP_ADDRESS" />
</bindings>

Before you do this , you will have to register this IP address using netsh command as below:
If you're running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.11:1234 with whatever IP and port you are using:
> netsh http add urlacl url=http://192.168.1.11:1234/ user=everyone

This just tells http.sys that it's ok to talk to this url.
> netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=1234 profile=private remoteip=localsubnet action=allow

This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.More information at this link.
Note: Be sure to change the bindings of your project only by locationg its name. You can even keep the localhost binding and add a new one , this way you can access same webpage using the given IP address.
Comment: If it's the same answer, then this is a duplicate of that question.
Comment: @JohnSaunders Yes it is.
Answer: The solution that worked for me was this one:
The one thing that fixed this for me was using the following line in the <bindings> section for my site in the applicationhost.config file:
<bindings>
    <binding protocol="http" bindingInformation="*:8099:" />
</bindings>

The key was to simply remove localhost. Don't replace it with an asterisk, don't replace it with an IP or a computer name. Just leave it blank after the colon.
After doing this, I don't need to run Visual Studio as administrator, and I can freely change the Project Url in the project properties to the local IP or computer name. I then set up port forwarding and it was accessible to the Internet.
EDIT:
I've discovered one more quirk that is important to getting IIS Express to properly serve external requests.
If you are running Visual Studio/IIS Express as an administrator, you must not add a reservation to HTTP.SYS using the "netsh http add urlacl ..." command. Doing so will cause an HTTP 503 Service Unavailable error. Delete any reservations you've made in the URLACL to fix this.
If you are not running Visual Studio/IIS Express as an administrator, you must add a reservation to the URLACL.
Answer: Where is it located? applicationhost.config  :)
Here

%userprofile%\Documents\IISExpress\config folder

or

%userprofile%\My Documents\IISExpress\config folder


Cut polygon shapefile with 2 parallel lines to derive new inside polygon?

Question: Using Python scripting: How can I clip a polygon shapefile with parallel lines (polyline shapefile) to derive new inside polygon?
Comment: Orange is the polygon and blue is the polyline.
Comment: Is orange the polyline and blue the polygon, or the other way around?
Answer: Here is how it can be done, but not the actual code to do it.  The Feature to Polygon tool would create 3 polygons from the input you have shown in a new feature class.  Then you could use a search cursor to process the original input lines layer to select each line separately and process each through a Select by Location operation, with the first using the create new selection option and the second using the select from current selection option.  This would select the polygon where both lines touched it.  Then you could use a search cursors on the new polygon feature class to read the geometry of the new polygon and an update cursor on the original polygon feature class that selects the original polygon and replaces its shape with the new shape.
Because you have no way of knowing if the removed portions of the polygon will be larger or smaller than the remaining polygon, and the centroid position representing the two irregularly shaped lines cannot be guaranteed to always fall inside of the polygon portion you want to keep, I don't think there is any other reliable process for getting the polygon portion you want to keep.


Rotation in iPad app

Question: In my iPad app, the view controller include three button, one navigation bar and one tool bar.
When i rotate my view controller from portrait to landscape mode, three buttons are disorder.
The navigation bar also collapse to tool bar.
How can i do it?
Answer: You need to learn about layout. You can lay out subviews of your view in three ways:

Manually
Autoresizing (springs and struts)
Autolayout (constraints)

If this is a new project in Xcode 4.5 or later, you are using autolayout by default. So you need to go back into the nib and edit the constraints that Xcode already gave you, because obviously they are not what you want.
You might want to read the Layout section of my book, which has extensive discussion of how autolayout works and how to edit constraints in the nib: http://www.apeth.com/iOSBook/ch14.html#_layout
Answer: Ideally you should keep your content under one xib per view controller, linking your buttons and nav bars by pinning to your layout should rotate properly; however there is one other option for a viewing a different xib when the device is rotated, see the answer below.
Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?

Rotation in iPad app


Why does Neelix cook, when the replicator can produce any meal?

Question: Similar to If everyone uses replicator, why do tailors still exist?, why is Neelix almost always cooking when we visit the officer's mess? Surely the replicator can produce any known recipe it has been programmed to? Or is Neelix cooking new recipes, to then program the replicator for?
Comment: I'm sure Neelix was asked about it, possibly repeatedly. I don't remember the reply, but it sure should be part of at least 1 answer.
Comment: Same reason as Voyager firing 123 of its 38 torpedoes during the series.  Or, non-canonically, because Janeway wanted an excuse for a morale officer / scapegoat to deflect complaints on the ship to a more manageable outlet.
Comment: Why do chefs exist today if the shops sells premade freezer meals?
Comment: To use the replicator, it must know what to replicate. For example, if someone wanted a cup of tea, then the replicator should be programmed with the data about India, about China, about Ceylon. It would be programmed with the data about broad leaves dying in the sun, about silver teapots, about summer afternoons, about putting the milk before the tea so it wouldn't get scalded. It would even need to be programmed with the history of the East India Company. Also, the process could pose a significant risk for the ship if the replicator were to block the ship systems during a Vogon/Borg attack.
Comment: @SJuan76 "milk before the tea"; sacralidge!
Answer: Replicators use Dilithium, which was scarce
Every use of the replicator takes energy:

A replicator, replicator system, replication system, or molecular synthesizer was a device that used matter-energy conversion technology similar to a transporter to produce almost anything from a ship's replicator reserves. (TNG: "Lonely Among Us", "Deja Q"; DS9: "Visionary"; VOY: "Virtuoso"; ENT: "Dead Stop")
— Memory Alpha

Because Voyager was low on that energy, Janeway implemented rationing:

After the USS Voyager was pulled to the Delta Quadrant in 2371, an energy crisis occurred several weeks into the journey back to the Alpha Quadrant, and Janeway ordered replicator usage to be rationed in order to conserve power for other key systems. These replicator rations became a type of currency among its crew. (VOY: "The Cloud")
— Memory Alpha

Neelix was able to cook with most of the plants native to the Delta quadrant, obviating the need to use replicators and thus letting crew members eat without having to use rationed resources or spending their replicator 'currency' elsewhere.
Comment: @Psychonaut Maybe shuttles running impulse engines use matter-antimatter power production, and procuring or creating antimatter was not an issue. I don't remember that point being explicitly addressed though.
Comment: @Psychonaut: I think the idea is that the transporter net zero mass change. With the input mass and output mass being identical, the only energy consumed was what was required to convert it back and forth (which I'm guessing is presumed to be "small"). The replicator, by contrast, only uses half as much energy on the conversion process but has to directly consume energy to *make* the matter it's arranging in the first place. In theory it has near perfect recycling, so some of that matter later becomes energy again, but some is lost (eaten, kept as physical objects, whatever).
Comment: I've long been skeptical about this official explanation. As you mention in your answer, transporters and replicators work in much the same way. So why is it that Voyager has enough energy to regularly beam tons of fresh, perishable food onto the ship, but not enough to simply replicate it? Are shuttles really that much more energy-efficient? Or are we to assume that Voyager negotiated delivery of fresh food with a new civilization every few weeks?
Comment: The part that's "lost" to being eaten makes me think about Voyager trying to consume energy by feeding not just table scraps, but, umm, "leavings" back into the replicator for deconstruction to energy for producing new things. Still some loss (shed skin, exhaled CO₂ and H₂O, the inefficiencies of the conversion process, etc.), but you gotta conserve! If this wasn't common practice when in Federation space, it might explain Neelix's popularity; replicated stuff may be whole new atoms, but you'd know most of it was the result of a direct poop-to-energy conversion. :-)
Comment: @Psychonaut They grew food in farms in some of Voyager's cargo bays. Presumably Voyager has water and nutrient reclamation systems so that would greatly reduce the need to beam aboard all of their produce.
Comment: @Psychonaut - maybe power usage by the transporter is non-linear - decreasing per unit of (volume,mass) - therefore bulk is easier?  Alternatively (or also, these aren't mutually exclusive), maybe the replicator has a high fixed "start-up" cost, outweighting other costs such as per-unit of (volume, mass), such that that ever time you use it you pay a significant price just to activate it.  Etc. etc.
Comment: I would think of the "replicator vs transporter" as "electric heater vs heat pump" where the heater must consume a large amount of energy to _create_ heat while the heat pump uses comparatively less to simply _move_ existing heat around. Just in the context of Star Trek they're creating/moving matter. There is, of course, a _lot_ of sci-fi handwaving involved since converting just an apple's worth of matter into energy would be like moving an exploding nuke around.
Answer: A couple of reasons:

Replicators have been stated multiple times as being inferior by most measures of quality to a real cook. It's never clearly explained why, but the implication is that it's similar to the difference in real life between mass-produced fast food and a hand cooked family meal made from scratch. It's worth noting that Neelix is not the only conventional cook we see throughout the various series (off the top of my head, Joseph Sisko is the master chef of his own restaurant), and this is implied to be a key reason why people still cook.
It's implied a couple of times throughout the various series that programming a replicator is at least as difficult as producing whatever the replicator is being programmed to produce by other means. This probably partially feeds into the above point, but is worth mentioning on it's own, because it does not appear that there is some fancy molecular gastronomy simulation package in universe that could translate a traditional recipe into a replicator program to produce the same food. In effect, this means that the crew of Voyager was otherwise stuck with whatever was already programmed into the replicator at the start of the voyage, and even with a rather broad menu eating the same things all the time gets boring after a while (which in turn is bad for morale).
Replicators still require power to work, and Voyager had a limited power budget throughout most of it's trip through the Delta Quadrant. Rationing of replicator usage was implemented early on, and is mentioned multiple times throughout the series. In that situation, I for one would very much welcome another option for daily sustenance, because it would mean I could spend my replicator rations on other things. This is compounded by the fact that replicator technology is not perfectly efficient (that is, it produces less matter than the amount of energy input would imply if all of that energy were converted with perfect efficiency into matter), which means that even recycling of waste matter could not eliminate the power budget issue, just mitigate it.
Neelix wants to help, but he's implied to be at best mediocre at most of the technical jobs that would be needed to run a starship (even ignoring the issue of a Starfleet vessel being completely different in many respects from the ships he's used to dealing with). He is, however, a good cook, and this is something that none of the rest of the crew seems to be interested in doing, so it's a logical job for him to pick up, especially since he already has experience dealing with the ingredients available in the Delta Quadrant.

Edit in response to comments requesting citations for the point about replicators requiring feedstock:
On further inspection, I have now realized that my point about the requirement for feedstock for the replicators was based solely on information from non-canon (albeit properly licensed) sources, and I have thus removed this point from the original answer.
However, looking into this has made me realized that I could actually further expand on the point about the power budget (because there are multiple canonical references implying that the matter-energy conversion used in replicator technology is not 100% efficient (most prominently a comment by Spock about the titular weapon in TAS S1E14 'The Slaver Weapon', which also relies on matter-energy conversion)), and I have expanded that point accordingly.
Comment: Hi and welcome! Great first answer! Please take the [tour] and view the [help] for anything else.
Comment: "Aside from the power budget, replicators don't produce something out of nothing." Could you provide a source for this? It always seemed implied that replicators created matter *from* energy, and no "source" matter was required for this process.
Comment: I think the point about Neelix wanting to help is honestly a big component. It seemed like for most of the series, people thought of Neelix's job almost as busywork, although eating hand cooked food together does occasionally add some amount of cultural element that binds the crew.
Answer: Because they're growing their own food
Replicators are very energy-intensive and a major drain on Voyager's limited resources.
One of the cargo bays was converted into a hydroponics/airponics bay to grow fresh food fairly early on.
I have to assume that keeping grow-lamps on and running the hydroponics-pumps is less energy-intensive than fabricating food via teleporter.
Aside from that, they were known to have traded for fresh vegetables which they stored in the cargo holds (I have to assume either frozen or in stasis-fields to preserve them long-term)
The upshot is that when you have a vegetable in hand, you need a cook to prepare it into food, the replicator can't do that for you.
Puzzlingly, most mentions of the Airponics bay refer to them growing decorative (non-edible) flowers.
Apparently they were growing food efficiently enough there that they had room to spare for "just-for-fun" projects like gladiolas and chrysanthemums.
Comment: @spikey_richie Transporters and Replicators apparently use much of the same underlying technology, just Replicators work to a lower resolution and use templates to rearrange the molecules, rather than beam the source-matter as-is.
Comment: "than fabricating food via teleporter" I think you mean "than fabricating food via replicator".
Comment: I wonder if replicators really are less efficient than growing food and cooking it. Replicators can produce hot food and drinks, and the heat is confined to the item itself where as in cooking much of the heat radiates away while life-support fights to keep the room temperature down. In general I'd be surprised if direct matter conversion was less efficient than growing plants.
Comment: I can't imagine it being more efficient to fabricate the food from base elements than it is to take something that already exists in more or less the right form and heat it up. I get the sense that the Replicator as a luxury exists because starships have such a huge surplus of energy that they can afford the energy-budget to do it. (after all, if you can generate the power to bend space/time and operate particle-beam weaponry, what's a cup of coffee matter?)
Answer: Similar answer to your link: sometimes the replicator is still not programmed for certain recipes, but mostly it's for the simple joy of cooking. And probably some would complain that "food from the replicator doesn't taste like the real thing".
As described on Memory Alpha:

Neelix was an enthusiastic cook and ran the ship's mess hall. He was fond of experimenting and often tried to adapt crew members' recipes with the limited ingredients available in the Delta Quadrant, although they often complained about the results. Early on, Tom Paris remarked that Neelix's cooking was "always interesting" and the glutinous "Even better than coffee substitute" Neelix developed from native plants strongly motivated Janeway to seek new sources of energy for the ship so that she could use the replicator guilt-free. (VOY: "The Cloud") However, he was able to successfully cook a blood pie for B'Elanna. (VOY: "Day of Honor") He enjoyed finding new ingredients to work with, which usually took the form of produce rather than meat. (VOY: "Random Thoughts")
Comment: @ToddWilcox: I believe it was supposed to be a power problem (which is a "raw materials" problem in the sense that you need fuel of some sort to power the ship/replicators). Replicators can make anything from anything (they're a direct energy-to-matter-and-back system AFAIK), but it's an energy-intensive process (the ratios in e=mc² mean you need a heck of a lot of energy to make appreciable amounts of matter). The cost to collect and cook food is dramatically lower than synthesizing the food's *atoms* from raw energy. A cook was a luxury in other Trek, but in Voyager it was necessary.
Comment: Wasn't there something about having a hard time finding raw materials for the replicators in the delta quadrant and the food they could scrounge from planets didn't fit into alpha quadrant recipes? Maybe I just inserted that notion on my own.
Comment: "...often tried to adapt crew members' recipes with the limited ingredients available in the Delta Quadrant..." this might relate to that @ToddWilcox
Answer: In TNG S2:E13, Riker comments that a replicator cannot mimic a good cook. Same principle might apply here.
Comment: Do we have evidence Neelix was a good enough cook for that to be the case here?
Comment: No, @AncientSwordRage, but there's plenty of evidence to the contrary! Everyone is _always_ complaining about his cooking.
Comment: @AncientSwordRage If you look at the TNG episode, only Worf likes Riker's omelet. He opined the principle but was not a good example in practice.
Answer: Voyagers case, it's lightyears between various stars and features which have access to it's most prized source... Deuterium. With only 1 out of every 6500 hydrogen atoms in abundance.protium-protium fusion does work (the sun). A ship at warp takes weeks to cover a single sector, in any situation fuel supply could be exhausted before refueling was sufficient. starShips in friendly space are refueled at ports or fuel containing starships...also the biggest aspect, anti-matter and dilithium.
Replication is an acceptable crutch, because it's alot better than the volume needs of a 150 person, multi-racial crew with different food desires, to carry foodstuffs....Growing food is more energy efficient but more time consuming.
The amount of energy to replicate is very substantial, They do it not because it's energy efficient but volume efficient. Carrying enough food to sustain a crew of 150 for 1 year would consume a modest amount of space, Tack on culinary demands and diverse menu options (Chicken, pork, beef, etc) not to mention alien species, volume demands grow 10 fold.


Do sparse graphs have to be large?

Question: I'm looking for a good definition of sparse graphs. Is a sparse graph effectively a big one, with millions/billions of nodes? An example from real world is the Facebook graph. Or can sparse graphs be in small networks as well?
Comment: Did you already check [the Wikipedia entry?](http://en.wikipedia.org/wiki/Dense_graph)
Comment: given the above comment, removing the question might be a wise idea, unless you have some reason to be dissatisfied with the wikipedia answer. In that case, you should explain why.
Comment: @Juho I did, and it does not seem to contain a definition of "sparse".
Answer: The common definition is that a family of graphs $G = (V, E)$ is sparse if $m \in o(n^2)$, with $n = |V|$ and $m = |E|$. Formally, that requires the family to be infinite, and we only know something in the limit.
The definition does not apply to graphs of a fixed size per se. One would certainly want $m \ll n^2$ in some sense. For instance, if $m \leq 5n$ or $m \approx \log n$ you would probably say that your graph is "sparse".
You can bridge this gap by requiring a bit more on the asymptotic side. Say we call a family of graphs sparse if
$\qquad\displaystyle m \leq f(n) + O(1)$ with $f \in o(n^2)$;
then we may want to call every graph with $m \leq f(n)$ sparse. The implicit assumption is that the error term hidden in $O(1)$ is well-behaved.
Comment: That said, I think people *want* smallish graphs to be "sparse" or "dense", but they got so used to abusing Landau notation to not notice that they don't give a definition for graphs of fixed size. In the folklore department, at least; the [Wikipedia entry](http://en.wikipedia.org/wiki/Dense_graph) references definitions that work for all sizes, but I've never seen or heard anyone use them. (Disclaimer: I'm not a member of a research community that regularly deals with sparse graphs.)
Answer: Sparsity is a fuzzy notion, and its meaning will depend on the context. It can be argued a graph is not sparse "by itself", but rather it is sparse relative to other graphs. Indeed, there are several ways to define or measure sparseness.
We can say a connected graph is maximally sparse if it is a tree. Intuitively, a tree-like graph is sparse. But what could be a "tree-like graph"? Perhaps the number of cycles is bounded, or by removing a constant number of vertices we get a tree. One very popular definition of sparseness rises from these considerations. Informally, the treewidth of a graph is a measure of how close a graph is to being a tree.
To address your question, a graph of low treewidth can be either small or large. For instance, forests, trees, and outerplanar graphs all have constant treewidth. In contrast, a complete graph on $n$ vertices has treewidth $n-1$. This corresponds to our intuition that complete graphs are not sparse.
Treewidth is just one measure of sparseness. You can dig deeper into the literature and explore other measures as well.
Answer: A graph is dense if the number of edges is closer to the maximum number of edges there could be. Formally, a graph is dense if $e=\cal \Omega(v^2)$ where $v,e$ are the number of vertices and edges. A graph is sparse if the above is not true.

Do sparse graphs have to be large?


Does show and don't tell mean something different in allegorical poems as opposed to novels, movie script, etc?

Question: Can you write a love poem by showing and not telling and only describing the landscape? I am thinking you need to make it allegorical, but without mentioning animals and humans and clothes, etc, just describing the landscape, I am thinking this is impossible, so what are some ways this is done most of the time and is it even possible to do this with just the landscape? I am wondering if show don't tell means something different in poetry.
Comment: Regardless of what allegory you want to make of it, the same "show, don't tell" applies. Don't say the "landscape" has "nice hills", but describe what makes them nice. But if it's a love poem, I'd avoid making it too much about physical features of the landscape...
Comment: Ever listened to the lyrics of a national anthem? Pretty much JUST allegorical love of the landscape.
Comment: @wetcircuit Sweden maybe... but not sure about others
Answer: No.
The meaning of show don't tell is independent of composition type.
Writing a poem about love as an allegory is a composition type. How to write the allegory itself is a matter of showing vs telling.
Telling1:
These hills are nice.
The sun loves them
and wakes them up
every morning with light,
caressing their tops,
warming their body.

Vs
showing1:
With a slow,
timid pace,
the sun's
morning hand
crawls from leaf
to leaf, peeks
between the branches
and brushes away the dew
from the drowsy tops
of these sleepy hills.

1: Disclaimer -- I am no poet. These are crude illustrative examples.
Same allegory, just a different way of composing it.
The allegory meaning is that of waking up next to the loved one.
In the telling example, we 'tell' what there is to know: the sun wakes up and cuddles with the hills.
In the showing example, we 'show' the waking up process, what it entails. In this case, showing is about conveying the same image through the feelings, the speed and the sensations involved.


Does Android SDK work in Solaris?

Question: I want to compile my Android app in a Solaris server. Though, from Android Developers all I can see are Windows/MacOS/Linux versions. Does anyone know if I can install and use the Linux binaries in a Solaris machine? If not, are there alternatives?
Answer: Unless there exist tools to make linux binaries run on Solaris you won't be able to use the Android SDK binaries on Solaris, except java based ones. If the Android SDK is open source you could of course compile it on solaris, however I was unable to determine if it is open source.
The alternative would be to set up a linux (virtual) machine. My distribution of choice would be Debian stable (which is what I use for Android development).
Comment: (Some versions of) Solaris can execute some Linux executables (for the same processor architectures) through a compatibility layer. The Android SDK is open source. In principle it could be ported to Solaris, but I doubt anyone cares to spend the effort.
Answer: Your going to need gnu make 1.8 I believe its very specific to that. You may also need GCC Gnu not Unix C Compiler. If you can get those and Sun-java6-sdk running on Unix, let us all know. Python 2.6-7, build-essential, a lot of other stuff to that you may not be able the get the source for like sun-java. Though I have heard of some successes with CM and Open-java-sdk . Its hard to imagine sun wouldn't have a Unix binary.
More I think about it. Why the hell did they leave gnu n GPL (ie glibc) if its all the foundation for building android?
Comment: Solaris includes Java out of the box.  (They were both Sun products, now both Oracle products.)  Python, gcc, & gmake are included in later Solaris releases as well.  None of that is specific to the Android SDK.

Does Android SDK work in Solaris?


Is there any way looking at Stars from that I can understand that we are revolving around the Sun?(Not caring about other planets for now)

Question: I am learning Astronomy. I videos or lessons I look at are already biased over heliocentric math to explain the parallax concept. I am looking for an intuition to get myself a deeper understanding of what we are part of the universe. I am not looking for math but if there is anyway I can understand that we revolve around the Sun without understanding the complex math behind it? I was told that unless I account for math & parallax, it was impossible to prove that we are revolving around the Sun. Is that true? What if our parallax calculations & newton laws related to our solar system are wrong?
Comment: The proof is not in the math, the proof is in all experimental evidence confirming the mathematical calculations based on the physical theory. So there is no bias towards the heliocentric model. Every experiment and measurement is confirming the theory and there are none that indicate something else.
Comment: We use extremely distant stars as a reference, what we consider as "stationary". Then we can determine how the Earth moves with respect to the Sun.
Comment: https://i.chzbgr.com/full/3121925/hB5B398F7/ ;)
Answer: Here are three things to consider:
(1) Telescopic observations of Venus show that it exhibits phases just like the Moon-- first seen by Galileo in 1610.
(2) Careful observations of starlight show the light is 'shifted' in the same way as raindrops that fall straight down when you stand still but appear to fall toward you at an angle when you walk through the rain. This is called stellar aberration-- first seen in 1725.
(3) Finally, there is stellar parallax, with the first observations in the 1830s.
All of these are straight-forward predictions of the heliocentric model, and all of them are observationally confirmed. A geocentric model could possibly account for #2 (am I correct here? maybe not), but not #1 and #3.
Comment: In the geocentric model, Venus is always positioned between the Earth and Sun and is constrained to never be far from the Sun. Therefore, the model predicts it will exhibit only crescent and new phases, and will never exhibit gibbous, quarter, or full phases. (And yet it does.) Because the Earth is immobile in the geocentric model, we observe the stars always from the same vantage point. Thus, the model predicts we will never see stellar parallax. (And yet we do.)
Comment: Can you explain how the geocentric theory contradicts above statements too. Thanks
Answer: First, suppose that the earth is spherical but not rotating on its axis once per day or orbiting around the sun once per year.
That is the view held by the ancient Greeks for several hundred years BCE forward. It was codified by Ptolemy in his Almagest. It was a complex clockwork where the domes carrying the sun and stars rotated around the world in amazingly precise ways. You don't want to think about planets, but they followed a system of cycles within cycles.
It wasn't until Copernicus a few hundred years ago basically said "Wouldn't it really simplify things a lot if the sun stood still, and the earth both rotated and orbited?" Things would look the same, but see how much simpler the explanation is?
Then of course Galileo said "I like that" and Newton proved how it all made sense with the simple fact that things fall on earth.
Of course, these guys ran up against the people in funny hats, but that's how it goes...
Answer: The fact that we see parallax in the distant stars (i.e. that the stars appear to shift by tiny amounts as the Earth moves) is just one of many pieces of experimental evidence that point to the Earth revolving around the Sun. There are many others, like:

the existence of phases of Venus besides "crescent"
the fact that we have put vehicles on other planets like the Mars rovers using the heliocentric model
distance and velocity measurements made by bouncing radar pulses off of planets
Newtonian gravity being tested in the laboratory  and correctly explaining behaviors in other star systems

and the fact that they all agree that the Earth revolves around the Sun is why it's a widely-accepted fact. In science, we arrive at the truth by seeing if our explanations for the natural world are consistent with the experiments we do to test them, and if the predictions they make turn out to be accurate. In the case of the heliocentric model, it has satisfied every rigorous test that we put it through* and has predicted the behavior of objects in the Solar System well enough for us to conduct numerous planetary missions, sending scores of probes to orbit or land on the surface of most of the larger astronomical bodies in the Solar System.
*There are numerous YouTube videos out there that claim to debunk the heliocentric model. However, invariably they run into one or more of the following problems: their methodology is not rigorous (i.e. they don't account for sources of uncertainty or bias in their experimental setup), their conclusions aren't supported by the data they take, or they aren't clear enough about their methods for others to repeat and verify their experiment. These problems are why you won't see experiments like this published in peer-reviewed scientific journals (who take the methodology of collecting data and the interpretation of that data very seriously, and tend to reject papers that are not sufficiently rigorous, well-reasoned, and transparent, regardless of the pedigree of their authorship), and they are also often highlighted in the numerous other YouTube channels that have arisen to debunk such claims.
Comment: Lets not get into FE vs GE discussion. I am not interested with that. I want to know more about understanding heliocentric conclusions. Can you elaborate on Venus besides crescent. What experiments did prove Newtonian gravity? Thanks
Answer: Here is the simplest I can think of as an answer. as the earth orbits the sun, there is a spot on the earth each night that, at midnight, is pointing directly away from the sun.
Now imagine that an observer at that spot notes the positions of the stars in the midnight sky, every night for a year. S/he then compares those observations and discovers that different constellations are visible at different times of the year, and that this pattern repeats itself year after year.
This would not happen if the sun were orbiting the earth. in that case, the constellations would not shift around in the sky with the passing of the seasons.
Comment: It would happen if the constellations were orbiting the earth, though, and if one assumes that the sun orbits the earth, there doesn't seem to be any reason why that wouldn't also be possible (indeed, this is what most early geocentric models did: the stars were points of light affixed on a rotating "celestial sphere").
Comment: in that case there would be no parallax shift in their positions. so if you  "really" want an airtight case you'd have to measure that as well. However, OP's question (as I interpreted it) deals just with sun vs. earth orbit.
Comment: Indeed, stellar parallax is the ultimate downfall of the celestial sphere, but that's very different (and much more difficult to measure) than your original evidence. And even then, a sufficiently complex geocentric theory could include stellar parallax (i.e. the stars all rotate around the Earth, _not quite_ fixed in a celestial sphere; the stars are allowed to shift very slightly in their moorings, like docked ships, and due to some celestial force, they move back and forth with a period of a year, where the amplitude varies from star to star, just like the amplitude of waves in a harbor).
Comment: this is why all the data must be brought to bear during a discussion of geocentrism with an ardent supporter of same: parallax, procession of the constellations, and the slant-line adjustment of stellar light (stellar aberrations). Then you artfully slit their throat with Occam's razor and hope for the best...


Principal Component Analysis on Graphs

Question: How can somebody apply PCA on a set of graphs? Is it possible to define a meaningful graph kernel for my problem, and then follow the typical procedure on the derived matrix of pairwise distances (kernel PCA) ?
Answer:
How can somebody apply PCA on a set of graphs?

It is perfectly legal to apply PCA on a set of graphs. After all, one graph is just a point in a space, and given a distance measure (kernel) in that space you can apply PCA as usual.

Is it possible to define a meaningful graph kernel for my problem, and then follow the typical procedure on the derived matrix of pairwise distances?

That's absolutely fine -- once you have a matrix of pairwise distances you're back to good old PCA.
If you're looking for some interesting kernels I would recommend you to search online for "graph distance measures" or "graph similarity measures," and you will find a lot of them. One particularly easy example is the Hamming distance, which is basically the number of edge additions or deletions needed to transform one graph into another.
Comment: @DionysisM Unfortunately I don't think thinking about graphs in terms of coordinates will take you very far. It's important to know the difference between a **Euclidean space** (where you have lengths and distances and you can actually plot points in it) and a **metric space** (where you only have distances between points and nothing else). $R^n$ is a Euclidean space while graphs live in a metric space, so there is no way you can map graphs onto $R^n$ without extra assumptions. I'm afraid you'll have to get familiar with the abstract mathematical notions of space and metric.
Comment: Thanks for your answer. Commenting on your point about seeing the graph as a point in a space - well I can think of that one such mapping would be using the adjacency matrix rows as coordinates in a high dimensional space. But this becomes a bit problematic when it comes to graphs of different sizes. And particularly when there is no mapping among the nodes of two graphs (modulo the permutations of the nodes) - do you have in mind a more natural instantiation of a graph as a point in space?

Principal Component Analysis on Graphs


How can I build a redstone-powered vehicle?

Question: I tried to build a redstone vehicle in Minecraft (vanilla), but my attempts proved futile. I tried to build it using pistons, wire and some pushable blocks, but it didn't work, because the wire breaks when pushed. Also, when I used redstone blocks right in front of the pistons, they haven't extended. Any idea for a redstone-using vehicle, on unmodded Minecraft?
Comment: Redstone wire vreaks when oushed by pistons. Some nice machines made with slime blocks, sticky pistons and redstone block can work as a redstone car. Browse through youtube, there are some machines like these.
Comment: I knew the wire breaks when pushed. That's why I need help. @spund3
Comment: A redstone vehicle using redstone wires is impossible. You can do one with slime blocks, sticky pistons and redstone blocks.
Comment: Ok. I'll give it a shot. @spund3
Comment: Try the following link, is the thing you need. https://youtu.be/Qa3paQM67YU
Answer: You need slime blocks. They not only prevent fall damage and a trampoline effect, it also gets attatched to blocks so when the block is moved with s piston, the slime block moves with it depending on what block it's next to. This is very useful for cars. Here's an example of a slime block car:

You need:

Pistons
Sticky Pistons
Redstone Blocks
Slime Blocks

Use these to build your slime block car. Since redstone falls of a moved block, use slime blocks and redstone blocks instead of dust!


Querying a foreign key on a association table

Question: Let's say i have the following model:
Customer(customer_id (PK), firstName, lastName, email)
Item(item_id (PK), name, description)
Orders(orders_id (PK), customer_id (FK), item_id (FK), promotion_id (FK)),
Promotion(promotion_id (PK), date, gift_id (FK))
Gift(gift_id (PK), name, description)

Now, let's say that i have the following requirement:

Retrieve the list of all orders (not grouped by) from all customers and the name column from both the item and gift associated.

The difficult part is that the association table orders has a foreign key column to a one to many table (promotion) that, in his turn, has the foreign key to the gift;
I have the following query that worked, but i figure out that should have a more elegant way to approach the problem than doing a lot of joins like this:
select concat(c.firstName, ' ', c.lastName) as customerName,
       i.name, g.name
from   customer as c
left join orders as o on c.customer_id = o.customer_id
inner join item as i on o.item_id = i.item_id
inner join promotion as p on o.promotion_id = p.promotion_id
inner join gift as g on p.gift_id = g.gift_id;

How i could resolve the query in a more elegant way?
Thanks in advance!
Answer: I think this is perfectly elegant. Joins are very classy and often misunderstood.
Answer: You can drop the INNER keywords as joins are inner by default, and the AS keywords are optional; also because your column names are the same across the joins, you can simply use USING instead of ON:
SELECT CONCAT_WS(' ', c.firstName, c.lastName) customerName,
       i.name, g.name
FROM   customer    c
  LEFT JOIN orders o USING (customer_id)
  JOIN item        i USING (item_id)
  JOIN promotion   p USING (promotion_id)
  JOIN gift        g USING (gift_id)

Indeed, if those are the only columns having the same name across the joined tables one could go further and use NATURAL joins (although I don't like that as it hides what's going on if the schema changes):
SELECT CONCAT_WS(' ', c.firstName, c.lastName) customerName,
       i.name, g.name
FROM   customer            c
  NATURAL LEFT JOIN orders o
  NATURAL JOIN item        i
  NATURAL JOIN promotion   p
  NATURAL JOIN gift        g

Comment: I prefer to specify INNER JOIN rather than just JOIN, just to confirm that's what you really wanted.


Use the default Python rather than the Anaconda installation when called from the terminal

Question: I recently installed the Anaconda version of Python. Now when I type python into the terminal it opens the Anaconda distribution rather than the default distribution. How do I get it to use the default version for the command python on Linux (Ubuntu 12.04 (Precise Pangolin))?
Comment: Place Python you want to be the default as the first one on the `PATH`?
Comment: in response to Piotr's comment, here is the command: `export PATH="/Users/YOURNAME/miniconda3/bin:$PATH"`
Comment: Can you paste the contents of what the conda init function added for your case? (btw how did you end up solving the problem?)
Comment: For me the conda init does add (to the `.zhrc`) the export command I pasted above but for some reason there is a nested set of if statements that prevent the export from being run. I'm not sure why, but that might be what's happening to you too. Anyway, adding the above after the piece of code that conda init added to my `.zshrc` worked.
Comment: Do you want to use Anaconda or just Python?
Answer: Anaconda adds the path to your .bashrc, so it is found first. You can add the path to your default Python instance to .bashrc or remove the path to Anaconda if you don't want to use it.
You can also use the full path /usr/bin/python in Bash to use the default Python interpreter.
If you leave your .bashrc file as is, any command you run using python will use the Anaconda interpreter. If you want, you could also use an alias for each interpreter.
You will see something like export PATH=$HOME/anaconda/bin:$PATH in your .bashrc file.
So basically, if you want to use Anaconda as your main everyday interpreter, use the full path to your default Python or create an alias. If you want it the other way around, remove the export PATH=.... from bashrc and use full path to Anaconda Python interpreter.
Comment: +1 for the alias idea. In fedora 25, I can add "alias python=/usr/bin/python", and now when I say "python" or "python2" I get the system python 2.7, but if I say "python3" I get the conda python. The advantage of this is that system tools which rely on python 2.7 (like gnome-tweak-tool) work fine.
Comment: What needs to be changed if we have a similar issue in Windows
Comment: Hi, conda added a section rather than a simple line: "# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/dingxin/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/dingxin/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/dingxin/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/dingxin/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<" . how to deal with it in this case?
Comment: Where to find .bashrc in windows?? I want to use python in cmd.
Comment: what is wrong with doing: `export PATH="/Users/YOURNAME/miniconda3/bin:$PATH"`? that seemed to work for me.
Comment: @CharlieParker, It is exactly the same. `$HOME` expands to `/home/user`. It is just shorthand for writing it out and developers are lazy...
Comment: What's annoying is, the conda `pip` also shadows the system `pip`. So if I install dependencies using (conda) `pip` and install another Python binding, which by default use system `Python`, it will fail to work. So for me changing the `PATH` variable  is a better solution.
Comment: I would like to delete Python from `/usr/bin` and use anaconda as default.
coz my IDEA only detecting `/usr/bin/python3` and `/usr/bin/python3.11` as interpreter.
what should I do?

OS: Debian 12
Answer: Having tried all the suggestions so far, I think modifying the export statement in file ~/.bashrc, as Piotr Dobrogost seems to suggest, is the best option considering the following:

If you remove the whole statement, you have to use full paths for Conda binaries.
Using Conda 4.4.10 links in the directory anaconda/bin/ point to binaries in the same directory, not the system ones in /usr/bin.
Using this approach you get the system programs for all that have been previously included in $PATH and also the ones specific to anaconda without using full paths.

So in file ~/.bashrc instead of
# Added by the Anaconda3 4.3.0 installer
export PATH="/home/user/anaconda3/bin:$PATH"

one would use
export PATH="$PATH:/home/user/anaconda3/bin"

Comment: This worked for me on MacOS with anaconda installed via `brew cask install anaconda`: `export PATH="$PATH:/usr/local/anaconda3/bin"`
Comment: This worked. I am curious. Please can you explain why adding the shell command '$PATH'  in front of the path rather than trailing the path prevents conda from being called as the default python interpreter.
Comment: I also had to change my `~/.bash_profile` in the same way
Comment: Because in that case the interpreter located in for instance /usr/bin is found before the one in the anaconda directory, and the first match is utilized (check https://www.baeldung.com/linux/path-variable for more details).
Comment: for me the first one you have works. I'm surprised you used the second one. My command: `export PATH="/Users/YOURNAME/miniconda3/bin:$PATH"`
Answer: I faced the same issue and you can do the following.
Go into your .bashrc file and you will find a similar sort of line:
export PATH=~/anaconda3/bin:$PATH

You comment it out and instead type out:
alias pyconda='~/anaconda3/bin/python3'

Or whatever your path is. This worked out for me.
Answer: In the year 2020, Conda adds in a more complicated block of code at the bottom of your .bash_profile file that looks something like this:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/spacetyper/opt/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/spacetyper/opt/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/spacetyper/opt/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/spacetyper/opt/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

To use the default Python install by default: Simply move this section of code to the very top of your .bash_profile file.
To give yourself the option of using the Conda installed Python: Add this line below the Conda code block above.
alias pyconda="/Users/spacetyper/opt/miniconda3/bin/python3"

Now you should be able to call the system Python install with python and the Conda install with pyconda.
Answer: at 2020, like the @spacetyper mentioned, it acted differently. I've found a handy solution for that from this question: How do I prevent Conda from activating the base environment by default?
To disable automatic base activation:
conda config --set auto_activate_base false

it'll create a ./condarc in home directory after running the first time.
Answer: I found that, though I remove export=.../anaconda3/bin:$PATH, there is still .../anaconda3/envs/py36/bin(my virtual environment in Anaconda) in PATH, and the shell still uses Anaconda Python.
So I export PATH=/usr/bin:$PATH (/usr/bin is where system Python reside). Though there is already /usr/bin inPATH, we make it searched before the path of Anaconda, and then the shell will use the system Python when you key python, python3.6, pip, pip3 ....
You can get back to Anaconda by using an alias like mentioned above, or default to Anaconda again by comment export PATH=/usr/bin:$PATH.
Comment: This does not seem to address the OP question.
Answer: There are python, python2 and python2.7 shortcuts in both the /home/username/anaconda/bin/ and /usr/bin/ directory. So you can delete any one of them from one folder and use that for the other.
I mean, if you delete the python2 shortcut from the Anaconda directory, you will have the Python for Anaconda version and
python2 for the default version in the terminal.
Answer: I use Anaconda sparingly to build cross-platform packages, but I don't want to use it as my daily driver for Python. For Anaconda, Ruby, and Node.js projects I've adopted to use environment sand-boxing, which essentially hides functionality behind a function away from your path until you specifically need it. I first learned about it from these two GitHub repositories:
https://github.com/benvan/sandboxd
https://github.com/maximbaz/dotfiles
I have a file of sandboxing functions that looks like this:
.zsh/sandboxd.zsh:
#!/bin/zsh
# Based on
#    https://github.com/maximbaz/dotfiles/.zsh/sandboxd.zsh
# which was originally adapted from:
#    https://github.vom/benvan/sandboxd

# Start with an empty list of all sandbox cmd:hook pairs
sandbox_hooks=()

# deletes all hooks associated with cmd
function sandbox_delete_hooks() {
    local cmd=$1
    for i in "${sandbox_hooks[@]}";
    do
        if [[ $i == "${cmd}:"* ]]; then
            local hook=$(echo $i | sed "s/.*://")
            unset -f "$hook"
        fi
    done
}

# Prepares the environment and removes hooks
function sandbox() {
    local cmd=$1
    # NOTE: Use original grep, because aliased grep is using color
    if [[ "$(type $cmd | \grep -o function)" = "function" ]]; then
        (>&2 echo "Lazy-loading '$cmd' for the first time...")
        sandbox_delete_hooks $cmd
        sandbox_init_$cmd
    else
        (>&2 echo "sandbox '$cmd' not found.\nIs 'sandbox_init_$cmd() { ... }' defined and 'sandbox_hook $cmd $cmd' called?")
        return 1
    fi
}

function sandbox_hook() {
    local cmd=$1
    local hook=$2

    #echo "Creating hook ($2) for cmd ($1)"
    sandbox_hooks+=("${cmd}:${hook}")

    eval "$hook(){ sandbox $cmd; $hook \$@ }"
}

.zshrc
In my .zshrc I create my sandbox'd function(s):
sandbox_hook conda conda

This command turns the normal conda executable into:
conda () {
    sandbox conda
    conda $@
}

An added bonus of using this technique is that it speeds up shell loading times because sourcing a number of wrapper scripts (e.g. nvm, rvm, etc.) can slow your shell startup time.
It also bugged me that Anaconda installed its Python 3 executable as python by default, which breaks a lot of legacy Python scripts, but that's a separate issue. Using sandboxing like this makes me explicitly aware that I'm using Anaconda's Python instead of the system default.
Comment: I'd recommend looking at the dotfiles I linked to above use it for a good example, but most simply you need to source the sandboxing functions in your `~/.bashrc` or `~/.zshrc`, and then create a sandbox for conda by placing the following _after_ sourcing the sandboxing functions: `sandbox_hook conda conda`
Comment: How do I use this?
Answer: Anaconda 3 adds more than a simple line in my .bashrc file.
However, it also backs up the original .bashrc file into a .bashrc-anaconda3.bak file.
So my solution was to swap the two.
Comment: A .bak file on Linux?
Answer: For my case, when I had
alias python='/usr/bin/python3.6'

in the ~/.bashrc, it always called python3.6 inside and outside of Anaconda Virtual Environment.
In this setting, you could set the Python version by python3 in each Virtual Environment.
Comment: Isn't a VM something else?
Comment: @PeterMortensen You're right. I corrected to Virtual Environment.


301 Redirect vs Rewrite

Question: I have a site that was hosted by someone else all the web pages were .html files.  I am now hosting the site and have changed it to a wordpress site.  The domain has not changed but obviously all the pages have.  What is the best way to redirect all the .html pages to the main url?
Answer: 301 Redirect in an .htaccess does not require the mod_rewrite library.  It's a much simpler way to redirect, but it doesn't have the flexibility and power you get using the Rewrite rules.  If you have a 1-1 mapping with explicit urls you can use the Redirect:
Redirect 301  /path/file.html http://new.site.com/newpath.php

If you're trying to do wild card matching of a number of similar patterns using regular expressions you'll need to use Rewrite.
RewriteRule ^(.*).html$ http://new.site.com/$1.php [R=301,NC,L]

Here's a pretty good overview of the 2 methods: http://www.ksl-consulting.co.uk/301-redirect-examples.html
Comment: What if I want to redirect WWW and non-WWW version? Can I do this without RewriteRule or mod_rewrite library?
Comment: @Boris_yo you can't catch domian / host names either with Redirect, only a RewriteRule with a RewriteCondition: `RewriteCond %{HTTP_HOST} ^foo.com[nc]`
`RewriteRule ^(.*)$ http://www.foo.com/$1 [r=301,nc]`
Comment: @Boris_yo no, you need rewrite conditions if you're trying to catch the protocol http vs. https
Comment: Not really a protocol but WWW and non-WWW
Answer: There is also RedirectMatch that also does wild card matching of similar patterns using regular expressions.  The choice depends on just what you need to do.
Rewrite is complex - learning curve - but you can serve alternative urls without giving a HTML code and things that seem imposible. But with great power comes complexity and lots of bugs.
If you are only doing a simple redirection - possibly matching some urls - redirect is the way to go.
When you can't do it with Redirect, you will probably want to start learning Mod_Rewrite.

301 Redirect vs Rewrite


can SPDT relays replace SPST switch? Or does it depend on the particular implementation of the relay?

Question: I am working on SKU consolidation and my concern right now is if I have a cheaper option of SPDT switch with all the ratings same as SPST switch which is currently used. Can I replace it? Or does it depend on the particular application of the relay.
Comment: Maybe.. for example, the relay will drop out if power is removed (most relays).. that might pose a safety hazard in some cases.
Answer: If all the ratings are the same, then yes you can use the SPDT in place of the SPST, you will just have an additional terminal on the package that is left floating that does not exist on the SPST. If there is already a PCB design utilizing the SPST, the PCB design may need to be updated for the new relay.
edit: Just to clarify, you used both the terms "switch" and "relay". My answer assumes you are talking about a relay.
Comment: Yes, I am sorry for that it was a typo, I meant relay. Thank you :)


How do people create DVDs which have more data that it allows

Question: Not that I like buying pirated stuff... but recently I got my hands on a DVD with 4 movies in it, and I was really surprised to find that the DVD contained full blown movies with subtitles and the total size was more than 7 GB. How could anyone do it?
Answer: This can be accomplished by using a dual layer DVD. Also, if the DVD had 4 full blown movies on it, chances are the quality of the video and/or sound is suffering or the originals had many features (bonus features, other languages) that have been removed.
Comment: Single layer max capacity is 4.7 GB (4.37 GiB) but dual layer max capacity is 8.54 GB (7.95 GiB).
Comment: To add to what I said above, check out the answer about transcoding. As that poster has mentioned, by reducing the bitrate, the quality is decreasing (which is what I meant when I said suffering).
Answer: Transcoding, or more precisely, transrating, that is, reducing the overall bitrate of the video and audio without changing its format, so that more fits in the same space. You may have not noticed it, but if the video and audio format where the same as the original, the quality had to be worse.
http://en.wikipedia.org/wiki/Transcoding
Answer: DVD shrink is a free program that can achieve this. It also maintains the DVD's quality.
Comment: No, it does not (maintain full quality)
Comment: No, it doesn't maintain "full quality," your right. But it does maintain quality. It may get a little, fuzzy, but not enough to notice if you only shrink the DVD to the recommended settings. If you use any program how it is recommended, everything should be ok, until you start trying to push things to the limit.
Comment: The only time you should use a program like this is if you are making a legal backup copy of a movie you have purchased. More times than not, its because the original is on a dual layer. There are applications out there that are better, in my opinion, on performing this same task because they allow you to remove unused languages and/or previews. Both typically take up between 0-20% of the space.
Comment: I don't think anything once "shrunk" maintains full quality. They have to be loosing data somewhere.