Is Brooklyn, NY 11217, USA a good home base for sightseeing?

Question: Is this area a good homebase for sightseeing in New York? To be more concrete: How long do I need by public transport to the major sights? How much does this cost? Is it a safe area in New York?
Answer: This zip code finder shows 11217 as the neighborhood of Boerum Hill.
This is a very nice part of Brooklyn.  You have a choice of several nearby subway lines (Atlantic Ave - Barclay's Center is a major transit hub), which will get you into downtown Manhattan in 10-15 minutes, midtown in maybe 15-20 more.  Smith Street has a lot of very good restaurants, as do 4th and 5th Aves.  The area should be quite safe.
[Edit from a Brooklyner: Boerum Hill is a very low-crime area; you can look up crime statistics on NYC.gov for any neighborhood. Here's Boerum Hill's. It's still part of the city, so be smart about not displaying valuables, etc., but it's a very nice neighborhood.]
I'm not sure what you mean by "how much does this cost".  If you mean the transport, as of 2017, New York City has a flat fare of $2.75 for all subway trips, including transfers, and local buses.  (You can also buy various kinds of passes, see http://www.mta.info/ for details as well as transport maps, etc.)  If you mean living in general, I'd expect Boerum Hill to be less than Manhattan but still fairly expensive.  For lodging, I think you'll just have to see what hotels are charging.  For food, there is a wide range of choices from cheap pizza at $2-3 per slice to gourmet restaurants charging $30-50 and up for dinner.
I would call it an excellent sightseeing base if it is in your price range.
Comment: Considering the moderately subjective question, this is an excellent answer! :)
Comment: *gourmet restaurants charging $30-50 and up for dinner* - depends on what you call "gourmet".  But basically any place in NYC with Subway access is a good base of operations.
Comment: @Karlson: Of course "gourmet" is subjective.  But the [Michelin guide](http://www.michelintravel.com/methodology/new-york-city-2012-starred-restaurants/) gave 3 stars to Brooklyn Fare on Hoyt Street, which I'd think should qualify it as "gourmet" by anyone's standards.  Saul on Smith Street also got 1 star.  (By the way, when you capitalized "Subway", I briefly thought you were referring to the sandwich chain, which I'm pretty sure is *not* gourmet by anyone's standards.)
Comment: @NateEldredge subway was a typo.  I personally prefer Zagat or Yelp.
Answer: The Boerum Hill neighborhood is not a bad option. I have never been there at night; however, it is a mostly residential area and I at least have never felt unsafe. While the media has made much of some recent incidents of violent crime, similar incidents happen in any gentrifying neighborhood, including the adjacent neighborhoods of Fort Greene or Park Slope.
Connections
It is a good location for transportation connections into Manhattan. For quick access to Midtown Manhattan there is a Long Island Rail Road (LIRR) terminal at Atlantic Avenue and for the City as a whole as there are many subway lines near the intersection of Atlantic and Flatbush Avenues, namely

Atlantic Av

2 and 3 Trains for the Financial District, west side of Lower Manhattan, Greenwich Village, Broadway/Theatre District
4 and 5 Trains for Battery Park and everywhere on the East Side from Union Square to Grand Central to all the museums on the Upper East Side

Atlantic Av-Pacific St

D Train for Midtown and the Upper West Side; outbound to Coney Island
N Train for the east side of Lower Manhattan, and Queens
R Train for South Ferry, Lower Manhattan, and Queens

Atlantic Av (a different one from above; check the signs at the entrance)

B Train for Midtown and the Upper West Side, or in the opposite direction to Brighton Beach
Q Train for the east side of Lower Manhattan, and Queens

A little farther north you can get to

Hoyt - Schermerhorn

A and C Trains for Greenwich Village and the Upper West Side
G Train if you have a lot of time to waste

On the western side of the neighborhood you have access to

Bergen St

F Train for Midtown Manhattan, Roosevelt Island, and Queens

Planning
Being in Brooklyn, it will take you some time to get uptown. The 4 Train from Atlantic Av to 86th Street for (e.g. for the Guggenheim Museum) would take at least 45 minutes, plus walking time. On evenings and weekends there is often construction and trains may be rerouted, and if you must transfer lines you will also need to account for headways of 20 minutes or more during off-peak times. Plan your days using sites like HopStop or 511 NY and remember that part of the fun of Manhattan is walking its streets, especially for distances under about 2½ miles (4km) or so.
Fares
Fares on the New York City Subway system and MTA buses are a flat $2.25. If you purchase a Metrocard with at $10 of value, you get a 7% bonus. If you will be spending a few days in New York there is a 7-day unlimited ride pass you can purchase from the same vending machine for $29.


"Seeing" the solution

Question: I often hear people say that so-and-so [some famous physicist] can see the solution without calculation. What exactly does this mean? Is it an intuition? But how does one have intuition when it comes to say QM? How might one develop such an intuition?
Comment: well, everyone has a brain which operates on knowledge and experience to create solutions to problems - it's a remarkable organ. So feed it knowledge and experience if you want to "see" solutions to problems.
Comment: It's a matter of experience.
Comment: When it comes to qm intuition is important to me it helps me see the complexities of the interactions. without a strong mathmatical background "seeing" the equations play out in my head is the only way i can make sense of all those silly looking symbols :)
Answer: There is nothing spectacular about "seeing" the solution, everyone does it. The reason they tell you this is to try to get you to do it. The famous physicists become famous because they see it for a new problem, where no-one else saw it before, and an important problem. Please, do it too. The purpose is to learn something about nature. Never in the history of the world, has anyone seen something internally that not everyone else could also see. They just saw it first. It does require learning the appropriate background, a short explanation from the seer, and questions/answers, but nowadays pretty much every good physicist can see everything that Newton saw, and Einstein, and Feynman, etc.
There is no magic to it, anyone can do it, but it does require a lot of mental work, and a tremendous amount of internal intellectual honesty, so you can catch when you did something wrong. Feynman was very good at it, but equally so was Bethe, and Landau, and Gribov, and many others. Feynman was easily the best at explaining to others how to do it, through his terrific popular works.
The thing that makes Feynman so much more famous than all the others is nothing to do with his physics (which is very great, don't get me wrong). It is his essentially American character, like a physics Walt Disney or Ronald Reagan, he fought alone against the big-shots and nay-sayers. By his own design, he fits into the American media story of the individual genius, standing out from the crowd. American capitalism uses such fables to justify awarding large amounts of wealth to a small number of people, and they need examples of people who actually do something exceptional who people will think are somehow exceptional people, people who deserve to be rich. This is not really Feynman's fault, he doesn't think this way. But I am sure that he understood that the media thinks this way. The bias for capitalist-reinforcing is strong, so much so that communists like Tullio Regge and Shoichi Sakata have been generally excluded from history books.
As for "seeing the solution", the best examples are cases where you can't do it by symbol manipulation. For instance, suppose I give you beads on a line of parallel circular tracks, all connected by springs at tension. I pull the first particle. What happens? Did you set up differential equations, or did you see the waves run down the spring?
Comment: @user2146: I think I am being realistic. These great physicists, aside from their great physics, were just ordinary people, some with social aversions. People who are truly insane, like John Nash, can't do work while they're crazy. Anyone nowadays can do Newton. Does that make him any less of a genius? I know exactly what Einstein was thinking. Does that make me Einstein? It is important to be first, because ideas percolate quickly. The social aversions are mostly due to the fact that one knows that it takes work to learn, and one does not want to talk to someone who hasn't done the work.
Comment: Very well said. I too believe that Feynman's fame had a lot to do with his dynamic personality. Dirac was an indisputable genius, but he never seemed to have the fame Feynman had. (Though of course Feynman was also undoubtedly a genius.)
Comment: I think you're being over generous by using phrases such as "anyone can do it". To do something outstandingly new based upon the old requires the coming together of multiple talents, hard work, luck etc which is very rare. it's even been suggested that Einstein, Newton, Dirac may have had Asperger's syndrome. So even possessing a disability in some area may play a part. At the very least, we can say that people can see solutions to various types of problems to varying degrees of sophistication.
Comment: @Ron: +1, I am becoming your fan :)
Comment: @user1333: I have been ron's fan since my first day on this site (ok maybe the second day after i got over feeling personally attacked and realized I had some pretty badly worded and severely lacking in research ideas) Once you get to know him he is not bias and if you have a good question he tries his best to give a good answer
Comment: This is a very good answer, but as you are banned - you may not reply to this. Which type of mental hard work (probably assiduous) are ideal for seeing such solution ? Is this type of seeing the solution same as what mentioned (in the Feynman Tips in Physics, probably laws and intuition chapter) in the story of round table ?
Answer: I will share with you a story from a famous physicist, Feynman,  related by him at a workshop back in the 80s.

During the, I think it was called the Manhattan project, when they were scrambling to create the A bomb, all physicists were employed in doing the laborious cross section calculations, integrals within integrals, that took the best of them ( I think Schwinger and Bethe were there at the time) at least a week to calculate. It was group work, everybody checking the calculations against the others.
Feynman said that he clearly remembered when the idea of the diagrams came to him whole, ( I suppose like Athena from the head of Zeus). He said he remembered his position on his bed, his blue jean legs up the wall.
He started going to the meetings and reproducing the calculations the others had taken a week to do, overnight. When he got confidence that his method worked he started teasing them, by working on the current problems and coming up with the solutions the next day. He had great fun before he told them his method.

