Passing data from javascript into Flask

Question: I know how to pass data with a jinja template from python into javascript, but I want to pass a javascript variable into python. I'd like to do it without reloading the page. Is that possible?
Comment: use an ajax request?
Answer: Yes, like monkut said--I believe you want to use JSON and Javascript/jQuery.
This will let allow communication from client to server and back again.
The most applicable example I found was in the Flask snippets/patterns: http://flask.pocoo.org/docs/patterns/jquery/
Answer: I did a similar kind of work in my project and would like to share my code here. I need to find out which post is selected and I was setting the selected post as a global variable at server side, so that I may use it for later comparison. This is how I pass my selected post into Javascript.
 Compare

Now from Javascript to Flask.
function myFunction(x) {
        $.getJSON($SCRIPT_ROOT + '/check_selected', {
        post: x
        }, function(data) {
            var response = data.result;
            console.log(response);
            }
        });
}

This is how I return the result from flask by using JSON.
import json
@main.route('/check_selected', methods=['GET','POST'])
def check_selected():
    global selected
    post = request.args.get('post', 0, type=int)
    return json.dumps({'selected post': str(post)});

As mentioned here, we need to include Google AJAX API in order to load jquery:

Comment: how would you call function on page load instead of user click button and then pass data from javascript to flask
Answer: Create a JSON string from your view code say, jsonData and in your Jinja Template, write something like

Comment: The OP specifically mentioned that he already knew how to do this and wanted to go the other direction.

Passing data from javascript into Flask


Best authentication method for Node.JS RESTful API

Question: I'm suppose to build a web application and a mobile application (for iOS) that share the same database. Currently I'm thiking about having a RESTful API and have both applications (web and iOS) comunicate with the API to access data. My problem is the authentication method that I should use. I've been researching about OAuth2.0 but that's not quite the thing I want because I don't want the user to have to authorize the connection as it happens when you log in somewhere using facebook or google+. I just want to make the login with a username and password and then stay logged in. And this for both the apps (web and iOS).
I'm using Node.JS and MongoDB to build the API.
I'm trying to do things "the correct way" because this is suppose to be the final project for my masters.
Can you guys give me some lights in how I can achieve this?
Answer: Use OAuth 2.0 so you have an extensible standard and token-based authentication which enables users to revoke authentication tickets, e.g. if their phone was stolen.
OAuth 2.0 supports various grant types. Those that you from facebook and twitter logins can be summarized as '3-legged oauth', but there's also two grant types for 2-legged OAuth, especially the resource owner password credentials grant (section 4.3 at the end of the page) which will simply exchange username and password for an authentication token. There's no need to implement 3-legged oauth if you don't want to.
I'd suggest to use database-stored tokens over crypto-based self-validating tokens for most use cases. The possibility to revoke individual grants, or all grants of specific client applications is super helpful in practice. It also shortens tokens a lot and reduces the risk of a catastrophic security leak because of a flaw in the implementation. Make sure the token itself is crypto-strong random and use a simple crypto-wrapper around the actual token value to enable cheap identification of (badly) faked tokens.
Comment: In a way, authentication is always stateful: you must first authenticate, get a ticket, then perform requests. Whether the server stores the tickets or creates them as self-validating is transparent to clients.
Comment: Thanks for the answer! I just have one more question relative to your answer. Isn't keeping database-stored tokens against the principles of RESTful? RESTful is stateless, and in my point of view keeping a database with tokens is not being stateless. Can you clarify this please?
Answer: Something like Passport (no, not the whisky, but the middleware) could be a good thing to test
It allows to choose among many different authentication methods in an easy and transparent way


For a guitar player, does jazz music demand more technical skills than blues one?

Question: Jazz guitar players are generally considered gifted by higher technical skills than others, maybe because of their aptitude to the improvisation and fast soloing. Often, they are also provided with a special familiarity with chords, "licks", melodic phrases and ideas.
Instead, as blues guitar players tend to play around a standard progression of chords, with quite standard style, they are often considered a step beneath, at least under a technical point of view.
Obviously, in the music history there have been extraordinarily talented blues players (B.B. King, Ray Vaughan...) and, as a consequence, this supremacy cannot be deeemed true in general.
But, if a beginner would make a decision to start playing jazz or blues (he likes both the same), preferring that one which "demand" less commitment in studying theory (hours of study) and in training the technique (hours of exercises), which one would you suggest?
Comment: "Jazz guitar players are generally considered gifted by higher technical skills than others". I'm not even sure this initial premise is true. Perhaps it could be claimed that the jazz canon contains a higher proportion of technically demanding pieces than the blues canon but that wouldn't imply that it demands higher technical skill to be involved in jazz, and as others have said where are the boundaries of jazz and blues.
Comment: There's a big grey area that joins jazz with blues, also the answers will probably be opinion based. Not good for this site.
Comment: I don't think either genre necessarily "demands" more or less than the other. Both allow players to perform with moderate technical skill and also showcase their skill level if they wish to. Also, it's a good question what the difference is between blues and jazz when it comes to technique. Stevie Ray Vaughan certainly calls about some jazz styling in his blues, and he was certainly a technical master.
Comment: I agree that there is a BIG grey area between jazz and blues. For example, see Oscar Peterson's album "Night Train", in which his chord progressions aren't overly complicated, typically tending more towards blues, but his chord voicings and use of harmony sound very jazzy - enough that the album is often labeled as being jazz.
Comment: Just saw your edit - this discussion might be better in our chat room http://chat.stackexchange.com/rooms/440/the-practice-room rather than as a question here on the main site. Overall though, if you want to be a musician I don't think you should attach too much importance to arbitrary lines around musical genres. Learn to play the things you want to play - and if that's a bit of jazz and a bit of blues, then learn a bit of jazz and a bit of blues. Very few good musicians are entirely limited to a single style.
Answer: Jazz guitar has considerably more variations in chords and progressions to learn, than the majority of most blues. If you're not constantly playing them , you forget them. The music is more complicated as well. I would have to say that as a guitarist, I find blues much easier to learn and play as opposed to jazz.
Comment: Blues has some of its own challenges too though: it requires the use of bends and pre-bends to allow use of (and movement between) pitches that aren't in the major, minor, or even the chromatic scale; Covering the full breadth of blues styles requires you to be comfortable with switching between different tunings, and use of a slide... not to mention that as a blues performer you probably need to be singing while playing!

Also, if you see blues forms as simple, that in itself lays down a creative challenge - how to come up with something within the style but isn't completely clichéd.
Comment: Yes I agree with especially on the singing and playing together part. That brings a whole other level of challenges. I think that one of the reasons Jimi Hendrix was such a good player was not only his guitar skills but also singing. I don't consider blues simple but I once saw an add looking for a jazz guitarist who knew up to 2000 chord variations. Now that is a challenge!


Binding function keys in carbon-emacs

