How should I mock out my data connectivity

Question: I'm trying to unit test my Data Access Layer and I'm in the process of trying to mock my data connectivity to unit test my DAL and I'm coming unstuck trying to mock out the creation of the commands.  I thought about using a queue of IDbParameters for the creation of the parameters, but the unit tests then require that the parameters are configured in the right order.  I'm using MOQ and having looked around for some documentation to walk me through this, I'm finding lots of recommendation not to do this, but to write a wrapper for the connection, but it's my contention that my DAL is supposed to be the wrapper for my database and I don't feel I should be writing wrappers... if I do, how do I unit test the connectivity to the database for my wrapper? By writing another wrapper? It seems like it's turtles all the way down.
So does anyone have any recommendations or tutorials regarding this particular area of unit testing/mocking?
Comment: Take a look at this article: http://bit.ly/bF7jL3.
Answer: I've had good success swapping an in-memory database.  This gives you the opportunity to set it up and tear it down easily.  You can also mock the connection call so you can assert the arguments passed in, and then return the in-memory database.
Answer: Moq uses inheritance to create a mocked class - the downside of this approach is that the class you're trying to fake should either be passed as an interface at least won't be a sealed class. One solution to is to create a wrapper class around the "un-mockable" class and mock that class instead, unfortunately this solution needs quite a lot of maintenance.
If you're willing to pay for a mocking framework that would enable you to mock sealed classes consider purchasing either Typemock Isolator or JustMock - both can mock virtually any .NET class and method (including sealed classes and static methods).
Answer: I'd recommend against using mocks for this type of testing. I went down this path with Java and it always ended with me feeling that I have proved little except that I can write mocking statements. I would recommend either using in-memory database or having a per-developer database and accept some things are integration tests.
I moved to .NET reciently and here a wrapper around System.Data & Oracle.DataAccess is used and to be honest, I love this approach.
The wrapper simply provides an IDatabase interface with a bunch of methods like DataTable ExecuteFunction(...) which offer an easy way to call a oracle function or procedure. The only class from System.Data seen by the clients of this API is DataTable. The wrapper handles all the messing about with IDbParameter. The wrapper only has integration tests.
Unit testing the actual DAL is very easy, plus writing the DAL gets that little bit nicer. Less horrid boilerplate to deal with.

contention that my DAL is supposed to be the wrapper for my database

The DAL provides access to business functions held in the database. The DB wrapper strips away boiler plate code (and allows you to mock it).

if I do, how do I unit test the connectivity to the database for my wrapper?

Don't. Accept that some things are integration tests.


Do we need to update Active Directory, When we upgrade windows 7 to windows 10

Question: There are 500 Computers on my network We have planned to upgrade all Computers to windows 10. Currently we are using windows 7. Our Microsoft Partner suggest to upgrade our active directory OS to server 2019. We have 3 AD domain controllers which is running on server 2012 r2.
But i don't have a requirement to change AD OS. Although server 2019 has more features,still we are not using all features in server 2012. Can you suggest what will be best solution.
Answer: I believe your MS partner is referring to the domain level.
If you already running on domain level 2012 it is not a requirement to raise the domain level to use windows 10.
There are a lot of considerations you need to take before raising the domain level, So I would recommend doing some research on this before raising it.
Comment: @user14132 is spot on.  No need to upgrade at this time.
As a recommendation, you do want to upgrade your AD functional level along over time.  If you get too far behind, moving ahead might get complicated.
Answer: Upgrading the servers is not necessary. You can upgrade the clients and AD will not be affected. Upgrading the servers would be nice  but it is not required to meet your stated goals. It sounds like your MS partner just wants to make a sale.
Answer: No, upgrade of AD is not necessary. Just make sure you take it into account before Windows 2012 is EoL.
Comment: Thank you so much for your answer. really appreciate it


Where do the bodies of the dead Tributes go?

Question: I've only seen the movie-version of The Hunger Games, and have yet to read the books. Is it explained where the bodies of the dead Tributes go, if they are removed at all?
Comment: IMHO, the accepted answer needs to be changed to one that actually explains where the bodies go (shipped back), not the current one that simply says they get picked up but doesn't explain what happens to them next
Comment: I managed to find the exact quote, and updated my answer to be properly canonical :-)
Answer: Hovercrafts are instantly dispatched to recover the body, perhaps to prevent cannibalism, which was an issue in previous Games:

There was a guy like that a few years ago from District 6 called Titus. He went completely savage and the Gamemakers had to have him stunned with electric guns to collect the bodies of the players he'd killed before he ate them. There are no rules in the arena, but cannibalism doesn't play well with the Capitol audience, so they tried to head it off. There was some speculation that the avalanche that finally took Titus out was specifically engineered to ensure the victor was not a lunatic.

And on the hovercraft to retrieve bodies quickly:

Suddenly, the birds fall silent. Then one gives a high-pitched warning call. A single note. Just like the one Gale and I heard when the redheaded Avox girl was caught. High above the dying campfire a hovercraft materializes. A set of huge metal teeth drops down. Slowly, gently, the dead tribute girl is lifted into the hovercraft. Then it vanishes. The birds resume their song.

This may have been the same hovercraft:
Comment: I will point out that (in the books explicitly, and shown but not explained in the movie) the bodies are not recovered if there are still Tributes nearby - this gives Tributes the time needed to strip the body of needed equipment or recover weapons.  It is also why they held off on claiming Rue's corpse long enough for Kadniss to do her mourning.
Comment: @Jeff Probably also the mourning made good TV.
Comment: @starsplusplus: Not so much, actually - they explicitly don't want the different districts to form close ties, and ended up cutting most of the mourning footage from replays and the commercial release.
Comment: @Jeff That's a good point. You're completely right
Answer: After being picked up by hovercraft as described in @Solemnity's answer, the bodies get shipped back to the districts and the mourning families:

I have the pearl, though, secured in a parachute with the spile and the medicine at my waist. I hope it makes it back to District 12.
Surely my mother and Prim will know to return it to Peeta before they bury my body.
-- Catching Fire, end of chapter 25
Comment: I can't believe this actual canonincal answer isn't just not accepted, but not even not upvoted
Answer: The bodies are collected from the arena when the others have taken anything they want from it and have moved on

For a moment, I hear them checking the girl for supplies... "Better clear out so they can get the body before it starts stinking."
Chapter 11, The Hunger Games

by hovercraft,

High above the dying campfire, a hovercraft materialises. A set of large metal teeth drop down. Slowly, gently, the dead tribute girl is lifted into the hovercraft. Then it vanishes.
Chapter 12, The Hunger Games

then readied for a funeral and taken back to their families.

...Peeta may already be lost, bled white, collected, and in the process of being transported back to the Capitol to be cleaned up, re-dressed, and shipped in a simple wooden box back to District 12. [...] Heading home.
Chapter 11, The Hunger Games
Answer: Well, it is pretty clear overall from the books at least that the bodies in the first hunger games are picked up by hovercraft.  However to more completely answer the question I would point out that Katniss thinks that the bodies of the tributes are revived (which would mean they would have to be retrieved quickly) and converted into the monsters she and Peeta have to face at the end.

...My head snaps from side to side as I examine the pack, taking in the various sizes and colors. The small one with the red coat and amber eyes…Foxface! And there, the ashen hair and hazel eyes of the boy from District 9 who died as we struggled for the backpack! And worst of all, the smallest mutt, with dark glossy fur, huge brown eyes and a collar that reads 11 in woven straw. Teeth bared in hatred....

So the mutts are likely the same tissue as existed in the tributes just revived and altered into a wolf.  This is why she can recognize foxface (due to the hair).
Comment: IIRC, the DNA from the Tributes is used in the genetic manipulation of the Mutts, but the bodies are not revived, nor are their eyes uses (as Katniss believes during the game).


How futures are sold, when they are first released?

Question:
When termed futures are released in the market, such as XBTU21 (Bitcoin futures for the 3rd quarter), how are they sold in the market?
Stocks, for example, are sold through IPO when they are first released in the market. Do futures also go through the similar thing as IPO?
I guess the futures should go through the same thing as IPO to determine its price, between buy side and sell side. But I haven't heard of anything as futures' IPO.
Answer: Futures are not "things" to sell. When you "buy" or "sell" a future, you enter into a contract with a counterparty. So the exchange releasing a future just means that they create a record in their system of a particular futures contract. That's all. Nothing needs to be "created" other than that.
The market (not the exchange) determines the price of the future just like a stock - bid and ask orders are made, and market orders are matched up with the order book just like stocks in the secondary market.
Comment: Can you explain how futures orders are filled between people longing and shortinf futures? For example, as far as i know, there is no partial fill in leveraged futures, unlike spot long orders which can be partially filled. (If I order 100 AAPL stocks at 100 USD, for instance, it can be the case that only 50 orders are filled because there is no available AAPL stocks at 100 USD). As such, how to fill the future orders must be different from that of stocks. Can you explain more on this part as well, please?
Comment: If I order a 100x leveraged long futures on Bitcoin, whose total value is 10000 USD (which means my initial deposit is just 100 USD), should I wait for another person whose short is exactly 10000 USD to fill my 100x leveraged long futures order?


Resume option on game in android