At the time Feynman was a trained physicist; in addition he had eidetic memory, books he read he could reread mentally.
Building up an intuition in physics does need a lot of perspiration, but the inspiration part should also be there, and surely genetics must play a role in an eidetic memory.
Comment: @Anna What's your source on Feynman having an unusual memory?  In everything I've read he insists that he can't do anything special.
Comment: I think this story is getting details wrong: Feynman was probably not doing Feynman diagram calculations at Los Alamos, because the method was developed at Cornell. The examples are probably path-integrals for diffusion equation solutions, or something like that, and it wasn't magic--- anyone who understands the path-integral is immediately quicker everyone else.
Comment: I was fortunate to spend about eight days in a small workshop where Feynman was participating, I think it was 1981, could have been 1982, or 1980, in Crete. He was very social, outgoing and full of jokes and flirtatious ( not with me :),with young girl students ). I remember the story because of the detail that the "graphs" came to him whole, while lying in bed with his feet on the wall. My impression was that it was the feynman graphs, I may be wrong. He could have developed the formalism of it later. My source of his unusual memory was again a story he told, of being able to read a formula
Comment: @anna: Wow, you've met Feynman? I am ever so jealous...!!
Comment: Thanks for the story. It is very interesting. Feynman is a genius :-)
Comment: continued: off a page he had read once. I was envious, because although at the time I could visualize the book and roughly the "topology" of the page where the formula I wanted was, I could not read it off :(. The ability of such a recall is called eidetic. He might not have known it was unusual.
Comment: @Ron Maimon As I said I may be wrong, but the description of how he joked with the seniors ( he was a junior apprentice at the time) coming out with cross section calculations in a night when it took them a week argues for Feynman diagrams. Maybe he developed the method formally later. I had never used path integrals for calculating cross sections so did not make/record a  connection .
Comment: No, you can't use path integrals for that. I thought he was talking about critical mass or diffusion equation calculations, where you can use path integrals. I take it back, it was possibly some nonrelativistic precurser of Feynman diagrams, used for nuclear calculations, which is strange, because they only appear in print in a relativistic context 5 years after.
Answer: It doesn't need to be such complicated stuff – "seeing the solution" can also apply to perfectly simple differential equations. For instance, in
$$
  \tfrac{\partial^2}{\partial t^2}y = -\eta\cdot y
$$
every physicist would immediately tell you the solution is $y(t)=\sin(\sqrt{\eta}\cdot t)$, or the corresponding cosine or complex exponential / linear combinations. Even many high school students would say this is pretty obvious.
But then, this very equation once turned up in a maths course I was in (functional analysis, not really advanced but not a beginner's lecture either), and when I told them this everybody was rather baffled. They said you can't just do it this way, you rather have to

classify this a 2nd order ordinary linear differential equation with constant coefficients
make the general ansatz of $y(t)=A\cdot e^{\lambda t}$
put it in the equation
get $\lambda^2=-\eta$, therefore $\lambda\in\{\pm i\sqrt{\eta}\}$
write out these two complex solutions
$$
     y_1(t) = A_1\cdot e^{- i\sqrt{\eta}\cdot t},\qquad
     y_2(t) = A_2\cdot e^{ i\sqrt{\eta}\cdot t}
   $$
try to find, since we're looking for real solutions rather than complex ones, linear combinations of $y_1$ and $y_2$ that are real. And this way eventually find out that the solution is a sine.

Physicists don't have the time to go through all of these steps every time they encounter this equation (it just comes up far too often), but they just know the solution. Now extend this to more complicated problems, then there will often still be clever guys who have seen the equation before (or, more often, a sufficiently similar one) so they can immidiately tell you the solution others will take hours to calculate.
Comment: Thanks, leftroundabout. I have met someone whom when given a equation, seem to be able to immediately translate it into physical observations. This is very amazing. I wonder how he does that...?!
Comment: Well, he probably knows a lot of physical equations and is good at recognizing similarity in mathematical expressions. Still he would probably not be able to translate an equation that is purposely designed to be "un-physical", like one involving lots of non-differentiable expressions.

"Seeing" the solution


When exactly does "overnight on" certain day happen?

Question: When somebody says for example "That will happen overnight on Wednesday", do they mean it will happen on the night between Tuesday and Wednesday, or between Wednesday and Thursday?
Comment: Wednesday and Thursday
Answer: Definition of overnight is "for the duration of a night" from ThefreeDictionary
"That will happen overnight on Wednesday"
It means this will happen on night between Wednesday and Thursday.
Comment: Sorry, did you mean Wednesday and *Thursday*, not Tuesday?
Comment: Yes see this ref. "At this very moment everything is standing awry to my eyes, for a man needs only to work late `overnight` in his writing of something or other for, in the morning, his eyes to be red, and the tears to be gushing from them in a way that makes him ashamed to be seen before strangers."


Custom Page Builder

Question: There is page builder for admin scope area, I want to create or use it for different scope area named as vendor.
Any suggestions on what should I do I should create the new one or I can use the admin scope page builder?
Thanks in advance.
Comment: Sorry, but your question is rather unclear. Are you talking about a product attribute of type "Page Builder"? Please elaborate further what you try to accomplish.
Answer: Your question is unclear
But may I suggest using this Page Builder instead https://github.com/Goomento/PageBuilder It's a Free and Opening Source
This extension come up with

Drag and Drop visual editor
Section, Pages, Templates control
Import, Export content
Undo, Redo, Duplicate, and more ...
History, Revision management
Reuse as page, template
Widgets hub management
Adaptability in any store
High speed optimize
Add custom CSS
Responsive design

Custom Page Builder


How to add time element to open date and close date when adding a quiz

Question: I am using the following modules.

Quiz, Version 7.x-4.0-rc2
Date, Version 7.x-2.9

When adding a quiz, in the availability options tab, I want to be able to set the time as well.
In the open date and close date, there should be an hour and minute option as well.
I did the following things.
1. In the hook_form_alter(), added the below code
if($form_id == 'quiz_node_form'){
  $form['quiz_availability']['quiz_open']['#type'] = 'date_select';
}

This gave a warning on the node/add/quizpage.

Warning: strlen() expects parameter 1 to be string, array given in
  date_default_date()

2.So added a patch in date_api_elements.inc
https://www.drupal.org/files/date-element-default-value-2038057-1.patch
This removed the warning but upon adding the date and time in the availability options and saving the form, it throws the huge error below.

Please supply a valid date. PDOException: SQLSTATE[01000]:
Warning: 1265 Data truncated for column 'quiz_open' at row 1: INSERT INTO {quiz_node_properties} (vid, nid, aid, number_of_random_questions,
   max_score_for_random, randomization, backwards_navigation,
  repeat_until_correct, quiz_open, quiz_close, takes,
  show_attempt_stats, keep_results, time_limit, pass_rate, summary_pass,
   summary_pass_format, summary_default, summary_default_format,
   quiz_always, feedback_time, display_feedback, tid, has_userpoints,
  userpoints_tid, allow_skipping, allow_resume, allow_jumping,
   show_passed, mark_doubtful, max_score) VALUES ....

3.In the hook_node_presave, printed the $node.
It stores the date as below.
  [quiz_open] => 2016-05-12 21:17

but it expects the date to be stored like this.
 [quiz_close] => Array(
      [month] => 6
      [day] => 11
      [year] => 2016
    )

How to store the date as an array or is there an alternative solution to the problem.
Answer: You can convert it to an array using the php function substr
// lets assume $date = Array ('quiz_open' => '2016-05-12 21:17');

$year = substr($date['quiz_open'], 0, 4); // grabs 2016
$month = substr($date['quiz_open'], 5, 2); // grabs 05
$day = substr($date['quiz_open'], 8, 2); // grabs 12

$date = array ('quiz_close' => array (
                                'day' => $day,
                                'month' => $month,
                                'year' => $year,
                                     )
              );


Hidden features of Android development?

Question: I am surprised that there is no Android Hidden Features post yet in the Hidden Features series that I've been tracking for a while now.
The Hidden Features series is great for people who are new to a certain language. It shows the ropes and certain valuable tricks, all in one place. I think it's a brilliant idea. Even experts sometimes find tricks they'd never heard about.
I am starting Android development and I'd love to hear about its hidden features, tips, tricks, and pitfalls.
So, here goes: what are some hidden features of Android?
Answer: Hopefully there aren't too many hidden, hidden features - but here's some of the less well known and non-intuitive features available for Android that will definitely make your life easier and your apps better.

All the source code for the platform and all the non-Google native apps is available for you to browse, download, borrow, or steal from the Android Open Source project.
Using the resources framework, creating localized versions of your app is as simple as adding a new annotated subfolder (Eg. values-fr) that contains an XML file with strings in a different language (Eg. French). Android will choose the right folder at runtime for you.

The same resources framework lets you use alternate layouts for different hardware configurations, screen pixel densities, and input devices just by dropping them in named folder.

Since Android 1.6, your app can produce results that will appear in the results from a homescreen Quick Search Box search. This is known as custom search suggestions.
Using Intents and Intent Filters your apps can make and service anonymous requests for an action to be completed (Eg. The Where app can request a table booking from the Open Table app).

They can request an unknown application to complete an action without needing to know which application(s) can fulfill that request
Your app can fulfill requests from unknown apps to complete actions without needing to know which apps will make the requests. Play this right and you can create the 'default' Twitter app, or booking app, etc.

Using Alarms you can set your app to complete tasks at predetermined times, even if your app isn't running.

You can save a lot of battery life using the setInexactRepeating method to schedule regular events (like server polling or updates). It will synchronize alarms from multiple apps to occur at the same time rather than adhoc.

Using the Preferences framework you can create settings screens for your apps in the same style as the system settings. You can even incorporate system settings screens (Eg. Security and Location) into your application's settings hierarchy.
Using the AudioTrack and AudioRecord APIs, you can stream audio data directly from and to the PCM audio buffers.
Answer: The tools in the /tools directory of the SDK deserve a mention:

our designer was particularly impressed with draw9patch which helped design stretchable buttons. He gave me assets from there, and I changed from a background colour to a 9-patch drawable and now we have a custom button, rounded corners, etc stretched to fit the text.
ddms, which is also integrated into the Eclipse plugin. It's immensely powerful, but I use it to take screenshots.
adb - interact with your device or emulator from the command line. I use this to follow the logs from my device in a terminal window on my desktop, though I have found it useful for installing and uninstalling apps which are misbehaving.
sqlite3 - great for interacting with an installed database, and trying out queries.
apkbuilder, zipalign, aapt - great for running headless builds
monkey for fuzz-testing your app.

I would also single out the three Designing for Performance, Responsiveness and Seamlessness, but I'd also like to add a fourth Coding for (Battery) Life.
Although the Javadoc can be a little sparse at times, it helps no end to have the source right there for you to look at.
It is also very useful to have plenty of sample apps written by Googlers to build, examine and then see how they did it.
Comment: You missed another nice tool layoutopt.
Comment: Another good one missing that I use all the time is hierarchyviewer.
Answer: I guess I'll start then.

A nice hidden feature I think is the Best Practices of the Android documentation. It lists plenty of great tips for designing responsive and fast apps.
Best Practices sections are:

Supporting Multiple Screens (multiple sizes and resolutions)
UI Guidelines

Icon Design
App Widget Design
Activity and Task Design
Menu Design

Designing for Performance
Designing for Responsiveness
Designing for Seamlessness

Another hidden feature is that these docs are available offline as part of the SDK. At first I was loading up a few pages every day for my morning train ride but didn't need to do that anymore after I found them in the SDK directory.

If you use Eclipse, you will notice that it doesn't format XML files very well and when it does, it's very inconsistent (sometimes it splits the attributes by new lines, sometimes it doesn't). To fix it, you can press Ctrl-Shift-F (auto-format). The rules Ctrl-Shift-F uses are in Window->Preferences->XML->XML Files->Editor.
Comment: The last one will for sure be part of my workflow. This was annoying me for the last week... Thanks you!!
Answer: Android supports XML <shape>'s which can be used as SVG-like drawables. Unfortunately there's no documentation for them. This is the best information I could find:
http://escomic.net/217
Comment: There is also http://idunnolol.com/android/drawables.html with a full documentation on all the xml features for shapes.

Shapes can be very important to do round courner backgrounds that change color when clicked or make xml defined gradients instead of custom background drawables.
Comment: is it possible to add a number of shapes to one xml document. e.g. a couple of circles and rectangles?
Answer: Also with regard to best practices, you may want to check out Android coding style:
http://source.android.com/source/code-style.html
as well as the eclipse code and imports formatters (android-formatting.xml, android.importorder) which are found in the platform source code under development/ide/eclipse
Comment: There's a bit too many hoops to jump through to get the code just for the Eclipse formatter, so find it here: http://www.google.com/codesearch/p?hl=en#CRBM04-7BoA/ide/eclipse/android-formatting.xml&q=android-formatting&sa=N&cd=1&ct=rc
Answer: hierarchyviewer in /tools allows you to debug/analyze your view layout: padding, positioning, view hierarchy etc.
It saved me a lot of time a couple of times when trying to figure out why things are laid out the way they are.

Hidden features of Android development?


How to identify cat5 mid-cable

Question: I've recently purchased a house with several cat5 cables running through the attic.  I'm trying to hook one of them up to an access point on the ceiling that is positioned in a place that is about mid-cable.  How do I identify which cable is which without cutting them in the middle?  Is there a tool that can detect a signal in a cable non-destructively?
Comment: Pretty sure it's a toner you need. See https://www.flukenetworks.com/datacom-cabling/installation-tools/Pro3000-Analog-Tone-and-Probe
Comment: cables usually have length markings ... use them to identify the cable
Comment: yes, if you can read the length markings at both ends of the cable you want to cut,  in between will have in-between numbers.
Answer: You can purchase a cheap tone and probe at harbor freight for less then $25. I have one and it works great. Harbor freight calls it a cable tracker, fyi
Answer: if you can't figure it out from the markings
use a tone genrator.

circulate an AC current one way through the cable use a clamp meter

circulate a DC current and use a magenetic compass.

these circulating currents will have to return to the source through some other path (not through the same cable) use a lamp or other load to limit the current.
Comment: Tone generator is the right answer. Homebrew solutions are fine too in general, but "circulate an AC current" could lead someone who doesn't know better to hooking up CAT5 to a standard 120V 15A receptacle, which is **not a good idea**. If you have a *specific* **safe** way to do such a thing, great, but there isn't enough information here to do it safely.
Comment: You can't circulate enough AC current on super-fine Ethernet wire to be detectable by a clamp meter made for AC mains.  Further, return current has to come back somehow.  If you did the obvious/expected thing of using other wires in the cable for return current, then **the two opposite currents would cancel each other out** and be undetectable by a clamp meter or compass.  Put one around an appliance cord and see what happens.  So you really need to drape a separate wire through the house.
Comment: @Harper READ TO THE END  they will not cancel, because they will not be in the same cable.  "Cat." cable can hadle 2A per conductor no problem, 1A should be easily detectable,
Comment: you could return the current through another cat cable if you don't care which one of the two you cut, (but with DC one will defelct the needle in the opposite direction)

How to identify cat5 mid-cable


Equal Euclidean distance of a single data point to all the Cluster Centers

Question: In K means Clustering, suppose, if there exists equal euclidean distance of a data point to all of its k cluster centers, which cluster the data point will choose to become its member?
Is there any literature proof supporting it?
Comment: You can just assign your data-point to one cluster centers (random choice), and continue to use K-means until convergence. However, if this is a new data-point that you want to consider after the convergence of your algorithm, and this data-point have "almost" the same distance to all cluster centers, then you may consider creating a new cluster having this data-point as a center.
Answer: Actually, $k$-means does not use Euclidean distance.
It assignes object so that the sum of squared deviations (across all dimensions) is minimized by this assignment. Let $X$ are the observation and $C$ are the current cluster centers, the objective is:
$$\sum_{x\in X} \min_{c\in C} \sum_{i=1}^d \left|x_i - c_i\right|^2$$
which is a trivial rearrangement of the sum of in-cluster-variances. Note that the part inside the $\min$ coincides with the squared euclidean distance formula, which in turn is monotone to Euclidean distance. So the interpretation that $k$-means assigns objects to the closes center is absolutely correct. It is just that $k$-means does not care about the distance itself, it tries to minimize the sum of variances.
If there is a tie, i.e. there are two cluster centers $c\in C$ an object can be assigned to that have the same variance, any of them can be chosen, as both minimize the objetive function. $k$-means is usually used randomized anyway, this little bit of indetermism does not change much.
In practise, you will see very different behaviour:

some implementations may prefer the "first best"
some implementations may prefer the "last best"
some implementations may prefer to keep the previous assignment, if possible, in the hope to converge faster this way
some implementations may prefer to reassign, in the hope to find better solutions this way

I don't think there is a clear reason to prefer one over the other. It is mostly for technical reasons that it is implemented one way or another. For the mathematical objective of minimizing variance, it clearly does not matter.
Comment: I don't understand clearly, what is "first best" and "last best"? And Is there any literature or some kind of proofs, to explain these behaviours.?
Comment: Well, the first result that is optimal, and the last result that is optimal. There is no literature or proofs for the way things tie handling is implemented technically. Mathematically they are all optimal and thus correct.
Comment: For *what exactly* do you want a proof? Your question is quite imprecise, somewhat like asking for a proof that even numbers are more even than odd numbers.


CXF web service issue when using @WebParam (header=true)

Question: I need help here. I have at work a CXF web service working really well running in a WebLogic server. I recently was asked to pass some extra parameters (for extra authentication purposes). We want these extra parameters to travel in the header, not as normal parameters.
I have two different scenarios to explain. In fact, in scenario number 1, everything works really well, I am very please with it as my web service received the header parameters and I can validate them. But then, in scenario number 2, in running time, all these new parameters in the header are NULL (and normal parameters are correctly populated!). So I cannot validate the header ones. And I need scenario 2 to work as we want these extra parameters to be in the header.
Why this binding is not working in my second scenario ? there is a bug ? Am I missing something ? Please help me. Here I describe both scenarios with some code for clarification:
1) Here everything works fine. In my cxf-servlet.xml file I have the endpoint defined as:
<code>    <jaxws:endpoint id="omniWebService"
                implementor="server.com.omnipay.webservice.webService.ServiceImpl"
                address="/omniWS" />
</code>
And one of the calls that my CXF web service interface is offering is for instance this one where you can see that the 3 first parameters are header=true, not the others.
<code>    @WebResult (name="merchantHierarchyParentResponse") MerchantHierarchyParentResponseDTO
getParent(
        @WebParam(header=true, name="callerId") String callerId,
        @WebParam(header=true, name="timestamp") String timestamp,
        @WebParam(header=true, name="signature") String signature,
        @WebParam(name="institutionNumber") @XmlElement(required=true) String institutionNumber,
        @WebParam(name="clientNumber") String clientNumber,
        @WebParam(name="ourReference") String ourReference,
        @WebParam(name="accessMerch") String accessMerch
);
</code>
That's all. I don't think I need to show more. This is working fine. I deploy in WebLogic and my client or soapUI or debugging or whatever I do, the web service receives all these parameters and I can work with them.
2) The real endpoint I want to use in my cxf-servlet.xml is the following:
<code>    <jaxws:endpoint id="omniWebService"
                implementor="server.com.omnipay.webservice.webService.ServiceImpl"
                address="/omniWS" wsdlLocation="WEB-INF/omniWebService.wsdl">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:endpoint>
</code>
And the reason to use this one is because I need a "local" WSDL that I can edit and make changes. This "local" WSDL is the exact WSDL that WebLogic provided me after my first deployment plus adding things like this plus using them instead of type="xs:string":
<code>            <!-- Institution Number is a required 8 numeric positions IN parameter -->
        <xs:simpleType name="institutionNumber">
            <xs:restriction base="xs:string">
                <xs:length value="8"/>
                <xs:pattern value="[0-9]+"/>
            </xs:restriction>
        </xs:simpleType>
</code>
This is, adding some restrictions so the WSDL will validate the user input. For instance 00000123 is a valid institution number but 000000XX is not.
This functionality works really nice. To be honest, it forces me to maintain a "local" WSDL file which I would prefer not but I didn't find any other way to do it.
And here is where I have my problem. Even if I put as "local" WSDL the exact content of the "automatic" WSDL that WebLogic provided me after deploying  (the original without any of my changes!), the result is that in execution time my normal parameters (institution number, client number, etc) are correctly populated but my 3 header parameters (callerId, timestamps and signature) are NULL.
Please any suggestion ? what I am doing wrong ? Both functionalities works very nicely when not working together but the moment I put them together I am having this problem in execution. Why the binding is working fine in scenario 1 but not in scenario 2 ?
thanks
Answer: I found the problem. Well, I tried something mad and it works. I put the 3 header parameters at the end, and then it works ! I find this very strange. Why can't I put them on the beginning ? Is it maybe a WebLogic problem ? Am I using old CXF classes with a bug ? Very strange but happy it is fixed now !
<code>    @WebResult (name="merchantHierarchyParentResponse") MerchantHierarchyParentResponseDTO
getParent(
        @WebParam(name="institutionNumber") @XmlElement(required=true) String institutionNumber,
        @WebParam(name="clientNumber") String clientNumber,
        @WebParam(name="ourReference") String ourReference,
        @WebParam(name="accessMerch") String accessMerch,
        @WebParam(header=true, name="callerId") String callerId,
        @WebParam(header=true, name="timestamp") String timestamp,
        @WebParam(header=true, name="signature") String signature
);
</code>


trying to store text file rows in VBA

Question: Greetings, I'm hoping for help in figuring out how to store each row of a text file read into a VBA program as a string.  I want to modify one of the strings and then put them all back together, but do not know how to read through a text file and store each row as a separate variable in an intelligent way.  Thanks for any help you can provide!
Comment: suggest you first learn VBA and then come back with any coding problems you have. You could also try typing "read a text file VBA" into a search engine
Answer: Look into the FileSystemObject (ref: 1, 2, 3)
You have to go to <Tools/References> menu and include the Microsoft Scripting Runtime and create a global variable Global fso as New FileSystemObject. Now anywhere in your code do things like fso.OpenTextFile() which returns a TextStream. Each TextStream has methods loke ReadLine(), ReadAll(), SkipLine(), WriteLine(), etc ...

Here is a quick sample code.
Global fso as New FileSystemObject

Sub TEST()
    Dim ts As TextStream
    Set ts = fso.OpenTextFile("text_file.txt", ForReading, False)
    Dim s As String
    s = ts.ReadAll()
End Sub

Answer: If you don't want to add references, you could just go with straight vba code.
Take for instance the following file wordlist.txt:
realize
empty
theorize
line
socialize
here
analyze

The following code uses two methods to do as you described (one more common than the other):
Option Explicit

Sub main()
    Dim sFileName As String
    Dim sMergedLineArray() As String
    Dim sTextToFind As String
    Dim sReplacementText As String
    Dim sOutputFile As String
    Const MY_DELIMITER = "|"

    sFileName = "C:\deleteme\wordlist.txt"

    sMergedLineArray = ReadFileIntoArray(sFileName)

    sTextToFind = "ze"
    sReplacementText = "se"

    'Loop through each value in the array and make a change if you need to
    Dim x As Integer
    For x = 0 To UBound(sMergedLineArray)
        If InStr(1, sMergedLineArray(x), sTextToFind, vbTextCompare) > 0 Then
            sMergedLineArray(x) = Replace(sMergedLineArray(x), sTextToFind, sReplacementText, 1, -1, vbTextCompare)
        End If
    Next x

    sOutputFile = "C:\deleteme\UK_Version.txt"
    If Not SpitFileOut(sOutputFile, sMergedLineArray) Then
        MsgBox "It didn't work :("
    End If

    'OR...put it all together, make a mass change and split it back out (this seems unlikely, but throwing it in there anyway)
    sTextToFind = "se"
    sReplacementText = "ze"
    Dim sBigString As String
    Dim sNewArray As Variant
    sBigString = Join(sMergedLineArray, MY_DELIMITER)
    sBigString = Replace(sBigString, sTextToFind, sReplacementText, 1, -1, vbTextCompare)

    sNewArray = Split(sBigString, MY_DELIMITER, -1, vbTextCompare)

    sOutputFile = "C:\deleteme\American_Version.txt"
    If Not SpitFileOut(sOutputFile, sNewArray) Then
        MsgBox "It didn't work"
    End If

    MsgBox "Finished!"

End Sub

Function ReadFileIntoArray(sFileName As String) As String()
    Dim sText As String
    Dim sLocalArray() As String
    Dim iFileNum As Integer
    Dim iLineCount As Integer

    iFileNum = FreeFile

    Open sFileName For Input As #iFileNum
    Do Until EOF(iFileNum)
        Input #iFileNum, sText
        ReDim Preserve sLocalArray(iLineCount)
        sLocalArray(iLineCount) = sText
        iLineCount = iLineCount + 1
    Loop

    Close #iFileNum

    ReadFileIntoArray = sLocalArray

End Function

Function SpitFileOut(sFileName As String, sMyArray As Variant) As Boolean
    Dim iFileNum As Integer
    Dim iCounter As Integer

    SpitFileOut = False

    iFileNum = FreeFile

    Open sFileName For Output As #iFileNum
        For iCounter = 0 To UBound(sMyArray)
            Print #iFileNum, sMyArray(iCounter)
        Next
    Close #iFileNum

    SpitFileOut = True
End Function

If you run the main sub, you'll end up with two files:

UK_Version.txt:  This is the result of the first method
American_Version.txt:  This is the result of the second

There's lesson 1 of VBA, young Padawan; absorb it, learn and change your login name :P

trying to store text file rows in VBA


Keyframes not animating object

Question: When I try to key frame a plane it indicates with the yellow bar on the timeline that I have set the key frame, but as soon as I go to set another key frame or play the animation the yellow bar remains but the object goes back to normal.
When I play the animation the object is idle as if there is no key frame. I have already searched a while on the web for this and found something on it but it had no solution.
Comment: What did you keyframe? You may have keyframed rotation instead of location for example
Comment: Please add more information or make your file available to download. So far we can't tell what is going on without knowing what you've done. Is the key frame to  move, scale, rotate, deform? What do you mean by "going back to normal?"
Answer: Your question is a bit difficult to understand, but I believe I am answering.
It being a plane should not make a difference.
It sounds like you need to add another keyframe. If I am interpreting your question correctly, you are inserting a keyframe, moving/rotating/scaling the plane, relocating the time cursor, and watching all of your transformations revert to the keyframed loc/rot/scale. You can animate by inserting that original keyframe, NEXT moving the time cursor, changing the loc/rot/scale, and finally keyframing again. The plane should now change it's loc/rot/scale between the two keyframes.
Comment: no im afraid the problem is not that what happens is that i set the first keyframe to the pose that it is already to initiate the move or scale in this place then i go to set a second keyframe the object reverts to original pose and does not move when i hit play
Answer: I'm only answering this old question because I discovered my own fix so anyone looking in the future can answer it here. I had the same issue after loading a days old project. All I had to do was individually click each keyframe choice I needed. I needed scale, rotation, and location. So by clicking each one individually instead of just "i", while mousing over the viewport, it worked and started animating like normal.

Keyframes not animating object


Banking industry chooses Secretary of Treasury?

Question: I remember being told before that the banking industry has effectively been choosing the Secretary of Treasury for a long time and, my memory is fuzzy, that the current U.S. Secretary of Treasury is a still part of a board of a major bank. I trust that it's true, but I would like to research more. However, I was unable to find any information online to backup the statements I was told. I was wondering if anyone here had more information on this?
Comment: Not directly answering the question, but wouldn't you rather have SecTreas who knows what the hell they are doing professionally and had a successful finance job previously, instead of a random yahoo with no experience?
Answer: The current Secretary of the Treasury is Jack Lew, who used to be President Obama's chief of staff. Before that, he was Obama's Director of the Office of Management and Budget (OMB), and before that he was President Clinton's OMB Director as well. In between his terms in the White House, he worked at Citigroup and was a member of its board of directors.
Before Lew was Secretary Timothy Geithner. He had served in the Treasury Department under three previous presidents. In between the Clinton and Obama administrations, he became CEO of the Federal Reserve Bank of New York.
So it is true the recent Secretaries have had ties to the banking industries. But there's never been any evidence that the banking industry actually selects the Secretary instead of the President. If the banking industry did select the Secretary of the Treasury, they've been very good about selecting exactly the Democratic loyalists and former bureaucrats you'd expect President Obama to select on his own.
And while the closeness between banks and the Department of the Treasury has always been a common complaint, no one has alleged that recent Secretaries currently have jobs in the industry, stock in banks, serve on a bank's board of directors, etc. Given how contentious the Geithner and Lew nominations were in the Senate, I guarantee you at least one Republican would have brought it up as ammunition.


Remove superfluous divs from views fields output?

Question: I've set the Wrapper HTML Element option to none, and removed any wrapper divs in the templates presented in Theme Information, but my image fields are still getting wrapped in plain divs.
Answer: There are several ways to strip HTML. You can under rewrite results Strip HTML tags or under style settings Customize the HTML. If you have tokens enabled you can exclude a bunch of fields then add a Global text markup field. Most of the wrapping markup will be removed and you can use the your own markup or not by typing HTML into the Global text field placing the placeholder tokens where in the HTML the field should be rendered. Another way to clean up Views markup is to create override theme templates by clicking on theme templates for the theme override template title and copying the default code changing anything you don't want in them before you save.
Comment: Derp. My problem was I was setting the "Customize field and label wrapper HTML" option to none, but did not notice I also needed to address "Customize field HTML".
Comment: Herp... Thanks @Joren, you probably saved me a lot of time.
Answer: From the looks of things, you're using D7/Views 3.x... For 2.x, there's an excellent Views companion module, Semantic Views, that enables this kind of functionality.
And, yes, it's often a bit confusing as to which setting in the Style options of a views field will turn on or off which HTML element... Hopefully the ux for that improves over time.


PhoneGap FileTransfer Upload Not Found

Question: I'm trying to upload an image taken with the device's camera via the FileTransfer.upload method and I'm consistently being given a FILE_NOT_FOUND_ERR. I'm using Cordova 2.2.0 via PhoneGap Build.
I'm taking a picture and saving the URI for it into localStorage (via Backbone):
navigator.camera.getPicture(
    (file_uri) =>
        params.file_uri = file_uri
        params.is_image = 1
        collection.create params
    (message) ->
        U.Alert "Failed: #{message}"
    options
)

Then attempting to upload that image:
file_uri = @get('file_uri')

transferOpts = new FileUploadOptions
transferOpts.fileKey = 'attachment'
transferOpts.fileName = file_uri.substr file_uri.lastIndexOf('/') + 1
transferOpts.chunkedMode = false

transfer = new FileTransfer
transfer.upload(file_uri, @url(), success, error, transferOpts)

With this, the FileTransfer's error callback is always thrown with the following:
{
    code: 1,
    http_status: 411,
    source: "content://media/external/images/media/8416",
    target: "https://mywebapp.com/api/endpoint"
}

Code 1 is PhoneGap's FILE_NOT_FOUND_ERR response code. But I've verified the file exists on the device. Firstly, I can display the file_uri as an image on the screen. Secondly, I can retrieve the contents of the image file via the Weinre debugger like so:
var reader = new FileReader();
reader.onloadend = function(e) {
    console.log('Read as data URL');
    console.log(e.target.result);
};
reader.readAsDataUrl(file_uri);

The logged data:image/jpeg;base64 response is the correct image.
Now, I even tried manually resolving the URI like so, as I've seen in one StackOverflow question:
resolveLocalFileSystemURI file_uri, (fileEntry) => fileEntry.file (fileObj) =>
    transferOpts = new FileUploadOptions
    transferOpts.fileKey = 'attachment'
    transferOpts.fileName = fileObj.name
    transferOpts.chunkedMode = false

    transfer = new FileTransfer
    transfer.upload(fileObj.fullPath, @url(), success, error, transferOpts)

In this case fileObj.fullPath resolves to: /mnt/sdcard/Android/data/com.COMPANY.APPNAME/cache/1359412873161.jpg
And still no luck. At this point I'm sure it's something stupid I'm missing!
Answer: I had similar problem and resolved by using source uri  in format "file://"
Comment: I have already the heading "file://" (automatically added) but I have the same error

PhoneGap FileTransfer Upload Not Found


Protocol Buffers for VB6?

Question: I can't seem to find any libraries for using Protocol Buffers in VB6?
Is my only option to use a wrapper C# library via COM Interop?
Comment: @MarkJ A C# wrapper library.
Comment: Yes, I expect so. What did you actually do?
Answer: Another option would be to write a protocol buffers library for VB6 ; it's not the friendliest language to write funky serialization code in, but it is an interesting intellectual exercise to work out how to do bit operations with the reduced operator set that VB6 hands you.
The pattern I used to use for VB6 serialization code was to implement a common interface on classes to be serialized ; you needed internal access to the instance variables because even public fields are encapsulated behind accessors by the compiler. I had a base library that declared the interfaces like this, along with some bits that managed class metadata, and you could write a number of serialization classes that understood this interface and transformed the instance variables into XML, SQL, bytes in an array, fields in a flat file, etc.
Alas, I no longer have access to this code, and the legality of sharing it would be dubious anyway.
Protocol Buffers entered the scene long after VB6 became unfashionable and you're unlikely to get a native VB6 library for them unless you pay someone or write it yourself.

Protocol Buffers for VB6?


Is "prior art" established by written consideration of an idea but not used?

Question: I had a website tying messages-with gifts online around 2006.  I notice that there are several patents dealing with this topic and I believe that I have written evidence that I considered the same processes that are now patented.  I am wondering if I have something to sell to the patent holders?
Comment: "I am wondering if I have something to sell to the patent holders?" - prior art would be used to negate or reduce claims from their patents, you can't license it back to the patent holder. If you had an earlier PATENT for the same thing, then yes, you could go after them on infringement.
Answer: Since you didn't apply for anything back then you do not have any particular rights. All you have is knowledge of something in the public domain that might be used to show someone's patent is invalid.
If you can document what you had, possibly by the wayback machine, and you studied  the history of specific patents you might conclude you have killer prior art and have something valuable to anyone whom those patents are trying to be enforced against. I would think it is only valuable if it is dead-on and hard to find. One problem is it is hard to see how you demonstrate its value without giving away its value. It is only prior art if it is published (on the web will do). If it is published and findable they do not need you. After you approach them with a proposition backed up by evidence it will become very easy to find.
I'm not an attorney but I wonder if contacting a patent owner and saying "pay me or I will publicize  my prior art" is considered proposing a legitimate  business relationship or something underhanded.
Comment: I'll try repeating my point. If the information *was* public before the filing then the fact that it was public is the point, not who owns it. If it *was not* public before the filing then it isn't prior art.
Comment: Thanks.  It appears I need to sell it to those who are affected by the patent so I just have to figure out who they are.  If I show my prior art specifically, the company can either subpoena it or just try to copy it.  This seems like a tricky business.  Any further suggestions?  Perhaps I can sell them my entity on faith without specifically disclosing what I've got?  Or, if they don't buy it, I might threaten to destroy it forever? I'm wondering what a provision would look like in a purchase agreement if the prior art is successfully asserted? How would I ever find that out?  Thoughts?
Comment: I didn't make it clear. You having done something, even if you can prove it, is not prior art. To be prior art it must have been *published* before the filing. If it was truly published it can't be unpublished. It is irrelevant that *you*, particularly did something. It is relevant that is was done and was published before a certain date. If it is a secret known only to you it is not prior art to anything.
Comment: 'Pay me or I will publicize my prior art' is pretty clearly extortion.
Comment: I consulted with a prominent patent lawyer and he believes, since my website was up for some 10 months and that, in writing we considered many ways of doing what we eventually did, that I have a good "argument" that I do possess prior art.  Regarding Mr. Kohne's "extortion" comment, my prior art was bought and paid for and is my property.  If someone wants to buy it, it's for sale.  That's capitalism and I'm a proud capitalist.
Answer: As George White says, this might not constitute prior art, if it was not published in some way before the priority date.
However, it might be possible to make it serve as evidence of "obviousness to a person skilled in the art".
This is different from an argument against "novelty", and involves a different requirement of the patent statute.  My impression is, however, that this is not as useful an argument as prior art would be - it is more difficult to argue.


What is the purpose of はある in this sentence?

Question:
顔の大きさの半分はあるであろう大きなマスク。(source)

I've been told that this sentence is describing the size of the mask being half the size of the face, Can't we simply say 「顔の大きさの半分であろう大きなマスク」 instead?
Answer: This type of は means "at least". That is, the mask covers roughly 55-70% of the area of the face.

Does は mean 'at least' in this sentence?
Can は be used to mean "at least"

The sentence can be rephrased as 顔の大きさの半分はありそうな大きなマスク, 顔の大きさの半分以上あるであろう大きなマスク, etc. But 顔の大きさの半分であろう大きなマスク does not have the same meaning.
Answer: While you probably already know this, [であろう] is a literary/formal way of saying だろう/でしょう.  It should not be separated into で and あろう any more than でしょう should be separated into で and しょう.
Let's rephrase the quote in question:

顔の大きさの半分はあるでしょう、大きなマスク。

Maybe it is easier to see now how the でしょう relates to the clause [顔の大きさの半分はある], or 'The mask was as large as half the size of a face.'. The end result (including でしょう) is a sentence more equivalent to '____ probably as large as half the size of a face.'.
The はある expression would, in English, be stated as 'there exists/existed', or 'it is/was'.
If you search for 「はあるでしょう」or 「はあるだろう」, there are many results. On Kotonoha alone, there are over 400 combined examples. If you change the particle は to も, there are over 1000 combined results.
Just to pick one out of the results:

「そんな経験が 誰にも 一度はある だろう。」
  'That type of experience, for everyone there probably exists that one time.', or more colloquially, 'Everyone has probably had that type of experience.'

Now, to remove the であろう expression entirely. Again, Kotonoha has over 1300 results for 「はある。」. Here is one:

一度見る価値    はある。'It is worth seeing once.'

From the above sentence and how it relates to your main question, I hope that you can see that はある helps to complete (round out) a clause.


APA: Citing an annual report over multiple years

Question: I have looked everywhere for an answer to this question. I don't often use APA format. In Chicago, when referencing in-text an annual report over a span of years, one simply types: (Smith, multiple years). I'm referencing an economic report, published annually, to analyse performance over a span of six years. Must I create a separate reference for each year, or may I do the same as in Chicago?
Best guess is the reference will look like:
Smith, J. (2002-2016) Annual Report
OR
Smith, J. (Multiple years) Annual Report
Comment: If it is not in the most updated APA Style Guide, I would consult whoever is reviewing your work, because APA can change so much that sometimes you will get different answers regarding format, depending who you ask.
Answer: I don't work in APA much, but in the several papers I have had published the journal has had particular requirements for special cases like that. Step one would be to reach out to the editor of your chosen publication.
In the mean time I would probably cite them separately.

Smith, J. (2002) Annual Report
   Smith, J. (2003) Annual Report
   Smith, J. (2004) Annual Report
   etc.

with the in text citation (Smith, 2002, 2003, 2004 ... ). I find it preferable to include too much detail and be asked to scale back than vice versa.
Answer: I use a lot of citations.  I would probably cite and allow for multiple years as long as the citation hasn't dramatically changed over those years (like a climate survey -- the trend would be the same).  It may also be useful to pull a specific quote/note from the most recent source (cited specifically by its year) to further illustrate your point, but I don't think it's needed unless that's the basis for your additional work.
Answer: I would show the range.  I am kind of a nit at trying to follow format.  But then there are times when you have something not covered by the book. I find if you are doing all the regular ones perfectly that the editors allow you some freedom to freestyle when you have something not covered.  At the end of the day people want to be able to find things from your citation.
Again, don't make the regular ones a mess or freestyle those. But when something is not 100% covered, just decide you are the grownup and write it the way you want.
Answer: I would suggest the following touch-ups to your two suggestions. Besides hyphen, an arrow, or a double dot, or a colon may also be used indicate a series without a break.

A series of reports without a break (note the plural, "Annual Reports", which is not the exact title. It is a class indicator):

Smith, J. (2002->2016) Annual Reports

A series of multiple reports, all have the same title "Annual Report"

Smith, J. (Multiple: 2002..2006) Annual Report

If the series is not a continuous sequence, the years may be enumerated in increasing order

Smith, J. (Multiple: 2002, 2004, 2007) Annual Report

If there is a mix of continuous series and isolated years, a combination can be used.

Smith, J. (Multiple: 2002..2004, 2007, 2011-2014) Annual Report
Answer: If it is a report / essay for your University check with them, if it is a paper for a journal, again, check with them. They may even have information on their site.


Monitoring and statistics through libvirt

Question: Is it possible to monitor and gather statistics in realtime (CPU,
memory, HDD, network, ... - something like dstat) of guest systems
with libvirt through console from host system (KVM based)? If yes, do
those guests need to be created through libvirt?
Answer: virt-top?
http://people.redhat.com/~rjones/virt-top/
Answer: virt-manager has some of this built in, but if you want more detail, look at nagios-virt.  Alternatively, you can monitor it by installing the same tools (nagios, ZenOSS, etc) on the guest that you'd use on a non-vm system.
Answer: I run munin on my virtual clients to gather this kind of information.  Information is gathered every 5 minutes and available in graphical format via rrd.  Data is available via http from my munin server.
Answer: You can use collectd with libvirt plugin
https://collectd.org/wiki/index.php/Plugin%3alibvirt


How do I access raw photos from Nikon D3500, if imported photos on my phone always appear in jpg format?

Question: I recently bough Nikon D3500 and I shoot in jpg+raw mode. In the history of taken photos, however, there's only one copy of each photo, rather than two. Similarly, when I import the photos to edit them, I find only jpg formats. So, how to access and transfer the raw data?
Comment: How are you importing them?
Comment: Sorry if this sounds obvious, but have you tried reading the memory directly in a card reader  on your computer?
Comment: Via bluetooth to Snapbridge app.
Comment: My laptop has a card reader indeed! Thanks, problem solved.
Answer: According to this Nikon page, NEF transfer in SnapBridge is only available if your camera supports WiFi (Bluetooth would likely be too slow), and as far as I can tell the D3500 has no WiFi.
Comment: @SvitLaris Or a more expensive camera :) But is editing RAW on the phone really worth it?
Comment: So wire is the only way to go?
Answer: The camera's built-in playback mode knows to just show you JPEG files when reviewing when a RAW also exists — there'd be no point in separately showing the RAW preview (whih will be identical).
Then, you say imported photo on my phone. You note that you're transferring via the Snapbridge app. Unfortunately, these apps are made for quick social media sharing — they solve the problem of "I took a nice picture with my real camera, and now I have to take a snapshot with my phone in order to immediately share this with my friends/family". They generally don't transfer RAW files, and often transfer smaller or recompressed JPEGs. (Depending on the camera and app, that may be an option.)
This is largely because RAW files tend to be much bigger than JPEGs, so it would be slow, but it's also matter of target market and use case. (The few RAW-processing apps for phones are targeted at processing your phone's photographs.)
So, your only option is to transfer via cable (or, remove the card and put in a reader, which is often faster and less fiddly).
Answer: What camera mode?  There are several of the auto "Scene" modes where raw recording is not possible. That is my guess.  See page 48 of the D3500 Reference Manual, free at https://downloadcenter.nikonimglib.com/en/products/471/D3500.html
Comment: Thanks, checked the manual, but I'm shooting in apeture priority. So my guess is that I did shoot the raw, but I don't know how to access/transfer it. BTW. if I shoot in raw mode, my camera says the preview photo it's in NEF format, but if I shoot in jpg+raw it says it's jpg. So there has to be a way of accessing the NEF files.