Question: While I was using the "normal" X11 emacs under Snow Leopard, my profile.el file had a line:

    (global-set-key [f14] 'my_function)

However this binding does not work with carbon-emacs. What is strange is that if I execute the command "M-x global-set-key", and give it the right arguments (pressing the F14 key), it works!
Any hints?
-- Tsf
Comment: Using the fink build of carbon-emacs22 it works as expected. (Well, I have a MacBook, thus no f14, and I tested it with f6.)
Answer: My line

   (global-set-key [f14] 'my_function)

was in an auxiliary profile.el file loaded by the command

   (load "profile")

in my .emacs file.  When I moved it to the .emacs file itself, it worked!  As a matter of fact the same happened with another definition I was having troubles with:

   (setq visible-bell t)

used to disable unpleasant sounds.
-- Tsf
Answer: I'm using the normal gnu emacs for mac, probably from one of the vanilla builds..., and [f14] works fine for me... why are you using a non-standard emacs?
Granted, i'm using emacs 22, so maybe things changed, but I doubt it...
Comment: I think carbon-emacs is better integrated with Mac OS X.

-- tsf

Binding function keys in carbon-emacs


What is the ideal temperature for growth within an Aeroponic Garden?

Question: What is the ideal temperature for growth for an Aeroponic Garden?
Comment: Different plants have different needs. What are you trying to grow?
Comment: Do you mean aeroponic growing, or are you talking about a particular product, and which plants?
Comment: @GrahamChiu I was speaking of aeroponic growing. I was interested in the four different plant types of lettuce, tomatoes, coffee and out of curiosity dwarf fruit (apple, cherry and pear) trees. Just curious. Thanks!
Answer: The optimum temperature is somewhere in the range between 70F and 95F - the specific optimum(s) certainly vary by species and even cultivar.
Simple chemical reaction rates increase rapidly with temperature. This means that metabolic activity and growth tends to increase rapidly with temperature. The same is true for photosynthesis except that the activity of the key enzyme RUBISCO saturates (stops increasing) at a temperature in the neighborhood of 90F. So, above 95F (or thereabouts) metabolic activity outpaces the rate of photosynthesis and growth ceases.
Rooting of cuttings is often done with bottom heat. Temperatures around 70F are most frequently used in large scale production. It seems reasonable to presume that this might be the optimal temperature for root growth and hence a lower limit to the 'ideal temperature'. Nevertheless, roots may indeed grow faster at temperatures above 70F (i.e., this 'optimum' maybe occurs because of factors unique to rooting cuttings, such as the need for minimal transpiration).
Answer: A terrestrial plant maintains a greater range of temperatures in the parts above ground (canopy), and usually lower and more stable temperatures below ground.  The same applies for aeroponics.  The root zone should be kept between 62°F - 71°F.  This is because the highest dissolved oxygen occurs at 68F (9ppm DO), and oxygen is transported inside the plant as dissolved oxygen even though the air roots might be exposed to higher oxygen levels.  However, it should be noted that some plants, such as lettuce, are less sensitive to levels of DO then other plants.
The canopy can be kept at higher temperatures. The leaf temperature range for fast growth is 72° (minimum) to 86°F. As a rule of thumb plant growth approximately doubles for every 10°F rise.

Within limits, rates of photosynthesis and respiration both rise with increasing temperatures. As temperatures reach the upper growing limits for the crop, the rate of food used by respiration may exceed the rate at which food is manufactured by photosynthesis. For tomatoes, growth peaks at 96°F.[1]

The temperature may also need to be lowered when plants flower and fruit.  Chilling the nutrient solution also helps protect the plant against heat stress, and lower temperatures are used for cool climate plants.
Note also that lighting has an effect on the plant.  LED lighting does not generates infra-red and so has no major effect on plant tissue temperatures, but HID lighting can raise tissue temperature by 5-7°F which is why it only appears that LED lighting is not as effective as high intensity discharge lighting. The effect of IR heating forms a gradient on the plant as distance increases from the light source.
CO2 requirements rise with temperature, and enriching the grow room with CO2 does allow also for higher temperatures.
At night you can drop the temperature by 10°F from the day period.
[1] http://www.ext.colostate.edu/mg/Gardennotes/143.html#temp
Comment: I don't understand what effects lead to "the highest dissolved oxygen occurs at 68F (9ppm DO)". As far as I know the solubility of all gasses in water declines monotonically with temperature. Anyway, the availability of oxygen for metabolic activities declining with increasing temperature highlights another fundamental reason for a maximum in growth rates and that roots die at temperatures of 105F to 115F.
Comment: @jimyoung this reference says solubility of gases in water is dependent on the gas. Some increase with heat, and others decrease. http://antoine.frostburg.edu/chem/senese/101/solutions/faq/temperature-gas-solubility.shtml
Comment: @Graham_Chiu, Thanks. Nitrogen, hydrogen, and helium are exceptions (I should have said 'most' not 'all'). Nitrogen solubility indeed peaks near 70F.  Your reference, though, also says that oxygen solubility only decreases with increasing temperature.An explanation for an optimum root temperature is, I believe, more involved.
Comment: At increasing temperatures, you increase metabolic activity in the roots at the expense of decreasing the dissolved oxygen.  Decreasing the temperature of the water increases the oxygen concentration allowing more nutrients to be transported in, but at the cost of lowering metabolic activity.


Defence from electrostatic discharges

Question: I work with SLED (superluminiscent light-emitting diodes). Datasheet said me that I must to avoid electrostatic discharges when I work with SLED. So I want to connect cathode with anode of SLED and will begin to mount SLED. It will be enough for safe operations (without electrostatic discharges) with SLED?
Comment: CAUTION: Always add a 1 Meg resistor in series with any wire you wrap around any part of you and connect to ground.  1 Meg is small enough to bleed off any charge but large enough so that if you somehow come in contact with high voltage you don't provide a nice path for the current.  Commercial wrist straps have the resistor built in so you don't have to worry about it.
Comment: Wrap a wire around your wrist and connect the end to earth - radiator, water pipe or anything metallic that is earthed in your house.
Comment: I know this way, but I'm not sure that any metallic things around me are connected with earth, so I asked this question
Comment: If you short the anode and cathode of the SLED, from the point that you short it it will be safe from ESD.  The trouble is if you are not sure you are charge-free how do you short it without potentially damaging it? (Pun intended.)
Comment: Ok, I have a ESD wrist band. But, when I will be mount SLED, my soldering tool might be contain a statical charge, isn't it? I want to protect SLED from it
Comment: Many soldering irons have ESD safe tips, but in case yours doesn't just touch the tip to something grounded before soldering.  (Whatever you attach the wrist strap to should work.)
Answer: Perhaps you need an ESD wrist band:

Those go on your arm, as you certainly have guessed. The terminal should be connected to a ground potential through 1 Mega-ohm resistor. Don't connect to ground directly as suggested in comments, unless you have high tolerance to electric shocks. Use a ESD plug:

Defence from electrostatic discharges


Cool APIs to help learn C++?

Question: This isnt quite a programming question, but for my CS class next semester, we're learning C++. Now I'm gonna be proactive and learn some over hte break, and I was wondering if there were any cool API's that are in C++ out there that are fun and not crazy hard, that I could tinker with to help solidify what im learning. Any Ideas?
(since this is a really broad question figured these might help narrow it down):
I run OSX and Ubuntu Linux
I have a kinect i want to tinker with at some point
I'd like to learn how to do network programing
I want to learn how to do hacker type things (in a legal way preferably)
Comment: Define "cool", "fun", and "crazy hard".
Comment: "Not a real question". Since this is for school/personal, I'd pick something **fun** that you **want to learn** and **play** with. (I do not know what **interests you**, so I cannot say more.)
Answer: I wouldn't recommend any API.
What I would recommend when learning any programming language is writing code.  If you don't have any idea of your own, then I highly recommend solving computer science problems.
SPOJ  has a database of problems, everything from easy problems to really challenging ones.  This will improve not only your programming skills, but you will also learn a lot about data structures and algorithms.  A cool thing about it is that you submit your solution and the online judge will let you know if your solution is correct.
UVa Online Judge  is another great site.
Comment: Agreed. APIs only distract you from learning core concepts. I tried learning MFC as my first C++ exercise, and I came away with some gross misconceptions about the language.
Answer: You could look at the Boost C++ APIs. They have a lot of neat APIs for all sorts of applications. Some of them could qualify as "crazy hard" though.
Answer: You might be interested in Qt. It is a nice graphical toolkit library in C++, and it is free software so you can (and should) look into its source code.

Cool APIs to help learn C++?


Differences between a Unified Process and an Agile project plan?

Question: There've been many discussions on SO about the differences between (Rational) Unified Process and the Agile methodology. Can someone please give me an example on how different a project plan would be if there are 2 teams doing the same project, but following these 2 different methods?
Answer: I'm going to use Scrum as a concrete agile example. Scrum has three artifacts: the Product Backlog, the Sprint Backlog, and a Burndown Chart. A backlog is simply a prioritized list of things to do. The chart is for plotting your progress through the current sprint (iteration). These three tools are what you use to track and plan your project in Scrum and that is is your Scrum project plan.
RUP, on the other hand, contains a very long list of documents and artifacts for planning the project. As an example, there is the Iteration Plan, a detailed list of activities and tasks, with assigned resources and task dependencies. This document can perhaps be compared to the "sprint backlog" in Scrum, but that's stretching it.
So the major difference between these approaces is the amount of stuff (roles, artifacts, activities) they prescribe. And as you see from the image, the difference is huge:
Comment: Would disagree with the "no project plan in Agile." Agile doesn't prescribe a project plan nor does it talk about it. You can work with a project plan in Agile, sometimes looked at as a Release Plan, but at the end of the day, a project plan (considering the environment) can be an effective communication tool to utilize.
Comment: Updated it to talk about Scrum explicitly and artifacts in Scrum. Hope it works better that way.
Comment: I like the diagram you have given Martin.
Answer: I would say that RUP is totally different from Agile. RUP is a Model Driven code generation from UML diagrams which have previously captured the requirements. This is therefore a top down process.
Agile is a permanent top down, down top processes.
I would say that even if RUP is not used you can use UML with agile methodologies as long as your model could be automatically updated from your code. Omondo has done a big job on model iterations. PIM and PSM are syncrhonized. It means from the metamodel, to the model to the code and back in two ways. Really powerful and easy to use.
Answer: Agile methodology is based on the principle that any change in the iteration must cost the least to the developers. Thus changes from the customers are welcomed. Where as the Rational Unified Process is based on the principle that development of software must be such that changes are least. Thus RUP requires more experienced developers than Agile.


vim mapping from q! to Q!

Question: I was trying to map 'q!' to 'Q!' in .vimrc ?  I tried the following but not working.
:command Q! q!
Please provide any suggestion to mitigate this issue. Thank you.
Answer: You just have to give
:command Q q

Similarly, you can do for other commands like,
:command WQ wq
:command W w

Comment: Thank you for your suggestion.  ":command Q q" is working perfectly, but the problem creates when I try to map the key "q!" (which is quit without implementing the changes.)
Comment: In that case, you could simply do ZQ in Normal mode although it takes some rewiring to remember! :)
Comment: Thank you.  However It is better to stick with q!.
Answer: This worked perfectly for me:
:command-bang Q q<bang>

From vim's help (:h command-bang):
Special cases                           :command-bang :command-bar
                                        :command-register :command-buffer
There are some special cases as well:

        -bang       The command can take a ! modifier (like :q or :w)

and
Replacement text

The replacement text for a user defined command is scanned for special escape
sequences, using <...> notation.  Escape sequences are replaced with values
from the entered command line, and all other text is copied unchanged.  The
resulting string is executed as an Ex command. [...]

The valid escape sequences are
        [...]
        <bang>  (See the '-bang' attribute) Expands to a ! if the
                command was executed with a ! modifier, otherwise
                expands to nothing.
        [...]

Answer: Try that:
:cmap Q! q!

Maps Q! in command mode to q!.
Comment: Thank you. It works fine.  But If I take time to type ! after Q, It doesn't work. When I type Q! quickly it automatically gets changed to q!.  Nevertheless  I am not that slow in typing. Thank you once again.

vim mapping from q! to Q!


Peoplepicker with ADFS login

Question: We are using ADFS for authentication. I have a people & groups in my custom list which accepts the users and groups. Currently I'm able to give the group names, but its not taking any user names. Its working, if I give the email address of the user. How can we add the user name in ADFS to the people picker instead of email address ?
Answer: While configuring ADFS you have to setup the username claim type aswell.  So that people picker can search against username.

Peoplepicker with ADFS login


Can somebody explain what is a REST API wrapper?

Question: Can somebody explain what is a REST API wrapper? How should it look like? When would we actually need it? Can we call them as DTO's? Please give some usecases, examples or links.
Answer: A Wrapper Class (or the Wrapper Pattern) is where you declare a Class as a container for an sObject to extend the functionality only for display or processing purposes (i.e. you don't intend for that attribute to be persisted) - the classic example is a checkbox to select records. I would say that a DTO is a slightly dumbed down version of such a wrapper (used in conventional OOP to pass structured data between the layers)
A REST Api wrapper is something slightly different. Salesforce exposes a REST Api and if you were to invoke that say from C#, you would have to perform a set of common steps such as login, query, etc. To make this available in C# by abstracting the innards of the actual REST calls to salesforce and exposing only the developer relevant detail, you could write a rest wrapper which performs these commonly used functions - creates requests, parses responses, etc
Comment: could you please give some code samples as you said //creates requests, parses responses, etc// so that i can get some idea
Comment: Is there a particular language you're looking for?
Comment: Josh,

i am looking for REST wrappers code samples in APEX lang to get an idea.
Answer: Force.com platform provides Standard REST API. These are Out Of Box API and no apex coding is necessary. Please find the below link to explore the standard REST API
http://www.salesforce.com/us/developer/docs/api_rest/index.htm
You can simulate all this using workbench. Please find below the workbench link
workbench.developerforce.com
Sometimes the business requirements are little complex and none of the API provided by salesforce fit and hence we can always make our own API by creating apex classes .(Restful APEX wrapper )
http://wiki.developerforce.com/page/Creating_REST_APIs_using_Apex_REST
Remember that since this is apex all the Governor limits of apex apply here.
A common design approach is to explore all standard API and if standard API's don't satisfy then an apex class can be built and a custom API can be formed.
Refer to the APEX guide for more info on how to write apex class to generate a REST API
REST can expose data both in XML as well as in JSON format.
Apex also gives ability to form your own class and these classes can be wrapped over native objects and these can be helpful to form the necessary data format needed by external system.
http://cloudyworlds.blogspot.in/2012/09/how-to-generate-wrapped-data-from.html
Edit: As per request posted the code
<code>{
"Accounts": [
    {
        "attributes": {
            "type": "Account",
            "url": "/services/data/v25.0/sobjects/Account/001W0000006XDG9IAO"
        },
        "CreatedDate": "2012-08-09T08:29:43.000+0000",
        "LastModifiedDate": "2012-08-09T15:24:42.000+0000",
        "IsDeleted": true,
        "Id": "001W0000006XDG9IAO"
    },
    {
        "attributes": {
            "type": "Account",
            "url": "/services/data/v25.0/sobjects/Account/001W0000006XGEuIAO"
        },
        "CreatedDate": "2012-08-09T15:44:29.000+0000",
        "LastModifiedDate": "2012-08-09T15:50:31.000+0000",
        "IsDeleted": false,
        "Id": "001W0000006XGEuIAO"
    },
    {
        "attributes": {
            "type": "Account",
            "url": "/services/data/v25.0/sobjects/Account/001W0000006QtKyIAK"
        },
        "Phone": "12131",
        "CreatedDate": "2012-08-02T14:46:48.000+0000",
        "LastModifiedDate": "2012-08-09T15:43:20.000+0000",
        "IsDeleted": true,
        "Id": "001W0000006QtKyIAK"
    },
    {
        "attributes": {
            "type": "Account",
            "url": "/services/data/v25.0/sobjects/Account/001W0000006XGI4IAO"
        },
        "CreatedDate": "2012-08-09T15:50:07.000+0000",
        "LastModifiedDate": "2012-08-14T11:33:05.000+0000",
        "FirstName": "Test",
        "IsDeleted": false,
        "Id": "001W0000006XGI4IAO",
        "LastName": "Thomas"
    },
    {
        "attributes": {
            "type": "Account",
            "url": "/services/data/v25.0/sobjects/Account/001W0000006XGIDIA4"
        },
        "CreatedDate": "2012-08-09T15:44:55.000+0000",
        "LastModifiedDate": "2012-08-14T10:15:39.000+0000",
        "FirstName": "shgdshg",
        "IsDeleted": false,
        "Id": "001W0000006XGIDIA4",
        "LastName": "Hello"
    },
    {
        "attributes": {
            "type": "Account",
            "url": "/services/data/v25.0/sobjects/Account/001W0000006XGhwIAG"
        },
        "CreatedDate": "2012-08-09T16:08:14.000+0000",
        "LastModifiedDate": "2012-08-09T16:08:19.000+0000",
        "FirstName": "deleted",
        "IsDeleted": true,
        "Id": "001W0000006XGhwIAG",
        "LastName": "check"
    },

  "Contacts": [
        {
        "attributes": {
            "type": "Contact",
            "url": "/services/data/v25.0/sobjects/Contact/003W0000007mNoqIAE"
        },
        "AccountId": "001W0000006XGI4IAO",
        "HCP__c": "001W0000006XGIDIA4",
        "FirstName": "Test",
        "IsDeleted": false,
        "Id": "003W0000007mNoqIAE",
        "LastName": "Thomas"
    },
    {
        "attributes": {
            "type": "Contact",
            "url": "/services/data/v25.0/sobjects/Contact/003W0000007mNp1IAE"
        },
        "AccountId": "001W0000006XGIDIA4",
        "HCP__c": "001W0000006XGEuIAO",
        "FirstName": "shgdshg",
        "IsDeleted": false,
        "Id": "003W0000007mNp1IAE",
        "LastName": "Hello"
    },
    {
        "attributes": {
            "type": "Contact",
            "url": "/services/data/v25.0/sobjects/Contact/003W0000007mNpGIAU"
        },
        "Phone": "3213",
        "AccountId": "001W0000006XGEuIAO",
        "HCP__c": "001W0000006XGIDIA4",
        "IsDeleted": false,
        "Id": "003W0000007mNpGIAU",
        "LastName": "ueiru"
    },
    {
        "attributes": {
            "type": "Contact",
            "url": "/services/data/v25.0/sobjects/Contact/003W0000007wAkwIAE"
        },
        "Phone": "206-999-1111",
        "AccountId": "001W0000006XJ3fIAG",
        "Email": "email@example.com",
        "HCP__c": "001W0000006XGIDIA4",
        "FirstName": "Mark",
        "IsDeleted": false,
        "Id": "003W0000007wAkwIAE",
        "LastName": "Wells"
    }
  ]}
</code>
For this we will have to use customized wrapping ,
Following is the source code that will automatically handle the generation of JSON in the expected format
<code>  global class SFA_AccountContactListedResponse{
 //Wrapper class to warp the various  List<sObject> as Super wrapper
  global class supersobjectWrapper{
  List<Account> Accounts=new List<Account>();//A list to hold the Accounts
  List<Contacts> Contacts=new List<Contact>();//A list to hold the Contacts
 }
 //This method will be called as the http get request
  public static supersobjectWrapper makeResponseString(){
 List<Account>  lstacc=new List<Account>();
 List<Contact> lstcontacts=new List<Contact>();
 lstacc=[Select Id,CreatedDate,LastModifiedDate,Isdeleted from Acccount ];
 lstcontacts=[Select id,CreatedDate,LastModifiedDate,Isdeleted from Contact];
 supersobjectWrapper superWrap=new supersobjectWrapper();//Instantiating thesuperclass
 superWrap.Contacts= lstcontacts ;
  superWrap.Accounts= lstacc;
  return superWrap;
 }
}
</code>
//The above class will be called as REST API using GET HTTP call,
<code>  @RestResource(urlMapping='/GetAcc/*')
  global with sharing class SFA_ListedJsonGenerator{
  @HttpGet
 global static SFA_AccountGroupSyncManagerRevised.supersobjectWrapper    returnJsonpacket(){
   RestRequest req = RestContext.request;
   SFA_AccountGroupSyncManagerRevised.supersobjectWrapper result;
   result=SFA_AccountContactListedResponse.supersobjectWrapper;
    return result;
   }
 }
</code>
Comment: Mohit, the link http://cloudyworlds.blogspot.in/2012/09/how-to-generate-wrapped-data-from.html is not opening for me. could you post some sample code to get an idea of REST wrapper.
Comment: Posted the code .Apologies for blog link not working.Looks some problem .Please find the exact replica of the work i did above


Why is greensleeves considered to be in sextuple meter?

Question: When I hear greensleeves it sounds like a waltz to me (bom-tah-tah / bom-tah-tah), why is it considered a sextuple ?
source : https://www.inkling.com/read/the-enjoyment-of-music-kristine-forney-11th/part-1/chapter-2
Answer: In simple terms, 6/8 is compound !! You are counting a relatively quick 1-2-3-1-2-3, as you say, which can feel like 3/4 or 3/8 - waltz like. However, the second '1' is slightly less emphasised in 6/8, so it's counted ONE-two-three four-five-six. (The four is where your second 'one', or 'bom' is).
6/8, being compound, means that it can simultaneously be counted in 2 time, as ONE-tah-tah TWO-tah-tah. Each syllable coinciding with one of the faster counts in the earlier example.
If the second 'bom' is as loud as the first 'bom' when you count, it will be in 3/4 or 3/8 time, but when the second 'bom' is quieter, but still louder than the other beats, the song will be in 6/8.
Comment: I like your answer. I will get back to it more deeply after I practice my listening a little more.
Comment: After practicing a little I could hear how the 6/8 applies here, as you said the cycle consists of 6 beats not three, the third one has less emphasis. Thanks for your nice explanation :)
Answer: Music theory generally uses only duple and triple, not the quadruple and sextuple that your link mentions.  Any meter can be explained in terms of duple or triple along with simple or compound.  For example, the "sextuple" meter she mentions is compound duple meter.
It works like this.  Meter is a combination of strong and weak beats.  Two or a multiple of two strong beats per measure is duple, three or a multiple of three strong beats per measure is triple.  If there is only one strong beat per measure (2/4, 3/4), then all the beats count.  As for simple vs. compound, strong beats that subdivide into two are simple, those that subdivide into three are compound.  2/4 and 3/4 subdivided in twos by default.
So, for the commonest time signatures:
2/2  Simple Duple
2/4  Simple Duple
3/4  Simple Triple
4/4  Simple Duple
6/8  Compound Duple
9/8  Compound Triple
12/8 Compound Duple
The fact that some strong beats are weaker than others makes no difference in whether a meter is compound or simple or duple or triple.
If you are having trouble with, say, the difference between 2/4 and 4/4, think about primary and secondary accents on syllables.  For example, "secondary" has a secondary accent on the third syllable: "SE-con-Da-ry".  In musical meter, the primary accent is on the first beat, and the secondary accent is on the other strong beat (if there is one).  In 4/4, the secondary accent is on 3.
Answer: Because it is in 6/8 and while you feel it in three, you feel it in two groups of three as is common for a song in 6/8. In 6/8 two dotted quarter notes get the beat, but each dotted quarter note can further be divided into 3 eighth notes making you feel each beat in 3. That is how songs in 6/8 typically works.
Answer: The distinction between a slow 6/8 meter and a waltz is largely arbitrary. It may be that the melody is intended to have a stronger downbeat on every alternate bar, and that many people perceive it that way, but the same is true for countless waltzes notated in 3/4 as well (mostly those that have even-length numbers of bars in their phrases). The only objective reason to call something 3/4 if it has an odd number of bars. (For a fast 6/8 meter, such as a typical tarantella, it's the short duration of the quavers that makes it much more appropriate to use 6/8, but "Greensleeves" isn't one of those at all.)
Comment: I'm sorry I don't have any background in music theory. What I find interesting in tarantella is that I can hear it in 2-beats, like a march, in 4-beats and in 6-beats. How does one know how to correctly "cut" the parts ? here's an audio question because I don't have the necessary vocabulary to express myself http://vocaroo.com/i/s1CMoQPpK6pf
Answer: Every copy I've seen of Greensleeves notates it in 3/4 time, but if one looks at the word stresses it could probably be notated just as well in 6/8 (with half as many measures) or perhaps 12/8 (with a quarter as many measures) since alternating measures definitely have stronger and weaker word stresses, as do alternating pairs of measures (though to a lesser degree).  I think that historically there has been a tendency to avoid the use of compound meters for slower tempos, even though such avoidance often results in notes being held routinely for entire measures.  Greensleeves doesn't have any really long notes, but consider the song "On top of Old Smokey".  All the sheet music I've seen for that is likewise in 3/4, but each four-measure phrase has two notes which is held for a whole measure each, and the downbeat of the third measure is a rest.
The article you linked cites a nice example of a piece which is in triple meter without any sort of sextuple feel: Brahms' Lullaby.  In the English text "Lul-la-BY, and good NIGHT; in the SKY stars are BRIGHT", the stresses on "-by", "night", "sky", and "bright" are all roughly equal (interestingly, the "triple" example where it shows word stresses, "America", would fit naturally into a 6/8 meter while Brahm's Lullaby would not).


Mimosa tree split...can it become a tree again

Question: Our Mimosa tree split for a few years due to the weather and we finally had to cut it down to a stump. Can it grow into a tree from the stump? There are tons of shoots coming out from it right now. Thanks!
Answer: Pick the best 3 (or so) shoots, cut the rest of the "ton" of shoots, repeat cutting of new shoots every few weeks until it gets the idea. If you want a single trunk, remove the worst/weakest of the 3 (or so,) let the remaining ones grow for a while, and continue remove the weakest stem until you are down to one.


How much to grout around receptacle box?

Question: At the tiled wall, when we grout the tiles, should we leave it out around the receptacle box?
Comment: You mean, between the tile and the box? Maybe a picture would help...
Answer: You want to fill in all the grout lines under the cover plate. Don't worry about that last tile edge next to the outlet box and don't fill in all the space around the box. If the distance between the face of the box and the finished wall is greater than 1/4"  then box extenders are needed. Enjoy your new kitchen.
Comment: I agree, assuming that you did a good job of fitting tiles to the box so that the cover plate will reach all tile edges.


What are the rules that the Gdal rasterize function follows to allocate a value to a cell?

Question: How does the rasterize tool decide which value to represent when a cell covers an area which inclueds different values? I need it in this case for polygons but would like to know for lines and points as well. What are the rules that it follows.
Answer: Looking at the source here and here, it seems GDAL just starts from the top of the list and works its way down, so it'll be in whatever order the shapes are stored in, overwriting any data that was stored in a given pixel. I'm not even sure it does anything with attribute indexes.
Addendum
The rasterizer by default just uses the centre of the pixel for polygons, or Bresenham's algorithm for lines (presumably points are just nearest neighbour). There appears to be an option to fill any touched pixel that can, I think, be supplied on the command line. There's a comment to this effect in the code:
462  *
"ALL_TOUCHED":

May be set to TRUE to set all pixels touched
463  * by the line or polygons, not just those whose center is within the polygon
464  * or that are selected by brezenhams line algorithm.  Defaults to FALSE.

So there is no blending at all, and it doesn't try to do anything clever.
Comment: Thanks for the reply.  Should prove useful later on.  What I would like to know is how the rasterize function selects the representative value from the shape. Does it use the centrepoint value or the highest percentage coverage and how does it deal with a 50/50 situation etc? The source is still a bit tricky for me to understand sorry.


Error when defining resistance values with parameters

Question: I'm trying to run this simulation but I'm getting an error (see image). I'm using brackets to define the parameters, so I don't understand what's wrong.
Answer: RE2, RE3, RE4 and R4 have a resistance value of R2 which is supposed to be defined somewhere in the simulation.
Define R2 with .param or something else e.g. .param R2 500


What can be said of a $6$-core Young diagram whose $2$-and $3$-cores are empty

Question: Let $\lambda$ be a partition. Suppose that $\lambda$ is both $2$- and $3$-decomposable, in the sense that $\lambda$ admits a total decomposition by both $2$-rim hooks (aka dominos) and $3$-rim hooks. Equivalently, assume that the $2$-core and $3$-core of $\lambda$ is zero. Then what can be said about the $6$-core of $\lambda$, if anything? Has this problem been studied (i.e. some sort of fundamental theorem of arithmetic for tableaux)? Must the $6$-core either be a $2\times 3$ or a $3\times 2$ rectangle? The problem is easily reduced to the classification of $6$-cores whose $2$-and $3$-cores are empty; I had difficulty writing down such a core other than the above two examples.
Answer: Let me comment a bit further on the fact that there are other 6-cores with trivial 2 and 3-core, in fact infinitely many of them. The fundamental paper of Garvan, Stanton, Kim, "Cranks and T-cores", gives a bijection between t-cores and integer tuples $(n_0,n_1,\dots,n_{t-1})$ which satisfy $\sum_{i=0}^{t-1}n_i=0$. Under this bijection the corresponding partition has size
$$\frac{t}{2}(n_0^2+\cdots +n_{t-1}^2)+n_1+2n_2+\cdots+(t-1)n_{t-1}.$$
Now, this means that our set of 6-cores can be identified with 6-tuples $(n_0,n_1,\cdots,n_5)$ which satisfy $\sum_{i=0}^5 n_i=0$. In order to have an empty 2-core they must further satisfy $n_0+n_2+n_4=n_1+n_3+n_5=0$, and in order to have empty 3-core they must satisfy $n_0+n_3=n_1+n_4=n_2+n_5=0$. Therefore we are left with a sublattice of $\mathbb Z^6$ of dimension 2 generated by $(1,1,0,-1,-1,0)$ and $(0,1,1,0,-1,-1)$. These correspond to your two partitions, $2^3, 3^2$. Thus, we can form the generating function for 6-cores with empty 2 and 3 core:
$$\sum_{m,n\in \mathbb Z^2}q^{12(m^2+mn+n^2)-6(m+n)}$$
This ends up being expressible as an infinite product, or a ratio of eta functions, if you will, as follows
$$\frac{\prod_{k\geq 1}(1-q^{12k})^3(1-q^{18k})^2}{\prod_{k\geq 1}(1-q^{6k})^2(1-q^{36k})}.$$
Presumably generating functions of partitions that are $n$-cores but have empty $d$-core for all $d|n$ (I would be tempted to call these "pure n-cores") also have infinite product expansions, although I haven't seen this written anywhere.
Comment: Thank you very much; this is extremely useful for what I had in mind.
Comment: Very nice answer.  I think the (6,2,2,2) partition I mentioned below corresponds under this bijection to (1,0,-1,-1,0,1), one of the differences between the two generating 6-tuples you gave.  (The conjugate, (4,4,1,1,1,1), corresponds to the other difference, (-1,0,1,1,0,-1), consistent with the paper's result on conjugation and these tuples.)  Glad for a reason to work through some examples of their bijection.
Answer: I believe a partition of 12 answers your 3rd question in the negative: Consider (6,2,2,2).  Each hook length is in the set $\{1,2,3,4,8,9\}$, so it is 6-core.  One can check that the partition admits total decompositions into both 2- and 3-rim hooks.
No answers for your more interesting questions.  Initially I thought of Jaclyn Anderson's 2002 Discrete Mathematics article "Partitions that are simultaneously $t_1$- and $t_2$-core" and the work it inspired, but your question is at the opposite extreme by asking about $t_1$- and $t_2$-decomposable partitions.


The meaning of "publicity blitz" in this text?

Question:
Thus, in the Spring of 2017, just as The New York Times began a
  publicity blitz that touted its commitment to the truth ("Truth: it
  needs your support") and that would greatly boost its number of online subscriptions, it headhunted Bret Stephens, a climate-denialist
  op-eel writer, from The Wall Street Journal - all in the name of
  editorial 'balance" (presumably between facts and non-facts).
Comment: Any prior research. Dictionary definitions?
Answer: The word "blitz" is used glibly to describe an intensive campaign. It refers to "the Blitz", which was a heavy bombing campaign during World War II. The word is German for "lightning" and so when used in a modern sense, speed is implied as well as intensity - a lot of work condensed into a short period of time. For example in British English "blitzing the kitchen" could mean cleaning the kitchen very quickly but thoroughly.
A "publicity blitz" would be an intensive publicity campaign.
Comment: And what is the meaning of "intensive publicity campaign"? Does it mean "an intensive campaign for advertisement"?


What type of grass or weed is this?

Question:
What type of grass or weed is this?
What stage in the plant is this in? Is it near germination?
How do you kill it?
Comment: Germination is seed sprouting - this is a pretty long way past that.
Answer: Bromus species, B. diandrus. Rip gut brome.
Bromus diandrus
Bromus diandrus_ripgut
Synonyms: B. rigidus, B. rigidus var gussonei, B. gussonei
Common names: ripgut brome; great brome; ripgut grass
Bromus diandrus (ripgut brome) is an annual grass (family Poaceae) found throughout California and other western states. Ripgut brome is one of several European annual grasses that have displaced much of the native grass throughout California. Ripgut brome becomes very dry and flammable during the dry season, increasing wildfire frequency. Increased wildfire frequency leads to conversion of shrubland and woodland to grassland. Ripgut brome is reported to hybridize with two other invasive grasses: downy brome (Bromus tectorum) and red brome (Bromus madritensis). Brome seeds may spread great distances via water and soil movement and by clinging to animals and people.
Brome grass can be controlled by using herbicide mixtures such as imazapic + imazapyr (for example, OnDuty®), imazapic + imazamox (for example, Intervix® ) or imazapic + imazapyr + MCPA (for example, Midas®) in Clearfield® (IT) wheat cultivars or metribuzin in Eagle Rock wheat. Brome grass can also be controlled using triazine herbicides in TT canola cultivars, glyphosate in Roundup Ready® canola, or OnDuty® herbicides in Clearfield® (IT) canola.
Comment: As it is annual, collecting the seed will prevent more growing next year. There will still be seed in the ground of course. The green seed shown may be advanced enough that after drying it will be viable. So too late for simply mowing and leaving on the ground.

What type of grass or weed is this?


Best way to create a gradient/blend like this one?

Question: I'm trying to create a blend similar to the one in the attached image. Would it have a better result in Photoshop or Illustrator, and what would be the best method?
Answer: It depends on your intent (and preferences) .
Especially for print I would use Illustrator.
If given the choice, always use vector, in my opinion.
It's definitely more  flexible (in terms of scaling at least), and using raster based graphics may result in a...  less smooth gradient/blend.
For a result like your example above I would recommend Illustrator's Mesh Tool.
You can learn more about the Mesh Tool here: https://helpx.adobe.com/illustrator/how-to/illustrator-growing-gradient-mesh-tomato.html
Photoshop is not excluded.
If you, like many people, are working mostly in Photoshop it's still an option.
You can get a nice result if you take your time. Try experiment with different soft brushes, maybe different blend modes etc.
But I would primarily use it for digital purposes.
Hope it helps!
Have fun :)
Comment: I agree with Tommy, Illustrator: Gradient Mesh. There are blogs out there on how to adjust meshes with stunning results.


Limit Openldap Transaction Log Disk Usage

Question: Openldap (specifically version 2.4) stores transaction history in log files by default in the ldap data directory (so /var/lib/ldap/log.###########). Currently these log files take up a lot of space, are never removed automatically, and grow infinitely. Manual removal for old logs works fine, but I'd like to limit the amount of logs slapd keeps automatically.
MY SCENARIO
I know that these transaction logs are used to recover ldap in case of a catastrophic failure. In my scenario ldap is regularly wiped and populated via a script (this isn't used for system login accounts). Because of this I don't need to concern myself with recovery, in case of a failure it's acceptable to run the script again. On the other hand, the regular wipe/population of ldap includes a lot of transactions, so these transaction logs build up pretty quickly.
LOGROTATE
logrotate has potential here, but if the most recent transaction log is ever removed then slapd will fail to start (it will complain about needing to perform recovery). Because I can't rely on the log names (because slapd keeps many small logs, incrementing the log file number as it goes) I'd like to use the Berkeley DB settings which creates these logs. I can count on the access/creation dates (most recent modify date is the most recent transaction log), but I'd still prefer to use Berkeley if possible.
DB_CONFIG
The settings for the transactions logs are said to be controlled by the Berkeley DB settings in /var/lib/ldap/DB_CONFIG. The example DB_CONFIG that comes with openldap specifies some transaction log settings:
set_lg_regionmax 262144
set_lg_bsize 2097152

According to the Oracle documentation on Berkeley:
set_lg_regionmax: Set the size of the underlying logging area of the
Berkeley DB environment, in bytes. The log region is used to store
filenames, and so may need to be increased in size if a large number of
files will be opened and registered with the specified Berkeley DB
environment's log manager.

So this seems to just set the size of the file that tracks the transaction log files.
set_lg_bsize: Set the size of the in-memory log buffer, in bytes.

This seems to control how much RAM is allotted to the transaction buffer.
The log.########### files in the ldap data directory are all 10485760 bytes which seems to correspond closely to set_lg_bsize (10485760 / 5 = 2097152 = set_lg_bsize) though I'm not sure if this is a coincidence.
My interpretation of this is that $lg_bsize amount of transaction history is stored in memory at a time. When this limit is exceeded it pushes some of the transaction history to the most recent log file, and creates a new log if the current log reaches a certain size.
DB_LOG_AUTOREMOVE
According to the Berkeley documentation transaction logs can be removed by setting the flag DB_LOG_AUTOREMOVE in the DB_CONFIG.
DB_LOG_AUTOREMOVE: If set, Berkeley DB will automatically remove log
files that are no longer needed.

However when I added this to the DB_CONFIG:
set_flags DB_LOG_AUTOREMOVE

and restarted slapd I didn't notice a difference. I removed the old transaction logs and ran the ldap population script that I have, and was able to rack up 290MB in transaction logs. It still doesn't seem to be limiting the logs at all. The reason for this may be related to the phrase: that are no longer needed
Actual Question
How does one configure the automatic removal of slapd's transaction logs using the Berkeley DB DB_CONFIG file?
Answer: I found the answer on Stackoverflow - you need to run slapindex after changes to DB_CONFIG.


Is it possible to create a binary analysis software which would sort out all possible vulnerabilities and bugs in other software?

Question: I find myself often questioning myself whether it is possible to design a software which would load up another software and try to emulate all possible outcomes from it and figure out bugs and vulnerabilities on the software being analyzed.
Theoretically, it could load any piece of software, have an internal representation of the underlying system (CPU registers, memory, etc) like a Virtual Machine software, and by means of analyzing, it would start fetching the instructions, emulating them, which would go linearly until it finds a conditional jump.
To make it simple to understand, when it finds a conditional jump, it would take a snapshot of the current representational state of the system and follow that conditional jump, it would keep evaluating the instructions and at some point would restore that snapshot and do not follow the conditional jump, going past over it and evaluating the next instructions, and so on.
Such software would be smart enough to emulate user supplied input.
To make things clearer lets imagine we are analyzing the following (pseudo?) C code:
<code>char* gets(char *s)
{
  int i = 0;
  while( (s[i] = _getche()) != VK_RETURN ) i++;
  s[i] = NULL;
  return s;
}

void main() {
  char buf[8];
  char is_admin = FALSE;

  do {
    gets( buf );

    if( _strcmp(buf, "s3cr3t!") == 0 )
      is_admin = TRUE;
    else
    {
      if( is_admin )
        super_user.exec( buf );
      else
        unprivileged_user.exec( buf );
    }

  } while( _strcmp(buf, "exit") != 0 );
}
</code>
It just keeps polling for user commands and executes them until the user input is "exit". if the user inputs a password "s3cr3t!" them it will execute the following commands as a super user, otherwise it will just impersonate an unprivileged user.
Moving on, we could ask our analysis software to detect and sort out which ways that would be possible to execute commands as a super user on the subject code being analyzed.
By going through each instruction, it will come to conditional jumps and test both cases, when the jump is made and when it is not. So after a few iterations it would know that if a user inputs the string "s3cr3t!", it will later on come to execute commands as a super user. It would not try every possible string combination until eventually it comes to "s3cr3t!", it would be smart to see there is a comparison for that string, and see what it changes in the program flow.
Then, it would also be able to see that any user input string that has more than 8 letters would overflow the allocated space for the buf char array, thereby corrupting memory. Which in this particular case, assuming that the stack memory layout for this was that the is_admin variable would be sitting right next to the buf char array, would set is_admin to evaluate to TRUE, and then comes to execute commands as super user.
It would also be able to spot an integer overflow in that gets() function, if that would corrupt stack memory somehow that would end up changing the RETURN address from a function call. Figuring it would be a scenario for exploitation where the user inputs the shellcode and by overwriting the RETURN address it would then jump to that shellcode which would also execute commands as a super user.
So... I know I could not go into much detail on the inner workings, but overall I think I made my point. Does anyone see something wrong with that approach or thinks it would not work?
I am thinking about going for an open project on this. I would appreciate any considerations.
Comment: http://en.wikipedia.org/wiki/Static_program_analysis
Answer: If I understand you correctly, there is such thing. Search for static analysis, control flow graph and such things. So generally, your idea is good.
However, writing a program that will find all the bugs in some program is impossible. The proof is by reduction from the Halting problem. So obviously, it is impossilbe to use your approach to find them all.
However, it might be possible to find all the bugs of some family.
For example: I can define the "bug family" of crashing within one minute when only one ASCII char is given as input. Of course you can check this (at least for deterministic programs, for probabilistic programs - a simple check will give probability that there is no bug).
So for spcific bugs your approach might work.
And last thing: notice that this approach might have high time complexity.


Electric field of a point source in QM

Question: We know that radiation from a point source vanishes at large distances. So when an atom emits a photon, the expectation value of the electric field must vanish at large distances. How we can explain this fact when we treat the photon as a quantum state?
In QM the photon state is |1> and the electric field operator is a sum over annihilation and creation operators of all modes.
Is it possible to show that the expectation value of the electric field depends on the distance r from the atom? and that it will vanish as r goes to infinity?
Answer: The expectation value of the electric field on a Fock's state is zero. It is a well known result which can be verified by taking into account that the electric field is a linear combination of a photon creation and a photon annihilation operators. But the expectation value of both operators is zero on any eigenstate of the number operator. In oder to compare quantum description of the field with the classical fields, one has to move to states which do not correspond to a fixed number of photons.
Comment: Ok, sorry, let me ask my question again slightly different. how  we can explain the fact that the expectation value for absorbing photon vanishes at large distances. This expectation value in QM is not zero in Fock state. It is proportional to 〈E^+ E^- 〉
Comment: @Jacob are you not mixing virtual photons (used to describe the static electric field) with real photons, i.e.. four vector length zero? Virtual photons are not "absorbed" they are under an integral of the problem at hand.. This might interest you https://motls.blogspot.com/2011/11/how-classical-fields-particles-emerge.html
Answer: The key is to work with multimode fields.
Basically, the reason that field vanishes is because you are integrating field (or intensity) from an atom over a fixed area, like the size of your detector. If instead you were looking at the intensity over a fixed solid angle, you would probably find the intensity does not change with distance away from the emitter.
To resolve all these intricacies one needs to work with many photon modes, i.e. creation/anihilation operators as a function of wave-vector, in Fourier space, or as a function of position, in  real space. Furthermore, this will only suffice for time-harmonic picture, even more care is needed for non-harmonic fields.
As an illistration consider this. Lets say you have a single-photon state propagating in the direction $\mathbf{\hat{k}}$ and with the wavelength $\lambda=2\pi/k$, where $\mathbf{k}$ is the wavevector. So your state of light is $|\psi\rangle=\hat{a}\left(\mathbf{k}\right)^\dagger |0\rangle$ (ignoring the polarization of light). What is the probability of detecting something on detector with detection area $S$, it will probably end up being somethething like $\int_S d^2 r'\langle\psi|\hat{a}^\dagger\left(\mathbf{r'}\right)\hat{a}\left(\mathbf{r'}\right)|\psi\rangle$, where $\mathbf{r'}$ is the position on the surface $S$ and $\hat{a}\left(\mathbf{r}\right)=\frac{1}{\left(2\pi\right)^3}\int d^3 k\, \hat{a}\left(\mathbf{k}\right)\exp\left(-i\mathbf{k}.\mathbf{r}\right)$ is the Fourier transform of the wavevector-based destruction (or creation) operators. The $1/r$ scaling will most likely arise once you start unravelling all these integrals - you have a 2D integral in space, but 3D in wavevector space, the mismatch will give you the scaling (I expect). We have not even touched upon the necessary commutation relations. What I am getting at here is that full treatment is more complex than $|0\rangle$ and $|1\rangle$ you see in simple accounts.

Electric field of a point source in QM


Should I still add "on average" when saying "per day"?

Question: When I say "...run 29km per day" or "She played music for 2 hours per day during last three month" should I add "on average" at the end of the sentence, or does "per day" already means "on average"?
Answer: It depends what you mean.

I ran 29km per day.

means that every day you ran 29km (usually understood to mean 29km or more).

I ran 29km per day on average

means that you can have run sometimes more than 29km, sometimes less, but that the average was 29km per day. Mathematically this would normally be the total of distance run divided by number of days is 29km.
Answer: You can add "on average" to make the meaning more clear.  But it isn't required grammatically, and most people would understand from the context.
Saying "I run 29km per day" could mean exactly 29km every day, or it could mean an average of 29km per day. In context, most people don't have a daily running route that is exactly 29 km long, so the meaning of  "on average" is understood from the context.  But I'd be surprised if someone ran 203km every Sunday and then told me "I run 29 km per day (on average)", even though mathematically it is true.
So "per day" doesn't mean "on average" but in many contexts it will be understood to mean "about and on average, not exactly".
Comment: Also, using a round number (30km rather than 29km) is more likely to be taken as an approximation or average.


Why don't motorcycles have as good a turning radius as bicycles?

Question: The question is about why are motorcycles not manufactured with handlebars that can turn to great degrees like a bicycle. In most motorcycles, you hardly have a steering angle of about 20-30 degrees, whereas on a bicycle, you can even go beyond 90 degrees. Is this done with the purpose of stability in mind, as motorcycles travel at far higher speeds than a bicycle, and sudden steering of the vehicle at such speeds can cause it to flip over.
Why is this not done at least for motorcycles belonging to the 'streetbike' or 'naked' category, as they are meant to be ridden in cities, at least theoretically, where you might need to take tight turns.
Comment: We probably can't help you with this. This is engineering, not physics. I would guess your answer is right - safety and stability. Motorcycles not only need to be safe, they need to be lawyerproof. Also bicycles are light and easy to pick up if they fall over.
Comment: As in most such cases, it is about trade offs. You could if you want , design a motorbike with a high steering angle , but there will be some engineering tradeoffs with safety, stability, design of fuel tank and frame clearance. So, they make  a decision, about which things are more important for them, and which are the things to trade off , and a high steering angle is probably not worth the trade offs required to make it happen
Comment: @silverrahul Please only use comments for their intended purpose: to ether ask for clarification or suggest improvements to the post
Comment: Have you tried riding a bicycle and turning the handlebars "more than 90 degrees?" to see what happens? The ability to "steer round sharp corners" is not the reason why the handlebars can turn so far. (Hint: think about how much space a bike occupies *when it is not being used*, if you remove the front wheel and turn the handlebars 90 degrees.)
Comment: @mmesser314, probably I will ask it there. didn't know that was a separate site.
Answer: The main reason I have ran into is so that the wider front forks on a motorcycle do not hit the fuel tank which is generally located close to the front forks. Also most motorcycles have a "triple tree" type front end which has to have more frame clearance than the typical bicycle steering stem needs.
Comment: But, is it that difficult to leave some gap between the fuel tank and the fork area to accomodate a wider turn angle ?


associated sequence is a short exact sequence iff the original sequence is a split short exact sequence.

Question: Let $0 \to L \to M \to N \to 0$ be a sequence of $R$-modules. Then to prove that the associated sequence
$$0 \to Hom_R(D, L) \to Hom_R(D, M) \to Hom_R(D, N) \to 0$$
is a short exact sequence of abelian groups for all $R$-modules $D$ if and only if the original sequence is a split short exact sequence.
Comment: Take $D=N{}{}$.
Comment: What's the question?
Comment: I have edited the question..@LordSharktheUnknown
Answer: Let $0\rightarrow L\xrightarrow{\psi}M\xrightarrow{\phi}N\rightarrow 0$ be the given sequence of $R$ modules.
We want to show that
$$0\rightarrow \text{Hom}_R(D,L)\xrightarrow{\psi'}\text{Hom}_R(D,M)\xrightarrow{\phi'}\text{Hom}_R(D,N)\rightarrow 0 $$
is exact for all $R$-modules $D$ if and only if $0\rightarrow L\xrightarrow{\psi}M\xrightarrow{\phi}N\rightarrow 0$ is a split short exact sequence.
($\Rightarrow$) Assume
$$0\rightarrow \text{Hom}_R(D,L)\xrightarrow{\psi'}\text{Hom}_R(D,M)\xrightarrow{\phi'}\text{Hom}_R(D,N)\rightarrow 0 $$
is exact for all $D$. Taking $D=R$ we have
$$0\rightarrow \text{Hom}_R(R,L)\xrightarrow{\psi'}\text{Hom}_R(R,M)\xrightarrow{\phi'}\text{Hom}_R(R,N)\rightarrow 0 $$
is exact. And since $\text{Hom}_R(R,X)\cong X$ for any $R$-module $X$,
$$0\rightarrow L\xrightarrow{\psi}M\xrightarrow{\phi}N\rightarrow 0$$
is exact. To show that this sequence splits it suffices to find a splitting homomorphism $\mu$, (i.e. a homomorphism $\mu:N\to M$ such that $\phi\circ\mu=\text{id}$). Setting $D=N$, we have that
$$0\rightarrow \text{Hom}_R(N,L)\xrightarrow{\psi'}\text{Hom}_R(N,M)\xrightarrow{\phi'}\text{Hom}_R(N,N)\rightarrow 0 $$
is exact, in particular $\phi':\text{Hom}_R(M,N)\rightarrow \text{Hom}_R(N,N)$ is surjective. Therefore there must exist a $\mu\in \text{Hom}_R(M,N)$ such that $\phi\circ\mu=\text{id}$ (and such a $\mu$ is a splitting homomorphism).
($\Leftarrow$) Assume that $0\rightarrow L\xrightarrow{\psi}M\xrightarrow{\phi}N\rightarrow 0$ is a split exact sequence. From exactness it follows that
$$0\rightarrow \text{Hom}_R(D,L)\xrightarrow{\psi'}\text{Hom}_R(D,M)\xrightarrow{\phi'}\text{Hom}_R(D,N)$$
is exact for all $D$, since Hom is a left exact functor. So to finish showing that
$$0\rightarrow \text{Hom}_R(D,L)\xrightarrow{\psi'}\text{Hom}_R(D,M)\xrightarrow{\phi'}\text{Hom}_R(D,N)\rightarrow 0$$
is exact, we just have to show that $\phi'$ is surjective:
Let $\rho\in\text{Hom}_R(D,N)$. Since $0\rightarrow L\xrightarrow{\psi}M\xrightarrow{\phi}N\rightarrow 0$ splits, there exists a $\mu:N\to M$ such that $\phi\circ\mu=\text{id}$. In particular, we have $\mu\circ\rho \in \text{Hom}_R(D,M)$, so that
$$\phi'\circ(\mu\circ\rho)=(\phi\circ\mu)\circ\rho=\text{id}\circ\rho=\rho,$$
confirming surjectivity.


Why do the drones explode?

Question:
In Star Trek Beyond, the Enterprise crew aboard the USS Franklin discerns by way of Spock and Bone's espionage the exact UHF frequency to play Beastie Boy's Sabotage for to disrupt the drone cooperation. When Starbase Yorktown joins the party, drones by the screen-full burst into spectacular fireballs. I understand that without their hive mind they would no longer fly in formation, but what causes them to freaking blow up? Did I miss some dialog?
Comment: @recognizer, I imagine you will ultimately be correct. That being said, isn't the bee ship the kind of ship that DOESN'T explode when it crashes - by design?
Comment: I recall some of the dialogue being about what kind of signal would disturb the swarm the most catastrophically, which I assumed meant they wanted to make the bee ships run into each other and blow up rather than simply go the wrong way. Though I agree the visuals made it look like all the ships just spontaneously combusted when confronted with classical music.
Comment: I agree with @Ixrec's interpretation. I had to think about it a bit while watching the film, as they don't exactly make it obvious. I think the real tipoff is to consider how the swarm ships work - their m.o. is to ram into a larger ship en masse. Given that, it's reasonable to conclude that, lacking guidance, they'll run into their neighbors.
Comment: @JerryNixon-TOS It's made of, um, a high-tech alloy that can't be pierced by anything except another ship made of that alloy. Sure, that sounds legit, right?
Comment: I don't think you missed any dialog, but I do think you maybe missed the last twenty years of blockbuster film...
Comment: Relevant: http://scifi.stackexchange.com/q/135477/44184. The *pilots* of the ship were drones as well, not just the actual ships. Makes the whole "crashing in absence of control" thing more plausible.
Comment: Related: [Why were the enemy ships blowing up?](http://movies.stackexchange.com/q/59551/49)
Comment: They were built by The Shredder.
Answer: They are not spontaneously exploding
The drones are attacking as an overwhelming, densely-packed precisely synchronized swarm, performing intricate and coordinated maneuvers, en masse, in perfect harmony, at very high velocity.
As soon as that perfect coordination is disrupted they are going to start bumping and colliding with each other.  Packed as tight as they are, moving as fast as they are, that's going to create a chain reaction of collisions.
EDIT: It is also possible that the close proximity to an exploding ship might cause another ship that close to explode, as well, and any combination of those two events throughout the swarm, but the specific quote provided by Valorum in his answer, where Spock references the disruption of coordination, suggests that collisions would be the main mechanism.
Comment: Which is fine, except that in the film you can clearly see individual ships exploding, not from collisions.
Comment: To be clear, I'm not saying that we see tiny drones colliding and then exploding.  We also don't see any in isolation spontaneously exploding.  We just see the cascade of explosions as the Enterprise flies by.  We don't see enough detail to see if there are collisions or not.  I'm responding to the assertion that we see explosions specifically "not from collisions."
Comment: Looking at it, I can see at least three instances where an "out of control" vessel simply explodes, one a few seconds after they initially turn on the music, another when they approach the "wave" and another less than a second after the Yorktown turns on their transmitters.
Comment: @Valorum - just re-watched the scene, based on your statement.  It doesn't show anything of the sort.  The quotes in your answer confirm what I wrote in mine.
Comment: That being said, the signal seems to result in the ships spontaneously coming apart as well as veering erratically.
Comment: Somewhere there is a digital artist shaking his fist and ironically cursing hi-def.
Answer: Having watched (and rewatched) this scene, I'm really no wiser as to why the ships started exploding, other than that the radio signal somehow causes it. The explanation given on screen is no real help.

Spock: From what I can ascertain, the ships share a cyberpathic link that coordinates their actions. Patching it through now.
Uhura: That's what that signal was. They weren't jamming us, they were talking to each other
Kirk: Well, how do we get them to stop talking?
Scott: What about ah, electromagnetic focusing? We could use the transporters to disrupt their network
Spock: The focus might be too specific. If we can find some sort of disruptive communication signal inside the swarm, it might inversely affect their
  capacity to coordinate.
Chekov: It would have to be at a frequency that they will not anticipate.
Sulu: It could cause a chain reaction that would wipe out the whole swarm.
Scott: Sir, a closed network like that might be susceptible to Very High Frequency.
Kirk: VHF. [beat] Radio! We can broadcast something from the ship to drown out the links. Loud and
  distracting.
Scott: Loud and distracting? I've got just the thing.
Comment: If Spock really meant *inversely*, not *adversely* then the answer is right there.   Obviously there is a magical frequency that makes them attack each other rather than cooperate.   Or whatever *inverse coordination* would be.  /s
Comment: @ThePopMachine - Could mean inversely as in - the signal uber-enhances their ability to focus and coordinate. Inversely could mean that the disruption does not just stop enhancing the effect, but negatively impacts those abilities.
Answer: Maybe they were flying a little too sideways when they got jammed
It didn't seem as though the drones tended to travel along a linear trajectory. Therefore, it seems reasonable to assume that they flew sideways into one another.
I've only seen the movie once, so I don't remember if they just suddenly exploded (which would make my answer worthless).
Comment: I love it! If everyone else is going to guess, why can't we guess something new?! Nice one.

Why do the drones explode?


Qualcomm Atheros QCA9377 dropping wifi

Question: I am having a lot of problems with Wifi (wired connection don't have any issues). The strange thing is that happens only on my Ubuntu 18.04.4 x86_64 4.15.0-101-generic computer (I also tried to reinstall and put the 20.04 fresh, but nothing changed), all others have Windows/Android and are not affected.
What happens is that after a while browsing, I lose my internet connection, leaving the icon in the upper right corner with the question mark and getting "err_disconnected_internet", "dns_probe_finished_nxdomain" or "dns_probe_finished_no_internet" from Chrome. To "solve" I need to switch from the 2.4G network to the 5G network (and vice versa), but soon afterwards the problem occurs, often in less than 5 minutes (sometimes more, sometimes less).
I've tried several things, but all without success, I'll leave all of them here:
When viewing the dmseg -w command information, I saw that my country code (which is currently Brazil) was apparently changed to IE:
[1610.124972] wlp2s0: associated
[1610.125195] ath: EEPROM regdomain: 0x804c
[1610.125197] ath: EEPROM indicates we should expect a country code
[1610.125200] ath: doing EEPROM country-> regdmn map search
[1610.125202] ath: country maps to regdmn code: 0x3b
[1610.125205] ath: Country alpha2 being used: BR
[1610.125206] ath: Regpair used: 0x3b
[1610.125210] ath: regdomain 0x804c dynamically updated by country IE
[1610.159599] wlp2s0: Limiting TX power to 30 (30 - 0) dBm as advertised by ...

I tried to change in /etc/default/crda, but without success. Afterwards, I tried to disable powersave by changing /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf to "2", but also without success.
Note: even after the two changes above, the output of dmseg -w remains the same, but iwconfig really shows that powersave is disabled.
After that, I tried reinstall netwok-manager, use Google Public DNS, and nothing changed.
After erasing everything and placing 20.04, I thought I had solved the problem, but it come back shortly after.
I managed to get some logs just before the drop:
journalctl -u NetworkManager --follow
jun 08 00:38:26 lucius-Lenovo-ideapad-320 NetworkManager[742]: <info>  [1591587506.4061] dhcp6 (wlp2s0): state changed unknown -> bound
jun 08 00:38:29 lucius-Lenovo-ideapad-320 NetworkManager[742]: <info>  [1591587509.3816] manager: NetworkManager state is now CONNECTED_GLOBAL

journalctl --follow:
jun 08 00:39:00 lucius-Lenovo-ideapad-320 systemd[1]: Starting Clean php session files...
jun 08 00:39:00 lucius-Lenovo-ideapad-320 systemd[1]: phpsessionclean.service: Succeeded.
jun 08 00:39:00 lucius-Lenovo-ideapad-320 systemd[1]: Finished Clean php session files.
jun 08 00:39:01 lucius-Lenovo-ideapad-320 CRON[78496]: pam_unix(cron:session): session opened for user root by (uid=0)
jun 08 00:39:01 lucius-Lenovo-ideapad-320 CRON[78497]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
jun 08 00:39:01 lucius-Lenovo-ideapad-320 CRON[78496]: pam_unix(cron:session): session closed for user root
jun 08 00:39:32 lucius-Lenovo-ideapad-320 systemd-resolved[700]: Using degraded feature set (UDP) for DNS server 2804:....
jun 08 00:39:33 lucius-Lenovo-ideapad-320 systemd-resolved[700]: Using degraded feature set (UDP) for DNS server 2804:....

Here's some outputs:
iwconfig:
lo        no wireless extensions.

docker0   no wireless extensions.

wlp2s0    IEEE 802.11  ESSID:"NAME_5G"
          Mode:Managed  Frequency:5.785 GHz  Access Point: ...
          Bit Rate=6 Mb/s   Tx-Power=30 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=53/70  Signal level=-57 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:154   Missed beacon:0

virbr0    no wireless extensions.

enp1s0    no wireless extensions.

virbr0-nic  no wireless extensions.

lspci | grep -i wireless:
02:00.0 Network controller: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter (rev 31)

/etc/network/interfaces:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

/etc/resolv.conf:
nameserver 127.0.0.53
options edns0
search spo.virtua.com.br

Please, I really don't know what else to do
EDIT
I forgot to mention something that may be very relevant:
Only on this particular network do I have drops, on any other I have no problems.
Router Info
HGJ310 HUMAX
Technology
DOCSIS 3.1
Hardware Version
1.0
Software Version
BRGCAI 1.0.18
EDIT 2
I don't know how much of a coincidence this is, but apparently accessing some specific sites makes the wifi go down faster, like some W3 Schools pages, giving me the following log:
Jun 08 02:09:24 lucius-Lenovo-ideapad-320 systemd-resolved [694]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP

With some research, I stopped that this is just an alert, and it didn't cause an error in itself...
Comment: Does this answer your question? [QCA9377 Unstable WiFi connection on Ubuntu 16.04](https://askubuntu.com/questions/1125262/qca9377-unstable-wifi-connection-on-ubuntu-16-04)
Comment: Thanks for the quick response! I got to see this link before, but the 2.4G network is already at 20MHz and it also has drops, so that doesn't seem to be the problem :/
Comment: Before I had no problem... Only on this Wi-Fi this started to happen (in others I have no problems), I will add this to the question, thanks
Comment: @WinEunuuchs2Unix fair enough, comment cheerfuly deleted. I also have several Atheros chipsets that work very well, and had others in the past that did not. Spotty service on just one network suggests possible congestion upon that channel.
Answer: There is a large Q&A here:

[Solved] QCA9377 Wireless device not working after upgraded Linux 4.14.85-1

After running dmesg | grep -i firmware and dmesg | grep -i ath10k amongst many other commands, the solution was this script:
#!/bin/bash
sudo nmcli networking off
sleep 1
sudo systemctl stop NetworkManager
sleep 1
sudo ip link set wlp2s0 down
sleep 1
sudo modprobe -r ath10k_pci
sleep 2
sudo modprobe -r ath10k_core
sleep 2
sudo modprobe ath10k_pci
sleep 2
sudo ip link set wlp2s0 up
sleep 1
sudo systemctl start NetworkManager
sleep 2
sudo nmcli networking on
sleep 1
exit

Even if the script doesn't work for you, read the entire Q&A in case something else does.
Comment: Thanks for the answer! Unfortunately, all the suggestions from the tbg user did not give me positive results. The wifi works for a few minutes, but stops again later.

Qualcomm Atheros QCA9377 dropping wifi


How to find out what a material is made of specifically?

Question: Let's say I buy a barbecue grill, is there a material testing kit that I can buy that'll allow me to find out what metal the grill is made from and if it were galvanized or cured in a particular substance?
Comment: Huh? What does it mean to "cure" a metal?
Answer: The test kit is a magnet and horse- sense. If magnetic = steel (most likely) , shiny and magnetic= chrome stainless. Non-magnetic and shiny = austenitic stainless aka 18-8 . Non-magnetic and silver grey but not shiny and feels cold and relatively light = aluminum ( likely ). Magnetic and silver grey = galvanized steel , a dumb material choice for a grill.  How do you "cure" a metal ?
Answer: You can buy a device that tells you what elements are in a lump of something.  This is gross overkill for a barbecue grill.  As others have said, a magnet and a little common sense goes a long way for that.
However, the device I'm talking about is a X-ray spectrometer.  These are available in a handheld "gun" configuration, as one example.  You point the device at your unknown lump of stuff and pull the trigger.  It blasts the lump with x-rays with controlled wavelengths, and looks at the resulting emissions.
Basically, bombarding with high enough energy photons makes pretty much everything act like a phosphor.  The high energy photons cause electrons to move to higher states.  The photons emitted by falling back to the lower states is distinctive of the particular element.  Collect enough of these re-emission photons to get a nice spectrum, and you can tell what elements are in the lump of stuff to surprising accuracy.
One company that makes such devices is Thermo Fisher.  Uses include assaying of minerals, looking for lead in paint on old houses, and lead and other bad things in toys being imported.  These devices have tables of common alloys built in to their firmware.  They not only tell you directly that your lump is stainless steel, but what type.
While such a thing would definitively answer your question, it would be gross overkill since its cost is many times that of a new barbecue grill.  If you are deciding which area is best to mine for gold though, the cost is likely well worth it.
Answer: There is no "material testing kit that [you] can buy", but there are recognised processes/sequences for determining both metals, and plastics.
weldinghandbook.com has an excelent article covering this, which I will not repeat in full!
In summary - check first if your material is magnetic, and then follow one of these three processes:

Non Magnetic
Slightly Magnetic
Magnetic


How to get mean geographic direction of a polygon in QGIS?

Question: I have a raster height model and would like to calculate the horizontal geographic direction (north, east, etc. - orientation) of each cell, then calculate then the mean value of all these cells in one region (polygon). This is to get information about to what direction a vineyard is exposed to. How do I do this?
Answer: The 'direction' you are referring to is known as the aspect of a slope. To calculate this for a raster DEM in QGIS you need to use the Raster > Analysis > DEM (Terrain models) tool which has a mode for aspect. There's a tutorial for working with terrain analysis in the QGIS Training Manual - lesson 8.3.
Once you've generated an aspect raster from your DEM, you can use the Raster Calculator and Zonal Statistics plugin to get the mean aspect value from your regions (zones). As whuber's comment points out this calculation is more complex than it initially sounds, and you can refer to his answer at Sum raster data visible from given point, by proportion of view for full details.
The values generated by the aspect analysis are angular (I believe clockwise from north, but you should confirm that). So if you want a N/E/S/W direction to that, you'll have to determine how fine you want to go (northwest or north-northwest) and then assign it based on the angular value.
Comment: Zonal stats, applied directly to aspects, will likely produce some wildly incorrect values. Proper procedures for averaging angular values have to be followed. The correct understanding of mean aspect in this application probably should take into account slope, too, so what is likely needed is the *mean normal vector to the slope.* Details can be found at http://gis.stackexchange.com/questions/53664/sum-raster-data-visible-from-given-point-by-proportion-of-view/54002#54002 and http://gis.stackexchange.com/questions/7496/phong-lighting-scheme-in-arcmap/7498#7498
Comment: @Rex It comes down to how you intend to interpret "mean aspect."  Regardless, you do have to use methods of analyzing circular data.  To see why, consider a polygon pointing due north, give or take a few degrees.  Some of the aspects will be 0, 1, 2 degrees and others will be 359, 358, 357 degrees.  The average will likely be close to 180 degrees, which is exactly the opposite of the average direction.  You must also treat the special aspect value of -1 properly (this represents an unknown aspect when the slope is zero).
Comment: @whuber I am obliged for clarity and enlightenment. Kind regards.
Comment: @whuber You're right, I didn't think that one all the way through. Not only was I making some assumptions based on what the zones were and how small I thought they'd be (which is largely irrelevant), I didn't (don't) fully understand all the math issues and apparently forgot how complicated the angular value thing was; because your comment is ringing bells now.
Comment: @whuber I have a Aspect raster with polygons overlaid on it. I am looking for mean aspect (slope directions) of each polygon by applying Zonal Statistics in ArcGIS. Do I need to consider slope in this case as well? Looking for guidance.


Must every question formulation be so formal?

Question: Isn't there a bit of bringing your own personality into the question?
I mean is it really that important to have cold not individual question formulations?
Revision because of grammar is okay but removing a have a good day and calling it "deleting the extra stuff" seems a bit too harsh in my eyes.
Comment: Sorry, I probably should have mentioned this when I edited.. It's not some much "formal" as just reducing clutter. A paragraph saying "I hope you can help me, have a good day, thanks :)" doesn't add any new information to the post, as it's kindof a given that the OP hopes someone can help them (given that they are posting a question).. See http://meta.blender.stackexchange.com/q/466/599
Comment: I agree with that.  If there is a whole bunch of dialogue with a bit of standard courtesy it can just be easier to erase the whole paragraph than to pick through it all to clean up.  I was thinking that the standard behaviour that is expected of people at a public library seems appropriate.  Yammering on and on is discouraged but if you bump into someone it is polite to excuse yourself.  Thank someone if they help you except in this case the 'upvote' button is the thank you.
Comment: I agree with the "I hope you can help me" it's pointless.  I think "Have a good day, thanks" is really just polite behavior and it's really not something people should drop for the sake of "rules"  If that's what's being pushed then the rules are very wrong or being used in a way that was never intended.  After all we are not robots and being curt when typing messages online tends to sound bossy and rude.
Comment: @MarcClintDion It can come out that way, but I think here on SE this is pretty much accepted as the norm without seeming bossy. At least in my mind, I think a lot of the tone is conveyed by the phrasing of the useful information, without the need for extraneous phrases that take up an extra few seconds to read without really providing any information. Also these aren't really hard rules per se, more like conventions that most SE users seem to follow. Usually I don't edit out this sort of stuff unless I'm already editing for another reason, but I made an exception in this case due to the amount
Comment: @MarcClintDion I seem to have pretty much the same [philosophy as CoDEmanX](http://meta.blender.stackexchange.com/questions/466/editing-questions-to-remove-thank-you-etc#comment1885_468).
Comment: Exactly. I'm still frumious at Ray Mairlot for REPEATEDLY removing the engaging titles that I use as hooks to get views and hopefully answers. Examples in point: (Lightning Strikes! The Problem with Emitters) was turned into (Are particle emitters a good starting point for creating lightning?) and (Portal Majjicks in Blender's Render) became (How can I create a portal?) and (Cube Confusion: Creating a d8 in Blender from One Object) became (How do I create an 8 sided die from one object?) I'll admit to having changed the title on one of my own questions myself... twice...
Answer: There are lots of question on this topic, such as:
Editing questions to remove "thank you" etc
Should 'Hi', 'thanks', taglines, and salutations be removed from posts?
What should I keep out of my posts and titles?
Editing for Brevity?
Are taglines & signatures disallowed?
What is the policy on signatures and links in answers?
Here and else where on the Stack Exchange network, it commonly accepted to keep extraneous text out of questions and answers. It is not about formal vs informal writing, but rather concisely conveying the relevant information.
While salutations seem harmless, and they are; they also do not add value to the question, and as such are should not be there.
I read a reason something like this once.

If it add no value to the question, but takes time for everybody who reads the question, why not edit out this extraneous text.
Answer: let's discuss :)
The mere fact that someone uses the site to ask a question implies that they 'hope we can help'. The site is really about exchanging information, and though it may seem cold, distant and impersonal when we cut out the pleasantries, all we really want to do is stream-line the information, and make it consistent with how questions are presented across the Stack Exchange network.
If you feel the need to see a less formal side of the site join us in the chatroom RenderFarm, and you might get a better understanding of the separation between the familiar and the matter of fact


Disabling script max-execution-time in flex?

Question: How do I completely disable the max-execution-time for scripts in flex? The configurable max is 60 seconds, but I'm calling off to other interactive processes which will probably run much longer than that. Is there an easy way to disable the maximum script execution time across my entire application?
Comment: How are you "calling off to other interactive processes" ?  In Flex all external calls are asynchronous so the script timeout wouldn't apply.
Comment: @Sam: you can make a synchronous call out to JavaScript for example. if JS doesn't respond with the timeout limit, you'll get a timeout, even if it's just a synchronous load operation (which doesn't hit CPU at all).
Answer: you can't. and probably, that's quite good. of course it's a pitty that you can't but when looking at the kind of things some people fabricate with the flash player, I am very happy.
For simplicity Adobe decided to promote a single threaded execution model that allows concurrent operations through asynchronous callbacks. sometimes this becomes anoying, verbous and even slower (performing a big calculation in a green thread simply takes longer than doing it directly). It's more of a political choice, so I guess the best you can do is live with it.
or you could explain what exactly you're up to, so I could propose a solution.
p.s.: there has been quite a lot of discussion going on about threads for background calculation. also, some people use seperate SWFs to perform calculation, or push it to pixel bender. also, you may wanna have a look at alchemy. it supports threading through relatively efficient continuation passing.
Answer: I have a long-running SOAP request that times-out with Error 1502.  "Error #1502: A script has executed for longer than the default timeout period of 15 seconds."
I went to the right-click Properties dialog on the project in Flash Builder 4, then the Flex Compiler Options.
I set the Flex Compiler Options to "-locale en_US -default-script-limits 1000 60".
The locale was already there.  It was the -default-script-limits that was cryptic to decipher from the compiler reference.
But I still got the fault with Error 1502 and 15 seconds.  I even did a Project->Clean... command and tried again.
So, where is that 15 second timeout set?  It turns out -- from some Googling and I'm not entirely sure -- that the Flex compiler accepts my setting, but the timeout message is fixed text with the 15 seconds message.
I also found that I could try: -default-script-limits 1000 65535.  That didn't help either.  This is from a posting on FlashDevelop.org 1
The bottom line for me is that I now need to page or otherwise divide up the information I am requesting in the SOAP call.  My code still works fine for small requests.


Can I apply for a UK tourist visa if I overstayed a Schengen visa 11 years ago?

Question: I overstayed in Italy for 2 years in 2012 (11 years ago). Will I be granted a UK tourist visa?
Comment: Nitpick: Your question body is not asking the same question as your title. Applying for a visa and actually being granted a visa are not the same thing. You can always apply, but you're generally not guaranteed to be granted a visa.
Answer: You can always apply, and you can get a visa, provided you are truthful, tick the appropriate boxes if asked and don't hide any facts
Comment: But getting the visa is not certain at all, best to make a strong case with many reasons for you to return home.
Answer: UK has never been in the Shengen area, so this should be equivalent to asking for a visa to any other country not in the Shengen area (like eg. Morrocco or Vietnam)
Comment: Except that the UK requires visitor visa applicants to disclose *all* such previous immigration rule breaches, in any country.


Extreme Bad thoughts about prophet muhammad saw

Question: Asalamualikum
I always suffer from extreme bad thoughts particularly about prophet muhammad pbuh and i have read a lot of online data and watched videos of scholars that it is the waswas of shaytaan but i am not able to stop myself from paying attention to these thoughts.i also tend to feel sometime that these are my own thoughts.i am not able to ignore these thoughts.and at height seldom i tend to repeat these thoughts in my mind and head and often feel an extreme tempation to say these in my heart.kindly help and pray for me
Comment: I have to add that I really hate un-commented downvotes. Even a bad question does not deserve dovnvote without explanation.
Comment: Like any library, Islam Stack Exchange offers great information, but does not offer personalized advice or legal verdicts, and does not take the place of seeking such advice from your Mufti, Imam, or other trustworthy Counselor.
Comment: To help you would include knowing the nature and details of your bad thoughts, but telling that here would very sure be considered offensive and attract hate and even more downvotes. Seek a trustworthy Counselor, one that tries to understand the reasons, not one of those that shoot on sight.
Comment: And again, reading your question, might it be that you think bad just about everything, your neighbors, your spouse, your house, your car or donkey? And thinking bad about the Prophet is just the top that makes you aware that somethings not right? If so, this would not be not so much a religious problem but rather a medical condition.
Comment: And yet again, there really are bad neighbors, bad spouses and bad donkeys. Did you ever drive a Chevrolet? You have to get out of the mood of "I hate everything".
Answer: سلام عليكم
you should try to stay away from things on the media that evolves Islam because the media isn't ran by anyone but kufr. if you want to gain knowledge about the religion read read read. having thought like this can put you in the state of kufr when you die you won't be a Muslim. it's scary. read about the deen and stop looking at social media. pray always, and go the the masjid. surround yourself around good Muslim people.
May Allah swt guide us all
الله اعلم


Source for the "gra's" calculation of pi

Question: I am looking for a textual source for this famous GRA which corrects the מקרא calculation of Pi from 3 to 3.1415 based on the kri and ksiv of קו vs קוה. Based on my research there may not be a written source in the Gra. If not, does anyone know the actual text that suggests this correction?
Comment: related https://judaism.stackexchange.com/q/16883/759
Comment: The passuk in question is Melachim 1:7:23, by the way. It's noteworthy that its pair in Divrei Hayamim (2:4:2) lacks the kri u'kesiv.
Comment: @Bach gave the one true answer. Just want to note, in Xian circles the usual mis-attribution is to Newton, who did spend more time on religion, spirituality and numerology than his more famous (and more successful) work in physics.
Answer: According to this (p. 9) the Gra never said this, it was actually proposed by Max Munk and was wrongly attributed to the former,

This solution is attributed to Eliyahu the Gaon of Vilna (18th
  century), known as the Gra. The Gra was not only a Gadol in Torah, but
  also an accomplished mathematician. However, there is evidence that
  this solution was first proposed by 20th century Torah scholar, Rabbi
  Matityahu Hakohen Munk (Max Munk), as noted in a private communication
  to me by Rabbi Professor Sid Leiman of Brooklyn College. He states:
  "The Gra did talk about pi, but never suggested the secret
  interpretation ascribed to him. That interpretation was first
  suggested by Max Munk in 1939. He published his suggestion in "Shalosh
  Ba'ayot Handasiyot be-Tanakh uveTalmud."

(This article was published in the journal "Sinai", by Mosad haRav Kook, Tamuz 5722. Pp. 218 - 227)
Comment: @Rebwass Well i'm sorry that my post wasn't too helpful, but from your OP it appeared that you were assuming that it was indeed the Gra who wrote it, you were just looking for the source. If you would've cited this source by Morris Engelson and asked for opinions whether it is reliable or not, that would've been helpful.
Comment: Added bibliographic detail on the article. I hope that's okay.
Comment: @ bach Yes, that is the source I found. I was looking for an actual primary text that actually writes it out.  (preferably a hebrew text)