Question: I made simple puzzle game. I want to add a "Resume" option to it, so when user opens the game, he can pick up where he left off last time.
Answer: You'll have to write your current game-state to "disk" whenever the user quits the application or triggers a "save-game" manually. This is also called serialization.
Whenever the application resumes, deserialize the data and restore the previous game-state.
The data that is needed for serialization heavily depends on your game.
I'm not an android developer, but I suggest you have a look at the Serializable Interface and the onPause and onResume callbacks.
Answer: There are several ways to preserve state in Android apps.
If your gameplay is limited to a single Activity (common for anything relying a SurfaceView), and your game state is relatively small, you can often rely on the savedInstanceState Bundle passed into Activity.onCreate.  Not only does this allow to to support saved state as the user goes into and out of the game, it will also bullet proof your code against various Configuration changes, such as opening the keyboard or changing display mode.
You can also use SharedPreferences to store data in one or more key/value maps.  This is probably the most common solution, and becomes available to all Activities within your app (and even other entry points, such as BroadcastReceivers, in a thread safe manner.
Probably not the best approach for games, other than some deep inventory RPGS, every Android device has an SQL instance built in.
Finally, you have access to the file system.  Both in an application private folder accessible by Context.getDir(..), or via the phone's SD Card.  The latter will require an additional user privledge, but it is the best route to go if you expect your game state to be large (half a meg or more).  Both will require you to get familiar with the java.io package, and maybe the java.nio package.
If you want state to persist between reinstalls, you'll have to look at setting up backup support for your app, or run a server that can store and retrieve state.  I've had good luck with using Google App Engine for network server (for free!).

Resume option on game in android


Rails 3: Is it possible to access a model's attribute in a query?

Question: Sorry if that question sounds strange, but I'm diving into Rails and I'm still learning the jargon.  Basically, I'm trying to create a single-pass query that uses the value of one of the model's attributes in a calculation in the query (assuming that's even possible).
I have a Tournament model that has a start_date attribute that is a DateTime object.  I'm trying to create a query that returns all the Tournaments that have a start_date no older than 1 hour + the length of the tournament, or put another way, all tournaments that haven't yet started or have started, but haven't ended longer than an hour ago.  My current query, which doesn't work, looks like this...
validTourneys = Tournament.where("start_date > (? - duration_in_mins)", (DateTime.now.utc - 1.hour))

where duration_in_mins is an integer attribute of the Tournament model, but this query doesn't work and it seems to be returning all the Tournaments all the time.  I'd like to include duration_in_mins in the (DateTime.now.utc - 1.hour) part of the calculation, but I don't know how to reference it, which is why I included it in the string part of the query, hoping that would work.  Am I at least on the right track?
I should mention I'm using SQLite for development and PostgreSQL for production.
Thanks for your wisdom!
Answer: The problem is that if you subtract minutes from a DateTime object, you are not subtracting minutes but days.
# This works as expected
dt = DateTime.now # Thu, 28 Apr 2011 09:55:14 +0900
an_hour_ago = dt - 1.hour  # Thu, 28 Apr 2011 08:55:14 +0900

# But, this does not...
two_hours_in_minutes = 120
two_hours_ago = dt - two_hours_in_minutes # Wed, 29 Dec 2010 09:55:14 +0900

In the last example 120 days are subtracted instead of minutes. This is probably also happening in your query. You have to convert duration_in_minutes to days and then subtract.
Answer: I don't know enough about SQL to answer your question directly (I think this will probably also depend on what database you're using, so you might want to mention that).
Have you considered, though, having start_date and end_date as DateTime columns instead of start_date and duration_in_mins? If this is going to be a common query, that would certainly make it more performant, as well as making your code easier to read and understand.
Answer: This query will only work if your database is smart enough to know how to add (what I am assuming) is a DateTime and and integer. And I can't think of a database that will do that correctly the way you have it coded. No database will assume minutes. Some might do ticks, seconds, or days.
This part of the calculation
(? - duration_in_mins)

is going to happen on the database, not in Ruby-land.


Recording / Logging CSP Violations

Question: I am in the process of implementing a CSP policy for a variety of domains and am looking for a method to record/log browser CSP violations encountered by any end user. I want to make sure I don't miss any domains, but would like to avoid having to manually visit every page and check the browser error console. What's the best practice here to identify external domains and resources that may be encountered?
Answer: Content Security Policy (CSP)
Quick Reference Guide
CSP-Reporting on Google Developers

If you're just starting out with CSP, it makes sense to evaluate the
current state of your application before rolling out a draconian
policy to your users. As a stepping stone to a complete deployment,
you can ask the browser to monitor a policy, reporting violations but
not enforcing the restrictions. Instead of sending a
Content-Security-Policy header, send a Content-Security-Policy-Report-Only header.

The Reporting API on google.dev

Reporting API on github.io (Editor's Draft)

Report URI Documentation - probably the easiest and fastest way to deploy policies and generate reports to track CSP violations. Includes CSP Analyser, CSP Builder and Data Watch monitoring tool for registered users. However, the free plan includes up to 10,000 reports.

Recording / Logging CSP Violations


How are "mvn clean package" and "mvn clean install" different?

Question: What exactly are the differences between mvn clean package and mvn clean install? When I run both of these commands, they both seem to do the same thing.
Comment: Please look at [Introduction to the Build Lifecycle - Lifecycle Reference](http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference) and looking for `package` and `install` .
Comment: One packages (builds it in target) and on installs (packages and places it in you repository)  You need to do the later if you want to use this version in another module.
Comment: Perhaps this should be reopened?  It's perfectly possible to answer and I didn't find it difficult to answer.  Also, if someone is brand new to maven, it's easy to see how the two phases appear to do the same thing.  I'll edit it in an attempt to make it less vague.
Answer: Well, both will clean.  That means they'll remove the target folder.   The real question is what's the difference between package and install?
package will compile your code and also package it.  For example, if your pom says the project is a jar, it will create a jar for you when you package it and put it somewhere in the target directory (by default).
install will compile and package, but it will also put the package in your local repository.  This will make it so other projects can refer to it and grab it from your local repository.
Documentation
Comment: @SharadHolani because builds are incremental. `mvn clean install` is not faster than `mvn package`.
Comment: Why is mvn install faster than mvn package then ?
Comment: @RakeshYadav yes it does
Comment: For my project, mvn package assembly:single which builds the fat jar takes longer than a mvn install.

Do package and install both build equivalent fat jars ?
Answer: What clean does (common in both the commands) - removes all files generated by the previous build

Coming to the difference between the commands package and install, you first need to understand the lifecycle of a maven project

These are the default life cycle phases in maven

validate - validate the project is correct and all necessary information is available
compile - compile the source code of the project
test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
package - take the compiled code and package it in its distributable format, such as a JAR.
verify - run any checks on results of integration tests to ensure quality criteria are met
install - install the package into the local repository, for use as a dependency in other projects locally
deploy - done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.

How Maven works is, if you run a command for any of the lifecycle phases, it executes each default life cycle phase in order, before executing the command itself.
order of execution

validate >> compile >> test (optional) >> package >> verify >> install >> deploy

So when you run the command mvn package, it runs the commands for all lifecycle phases till package

validate >> compile >> test (optional) >> package

And as for mvn install, it runs the commands for all lifecycle phases till install, which includes package as well

validate >> compile >> test (optional) >> package >> verify >> install

So, effectively what it means is, install commands does everything that package command does and some more (install the package into the local repository, for use as a dependency in other projects locally)
Source: Maven lifecycle reference
Comment: This should be marked as accepted answer. This clearly defines and helps the OP to understand what the different phases of maven lifecycle and why mvn install includes mvn package but not the other way around.
Answer: package will generate Jar/war as per POM file.
install will install generated jar file to the local repository for other dependencies if any.
install phase comes after package phase
Comment: "Install phase _follows_ package phase". The way it's currently phrased is backwards. "Followed by" means "after".
Comment: first packaging will happen then those packages (jar/war) will install.
Answer: package will add packaged jar or war to your  target folder, We can check it when, we empty the target folder (using  mvn clean) and then run mvn package.

install will do all the things that package does, additionally it will add packaged jar or war in local repository as well. We can confirm it by checking in your .m2 folder.
Comment: Thanks for pointing out to check the .m2 folder
Answer: Package & install are various phases in maven build lifecycle. package phase will execute all phases prior to that & it will stop with packaging the project as a jar. Similarly install phase will execute all prior phases & finally install the project locally for other dependent projects.
For understanding maven build lifecycle please go through the following link https://ayolajayamaha.blogspot.in/2014/05/difference-between-mvn-clean-install.html
Comment: @ArunGowda it means in the .m2 which is created in your system upon installing of the maven will be added with projects you are packaging and will be available for other projects as dependency.
Comment: What do you mean by " & finally install the project locally for other dependent projects "
Comment: a picture is a 1000 words, anyone got a diagram?
Comment: @MrCholo *mvn install* will put the jar/war into your maven repo.  The place where all your maven dependencies get stored, usually ~/.m2
Answer: mvn package command will compile source code and also package it as a jar or war as per pom file and put it into the target folder(by default).
mvn install command will compile and package, but it will also put the package in your local repository. So that other projects can refer to it and grab it from your local repository.
mvn install command is mostly used when you wants to compile a project(library) which other projects in your repository are depending on.


Offline transaction with light wallet?

Question: How would an offline transactions look like on a mobile phone? In my wallet I can not even log in with my seed if I am not online... So how can I send funds?
Answer: Offline transaction must be understood as "not connected to a full node".
Offline transaction can occurs using the "flash channel" technology.
"Flash channel" are currently not supported by the wallet and I don't see any reason to support it in the wallet.
Flash channel make sense in a specific applicative context, where one device sell a real service to another.
Answer: There are a few approaches to achieve offline transactions:
Flash Channels

Alice and Bob open a Flash Channel (while still online)
Alice and Bob loose connection to any full nodes but are still connected with each other
now Alice can send IOTAs to Bob and vice versa, POW is not required
once they reconnect to a full node, they close the channel

Connected to an offline full node
In this scenario Alice and Bob are not completely offline, they either have full nodes on their mobile phones or are connected any other devices that are full nodes. But they have no connection the the rest of the network.

Alice's and Bob's host full nodes loose connection to the rest of the network
Alice and Bob transact with each other as usual (with POW)

if at this point somebody who is online has access to Alice's or Bob's seed, they could perform a double spend to make the offline transactions made by Alice and Bob invalid

Alice's or Bob's host full node connects to the rest of the network again and  broadcasts their transactions.

This already works today. You just have to change your host to the "offline full node".
Exchanging signatures

I'm not 100% sure about this but I think it would also work.
  Please edit the question and remove these 2 lines/the whole section if you know more and I am right/wrong.

Alice and Bob loose connection to any full nodes but are still connected with each other
now Alice can build a transaction/bundle without attaching it to the Tangle (not doing POW, not doing tip selection, just inserting Bob's address, the amount and the signature)
Alice sends this incomplete transaction to Bob
once Bob connects to a full node again, he does the tip selection, the POW and publishes the transaction

again: if Alice performs a double spend and publishes the transaction before Bob does the offline transaction is most likely invalid

Offline transaction with light wallet?


equisetum and soil pH

Question: To make my garden soil less acidic, I have sprayed a 1 percent aqueous solution of dolomite to control the spread of horsetail. Will this measure help me achieve the desired result?
Comment: @PatrickB. I understand now. My concern was that "snob" is a slightly derogatory term in English, so it shouldn't be in a post to begin with (except perhaps in a question on a language Q&A site). In future, please edit out off-topic sections like that. The OP can post them in a comment (with suitably toned-down language) if they wish.
Comment: Did you get a message that this question "doesn't meet the quality standards?". That's an automated check that has more to do with the length of the post (which is easy for a computer to check) than grammar (which isn't). A very short question can indicate that more detail about the problem is needed in order to be able to provide a good, specific, answer
Answer: I don't think this solution will have any effect. This is based on my experience where I live so there is still a possibility it will work. Gardening is not a science and results differ widely due to climate, soil types and variation within a species.

trying to change the ph of your soil by applying acid or alkaline solutions will only cause a short term change in the soil conditions. Unless you amend the soil and add lime or acid yearly pH changes will be minimal
where I live I am surrounded by limestone. The soil is alkaline and the groundwater is alkaline.  The equisetum in my garden seems quite vigorous at a soil pH of 7.1.

This answer on control methods may be helpful.

equisetum and soil pH


How to Change Sharepoint Domain Name

Question: I would like to know how to change the name of my SharePoint intranet domain name from how do i change my SharePoint domain name from "oldsite.sharepoint.com" to "newsite.sharepoint.com"
Answer: Unfortunately, it isn't possible to change the SharePoint Online domain name  from "oldsite.sharepoint.com" to "newsite.sharepoint.com" for your organization in Office 365!
To use the domain name newsite.sharepoint.com , you would need to purchase a new Office 365 subscription and move all email, files, and any other data you want to keep to the new subscription.
For more details, Check, Change your SharePoint domain name

How to Change Sharepoint Domain Name


Best way to sync data from one database to another

Question: Let's say I have my web shop and database have multiple tables like Products, Product prices and similar.
I'm selling my software solution to my affiliate partner. He gets its database, it window application for entering data and I want all he's products are available on my website also.
So, I have my products and  sell them on my website. Partner has his website and his products, but I also want that all his products are also available in my database.
My initial idea was to build some kind of app that periodically connects to Partner's database and insert/update data to my tables.
But recently I think  about some service buses. Is service bus way to go ?
So situation would be like this. Partner inserts product (bus sends message that products was inserted, partner updates prices then bus sends message that some row in prices row was changed. I would then have some console app running on server that listens to message and updates to my database. What do you think would be scalable solution? Example is fictional and in real life I have lot of tables.
Comment: The easist is to downvote
Answer: Firstly you need to ask yourself some questions:

do you need to sync the data in realtime, quasi-realtime or in sort of backup mode (like once per day).
when moving the data are you manipulating it or just fully replicating to another data base (maybe of some time).
what is the amount of data per, say minute? Is it 1000 records or 100000 records? Are there may relations in your db that need to be replicated on other end? Or maybe the other end is schemaless so you don't care?
What is the technology on both sides? For example, MS SQL sever has built-in replication functionalities, at least 3 options as I recall.
Is there any problem with connection between 1st and 2nd storage? Are they in same network, same organization maybe? Or maybe they are in 2 different networks VPN connected.
How will you mark records that have been replicated?
How will you discover that records have been updated and need to be replcated again (triggers? - but can add them to each table)?

Each answer can be decisive. Even in 2017 we can still find synchronization by FTP files, because of non-technical reasons.
Console application? Only if run periodically from windows scheduler, never use it as permanent service - this is what linux deamons / windows services are for.
Service bus - sounds cool, as always, but again, if you need to replicate db wth lot of relationships, it might turn out, you're pulling half database for each transferred object.
Hope this helps you choose a solution,
Łukasz
Answer: Are you handling the database for your partner? If not, i don't think they giving you access to their database is a good idea (security concerns). Another thing: you probably want your products separated from those of your partner(s).
In any case, service bus is part of your solution, just as a message handler. So what you need is this:

Something to send new and updated products from your partner's side to yours (that can very well be a job sending messages to a service bus).
Something to listen to the message queue and grab the products and insert them into your database in the form you like.

Scalability depends on your platform. But even for small, on-premise solutions, this seems very small and able to work with reasonable amounts of data (nothing amazon sized).
Comment: Yes we are handling database for partner. We offer them our sotware solutions and we have access to "their" database because we made it. In fact, products are just example, in real life those are apartments which partner handle in one town, and with this type of cooperation we receive their offer of apartments (products) and they get database and website we madw for them
Comment: Its easier for you then. But solution is essentially the same, you'll need 2 jobs, one to send, one to retrieve. Just because it is way easier to maintain, i would do it like that. But if you have access to database, and since we are dealing mainly with data, you could also create a replicating job. It depends on what is better for your dev team.


Changes to classic ASP

Question: I've just been asked to look after some classic asp code, currently running on IIS6, I'm on IIS7...and the existing code is throwing up a few errors I'm not sure I'd expect.  Has anything changed in the way it should behave/is there a way to make it behave like it used to so I can fix these issues as it gets rebuilt?
The first is this:
    If NOT ISNULL(fieldforfiltering) then

    fieldforfiltering = TRIM(fieldforfiltering)

    convertbackfield = Replace(fieldforfiltering, """, chr(34))

            .....

    End If

This is complaining that fieldforfiltering is null on the 3rd line.  This I would expect from my C# life as the whole body of the if is not enclosed, so only the first line would get run (although there is an End If, so I'd sort of expect that to work...).  However, it's working on IIS6, just not IIS7.
The second is a Cint issue
    totcat = rs("totcat")
    totalpage = totcat / 50

...throws a Type Mismatch error on the second line.  If I change it to
    totalpage = CInt(totcat) / 50

...it's fine.  Again, I sort of know why - but why would that work on IIS6 and not IIS7?
I'd like to get it working as it is (as it clearly does work) and then go through and fix these over the coming months...it's too big a job to do it in one go.
Comment: It's worth noting I haven't worked on classic asp for a good few years, so I've probably missed any changes to asp that may have caused this...
Answer: It sounds like you might be running with different options: Option Strict On vs Option Strict Off, for example.

Changes to classic ASP


Membership state deceased

Question: Can anyone please explain why a membership state Deceased exists (along with the contact's state)? Is there a use case where the membership is Deceased, but the contact is not?
Answer: I wouldn't have thought that just a membership would be deceased. As for logic, I've always made the assumptions that it's a safeguard from 'accidentally' soliciting membership renewals.

Membership state deceased


Reading TCP Port of an IIS 7 website programmatically

Question: I have a C++ application that uses AHADMIN to interface with IIS 7. I know how to get a IAppHostElement object of my website, but no idea how to read properties (found here http://msdn.microsoft.com/en-us/library/aa347565(v=vs.90).aspx, such as Object.ConfiguredObject.Site.Bindings) from there. Any help would be much appreciated!
Answer: You should bheck out Kanwal's post about AHADMIN: http://www.ksingla.net/tag/ahadmin/
In general you will want to use a combination of GetAdminSection (to get the section first), get_Collection (to get a pointer to the collection), get_Item (to get the item in the sites collection)  and GetElementByName (to get the bindings and repeat the collection/get_item) and GetPropertyByName for the value.
See also: http://www.ksingla.net/2009/04/implementing_iapphostpathmapper_in_c/
and http://forums.iis.net/t/1029458.aspx


On the number of consecutive divisors of an integer

Question: Define for $n \in \mathbb{N}$ the function $$\tau_1(n):=\sum_{\substack{d|n, \\ d+1|n}}1,$$ i.e. the number of consecutive divisors of an integer. The average of $\tau_1(n)$ is $1$ since $$\sum_{n\leq x}\tau_1(n)=\sum_{d<\sqrt{x}}\Big[\frac{x}{d(d+1)}\Big]=x+O(\sqrt{x}).$$ I was wondering whether more is known about $\tau_1(n)$, for example does it have a distribution function, meaning does the following limit exist for all $z \in \mathbb{R}$,
$$F(z):=\lim_{x \to +\infty}\frac{1}{x}\#\{n\leq x \ \text{such that} \ \tau_1(n)\geq z\}?
$$
Comment: Of course a suitably modulated question can be posed for $\tau_f(n):=\sum_{[f(d)]|n}1$, where $f:\mathbb{N}\to \mathbb{R}$ is any function, the previous example having $f(d)=d(d+1)$.
Answer: See Katalin Gyarmati, On the density of integers with consecutive divisors, Publ. Math. Debrecen 74 (2009), no. 1-2, 1–17, MR2490419 (2010e:11087).
The first paragraph of the review:
P. Erdős and R. R. Hall [J. Austral. Math. Soc. Ser. A 25 (1978), no. 4, 479–485; MR0506088 (58 #21975)] first studied the number of consecutive divisors. Let $k\ge2$ be a fixed integer; the function $\tau_k(n)$ is defined as the number of positive divisors of the form $m(m+1)\cdots(m+k−1)$ with $m\ge1$. Erdős and Hall proved that the estimate $\tau_k(n)>(\log n)^{e^{1/k}−\epsilon}$ holds for infinitely many $n$. They also proved that $$\sum_{n\le x}\tau_k(n)={x\over(k-1)(k-1)!}+O(x^{1/k})$$
The review goes on to discuss the work of Tenenbaum and other authors, and then gets to Gyamarti's paper, which is concerned with $$A_P(K)=\lim_{N\to\infty}\#\{\,n:1\le n\le N,P(m)\mid n{\rm\ for\ some\ }m\ge K\,\}$$ and finds asymptotics for $P$ a quadratic polynomial with integer coefficients.
Comment: The reviews indicate that there is work by Tenenbaum and dL Breteche for bounding $\tau_k$ by a power of $\tau$ which is smaller than $1$. The asymptotic estimate is also rather straightforward. But it gives the interesting result that the average number of more than one consecutive divisors is $\int_0^1 \frac{e^x-1}{x}dx$.I am wondering whether it is any easy to prove asymptotics for the higher moments of $\tau_2$.
Answer: Yes, $F(z)$ exists for all $z$. Let $y\ge 2$, and define $\tau_{1,y}(n)$ as the number of $d\le y$ for which both $d,d+1$ divide n. Let $F_y$ denote the analogue of $F$ with $\tau_{1,y}$ replacing $\tau_1$. It's clear that $F_y(z)$ exists for all $z$, since $\tau_y(n)$ is actually a periodic arithmetic function (with period the lcm of $1, 2, \dots, \lfloor y\rfloor +1$). Moreover, $F_y(z)$ is increasing as a function of $y$, and $F_y(z) \le 1$. So for each $z$, the limit $\lim_{y\to\infty} F_y(z)$ exists.
Claim: The limit definining $F(z)$ coincides with $\lim_{y\to\infty} F_y(z)$.
If $n \le x$ and $\tau_1(n) \ge z$, then either $\tau_{1,y}(n) \ge z$, or $n$ is divisible by some $d(d+1)$ with $d > y$. Hence,
$$ \#\{n \le x: \tau_1(n) \ge z\} \le \#\{n \le x: \tau_{1,y}(n) \ge z\} + O(x/y). $$
Divide by $x$, and take the limsup as $x\to\infty$, and then let $y\to\infty$. This shows that the $\limsup$ of the expression in the definition of $F$ is at most $\lim_{y\to\infty} F_y(z)$. On the other hand, since $\tau_{1,y} \le \tau_{1}$, a similar but simpler argument shows that the $\liminf$ in the definition of $F$ is at least $\lim_{y\to\infty} F_y(z)$.
It seems this was known to Erdős and Hall; in their paper, they remark "It is easy to see that the density of integers $n$ for which $\tau_k(n)=r$ exists." Probably they had the above argument in mind.
Comment: Here's a PDF: https://www.renyi.hu/~p_erdos/1978-26.pdf
Comment: Ok so the probability distribution result is valid with the same proof even taking any polynomial $f(d)$ with integer coefficients in place of $d(d+1)$ and such that the leading coefficient is positive and the degree of $f$ is greater than $1$. It might be interesting to try and figure explicit formulas for $F(z)$...
Comment: That is rather great, could you please link their paper ?  could not find it...
Answer: This supplements the two previous answers, giving further references that provide information on $F(z)$.   Theorem 2 of Konyagin and Soundararajan shows that there exist arbitrarily (square-free) large integers $N$ with
$$
\# \{ d: d(d+1)| N \} \ge \exp ((\log N)^{\frac 1{16}}).
$$
Therefore for large $z$, there exists an integer $N$ below $\exp( (\log z)^{16})$ with $\# \{ d: d(d+1)|N \} \ge z$.  Since all multiples of $N$ have at least $z$ consecutive divisors, it follows that
$$
F(z) \ge \exp(- (\log z)^{16})
$$
for large $z$.  This improves substantially upon the results of Erdos and Hall, who had a bound like $F(z) \ge \exp(-z^{1/\sqrt{e}+o(1)})$.  Harper's paper could probably be adapted slightly to improve the $16$ in the result of Konyagin and Soundararajan to $6$, and further improvements could also be made.  One might guess that $F(z)$ (see the heuristic in the paper of Konyagin and Soundararajan) should be something like $\exp(-(\log z)^{2+o(1)})$, but this appears difficult.
Comment: That is interesting, doesn't the last guess suggest that  the distribution of $\tau_1(n)$ should have a heuristic behavior conforming to the gaussian law ?
Comment: @CaptainDarling: Note it's $\exp(-(\log z)^{2+o(1)})$, not like $\exp(-z^2/2)$ (Gaussian).  I don't expect it to be anything nice.
Comment: Indeed you are right, however my implication was that considering $F\left(\exp\left(\frac{t}{\sqrt{2}}\right)\right)$ would lead to a probabilistic interpretation, after all the events $d|n$ and $d+1|n$ are morally independent.


Square root of -1

Question: Hello stackexchange users! I am somewhat confused on $\sqrt{-1}$. I believe the answer should be no solution, or inconsistent, or at least something in that nature. Am I correct or am I most likely wrong? Any help or insight would be deeply appreciated
Comment: Your answer is in the tags.
Comment: Could you please clarify?
Comment: Just look up imaginary and complex numbers on Wikipedia.
Comment: I asked this question on math.stackexchange.... I wasn't really looking for imaginary and complex numbers on Wikipedia. I simply wanted some clarification as you can see in my question.
Answer: if you consider all polynomials to have roots you can ask what is the root of x^2+1 well it turns out that this is only 0 when x =sqrt(-1) so imagine we have a value, i ,for the x that solves it. you can ask what set it's in but positive*positive=negative * negative = positive, so no positive or negative number works. to make sure all polynomials have roots you need to invent imaginary numbers.

Square root of -1


How does lasso regularization select the "less important" features?

Question: I'm just starting in machine learning and I can't figure out how does lasso method find which features are redundant to shrink their coefficients to zero?
Comment: Possible duplicate of [Why L1 norm for sparse models](https://stats.stackexchange.com/questions/45643/why-l1-norm-for-sparse-models)
Comment: Your mistaken - lasso doesnt find the redundant features - it just shrinks features to zero somewhat arbitrarily - you need.to use another method like cross validation or scoring to determine which features are best
Answer: There are many ways to think about regularization. I find the restricted optimization formulation to be quite intuitive.
$$\hat\beta = \arg\min_\beta \|\bf y - X\bf\beta\|$$
$$\text{subject to } \|\bf \beta\| \leq \lambda_\star$$
Usually in the first line, we use the L2 norm (squared), which corresponds to Ordinary Least Squares estimates. The restriction gives a way of "shrinking" the estimates back to the origin.
If an L2 norm is used in the second line, we have Ridge Regression, which effectively pulls the OLS estimates back towards the origin. Useful in many situations, but not very good at setting estimates equal to 0.
If an L1 norm is used in the second line, we get LASSO. This is good for "feature selection" since it is able to effectively set inert or nearly-inert features to 0.
The following image illustrates this nicely in two dimensions.

Figure from Elements of Statistical Learning by Hastie, Tibshirani, and Friedman
Comment: @knrumsey How do we know that ellipses have these orientations? I mean we can imaging ellipses that hit the circle (ridge case) on point $(0, 1)$ and as such ridge would also perform feature selection. In other words, can we in general show that whatever the solution $\hat{\boldsymbol{\beta}}$ of (unpenalized) least squares is, then the contours would have such orientation so that they hit a corner on lasso?
Comment: Also how intercept affect the ellipses. The least square solution $\hat{\boldsymbol{\beta}}$ is equal to $(\hat{\beta_0}, \hat{\beta_1}, \hat{\beta_2})$, not just $(\hat{\beta_1}, \hat{\beta_2})$.
Comment: @adosar 1. The ellipses orientation roughly depicts the covariance of the sampling distributions of $\hat\beta$. 2. Generally, the only way that this can happen is if $\hat\beta_2$ is already $0$. It can be shrunk to nearly zero (as seen in the figure), but won't be exactly zero. You should be able to convince yourself of this geometrically. 3. It is common in the regularization literature to first centralize the variables (mean zero) to enforce $\hat\beta_0 = 0$.
Answer:
how does lasso method find which features are redundant to shrink their coefficients to zero?

The Lasso method on its own does not find which features to shrink. Instead, it is a combination of Lasso and Cross Validation (CV) which allows us to determine the best Lasso parameter $\lambda$.
Different $\lambda$ may shrink different parameters to zero, and choosing the right $\lambda$ can sometimes be easy (e.g.) in the graphic below, and sometimes be difficult/subjective task.
A good introduction to combining Lasso and cross validation is provided by the inventor of the Lasso, Robert Tibshirani, pages 15 and 16 here. Also here: Lasso cross validation and here

What happens when features are correlated
The case of correlated features and Lasso is more subtle and is well explained here: How does LASSO select among collinear predictors?.
But in practice there is some arbitrariness in which features are included in the model and when/why. Quoting EdM

In practice, the choice among correlated predictors in final models with either method is highly sample dependent, as can be checked by repeating these model-building processes on bootstrap samples of the same data. If there aren't too many predictors, and your primary interest is in prediction on new data sets, ridge regression, which tends to keep all predictors, may be a better choice.


Will grayscale increase or decrease battery consumption?

Question: If I turn on grayscale on my iPhone 6, will the consumption of battery increase or decrease?
Comment: I would assume that with an LCD it would make no significant difference as the vast majority of the energy consumed by the screen is for the backlight.
Answer: It makes no difference on the iPhone 6. So neither a reduction, nor extra consumption.
Some sources that tell the same story:

From a SuperUser question LCD/LED screens; how color affects the power consumption?:

Conventional LCDs and LED based LCDs consume power that largely depends only on the intensity of backlight. This means to save power you want to reduce brightness of the screen.
OLED displays, like those found in Samsung (and other) smartphones, on the other hand, have power consumption that depends on color being displayed.

As the iPhone 6 uses a conventional IPS LCD panel, it means that the power usage is mainly due to the backlight - and the backlight power usage does not change whether the displayed image is full color or monochrome. However it does change according to the brightness setting and how dark the displayed image is.
From CNET's article LED LCD vs. OLED: TV display technologies compared:

The energy consumption of LCD only varies depending on the backlight setting. The lower the backlight, the lower the power consumption. A basic LED LCD with its backlight set low will draw less power than OLED.
Comment: Could you elaborate on this, preferably with a source?
Comment: I guess you missed the "_preferably with a source_" part of the question.
Comment: The iPhone 6 has an IPS LCD display. They do not require more power to display a certain color such as blue compared to a light gray for example. It's not like an AMOLED screen, where black pixels require considerably less color than a white pixel. In any case, the actual draw from the IPS panel itself is tiny compared to the power draw from the backlight. The iPhone backlight uses the same amount of power to display a monochrome image as compared to a full-color image.
Comment: @user3439894 I guess you missed that it said "preferably" and not "necessarily". Which part of the answer is it you disagree with and want a source on?
Comment: The iPhone X has an OLED display, it might be best to update the answer.
Comment: @Alex The question is about an iPhone 6, not an iPhone X.
Answer: I haven't read any analysis of this, but my guess would be that it would make no significant difference. Really all that it does is average out the colors of all pixels (so red green and blue of each pixel are the same rather than different strengths).
Night Shift does use a little extra battery, though. Apparently it uses more energy to show the yellower hues. But this isn't the same as that.
If you want to use less battery, you can turn on Power Saver mode (are you running iOS 9?). That will save energy by reducing certain things that use more power like email fetching.
Other things to do are to close background apps, go to Settings>Privacy>Location Services and go to the bottom and go to system services and disable things you don't need it to use your location for.
Also wifi, Bluetooth, cellular data, these can all be turned off to save battery. Reduce the screen to minimum as well. Don't do anything on the phone you don't need to. If possible put it in airplane mode or shut it altogether.
Answer: I have an iPhone 6 and have set the display to grayscale for an extended period of time. Unfortunately the phone runs extremely hot when on grayscale. I switched back to color mode and have not had any heating issues since.


How to distinguish watch-only addresses from spendable addresses when deleting addresses

Question: An answer to I have watched addresses in my wallet..how do i use them? says:

"If you do not have the private keys for those addresses, then they are not yours and you cannot do anything with them. Those addresses and their associated Bitcoin do not belong to you, so you cannot use them.
You can delete the watch only addresses if possible; you will not lose any money if you delete just those addresses because there is no money that belongs to you in the first place with those addresses. However be careful of deleting the wallet entirely, it could have addresses and private keys which do belong to you and those you do not want to delete."

Based on the answer above, how do you then establish which addresses belongs to me that I must not delete?
Answer: It depends on which wallet you are using, if you are using the Bitcoin core wallet for example, you can see the amounts separated, the watch-only amount will be one, and the spendable amount will be another one.
You can also use the command listunspent into your console to know which addresses contain the spendable amounts.
Comment: I have no idea how to do that
Comment: The ways will be different on each wallet, you should edit your question and mention which wallet you are using.


Excel 365 fill handle when connected to a source

Question: I am using Excel RTD from FX Blue Labs to connect my Excel 365 (Desktop) to MT4 to get real-time forex data and historical ones.
I need to know how to use the fill handle to fill all the cells without typing the formula in each row.
An example:
After connecting MT4 to Excel, I type this formula
=RTD("fxbluelabs.excelrtd", ,"Account Number", "@bh,GBPUSD,H4,close,0") to get the current close of GBPUSD H4.
If I change the last number (0) to (1), I will get the previous close.
If I type the formula as =RTD("fxbluelabs.excelrtd", ,"Account Number", "@bh,GBPUSD,H4,close,200") I will get the close of the 200th bar.
Now, the problem is that when I selected the first three or four cells (in a column) with the above formulas and try to use the fill handle, I get the new rows filled the same as the selected row cells.
For ex:
the columns I have
col 1         column2
1st            (formula typed) 1.23
2nd            (formula typed )1.34
3rd              (formula typed) 1.22
If I drag the first column, it is filled in the right order with 4th, 5th, 6th etc..
But the column with the formulas that are linked to MT4 is not being filled correctly. Excel just repeats the values of those three rows in the second column.
Any solution for this?
Thanks
Answer: The function of Fill Handle in Excel is limited, sometimes filling works well, and other times it doesn't work as you expect. You can check the cell reference of the cells.


What causes banding noise in CMOS sensors?

Question: I'm looking for information (and references) on three related topics:

What causes banding noise in CMOS sensors?  What is the physical/technological cause?  Is the cause the same in CCD and CMOS sensors?
How do the various relevant factors (ISO setting, exposure time, and exposure level) influence the banding strength and pattern?
Is the band pattern stable in the short term (sequential shots) and in the long term?  Is there a chance the band pattern of an actual sensor could be measured and used to reduce the effect in actual photos?

To clarify what I mean by banding, here's an example image from the TopazLabs website.  Notice the horizontal bands in the noisy image.

A naive experiment didn't show any positive correlation between the banding in several images of a plain white surface.
Comment: Thanks for this question.  I've seen similar horizontal and vertical stripe artefacts on photos made by a Canon DSLR camera at ISO 100 sensitivity when the photos were very underexposed (by 5 or 6 stops because the flash didn't shoot).
Answer: Horizontal and Vertical Banding Noise (HVBN) is caused by sensor readout, downstream amplification, and ADC. There can be multiple sources of HVBN, some of them cause a relatively fixed pattern, others can cause random pattern. External signal interference is often a source of softer and more random banding. Exactly which causes banding in which sensors really depends, and no one but the manufacturer has enough information to point to the exact causes for any given camera.
Primarily, HVBN is caused by the way rows of pixels are activated, and each column for a row is read, and the nature of the transistors involved in that readout process. First, transistors manufactured via photolithography are imperfect. Imperfections in the base silicon, imperfections in the template and etching, etc. can all affect the response of transistors. As such, each pixel in a sensor, as well as buckets for on-die image processing such as CDS (Correlated Double Sampling), will not necessarily behave like all the rest, producing differences. In modern CMOS sensors (Sony Exmor type sensors excluded), on-die CDS circuitry is often a culprit for introducing banding noise at lower ISO settings (ISO 100 through maybe 800) in the deep shadows.
Some readout designs also involve an additional downstream amplifier used in certain circumstances, used in addition to the per-pixel amplifiers. Banding noise introduced within the sensor die itself will be exacerbated by any downstream amplifier. These kinds of amplifiers usually kick in at really high ISO, such as 6400 and higher, which is why relatively "clean" output at ISO 1600 and maybe 3200 suddenly becomes much worse at even higher settings.
Another source of banding is the ADC. There are potentially two culprits here. In the case of a camera like the 7D, which uses split parallel readout (where four readout channels are directed to one DIGIC 4 chip and another four are directed to another DIGIC 4 chip in an interleaved fashion), a fairly pronounced but even vertical banding can occur, even in the midtones, thanks to different response of the DIGIC DSP image processors that house four ADC units each. As even bands are sent to one DIGIC's ADC units, and odd bands are sent to the other DICIC's ADC units, 100% identical processing is unlikely, and slight differences manifest as vertical bands.
The final potential source is high frequency components. High frequency logic has a tendency to be noisy. Using the 7D again as an example, it is an 18 megapixel sensor, which a grand total of eight ADC units must process, at a speed fast enough to support an 8fps shutter rate. (Technically speaking, the 7D has even more than 18 million pixels...it is actually a 19.1 megapixel sensor, as Canon always masks off a border of pixels for bias offset and black point calibration.) At 8fps, total pixels processed per second must be at least 152,800,000, and since there are eight ADC units, each unit must process 19.1 million pixels each and every second. That requires a higher frequency, which can (via a variety of mechanisms I won't go into here) introduce additional noise.

There are ways HVBN can be reduced. Some sensor designs clip negative signal values from pixels (or, in other words, do not use a bias offset), which has the effect of halving banding, but also costing some potentially recoverable detail deep within the shadows of the image. Sensors that do use a bias offset (which allows negative signal values up to a preset level) tend to have more HVBN at lower ISO as less clipping is performed in order to support a larger full-well capacity. More advanced ADC design can reduce noise, some even utilize noise along with a form of dithering to nearly eliminate ADC introduced noise.
Another way banding noise can be reduced is by moving the analog signal to digital earlier, preferably on the sensor die itself. Digital data can be error corrected during transfer, where as analog signals tend to pick up noise the more they travel along electronic busses and through processing units. An increase in the number of ADC units improves parallelism, reducing the speed each unit must operate at, therefor allowing lower frequency components to be used. Better manufacturing techniques (usually afforded by a smaller fabrication process, which increases the room for more complex hardware) as well as better silicon wafers can be used to normalize the response curve for each transistor or logic unit, allowing them to produce cleaner results, even at higher frequencies.

Sony Exmor, the well-known nearly noise-free sensor in Nikon's D800 and D600 cameras, took a fairly radical approach to reducing the most intrusive and frustrating form of noise. Exmor moves the entire image processing pipeline up to and including the ADC onto the sensor die. It hyperparallelized the ADC, adding one per pixel column (CP-ADC, or column-parallel ADC). It eliminated analog per-pixel amplification and analog CDS in favor of digital amplification and digital CDS. It isolated high frequency components in a remote area of the sensor die, which nearly eliminated noise introduced by each ADC unit themselves. Pixel read results in immediate conversion from an analog charge into a digital unit, and it remain digital from that point on. Once digital, all information transfer is effectively noise free, as data transmission can be error corrected, thus guaranteeing proper transmission through buses and downstream image processors.
One of the big wins for Exmor (according to Sony) was the elimination of analog CDS circuitry, and a move to digital CDS logic. Sony's claim was that the differences in response for analog CDS units were a source of banding noise. Instead of storing the reset charge of each pixel as a charge, a "reset read" is performed, that reset read is run through the same ADC process as a normal image read with the exception that the digital output is tracked as negative values. When the actual exposure is read, it is read out as positive values, and the prior "negative" CDS read is applied inline (i.e. each pixel read out starts at some negative value, and counting increases from there). This eliminates noise both from non-uniform transistor response as well as from dark current simultaneously.
With an Exmor sensor, readout is effectively ISO-less (you may have heard that term elsewhere on the net). All ISO settings are achieved via a simple digital boost (digital amplification) to the appropriate level. For RAW, the ISO setting simply needs to be stored as metadata, and RAW editors boost each pixel value to the appropriate level during demosaicing. This is why an ISO 100 D800 shot can be underexposed, then lifted in post by many stops, without introducing banding noise in the shadows.
Answer: Banding is caused by a number of factors.
Just as in colour management, any device along the imaging process can cause you to see banding. It could be caused by a badly calibrated monitor, a badly calibrated printer, a monitor not able to show a true 8-bit/12-bit LUT. From my experience, most banding is not actually inherent. It is caused by your monitor not being able to distinguish between discrete levels of gray on a fine gradient.
I don't really see how CMOS/CCD would make a difference. To understand this requires a bit of technical savvy, you need to understand that the most important factor that will influence banding is the bit depth of your sensor, this alone determines the amount of discrete tonal values your sensor can record. A 12-bit sensor will record 2^12 levels of gray while a 14-bit sensor will record 2^14 = 16384 levels of gray. Now, to complicate matters, most digital cameras do not assign a linear weight function to the tonal distribution of their sensors, this means that the camera (in fact most cameras) may be more biased to the highlights part of the spectrum (this is where the phrase "shoot to the right" comes from, with regard to histograms).
To further complicate matters, most sensor processors may do (definitely do) their own interpolation between sparse tonal values. This means, for example that if I have a tonal value of 5 in a particular part of the image, and a nearby area has a tonal value of 8, the camera will "guess" what the intermediate tonal value should be. ISO can also be a factor as it influences dynamic range and exposure latitude.
What you should be investigating is if the banding is displayed on more than one device. If you find that it is, you can try adding Gaussian noise with a blending mode and mask to get rid of it. I'll include some images to show you what I mean:
Created some banding with a dark gradient
Now add a noise layer:
(1) Create new Layer
(2) Fill it with 50% Gray: Edit -> Fill -> 50% Gray
(3) Set the Blending Mode of that layer to Hard Light
(4) Add Noise: Filter -> Add Noise (Gaussian, 1% or so)
You can then play with the opacity of that layer until the banding disappears, you can also create a mask on it if you like.
Adding Noise Layer
Comment: Thanks for the comments, but I was asking about a different kind of banding.  Please see the example I linked from "banding".  I meant the horizontal (or vertical) lines that appear in underexposed high ISO images.  It's a kind of "structured" noise, and this structure (horizontal lines in my case) makes it much much more distracting than the usual random noise.


Energy spectrum of a tight-binding model

Question: Consider the one-dimensional tight-binding Hamiltonian
$$\mathcal{H}=t\sum_m\left(a^\dagger_m a_{m+1}+a^\dagger_{m+1} a_{m}\right).$$
With the lattice constant set to 1, the energy spectrum is given by $$\epsilon(k)=2t\cos{k},$$ for $k\in[-\pi,\pi]$ in the first Brillouin zone. However, if we repeat the calculation with each unit cell containing two sites, we would obtain an energy spectrum of $$\epsilon(k)=\pm2t\cos{k}$$
instead, with the size of the first Brillouin zone reduced by half. Since the energy spectrum of a system can be determined unambiguously by experiments such as neutron scattering, it seems that we have a contradiction. What am I missing here?
Comment: @nervxxx To do so, we split the system into the two sublattices consisting of the even and odd sites. Then, expressing the operators in each of the sublattices in momentum space, we can write the Hamiltonian as a $2\times 2$ matrix coupling the two sublattices. Finally, diagonalizing the matrix yields the energy spectrum.
Comment: sorry, how did you do the calculation with 'each unit cell containing two sites'?
Answer: What you're missing is that the two treatments are the same. In the second one, the Brillouin zone is 2 times smaller but
$$ \cos(k+\pi) =-\cos(k)$$
so choosing the opposite sign in front of the energy is equivalent to shifting to the now-forbidden half of the Brillouin zone. When you identify the states correctly, there are of course the same states in both cases.
Note that changing $k$ to $k+\pi$ is equivalent to the alternating sign flips at the lattice sites,
$$ a_m\to (-1)^m a_m $$
in the position representation. Most typically, the original large Brillouin zone may be divided to two – one for which $a_{m+1}$ is closer to $+a_m$ and one-half for which it is closer to $-a_m$ and it's sensible to redefine the sites by the alternating signs. At any rate, the doubling of the states coming from the $\pm$ sign exactly compensates the halving of the Brillouin zone for $k$.
Comment: What would experiments say about the excitation spectrum then? Would the energy at zero momentum be $2t$ or $\pm 2t$?
Comment: It depends what you mean by momentum. If it means that the phase changes by $\exp ik$ every time you shift to the next atom, $x\to x+1$, then it's just $2t$. If you mean by momentum $k$ the number $k$ from $\exp 2ik$ that one gets by moving by two lattice sites, $x\to x+2$, then there are two possible states obeying this condition and their energies are $\pm 2t$. But I have already told you so.


windows 8.1 broke internet

Question: recently I was forced to update to windows 8.1, and now neither my WiFi nor Ethernet works at all. I have a Qualcomm atheros Ethernet adapter and an Intel WiFi one. I've tried changing drivers multiple times on both the wifi and the ethernet but it seems to have no effect. I really need internet access, so any help is appreciated.
Comment: Can you give you computer model and the network adapter model numbers?
Comment: I'm actually not entirely sure, because I've changed the drivers a couple times, but I think it's supposed to be AR8161 pci-e gigabit ethernet controller and intel centrino wireless-N 2200 for wifi.
Comment: What are your current network settings? What are the errors that you are getting? When you open the browser and try Google, what do yo see? Does your computer recognize that you have anything plugged in?
Comment: computer recognizes both ethernet and wifi networks, and acknowledges that they are connected to the internet. on attempt to connect to website, i get webpage not available.
Comment: Check your network settings both on windows and in the browser. Ensure that you are not attempting to go through a proxy (or have it set correctly if you need to go through one). Let me know if you don't know where to look.
Comment: I'm definitely not using a proxy, and there's not much to see in the windows network settings, it just says I'm connected.
Comment: What browser are you using?
Comment: chrome, but no browser works
Answer: So, the windows update from yesterday (10/29/14 pst) seems to have solved the issue, it took a little while after logging in to be connected to working Internet again, but it eventually started working.
Comment: How did you download and apply a Windows Update if your internet wasn't working?
Comment: I actually don't know, i just restarted and it said there were updates to install
Answer: The situation that you are currently running into could have several to many possible reasons. If your network settings show that you are connected to a network, then your hardware should be fine (so no need to install more drivers).
I suspect incorrect network settings, either in you Windows Network Preferences, or in the browser (or in both).
As an idiot check, using something you know can connect to the internet, try to visit Google. Make sure that the network you are on is actually an internet connection, not some internal network.
If that works, then check the settings.
First, check the Windows Network Settings by:

Open Control Panel
Go to Network Connections
In the Network Connections window, right-click your network connection, and then click Properties.
On the General tab, under "This connection uses the following items", click Internet Protocol (TCP/IP), and then click Properties.
In the Internet Protocol (TCP/IP) Properties dialog box, check to see if you are trying to go through a proxy, or some other thing. This might be in an "advanced" tab or window.

Next, go to your browser's (Chrome's) network settings by:

Click the wrench icon in the top right corner (under the bookmarks toolbar).
Go to "Settings" in the drop down.
Select "Show advanced settings"
In the "Network" field, click "Change proxy settings" and make sure you are not using a proxy.

If all settings are correct and you have verified that your network connection is an internet connection, then it should work.
Comment: Did you give up @Jimmt?
Comment: Nothing unusual under network connections, doesn't show any proxy use.
Comment: You sure the network is internet @Jimmt?
Comment: yeah, it's wifi and ethernet
Comment: Try pinging google from Cmd Prompt

windows 8.1 broke internet


Kaleidoscope and mandala generation tools?

Question: Are there any good tools (free or paid) to easily create kaleidoscopes/mandalas and save them as vectors? Preferably that allow to use the outcome for commercial purposes / sell it.
Tool types: online generators, soft for Windows or Ubuntu, easy to run scripts, Processing programs.
Outcome examples:
Answer: Have you performed a search with your preferred internet search engine? A quick hit on The Google for "mandela svg generator" gave up a large number of results. The first one, mandela creator,  has links to github, which implies open source. There is no reference to licensing nor to restrictions.
An SVG save button also exists on the site, as well as a large number of user created designs.
There are some talented artists whose work is posted there.

I did not pursue the results from all of the search links returned, only this one, as it appeared to be the most promising. As I lack artistic skills, my attempt to create will not be published.
If you are an Inkscape or Illustrator user, there are also tutorials on the 'net to assist you in creating your own. This search is left as an exercise for the reader.
Comment: Thank you for proposing  mandela creator, I will check it out. It's currently unavailable for me, probably the reason I missed it. It's the only one that looks decent in search results though. And I would really appreciate answers without the "use search engine!11" part.
Comment: the search engine reference is because that's how I found the linked programs. If you cannot access a linked reference, your country may have restrictions that prevent you from getting good results from your preferred search engine. Equally valid is that you did not state that you searched for the desired programs, suggesting no access or some other aspect overlooked.


Can I choose 0 targets for Terror of the Peaks?

Question: My Terror of the Peaks triggers when my creatures entered the battlefield. My opponent responds to the trigger with Teferi's Protection and phases out along with his board. Can I submit 0 targets or, must I choose one of own creatures/myself?
Answer: If they cast Teferi's Protection in response to the triggered ability, then you have already chosen the target of that ability. Teferi's Protection can make the chosen target invalid, and the result is that the ability deals no damage.
However, if they instead cast Teferi's Protection in response to the creature spell, then Terror of the Peaks' ability will not trigger until after they have phased their permanents out and gained protection from everything. In that case, by the time you choose targets for the triggered ability, the only valid targets are you and your permanents, and you must choose one of them.
Comment: Yes, "protection from [something]" means "prevent all damage that would be dealt by [something], and can't be equipped, enchanted, fortified, blocked, or targeted by [something]" I specifically mentioned protection and phasing because those are the two parts of Teferi's Protection that affect what legal targets are available.
Comment: Is it somehow obvious that "Your life can not change" means you can't be targeted by damage effects as opposed to meaning, any damage you are dealt is nullified? Ahh it's the protection from everything that means they can't be targeted huh?
Answer: Murgatroid99 has nicely explained how protection works, but let's dig further into why Terror of the Peaks must target one of your own creatures (or yourself), and how the wording differs from other similar effects (I'll emphasize the key parts):

Whenever another creature enters the battlefield under your control, Terror of the Peaks deals damage equal to that creature's power to any target.

When this effect triggers, you must choose a valid target and you must deal the damage; nothing in there that makes the effect optional.
Some cards make an effect optional by including the word "may". See Cosi's Ravager, for example:

Landfall - Whenever a land enters the battlefield under your control, you may have Cosi's Ravager deal 1 damage to target player.

If your opponent can't be targeted (due to Teferi's Protection or a similar effect), then while you still have to select a valid target (yourself in a 2-player game), the "may" means that you don't have to actually deal the 1 damage to yourself.
Some other cards have similar effects but specify that the target must be a creature controlled by an opponent, like Banisher Priest:

When Banisher Priest enters the battlefield, exile target creature an opponent controls until Banisher Priest leaves the battlefield.

So if your opponent doesn't have any creatures, or if they all have protection, you don't have to exile your own creature (in fact, you can't exile your own creature, even if you wanted to), since its not a valid target.
Compare this again to Flametongue Kavu:

When Flametongue Kavu enters the battlefield, it deals 4 damage to target creature.

Do not play this card when your opponent has no creatures, because you will still have to choose a valid target (one of your own creatures), or even itself if it's the only target. The good news is that killing your own Kavu with its own ETB is a great way to learn this lesson :).
Finally, some cards use the phrase "up to one" to indicate you can choose zero targets or one target for its effect. For example, Brightmare:

When Brightmare enters the battlefield, tap up to one target creature. You gain life equal to that creature's power.

If your opponent controls no creatures, you don't have to target your own (although you can, if you'd like to gain the life).
Comment: I suppose a final case of a similar effect is [Bogardan Hellkite](https://scryfall.com/card/afc/115/bogardan-hellkite), which should be safe to play even when your opponent has no creatures and can't be targeted; if you choose "any number" of targets, *then* you can choose zero targets.
Comment: @MishaLavrov: I don't think that's the case for Bogardan Hellkite - "any number" usually includes 0 in MtG, but you *also* have to declare how you're dividing 5 damage among the targets as you put the ability on the stack, and you have to choose targets in a way that lets you divide 5 damage among them.
Comment: Bogardan Hellkite is a tricky one; I asked the mtg rules chat and they said yes, you *can* choose zero targets. Compare to the ruling on Stumpsquall Hydra, which says "you can still distribute the counters among any number of commanders, including none of them."
Comment: "When this effect triggers, you must choose a valid target and you must deal the damage" This is slightly misleading. Damage is dealt when the triggers resolves, not when the effect triggers.


Energy levels splitting in double-well potentials

Question: As it is well known, the tunnel splitting (which are certain differences between energy levels) is the characteristic of the energy spectrum for the double-well potentials. When we calculate the energy eigenvalues for the ground state and the other higher states, we see that the energy levels satisfy the inequality $ E_1-E_0 < E_3-E_2 < E_5-E_4 < … $ which implies that the adjacent energy levels are paired together. For example, $E_1$ is close to  $E_0$  but far from $E_2$. Similarly,  $E_2$  is far from  $E_1$  but close to  $ E_3$.
My question is that why we observe such a manner in double-well potentials? In other words, what is the physical interpretation of this effect?
Answer: The lowest energy level corresponds to a symmetric wave function $\psi_0(x)$ while the second is an antisymmetric wave function $\psi_1(x)$. Their squared amplitudes are almost equal $|\psi_0(x)|^2\approx |\psi_1(x)|^2$ and both correspond to a particle equally likely to be found in the left or right well (to get a definite well one needs to be in the state $(\psi_0(x)\pm \psi_1(x))/\sqrt{2}$). As one increases the quantum number one gets similar pairs of nearly identical wave functions, only differing by having a zero between the wells. Inside each well (especially if one looks at superpositions that are nearly zero in the other well) they behave very much like the solutions in the single well potential.
Why does the energy level for small $n$ increase only a tiny amount between the near identical functions but a larger amount between the pairs? $\psi_n(x)$ has $n$ nodes, which is why the ground state cannot be degenerate: each node of the wave function corresponds to a place where $\psi'_n(x)$ must be nonzero and is hence associated with some kinetic energy. But since the first two eigenfunctions are almost identical the difference is slight, while the step towards the next pair corresponds to getting some node in the low-potential region with much bigger kinetic energy. Eventually the number of nodes become so many that the steps even out, and the near degeneracy disappears.


Install groovy console on Mac and make it runnable from dock

Question: How can I install and run Groovy console/IDE from the dock on Mac Sierra?
Comment: Does that 'best solution' work for you? If so you should post it as an answer, and not as part of the question :)
Comment: Try asking on the apple forum here: https://apple.stackexchange.com/
Comment: @bertieb answer converted to community wiki
Comment: Can I have a link to that wiki @
Answer:
Follow these instructions http://sdkman.io/install.html and make sure you restart your terminal session after each step;
Say $ sdk install groovy to install groovy (I assume you have jdk already installed);
Start your Groovy Console in terminal
$ ~/.sdkman/candidates/groovy/current/bin/groovyConsole

It runs as a separate process;
Say $ ps aux |grep groovy - you will find out that the console is run as

/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java -Xdock:name=GroovyConsole -Xdock:icon=/Users/yourname/.sdkman/candidates/groovy/current/lib/groovy.icns -classpath /Users/yourname/.sdkman/candidates/groovy/current/lib/groovy-2.4.14.jar -Dscript.name=/Users/yourname/.sdkman/candidates/groovy/current/bin/groovyConsole -Dprogram.name=groovyConsole -Dgroovy.starter.conf=/Users/yourname/.sdkman/candidates/groovy/current/conf/groovy-starter.conf -Dgroovy.home=/Users/yourname/.sdkman/candidates/groovy/current -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/tools.jar org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.Console --conf /Users/yourname/.sdkman/candidates/groovy/current/conf/groovy-starter.conf --classpath .

I will refer that mess as jvm-verylongline
Exit the console and start automator.app, choose Application and double-click Run Shell Script action;
Save it as groovyConsole.app to your home folder and exit automator;
Edit ~/groovyConsole.app/Contents/Info.plist and change 3 lines:
<key>CFBundleExecutable</key>
<string>fuckmac</string>
<key>CFBundleIconFile</key>
<string>groovy</string>
<key>CFBundleIdentifier</key>
<string>com.apple.groovyConsole</string>

Create file ~/groovyConsole.app/Contents/MacOS/fuckmac and make it read:
#!/bin/bash
exec -c jvm-verylongline

Replacing jvm-verylongline as per above, obviously;
Say $ chmod +x ~/groovyConsole.app/Contents/MacOS/fuckmac
As the icon is conveniently named in the jvm-verylongline, do
$ cp /Users/yourname/.sdkman/candidates/groovy/current/lib/groovy.icns ~/groovyConsole.app/Contents/Resources/

Now you should be able to run the app by double-clicking it in Finder, but probably still with the wrong icon due to caching;
Drag-and-drop the app from your home folder to Applications in Finder - this is when the icon malarkey gets fixed;
Now you can also drag-and-drop to dock the app.

Note: This solution was originally posted by the OP as an edit to the question


Can I import villager trading values to another player/level.dat?

Question: I had to make a villager hall on my survival world and noticed that I was on the world with the wrong account and switched my account. When I loaded up the world, I had the same items, everything looks like normal, but the prices that villagers gave me for healing them disappeared and my tame animals like dogs and cats don't sit/wander when I order the to. I thought it might be because of my player.dat/level.dat and I could just Ctrl-C
Ctrl-V something using NBTexplorer or Universal Minecraft Editor but I don't know what I am supposed to search for.
Answer: I'm not 100% sure of the exact details but I believe that this information is stored on the villager, not on the player. So you would have to go into each villagers data individually and modify it to give the discounts to the new account.


My employer never asked me to fill out a w4

Question: I have been working for the Same employer for almost a year now. I have never been given a w4 to fill out for tax purposes, instead he asked me to fill out a I9. I was under the impression that the I9 form is used for private contractors, meaning I will have to pay taxes at the end of the year but he has been withholding taxes from my checks this whole time. Should I fill out a w4 anyways and give it to him? Or
Comment: Contact your state's Department of Labor and ask them. The Federal government has established standards as to who is an employee and who is a contractor and your state's Department of Labor enforces these standards along with the applicable labor laws.
Comment: He *should* have given you a W-4 in order to determine what your withholding rate should be (based on number of dependents).  However, if they've been withheld, be certain you're hanging on to your paystubs.  You may have to prove that taxes were withheld later, if this guy is bad with his paperwork.
Answer:
Should I fill out a w4 anyways and give it to him?

Yes.
The W4 just determines how much should be withheld from each paycheck for taxes. It won't matter for 2016, but might for 2017.
For 2016, the employer already withheld at some rate, which you can determine from your pay stubs or from your W2 when you get it. If too much was withheld, you'll get a refund. If too little was withheld, you'll owe some taxes.
(This has nothing to do with an I9 form.)
Answer: You don't mention a country, but I bet you can ask your tax office whether income taxes have been paid on your behalf.
In many countries the situation will be like this: If you are an employee, and the employer doesn't pay your income tax to the tax office, the employer is in deep shit as soon as the tax office finds out. It can get the company closed down, and/or makes the employer personally liable for payment. If you are a contractor, and the employer lied to you about having a higher salary with tax deducted when he really is paying you a lower salary, that's just plain fraud.
Answer: The i9 form is not a tax form. It is use for Employment Eligibility Verification and it is used by the United States Citizenship and Immigration Services.

Form I-9 is used for verifying the identity and employment
  authorization of individuals hired for employment in the United
  States. All U.S. employers must ensure proper completion of Form I-9
  for each individual they hire for employment in the United States.
  This includes citizens and noncitizens. Both employees and employers
  (or authorized representatives of the employer) must complete the
  form. On the form, an employee must attest to his or her employment
  authorization. The employee must also present his or her employer with
  acceptable documents evidencing identity and employment authorization.
  The employer must examine the employment eligibility and identity
  document(s) an employee presents to determine whether the document(s)
  reasonably appear to be genuine and to relate to the employee and
  record the document information on the Form I-9. The list of
  acceptable documents can be found on the last page of the form.
  Employers must retain Form I-9 for a designated period and make it
  available for inspection by authorized government officers. NOTE:
  State agencies may use Form I-9. Also, some agricultural recruiters
  and referrers for a fee may be required to use Form I-9.

that is different from the w-9 tax form

Form W-9, Request for Taxpayer Identification Number (TIN) and
  Certification
Use this form to provide your correct TIN to the person who is
  required to file an information return with the IRS to report, for
  example, income paid to you, real estate transactions, mortgage
  interest you paid, acquisition or abandonment of secured property,
  cancellation of debt, or contributions you made to an IRA.

The fact that they have been withholding taxes tells you that you are an employee and not a contractor.
The paycheck stubs should tell you single/married and number of exemptions. You can submit to payroll or HR an updated Federal or state W-4 at any time. So just download the forms and submit them. Or contact payroll/HR to see if they have an electronic way of doing so.


Why do piezoelectric elements have a resonant frequency?

Question: While working with a piezoelectric element, I noticed some high frequency oscillations at 6kHz. I can't figure out why the piezo element has a resonant frequency. This is unlikely to be noise as there are setups that mention the self resonant frequency of the piezoelectric element. Where does the resonance come from? I'm guessing that it's the internal mechanical resonance?
Comment: Yes it is a vibrational mode. In a rod it would depend on the speed of sound in the material and length. In other shapes it would depend on stiffness and mass.
Comment: There should be a lot of information on the subject of piezoelectrics and resonance since (piezoelectric) quartz crystal oscillators are a core component of many clocks and watches. Google "quartz crystal oscillators" for more info.
Answer: Most practical piezoelectric elements in use today are piezoceramics and the physics of these materials have been carefully studied, modeled and engineered to predict how they will behave for use as either sensors or actuators; transducers in general.
American PiezoCeramics (APC) has been thoughtful enough to post on their website a summary modes of piezoceramics elements. If you link to that page you'll see that indeed there are multiple modes to consider that depend on the shape and dimensions of the element as well as the particular material.
The frequency you are seeing is probably a mode (resonance) being excited across another dimension in the element. You should be able to use the chart to explain the 6kHz. If I recall there are 'tricks' you can employ like mounting the element in epoxy that can isolate the specific mode you are trying to excite and attenuate others.


What is a substitute for going to culinary school? Is there?

Question: We live in the information age. What can I do to learn everything that I would learn in culinary school, but use the available resources that are out there?
Comment: Dear God no, Justin. The Food Network has long since run far away from actually teaching people how to cook into endless food porn. Just look at the lineups from 10-15 years ago--Rosengarten, Emeril (before Live), Sara whatsername on Cooking Live, Mario Batali, etc etc etc. Now it's all bizarre competitions, reality shows, and Paula Deen deepfrying Rachael Ray's head in butte--- oops, that last bit was just a fantasy. Food Network is categorically _not_ a replacement for culinary school.
Comment: @hobo: he's not on anything other than ICA here in the Great White North anymore :( (well there was that thing about spain he did with Paltrow, but it wasn't realy a cooking show as such)
Comment: Watch the Food Network.
Comment: @roux: Mario Batali is hands down the best regular chef they have.
Comment: Start cooking with a grandma of the particular ethnic variety whos cooking you are interested in learning.
Answer: One resource I'm impressed with is Rouxbe.com, which is an "online cooking school" with truly excellent video content. (Disclosure: I'm an affiliate, though I haven't earned anything from it - I only signed up because I think it is great, I don't refer anything just to hope to make a buck). That link will give you a 14 day free trial. The thing I like is that it is broken down into really small, highly detailed sections, and the video is HD and shot extremely close up on the hands and pots so you can really see what is happening.
Comment: that's actually a pretty cool site/concept
Comment: I accepted the answer, but I want to say that a combination of learning the proper skills and practicing A LOT as some of the other answers have alluded to is probably the way to go.
Answer: Based on my reading, (Buford, Bourdain, etc.)  The only way to really learn how to cook is to intern in a restaurant.  It's not about recipes, it's about being forced to cut 50 pounds of onions in 2 hours, and about grilling 60 steaks in an evening.  It's about being able to sense when something is done. There is no substitute for being thrown to the wolves.
I suppose you could volunteer at a soup kitchen, which would give you a near equivalent experience (although you wouldn't be exposed to the higher end of cuisine.)
The next thing you can do is eat at good restaurants.  Deconstruct the dish, and try it or something similar at home.
Comment: I think that cooking lots of the same things over and over is key. Practice makes perfect. You rarely get a chance to do that when cooking dinner for two.
Comment: http://ruhlman.com/2010/09/so-you-wanna-be-a-chef—-by-bourdain-2.html
Comment: Stackexchange ate your link. Here's a short one:    http://tinyurl.com/2e6kswo
Comment: Yup. Sink or swim is the only way. Now, good kitchens won't put you in a situation where you will be hopelessly out of your depth; they will ensure you are being challenged, not overwhelmed.
Comment: Great, great essay. (So You Wanna be a Chef) It should be required reading for anyone who thinks they want to be a "serious" chef.
Comment: This is not true there are many great chefs who never worked in a restaurant. How many of our mothers and grandmothers and aunts were and still are great cooks, even if they never worked at a restaurant before
Answer: Upvote for chris (I don't have the rep yet). Though I'm no longer in the culinary industry, I graduated from a cooking school (Scottsdale Culinary Institute) a number of years ago and worked in a couple of high-end kitchens (namely, Christopher Gross). If you want to cook at home, watch Food Network and read cooking books/magazines. However, if you think you want to cook professionally, an apprenticeship under a good chef is hard to beat. Cooking is hard work in any kitchen, but it's even harder when the standards of flavor, texture, and presentation approach perfection with every plate.
So if you fall into the latter category, my advice is to go work for the best chef you can find. Take a low wage if you have to, stay motivated, and do as many different things as you can, because you're there to learn, not fund a new television (that will come later with success).
Good luck!
Answer: Echoing a few comments above: repetition is key. Feedback is key.
And very importantly: pay attention to your food! From now on, think about everything that goes in your mouth. I mean everything. Water, toothpaste, roast beef, oranges--whatever. Pay attention to the textures, to how textures and flavours change at different temperatures, how things feel as they are chewed and swallowed. Also pay attention to scents, as scent is actually most of what we think of as 'flavour.' And also also, pay attention to food associations--how do things make you feel? What memories does this taste evoke? Paying attention to those things will help you become more creative, and aim for specific feelings and sensations when cooking for other people.
There are some key books to get as well. A good edition of Larousse Gastronimique (in French if you read it or a good English translation). Saint Julia's Mastering the Art of French Cooking. The French Laundry Cookbook. Harold McGee's On Food & Cooking: The Science & Lore of the Kitchen.
And then if you want to get really crazy and spend monstrous amounts of money, get the Fat Duck cookbook, and the elBulli series of books (which will set you back only slightly more money than I make in a month. They are frighteningly expensive, which is why I do not yet own them).
Watch some, very selective, shows on the Food Network: Ina Garten (Barefoot Contessa), old reruns of Nigella Lawson (not her latest couple of series, which are only barely a step above boil-in-the-bag), old Mario Batali. Laura Calder, if you get her show in the USA, is (despite her protestations) a professionally-trained cook who is obsessed with French food and technique. The F-Word is also surprisingly good for actual recipes presented with not much fuss.
Watch, on YouTube: Saint Julia, Jacques Pepin.
Practice, practice, practice, practice. Want to get good and fast at chopping onions, carrots, whatnot? Buy a case of onions, process them all at once. (Helpful hint: chill them first; less crying). Make a gigantic pot of soupe a l'oignon les Halles, freeze whatever you can't use immediately. Do the same with carrots, with cucumbers, with bell peppers. (Well, don't make the same soup obviously).
Get good equipment. Good knives--you don't need to go and buy a set of Globals, obviously, but get good knives. Discard gadgetry from your kitchen--I'm not saying get rid of your potato masher; it's a great tool. But ditch the egg separator--your hands are the best egg separator there is.
Shop well. Find local suppliers wherever you can. When you're buying fruit and vegetables, get up close and personal: touch them, smell them, taste them if it's an option before buying (in my experience, farmer's markets will be really good about letting you slice something open once they get to know you). Then in the kitchen, let the ingredients speak to you.
All of these things will help you become a much, much better cook. But as mentioned by Dinah, the only way to get to a professional level is to cook with, for and be cooked for by cooks who are better than you are.
Comment: +1 for feedback. Watch Ramsay's "Kitchen Nightmares."  Every single one is about a cook or owner who won't accept feedback.  They think they are perfect, and their food is the greatest, and anyone who disagrees just doesn't know good food.  Hell, I bet the greats, when working on a new recipe, have everyone in the kitchen taste and critique.
Answer: As you're assessing your resources, remember that the one thing school always gives you, books can't give you, and the internet rarely gives you: feedback.
For casual learning, books and trial and error are fine. Since you specifically asked about the caliber of skill that comes from culinary school though, you'll want feedback from people who are more advanced than you are, not just information. (Sites like this one are certainly a start.)