Automatically create donut polygons based on distance from boundary

Question: I have a file with polygons representing risk of townships however the risk decreases inside each polygon so I'm wanting to create rings from each polygon for example from the boundary to 500m then another ring from 500m from the boundary to 750m from the boundary then another ring from 750m from the boundary to 1000m from the boundary and so on
I can do this manually by creating donut polygons but I was hoping for a more automated solution.
Comment: Look at multiple ring buffer http://resources.arcgis.com/en/help/main/10.2/index.html#//00080000001p000000, there's an option for overlapping and non-overlapping rings.
Comment: Convert your polygons to polylines and calculate euclidian distance to it. Erase raster outside polygons and reclassify result using 500 increment. Vector solution is more hectic
Answer: The Multiple Ring Buffer tool would seem to be the place to start your investigations:

Creates multiple buffers at specified distances around the input
  features. These buffers can optionally be merged and dissolved using
  the buffer distance values to create non-overlapping buffers.
Comment: I always thought it works on points only and does not on polygons especially with negative buffers
Comment: @FelixIP The Illustration at http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/multiple-ring-buffer.htm shows a polygon being multiple buffered.  I don't recall trying that tool recently but I think the asker should.
Comment: Thanks for the multiple ring buffer. That is what I want to do but in reverse. I'm not sure how this would work though?
Comment: @AJ1984 I think you should edit your question to describe what you mean by "in reverse" of what the Multiple Ring Buffer tool does.


Help needed!!! I have an upcoming exam

Question: I have an upcoming exam about the codes and stuff. Its about the basics like "blink with delay" and the "millis function". I need to get these things learned but i have no idea how?! Does anybody know a good site or how i can learn this?
Comment: Why don't you use the material your teacher provided you with? Or aren't there any sources? The ardiuno.cc site teaches you some basics https://www.arduino.cc/en/Tutorial/HomePage . But that's lot of stuff, so i would prefer the material from school. If you have an Arduino to use it, you can install the Arduino IDE and try some of the examples and learn from it.
Comment: Don't you mean "blink without delay"? The point is that the `delay()` function is to be avoided.
Comment: You should get an Arduino, a couple of LEDs, properly sized current limiting resistors, and spend a couple of days figuring out how to write a sketch that blinks the 2 LEDs at the same time on different intervals (Say you blink the first LED on and off every 3 seconds and the 2nd LED every 2 seconds.) If you figure that out, you will understand using `millis()` to manage timed events well enough for an exam.
Comment: There are tons of tutorials on the web about this (if you search for terms like "arduino blink without delay" or "arduino millis"). Even on this site the principle has been described numerous times. You should read some tutorials about it. If you don't have the actual Arduino hardware, you can use a simulator like from tinkercad. Try, what you have read in the tutorials and you will be able to figure this out fast.
Answer: Learning to write code really takes practice - you learn far more by doing it than by reading about it. Start with the basic Blink example - search for a tutorial online if you want one, there are many - and get that running. Then play with it. Change the blink interval. Try adding a second LED, perhaps it turns off when the other turns on, for instance.
Every time you touch the code you'll have an "opportunity" to make a mistake or a typo. Fixing those will give you some insights you'll never get from reading about coding.
Once you've "squeezed all the juice" out of Blink, move on to Blink Without Delay. Run it, just as it is, at first. Than start tweaking it. Change one or both of the blinking periods. Again, try adding another LED with yet another blink rate.
These hands-on games are the best way to learn this stuff. Having someone (or Arduino Stack Exchange) who can help you when you're stuck is a great resource but the things you discover and the skills you acquire on your own when you fix your own mistakes are the ones that will stick with you (even 50 years later! ;-)

Help needed!!! I have an upcoming exam


Employee Leave Balances

Question: How can I use the Absence Request and Vacation Schedule Management template to keep track of everyone's balances.
Say an employee had 15 days of leave available on May 1.  For each day of vacation they take from that date their balance decreases.
Can this be done?
I've been all over the web looking for an answer and am about ready to give up :(
Comment: @Nav could you please explain this a little more ?
Answer: You could always apply a workflow to the list so that whenever time taken off it updates a secondary list containing available vacation hours for your users.  You could then kick off a second workflow to notify you when that column value drops to zero
Comment: I was thinking the exact same thing but I don't know how to do the math.
To enter a request for one day off, a user would likely select the day they want and check the "All Day Event" check-box.  How do I take that all day event and give it a value of "1" to subtract from my balances?
Comment: The all day event is a boolean type so you could do a logic check on whether that field equals yes. If so, update the appropriate timeoff value for a full day's time.  If it says no, subtract the alternate selected amount.
Answer: I did this by having an employee leave list which has the employees name, allowance and balance. When an employee makes a request they enter the days taken (which gets approved by their manager).
Then minus the days requested from their holiday balance in the employee leave list. Matching the employee name and the to the name of the employee who created the holiday request.

Employee Leave Balances


How to get back deleted data using sudo rm -rf

Question: I have deleted folder using sudo rm -rf. How to recover back?
Im not able to find it in trash folder
Answer: The 'rm' command does not employ the Trashcan mechanism of Unity.  You may be able to employ some of the tools mentioned in How to recover deleted files?, however it might already be too late - one of the first steps in a situation like this is "stop using the hard disk"
Answer: First you should mount the partition in read only mode to prevent the OS accidentally overwriting the deleted content.
You could try it with PhotoRec. Although there is "Photo" in the title it can recover any files. You need a second partition in which PhotoRec then writes the recovered files. Because it can't check how recent the file was deleted, it will recover files which you might have deleted ages ago (depending on the usage of the drive).


Why must the sentence form of a valid argument be tautological?

Question: I was thinking along the lines of the obvious, such as when found tautological the form must have been valid but I'm sure there is a more in-depth explanation that I can't reach.
Comment: Could you please add some background information: What is the sentence form of an argument, what is a tautological sentence form? Can you give an example, thanks.
Answer: There's nothing deeper going on here. An argument, "P proves Q" is valid iff it is true for all assignments P,Q iff P-> Q is a logical truth, also known as a tautology
This does invoke soundness/completeness.
Comment: I just spoke to my AI and he said that what my professor really wanted was for me to prove that is was impossible to have a valid argument NOT be tautological. So basically show, in an example, that if you assume an argument to be valid and then assume that it is not tautological you will reach the conclusion that it is both invalid and valid when doing the a table, leading to the statement that "the sentence form of a valid argument must be tautological"  because otherwise, the argument, which we said was valid, is actually invalid. She just wanted the reasoning behind it ig, thank you!
Comment: @noni have you figured that out? If not, can you provide your definitions of tautology and valid so I can explain?
Comment: yes, my AI explained it to me, thank you though!


How to resize a pdf from 1MB to 400KB

Question: I have a pdf file that is 1.1MB of size but I need upload 400kb of that file. Please tell me how to resize the file to get an output of 400kb.
Answer: Personally I always use a website such as CompressPDF or Neevia Document Converter for all of it, it is easy to use, takes a few seconds and knowing anything about PDF is completely optional.

How to resize a pdf from 1MB to 400KB


Geometry: Construct a rectangle with area equal to a given triangle and with one side equal to a given segment.

Question: So we have triangle, ABC, and line segment DE.  We don't know anything about them other than ABC is a triangle of some sort and DE is a line segment.  We're tasked with constructing a rectangle such that its area is equal to that of triangle ABC and one side of said rectangle is equal to that of line segment DE.  I think book one, proposition 44 of Euclid's elements relates to this, but otherwise, I'm not sure how to do this.  Thanks.
Answer: Take $F$ on the $BC$-line such that $BF=DE$. Take $G$ on the $AB$-line such that $CG\parallel AF$ and let $M$ be the midpoint of $CG$. In the following figure, the depicted rectangle and the triangle $ABC$ have the same area:

This happens because the area of the rectangle equals the area of $BGF$, and since $\frac{BG}{BA}=\frac{BC}{BF}$,
$$[BGF]=[ABC].$$
Answer: I would give an
executive summary like this:

Construct a rectangle
with the same base and area
as the triangle
(height = triangle height/2).
Construct a square
with the same area
as the rectangle
(from the proof
of the Pythagorean theorem).
Construct a rectangle
with side DE
and area the same
as the square
(same reason).

Done.


Can I claim a refugee status by entering an embassy?

Question: Well, I'm Syrian refugee in Turkey and things doesn't getting better, let's say that I have entered the Canadian Embassy in Istanbul, and claim a refugee status there, what will happen next ?
Answer: There have been prominent cases before (József Mindszenty, Julian Assange) but that's only because the sending country supported them for political reasons. In that case, the host country cannot simply send police into the embassy and snatch the person, that would be a major breach of international laws and customs.
In all likelihood, however, you won't be able to enter the embassy and if you do, you will be handed over to the Turkish police. Canada is likely to consider that Turkey is a safe country and therefore that this is a regular intrusion by someone who is not in immediate danger. Note that in the cases I mentioned, Mindszenty or Assange were seeking protection from the country where they were physically present, which is not your case, at least if you plan to argue that you were persecuted or threatened by the war in Syria (as opposed to being somehow threatened by the Turkish authorities).
Some countries do have provisions to apply for asylum from a consular post abroad but that doesn't mean they welcome you forcing their hand by showing up on embassy grounds. They would rather have you lodge a proper application or go through the UNHCR resettlement programs. In both cases, the chances of success are very low.
Comment: Another interesting case are the thousands of East-German refugees who camped in the Prague embassy in 1989, and were eventually allowed to settle in West-Germany.
Comment: @Carpetsmoker Yes, I also thought of mentioning that one too. But I think the main issue was securing safe passage from the Czechoslovak authorities and the consent of the East Germans and the Soviets. IIRC, East Germans never required any sort of special status to settle in West Germany as they had always been considered citizens by the Federal Republic.
Comment: @Relaxed What about I mention to the Canadian Embassy I can't work legally, is that effect my claim ?
Comment: @MohammadEliassAlhusain I am not sure what you mean but that's unlikely to change anything. I answered the question at a theoretical level since this is politics.SE but the reality is that you have little chance of success. If you go there and insist on staying on embassy grounds, they will throw you out. If you go there and ask how to apply, they *might* give you an application to fill in, tell you to go home and give you a decision later but that decision is very unlikely to be positive.
Comment: @Relaxed To make things clearer, I got a temporary protection Document form the Turkish Gov. with ID number it's equal to UNHCR refugee status also I'm filling the application for resettlement to Canada with private sponsors, and this protection ID is valueless like you can't open a bank account with it, but you could send your children to school, you can't travel to another state, but you could buy the ticket .... and so on and so forth.
Comment: @MohammadEliassAlhusain That's not a basis for a successful application.
Comment: @Relaxed Could you explain more, please ? !
Comment: @MohammadEliassAlhusain You don't have a right to go to Canada or any other country because you cannot work in Turkey or travel, nobody can force them to issue visas and they don't want to take more than a few thousands people every year through resettlement programmes.
Comment: @Relaxed But a lot of Syrians last year resettled from Turkey just like my situation worse or better.
Comment: @MohammadEliassAlhusain I know but that's at the discretion of the destination countries, with a limited number of spots each year. It's not at all like claiming refugee status, which should in principle be granted based on your situation, no matter how many people are in the same situation. That is only possible if you make it to the country's territory, not in its embassies.
Comment: @Relaxed I understand every thing you meant, but if you got any tips to my application, would made it successful, I'm all listening !

`1) I can't go from Turkey to Greece because they won't let me leave and put me on camps, 2) also to Italy it costs 4K $ USD after 5 days in water (this is suicide).`


Configure Tomcat as a service (no catalina.bat)

Question: I install Tomcat as a service using the installer from Apache website. I don't have catalina.bat in my bin folder. How can I set the permgem memory size? Any recommended size to set?
Answer: You have to use tomcatXw.exe (where X is your major Tomcat version) to configure the service: there are places to configure all JVM options, there.
Answer: To Configure Tomcat's Java_OPT in catalina,
First of all in Installer adaddition of tomcat, you never find out catalina  file in bin Folder.
To set parameters you have to use tomcate property(use tomcatXw.exe to open that)
Giving little idea how to set param in property file.
In catalina file:(write something like this)
JAVA_OPTS="-Djava.awt.headless=true -Xms2048m -Xmx4048m -XX:NewSize=1024m -XX:MaxNewSize=2048m -XX:PermSize=1024m -XX:MaxPermSize=2048m -XX:+DisableExplicitGC"

In Tomcate Property file:(add your parameter in Java options: same as in picture)
Answer: This link tells how to configure heap max size on tomcat7 exe installation where we don't have catalina.bat file. http://plavc.wordpress.com/2012/02/08/tomcat-service-on-windows/


Possessive adjective / pronoun

Question: Why do we write yours sincerely instead of your sincerely. Here I think before sincerely we need a possessive adjective and 'your' is doing this job well.
Answer: "Yours sincerely" is short for "I am yours sincerely". "Sincerely" is always an adverb. Because there is no noun, "yours" is used instead of "your".

(If signing off of letters like this seems weird, it was definitely a lot weirder in the past.)

Possessive adjective / pronoun


Increasing the length of frame ticks

Question: I know that I can manually adjust the frame tick length using FrameTickStyle. However, is there a way to globally increase the tick length?
Comment: What algorithm do you have in mind for increasing the tick length? How would it handle the production of major and minor ticks? `FrameTicks` does accept a generating function on righthand side of it rule. I think the best you can do is write a generating function includes code for producing  ticks long enough to satisfy you.
Answer: You can use the internal function Charting`ScaledTicks (it takes the option TicksLength):
tickFunc = Charting`ScaledTicks[{Identity, Identity},
 TicksLength -> {.05, .02}][##] &;

Plot[
   x^2,
   {x, 0, 5},
   Axes -> False,
   Frame -> True,
 FrameTicks -> {{tickFunc , Automatic}, {tickFunc , Automatic}}
 ]

Alternatively, to have the setting apply to all subsequent calls to Plot, you can set the option TicksLength globally:
SetOptions[Charting`ScaledTicks, TicksLength -> {.05, .02}];

and use the setting {{All, Automatic}, {All, Automatic}} for FrameTicks:
Plot[
  x^2,
  {x, 0, 5},
  Axes -> False,
  Frame -> True, FrameTicks -> {{All, Automatic},{All, Automatic}}
]

same picture

Plot[
  Sin[x],
  {x, 0, 5},
  Axes -> False,
  Frame -> True, FrameTicks -> {{All, Automatic},{All, Automatic}}
]

Comment: @baker,  ``Charting`ScaledTicks`` is not documented. You can use ``Needs["GeneralUtilities`"]; PrintDefinitions[Charting`ScaledTicks]`` to see its definition.
Comment: Awesome! Thanks kglr, this is exactly what I am looking for. However, where can I find documentation for functions such as `Charting`ScaledTicks`??
Comment: @kglr this comment is more valuable than I can express!!! I feel there should be a general answer to show the usage of this function, even if it is undocumented (because it is undocumented!).
Answer: Honestly, I'm a little amazed that plot ticks didn't get a little bit of TLC during this last big update. I'm a little hopeful that it's on their list, but I'm not going to hold my breath.
The best way I've found to do this somewhat easily, is to download and install one of Mark Caprio's packages, either SciDraw or CustomTicks(http://library.wolfram.com/infocenter/MathSource/5599/). Once installed in the directory appropriate for your system (the guide provides instructions), you can do something like this:
<<CustomTicks`
SetOptions[LinTicks, TickLengthScale -> 2];
Plot[
  x^2,
  {x, 0, 5},
  Axes -> False,
  Frame -> True,
  FrameTicks -> {{LinTicks, StripTickLabels[LinTicks]},
                 {LinTicks, StripTickLabels[LinTicks]}}
]

I admit that this requires a bit of extra work the first time, but I set it up once back when I first got Mathematica 10, and haven't had to worry about it since. Plus, CustomTicks has a number of other useful features for ticks such as easily switching from inner ticks to outer ticks.
The other approach is to create your own function for generating ticks. It works, but it's cumbersome, and there are often unforeseen edge cases (well, there are for me, but perhaps others have better foresight).
ticks[min_, max_, stepsz_, majdivs_, baselength_,
  insideticks_?BooleanQ, labels_?BooleanQ] :=
    Table[
      {i, If[Mod[i - min, majdivs] == 0 \[And] labels, ToString[Round@i], ""],
        If[insideticks, #, Reverse[#]] &[{If[Mod[i - min, majdivs] == 0, 2
          baselength, baselength], 0}]},
      {i, min, max, stepsz}
    ]

Plot[
  x^2,
  {x, 0, 10},
  Axes -> False,
  Frame -> True,
  FrameTicks -> {{Automatic, Automatic},
                 {ticks[1, 9, 0.2, 2, 0.02, True, True],
                  ticks[1, 9, 2/10, 2, 0.02, True, False]}}
]

Increasing the length of frame ticks


How do biologists infect cells with viruses within a lab setting?

Question: I'm writing an experimental proposal as my final paper for my single molecule biophysics class. Part of the procedure I wrote involves intentionally infecting a culture of HeLa cells with SARS-CoV-2 in order to perform a series of tests on it. Are there any readings or articles that you guys can point me to which detail how biologists intentionally infect cells with viruses within a lab setting?
Comment: A good strategy when writing a proposal like this is to read the methods sections of papers in the literature. You can probably use searches that include terms like "in vitro" and members of the class of viruses you are interested in studying - both the original SARS virus and SARS-CoV-2 would be good places to start, MERS would also be reasonable. You might not find your answer in the first paper you look at, so expect to look at a few, and expect that you might need to go to a source that is cited by one of the papers you initially read. Note that your instructor likely wants you do to this.
Comment: I'm closing this question as Homework because I think getting a thorough answer here would interfere with the purpose of the assignment you were given. I'll let @MikeyC's answer remain because it is helpful but doesn't go so far as to complete your homework for you.
Answer: You'll probably want to consider whether HeLa cells are the optimal cell line for acheiving your objectives. This paper shows minimal change in cell viability of HeLa cells innoculated with SARS-CoV and SARS-CoV2, but it's probably a good resource for how cell-culture infections are performed. This paper claims that VeroE6 is the standard cell line for producing viral stocks of SARS CoV-2.
Best of luck with your proposal.


Rotate Parametric Ellipse Around Top

Question: I have an ellipse centered around the origin, defined by the parametric equation: $$(x,y)=(45\cos\theta,15\sin\theta)$$
How can I modify this equation to rotate the ellipse around the top of the semi-minor ($y$) axis?
In the screenshot below, I used $30^\circ$ as an example.
But I need the rotation angle to be an input parameter - in addition to $\theta$.
If the angle should be $330^\circ$ vs. $30^\circ$, that's fine - I'm not sure which direction is which, and I'd just use CAD + trial and error to pick the correct one for my situation anyway.
Answer: $$
\pmatrix{x'\\ y'-15}=
\pmatrix{\cos\alpha & \sin\alpha\\ -\sin\alpha & \cos\alpha}
\pmatrix{x\\ y-15}
$$

Rotate Parametric Ellipse Around Top


istockphoto for videos

Question: I am thinking about make some story video and I would leverage some general footage -- timelapses, cars passing streets, etc. Is there some service which provides such assets? I think I saw something like "video building block" service or something like that. I don't need this service specifically, but just something where could I download/buy such video assets shoot by somebody else.
Comment: All the replies are cool. Which should I mark as the correct answer?! :)
Answer:
http://www.gettyimages.de/footage
https://www.shutterstock.com/video/
http://www.dissolve.com/
http://videohive.net/

to name a few, probably there are much much more.
Answer: Well, I think your best source to tell stories with would be public domain videoes.
Either videos placed directly into the public domain or those whose copyright has expired and are now in the public domain
see (a good resource):
http://www.pond5.com/free
For example, the charlie chaplin videos, all the silent movies, unfortunately all movies including the 70's should have been in the public domain by now if it wasn't for the walt disney copyright extension law. Oh well, we take things as they are. Lots of great resources to be found in the public domain.
other sites:
(Public domain films)
https://www.loc.gov/rr/mopic/pubdomain.html
https://archive.org/details/stock_footage
Answer: I've used the following services:
Video Blocks - perhaps this is the one you were thinking of?
iStockPhoto
ShutterStock

istockphoto for videos


from django.db import utils ImportError: cannot import name utils

Question: As I am trying to import modules from ConceptNet (from conceptnet.models import Concept), I received this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/conceptnet/models.py", line 2, in <module>
from django.db import models
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 40, in     <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 34, in    __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in   import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2  /base.py", line 9, in <module>
from django.db import utils
ImportError: cannot import name utils

To be sure that this problem is not caused by something in ConceptNet, but rather by django.db, I tried, import django.db and that was sufficient to give me the same error. Something tells me that there is some circularity here: import django.db sets something in motion that at some point is trying to import something from django.db. I don't know how to make this work?
Answer: See: django-error #16136
Check that you use a newer version of Django
Check your DATABASE CONFIG in settings.py:
DATABASES['default'] =  {
    'ENGINE':   'django.db.backends.postgresql_psycopg2',

Check if your hosting provider has set up your db properly


How can I decode OGG vorbis data from a ByteBuffer?

Question: The libraries I founded so far only have methods to decode from a file or InputStream. I have a ByteBuffer with OGG vorbis data and I need it decoded to PCM without having to write it to a file first.
Answer: There seem to be 2 parts to this problem.
1) Getting Java Sound to deal with OGG Vorbis format.
2) Avoiding the File.
For (1), the Java Sound API allows the addition of extra formats via the Service Provider Interface.  The idea is to put an encoder/decoder into a Jar and use a standard path and format of file to identify the class that does the encoding/decoding.
For (2), it is simply a matter of supplying an InputStream and required AudioFormat to the relevant methods of the AudioSystem static functions.  E.G. (Pseudo code..)
byte[] b = byteBuffer.array();
ByteArrayInputStream bais = new ByteArrayInputStream(b);
InputStream is = new InputStream(bais);
AudioInputStrream aisOgg = AudioSystem.getAudioInputStream(is);
AudioInputStrream aisPcm = AudioSystem.
    getAudioInputStream(pcmAudioFormat, aisOgg);

Comment: oh I didn't knew I could create a inputstream from a bytearray thanks, but I really only had 1 problem, the pcm is going directly to openal, java spi won't touch it.
Answer: You can use ByteArrayInputStream which is a subclass of InputStream.
If your stream is very large you probably will have to write to file.


How to handle unit tests in F#?

Question: How do you create unit tests in F#? I typically use the UnitTest portion of Visual Studio with a [TestClass] and [TestMethod] attributes and use the Test View to run these. I know I can just create a script file and run these, but I like the way that it is currently handled.
Comment: [This recent article of mine](http://fsharpnews.blogspot.com/2011/01/testing-behaviour-driven-development.html) described this and a lot more (BDD testing from F#).
Comment: Here's a place to start: http://bit.ly/1JhEbA7
Answer: Check out fscheck. It's a port of Haskell's Quickcheck. Fscheck allows you to specify properties a function must satisfy which it will then verify against a "large number of randomly generated cases".
It's something you can't easily do with an imperative language like C#.
Comment: @Mauricio: I agree that it's possible to do what FsCheck does (randomly generating test cases) in an OO setting (another example: RANDOOP). Maybe one day we will have one specification language (which looks much nicer in a functional setting in my very biased opinion) that can generate both randomly generated cases and covering cases like Pex does.
Comment: Now FsCheck has a C# interface so you can use the most important features of FsCheck in C# too.
Answer: I'd rather use FsUnit or FsTest to write tests in F#, it feels more natural than OO xUnit style tests.
EDIT 2014: I now consider FsUnit/FsTest to be mostly useless syntax sugar. And "more natural than OO" doesn't mean absolutely anything. A few months ago I wrote my current thoughts on testing here (I recommend reading the entire thread).
Answer: In VS2013 you can use the below.
open Microsoft.VisualStudio.TestTools.UnitTesting
[<TestClass>]
type testrun() =
    [<TestInitialize>]
    member x.setup() =
        //your setup code

    [<TestMethod>]
    member x.yourTestName() =
        //your test code

Hint:  If you are looking for UI unit testing then you can use this setup with Canopy.
Comment: This should be the accepted answer. This uses built-in unit testing functionality. Additionally (and not obviously), this approach requires adding a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.
Comment: @alancnet it's only built-in if you're using Visual Studio.
Answer: I use a combination of xUnit.net, TestDriven.Net (Visual Studio Add-in for running tests, free for "students, open source developers and trial users"), and my own open source Unquote library (which also works with NUnit and any other exception-based assertion framework). This has worked out great and getting started is really easy:

Download and install TestDriven.Net
Download xUnit.net, unzip to any location and run xunit.installer.exe to integrate with TestDriven.Net
Download Unquote, unzip to any location
Create a project within your solution for unit tests
Add references to xunit.dll and Unquote.dll (from unzipped downloads) in your unit test project
The following is a simple example of a .fs file in the unit test project containing xUnit.net / Unquote style unit tests.
module Tests
open Swensen.Unquote
open Xunit

[<Fact>]
let ``description of first unit test`` () =
    test <@ (11 + 3) / 2 = String.length ("hello world".Substring(4, 5)) @>

[<Fact>]
let ``description of second unit test`` () =
    let x = List.rev [1;2;3;4]
    x =? [4;3;1;2]

Run all the unit tests in the project by right-clicking the project in the solution explorer and selecting Run Test(s). Both of the previous example tests will fail with the following printed to the Visual Studio Output window:
------ Test started: Assembly: Tests.dll ------

Test 'Tests.description of second unit test' failed:

[4; 3; 2; 1] = [4; 3; 1; 2]
false

    C:\Solution\Project\Tests.fs(12,0): at Tests.description of second unit test()

Test 'Tests.description of first unit test' failed:

(11 + 3) / 2 = String.length ("hello world".Substring(4, 5))
14 / 2 = String.length "o wor"
7 = 5
false

    C:\Solution\Project\Tests.fs(7,0): at Tests.description of first unit test()

0 passed, 2 failed, 0 skipped, took 1.09 seconds (xUnit.net 1.7.0 build 1540).

Answer: You might want to try NaturalSpec. It's a F# UnitTest-Framework on top of NUnit.
Answer: Try XUnit.net
Comment: Agreed. (only?) xUnit.NET can run test cases in static methods, so if you want to stay in the mainstream .NET unit test frameworks that is the one that takes the least effort to use.
Answer: As of version 2.5, NUnit allows you to use static members as tests. Also, the class-level TestFixtureAttribute is only necessary for generic or classes with non-default constructors. NUnit also has a backward-compatible convention that a test member may start with the word "test" instead of using TestAttribute, so you can almost write idiomatic F# with NUnit > 2.5.
Update
You can see some test examples without the TestFixtureAttribute in the Cashel library. I continued using the TestAttribute since it appears few test runners correctly pick up tests when it is not present, so that part of the NUnit post may be incorrect or at least misleading.
Comment: Ryan, would you like to elaborate with an example test in F#? Or a link to a site that shows F# unit tests with no TestAttribute or TestFixtureAtrribute?
Comment: @David I added a link to my tests for Cashel.

How to handle unit tests in F#?


What is breeze's 1.0.5 metadata schema

Question: I just downloaded Breeze js 1.4.4. The problem is that the package comes with metadata examples  in version 1.0.3, yet the library is looking for 1.0.5. Furthermore, the documentation on breeze's site provides metadata examples in 1.0.2. What am I to do?
Comment: Care to make your question a bit clearer? BreezeJS uses standard [OData $metadata][1].

  [1]: http://services.odata.org/OData/OData.svc/$metadata
Answer: The documentation needs to be updated.  Thanks for catching it.  I'll try to get it fixed this week.
However with the exception of the version number the docs are correct. All of the metadata changes since 1.0.2 have been to add additional capabilities so everything is backward compatible.
If you are exporting and then importing from the same version of Breeze then you will have no issues because the latest version is always used.  In this case, 1.0.5.  If you are creating a Breeze native metadata config then you can either use metadataVersion: 1.0.5 or just omit the metadataVersion property. If omitted then no version checking is performed.
If you are importing old metadata from a Breeze version before 1.0.5, then you will need to either remove the metadataVersion property or set it to 1.0.5.

What is breeze's 1.0.5 metadata schema