How do I implement a simple cross platform Python daemon?

Question: I would like to have my Python program run in the background as a daemon, on either Windows or Unix. I see that the python-daemon package is for Unix only; is there an alternative for cross platform? If possible, I would like to keep the code as simple as I can.
Comment: I don't know the answer but I am very interested in this.
Comment: Yeah, it's something that'd be handy to know if there's a cross-platform way of starting a Unix daemon or Windows service depending on the platform with the same/similar code. Maybe not practical, I don't know...
Comment: Can elaborate a little on what your program does?
Comment: @Adam, it's probably too lengthy and off-topic to describe here ;)
Comment: Since "daemon" is just a concept, and implementations are highly platform-specific, this question doesn't make sense.  Are you asking about platform-specific wrappers so your application doesn't change much?
Answer: In Windows it's called a "service" and you could implement it pretty easily e.g. with the win32serviceutil module, part of pywin32.  Unfortunately the two "mental models" -- service vs daemon -- are very different in detail, even though they serve similar purposes, and I know of no Python facade that tries to unify them into a single framework.
Comment: @Nick, right -- for solidity in Windows, a service is the way to go. It's not really overkill -- it's rather simple to make a Windows service, actually, just different from making a Unix daemon (and beyond the scaffolding, which is different, the body of your code can often be essentially unchanged between the two use cases -- Unix daemon and Windows service).
Comment: Ah, so you actually recommend going down the service route in Windows; I was thinking that'd be overkill... though, I suppose Windows doesn't support background processes (only hidden windows) -- correct?
Answer: This question is 6 years old, but I had the same problem, and the existing answers weren't cross-platform enough for my use case. Though Windows services are often used in similar ways as Unix daemons, at the end of the day they differ substantially, and "the devil's in the details". Long story short, I set out to try and find something that allows me to run the exact same application code on both Unix and Windows, while fulfilling the expectations for a well-behaved Unix daemon (which is better explained elsewhere) as best as possible on both platforms:

Close open file descriptors (typically all of them, but some applications may need to protect some descriptors from closure)
Change the working directory for the process to a suitable location to prevent "Directory Busy" errors
Change the file access creation mask (os.umask in the Python world)
Move the application into the background and make it dissociate itself from the initiating process
Completely divorce from the terminal, including redirecting STDIN, STDOUT, and STDERR to different streams (often DEVNULL), and prevent reacquisition of a controlling terminal
Handle signals, in particular, SIGTERM.

The fundamental problem with cross-platform daemonization is that Windows, as an operating system, really doesn't support the notion of a daemon: applications that start from a terminal (or in any other interactive context, including launching from Explorer, etc) will continue to run with a visible window, unless the controlling application (in this example, Python) has included a windowless GUI. Furthermore, Windows signal handling is woefully inadequate, and attempts to send signals to an independent Python process (as opposed to a subprocess, which would not survive terminal closure) will almost always result in the immediate exit of that Python process without any cleanup (no finally:, no atexit, no __del__, etc).
Windows services (though a viable alternative in many cases) were basically out of the question for me: they aren't cross-platform, and they're going to require code modification. pythonw.exe (a windowless version of Python that ships with all recent Windows Python binaries) is closer, but it still doesn't quite make the cut: in particular, it fails to improve the situation for signal handling, and you still cannot easily launch a pythonw.exe application from the terminal and interact with it during startup (for example, to deliver dynamic startup arguments to your script, say, perhaps, a password, file path, etc), before "daemonizing".
In the end, I settled on using subprocess.Popen with the creationflags=subprocess.CREATE_NEW_PROCESS_GROUP keyword to create an independent, windowless process:
import subprocess

independent_process = subprocess.Popen(
    '/path/to/pythonw.exe /path/to/file.py',
    creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
)

However, that still left me with the added challenge of startup communications and signal handling. Without going into a ton of detail, for the former, my strategy was:

pickle the important parts of the launching process' namespace
Store that in a tempfile
Add the path to that file in the daughter process' environment before launching
Extract and return the namespace from the "daemonization" function

For signal handling I had to get a bit more creative. Within the "daemonized" process:

Ignore signals in the daemon process, since, as mentioned, they all terminate the process immediately and without cleanup
Create a new thread to manage signal handling
That thread launches daughter signal-handling processes and waits for them to complete
External applications send signals to the daughter signal-handling process, causing it to terminate and complete
Those processes then use the signal number as their return code
The signal handling thread reads the return code, and then calls either a user-defined signal handler, or uses a cytpes API to raise an appropriate exception within the Python main thread
Rinse and repeat for new signals

That all being said, for anyone encountering this problem in the future, I've rolled a library called daemoniker that wraps both proper Unix daemonization and the above Windows strategy into a unified facade. The cross-platform API looks like this:
from daemoniker import Daemonizer

with Daemonizer() as (is_setup, daemonizer):
    if is_setup:
        # This code is run before daemonization.
        do_things_here()

    # We need to explicitly pass resources to the daemon; other variables
    # may not be correct
    is_parent, my_arg1, my_arg2 = daemonizer(
        path_to_pid_file,
        my_arg1,
        my_arg2
    )

    if is_parent:
        # Run code in the parent after daemonization
        parent_only_code()

# We are now daemonized, and the parent just exited.
code_continues_here()

Answer: Two options come to mind:

Port your program into a windows service. You can probably share much of your code between the two implementations.
Does your program really use any daemon functionality? If not, you rewrite it as a simple server that runs in the background, manages communications through sockets, and perform its tasks. It will probably consume more system resources than a daemon would, but it would be quote platform independent.
Answer: In general the concept of a daemon is Unix specific, in particular expected behaviour with respect to file creation masks, process hierarchy, and signal handling.
You may find PEP 3143 useful wherein a proposed continuation of python-daemon is considered for Python 3.2, and many related daemonizing modules and implementations are discussed.
Answer: The reason it's unix only is that daemons are a Unix specific concept i.e a background process initiated by the os and usually running as a child of the root PID .
Windows has no direct equivalent of a unix daemon, the closest I can think of is a Windows Service.
There's a program called pythonservice.exe for windows . Not sure if it's supported on all versions of python though


Where does the spring's energy go?

Question: I have learned that ideal spring has no mass. Suppose, I attach a ideal spring (spring constant $K$) to a wall and pull it a distance $x$ it will have a potential energy $U = \frac{1}{2}Kx^2$ and if I release it then what happens it has no mass so it can't have kinetic energy. What will happen to it, will it be at rest? If yes then how can it be possible that a spring extended a distance $x$ (force $Kx$ towards wall is acting on it) is at rest. If it will come to its original position then what happens to the potential energy? Where does it go?
Answer: There are no ideal springs. Therefore the paradox with the infinite acceleration is not a physical one, but an artefact of the mathematical modelling. Conservation of energy does obviously not hold, when there are objects of mass zero in a system (because the kinetic energy will always be 0). So your setting simply does not fulfil the requirements for energy conservation.
It is not uncommon for systems not to conserve energy. Mechanic problems involving friction or time dependent constraints, for example, do not conserve mechanic energy either. It is all a question of modelling. If you model something completely, then energy will be conserved. But if you let masses go to zero or infinity or simply not include degrees of freedom (as when ignoring the heat generated by friction), energy need not be conserved. The modelling can nevertheless be useful or give meaningful results. In the case of the ideal spring without any connected masses it does not.
Answer: Normally it is said that the spring has no mass, but in problems where the spring is attached to bodies with larger mass compared to the spring mass. So you pull the string  from the side where you have a body of mass $m$ (tha other side is attached to the wall). Then when you release this body with potential $\frac{1}{2} K x^2$ it will be converted in kinetic energy (maximal at $x=0$).
Comment: there is no mass attached to spring in my question so potential energy can't convert into kinetic energy . I am saying consider a massless spring and answer this question.I know this is not practical but just theoretically ,can't you answer this question.
Comment: @DhruvaMehrotra, that's correct.  The theory doesn't work---equations can't be solved---if there's no mass.  But that's not a problem because an ideal spring can not actually exist.
Answer:
where spring's energy goes

It does not go.
From the conservation of energy, $\frac12Kx_\text{max}^2=\frac12mv_\text{max}^2$, and $m = 0$ you get $v_\text{max}=\infty$.
In conclusion, your spring will oscillate with $\text{Amplitude} = x_\text{max}\;,v_\text{max}=\infty \; \&\; \omega = \infty\; .$
For more information see: https://en.wikipedia.org/wiki/Harmonic_oscillator
Comment: $v_{max}$ can't be infinite as max velocity that can be achived is c=speed of light
Comment: I believe I have answered your question in an elegant way using pure Newtonian mechanics. If you ask for impossibilities the answer is an impossibility.
Comment: @PeterS: An apt & smart reply:)

Where does the spring's energy go?


Can I send data to Salesforce Analytics / Einstein as JSON and not CSV?

Question: The Salesforce Analytics / Einstein API documentation says that in order to upload actual data to the datasets you need to prepare CSV files and JSON is used only for metadata.
Is there any way to send/upload actual dataset data in Analytics via an API in a JSON format?
Answer: No, there is no way to do that but you may explore more  about it doing R and D
But When you upload the csv file then the datasets itself create a json of it .


Why does $x^{15}+x^{14}+1$ detect all errors at most 32768 bits apart?

Question: Reference Question from Forouzon Book Computer Network.
Find the status of the following generator related to two isolated, single-bit errors.
$$x^{15} + x^{14} + 1$$
Answer given :
This polynomial cannot divide any error of type $x^t + 1$ if t is less than 32,768. This means
that a codeword with two isolated errors that are next to each other or up to 32,768 bits
apart can be detected by this generator.
Can some one please help me why is this true...? Or even how should I have an in general approach to analyze such questions...?
(Sorry if this is very silly, but I am unable to get a grasp of how the reason works...!)
Answer: Your polynomial is primitive, which means that the order of $x$ modulo your polynomial is exactly $2^{15}-1$. In particular, $x^a \not\equiv 1$ modulo your polynomial for all $1 \leq a \leq 2^{15}-2$, which means that your polynomial doesn't divide $x^a-1$ for this range of $a$.
(This also means that your polynomial should divide $x^{2^{15}-1}-1$, in contrast to what the question claims.)
Comment: Can you please explain it a bit more briefly I am trying to understand it but still stuck at how come a Database Management Course book taking me to primitive ..and plz also explain a bit more about how and why are these primitive polynomials coming to picture...(sorry if you find it silly)
Comment: The internet has an endless amount of material on primitive polynomials.
Comment: Okay so tell me one thing ..if I have $x^5+x^4+1$ then would this be also equivalent to $x^{2^5-1}-1$..?
Comment: I could look it up in a list of primitive polynomials, but so could you.
Comment: ok..now I got it thanks for help!!


Find out if user pressed the back button in uinavigationcontroller?

Question: When a view loads, i want to see if it's because the user pressed the back button. How can i check this?
Comment: Do you want to to know whether it was a user initiated popping or popping in general?
Comment: It might be good to elaborate on your overall goal. There might be an easier way to do what you're trying to do. If you need to know whether some value was changed or set in the second view, for instance, you should simply check that value.
Comment: Popping is what i want to be told about.
Answer: The best solution I've found to detect a UINavigationController's back button press (pre-iOS 5.0) is by verifying that the current view controller is not present in the in the navigation controller's view controller stack.
It is possibly safer to check this condition in - (void)viewDidDisappear:(BOOL)animated as logically, by the time that method is called it would be extremely likely that the view controller was removed from the stack.
Pre-iOS 5.0:
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    if (![[self.navigationController viewControllers] containsObject:self]) {
        // We were removed from the navigation controller's view controller stack
        // thus, we can infer that the back button was pressed
    }
}

iOS 5.0+ you can use -didMoveToParentViewController:
- (void)didMoveToParentViewController:(UIViewController *)parent
{
    // parent is nil if this view controller was removed
}

Comment: This gets also gets called when the VC is pushed (at least on iOS 6).
Comment: didMoveToParentViewController; is not a good solution, it will also be call when this view is appear.
Comment: You need to check if the parent is nil in order to determine if the view was added or removed.
Comment: This works great! But you mentioned pre-iOS 5.0.. Is there an iOS 5 specific method that can be used to catch the back button callback?
Comment: Hey, viewDidDisappear did not get called in iOS 4.3 for me. While both methods are called for me in iOS 5. Any thoughts?
Answer: in your viewWillDisappear method check
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    if ([self isMovingFromParentViewController]) {
      //specific stuff for being popped off stack
    }
}

This is only for post iOS 5
Comment: As an alternative to this, inspired by Andrew's answer, you can do something before the move by overriding
`willMoveToParentViewController:` instead of `didMoveToParentViewController:`.
Comment: Way better method than programming your custom button. Thanks.
Comment: it doesn't mean exactly if user presses back button. There are tons of other cases when it's triggered
Comment: missing parenthesis in the if statement, but otherwise very helpful answer. thanks!
Answer: UINavigationController has a delegate property that issues delegate callbacks.  Please see the iOS reference here.
The delegate doesn't have a "back button pressed" callback, but instead it tells you when something is going to appear on the navigation stack.  When you press back, you are "popping" the top view controller off the stack, so it will tell you that the view is about to appear.  I think this is the callback you'd be looking for.
You could have some simple logic to check if it's the view controller that's "interested", and then you could send a notification, et al.
Comment: There is no delegate that shows when a uinavigationcontroller has popped off the stack
Comment: I said that UINavigationController has a delegate.  If UINavigationController is managing your view hierarchy, it indeed will callback to the delegate, if set.
Comment: I am trying to do this.  When backing up, unfortunately, it calls the "new" view controller [the one being backed up to] -viewWillAppear before the delegate method -navigationController:willShowViewContoller:animated: is called for that same viewController...
Answer: For the sake of completeness, mix of two most upvoted answers (1, 2) in Swift:
override func willMoveToParentViewController(parent: UIViewController?) {
    super.willMoveToParentViewController(parent)
    if parent == nil {
        // view controller is popping
    }
}

Comment: Don't use `will`, use `did` since there's screen edge pop gesture.
Answer: This is a slightly different scenario, but I thought the solution might help others out.
In my situation, I had a UINavigationController within a UIPopoverController.  I needed to detect whether the user clicked the back button, or clicked outside of the popover.  To do this I checked the visibleViewController property in viewWillDisappear.  If the view controller is still the visibleViewController when closing, then the popover is being closed by another means.  If the view controller is not the visibleViewController when closing, then the back button was pressed.
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    if (self.navigationController.visibleViewController != self) {
        <Do something since we're closing using something else>
    } else {
        <Do something since we're closing because of the back button>
    }
}

I tried using zach's solution, but isMovingFromParentViewController returns true for both cases.
I verified this works in iOS 5+
I hope this helps.
Answer: Create a custom back bar button and set the target,
Step 1: Add these methods to your class
- (void)backButtonClicked :(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)addBackBarButton{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 55, 35);
    [button setTitle:@"back" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = customBarItem;
}

Step 2: Call [self addBackBarButton]; in viewDiDLoad method
You will get the action in backButtonClicked method. You can play around with it the way you want.
Cheers!
Answer: The only way to do this so you know for sure that it was the back button is to create a custom button.  If you don't know how to do that, check out this tutorial.  It won't look exactly like the normal back button, but close.  If you need more help, post a comment
Comment: This answer is incorrect and should be removed by the poster.
Comment: Check andrews other answer, and if the poster reads this perhaps accept that as the correct answer
Comment: @user461864, you mean the other Andrew, not Andrew's other answer--they're different Andrews. But you are right, the other answer is far superior; the present one is a lot of extra work by comparison.
Comment: Damn you are right,.. I thought it was weird that he answered twice but that explains


Can I have a different Org Wide Email address in Production and Sandbox

Question: I'm trying to get Email to Case set up in Sandbox to do some testing and keep running into a situation where a response email to the user (who sent the original email to case) has a From: email address that reflects the org wide email setting in our Production Org instead of the one defined in the Sandbox.  Consequently the users return email goes to an email that doesn't exist in the Sandbox.  Weird!  Any help greatly appreciated.
Answer: You can have multiple org wide email addresses linked to multiple profiles. So that users can select each of them according to their requirement.
Here you can see from where to access.

And then define one for your organization.

You can have different set of org-wide addresses for each org.
Answer: Have you verified the settings in your Case Auto-Response rules in the Sandbox?
Comment: Found it!  Turns out that this (rogue) email address was under Setup>Communities>All Communities>Manage>Administration>Emails>Sender!  - Exactly where I would think to look for it when trying to get email to case working!
Comment: Yep, already checked that... Pulling my Sandbox into IDE to find out where that hidden instance is


How to find basis for subspace of $P_n(R)$

Question: I'm working on an exercise in Friedberg's Linear Algebra. The exercise is as follows
For a fixed $a \in R$, determine the dimension of the subspace of $P_n(R)$ defined by $S = \{f \in P_n(R) \ |\ f(a) = 0 \} $.
(The answer in the book is $n-1$)
This is my work so far:

We begin by considering an arbitrary element $f \in S$. We express $f$ as
\begin{align}
f(x) = b_0 + b_1x + b_2x^2 + \cdots + b_nx^n.
\end{align}
  Since $f(a) = 0$, it follows that
\begin{align*}
  f(a) &= b_0 + b_1a + b_2a^2 + \cdots + b_na^n \\
  0    &= b_0 +  \sum_{k=1}^n b_ka^k\\
  b_0  &= -(\sum_{k=1}^n b_ka^k) \\
  b_0  &= -b_1a - b_2a^2 - \cdots - b_na^n
\end{align*}
Reinserting this expression into our expression for $f(x)$, we have
\begin{align*}
  f(x) &= b_0 + b_1x + b_2x^2 + \cdots + b_nx^n \\
       &= (-b_1a - b_2a^2 - \cdots - b_na^n) + b_1x + b_2x^2 + \cdots + b_nx^n \\
       &= b_1(x-a) + b_2(x^2 - a^2) + b_3(x^3 - a^3) + \cdots + b_n(x^n - a^n)\\
\end{align*}

I'm terribly confused for the following reasons:

If we let $b_1 = -(x+a)$ , $b_2 = 1$, and $b_3, \cdots , b_n = 0$, then we have a nontrivial solution to the homogeneous equation.
I'm having difficulty understanding how the value of $x$ affects answers to the homogeneous equation. For instance, if we let $x = a$ in this equation, then clearly the equation equals $0$ (by hypothesis).
It seems to me that we could do the same thing as in (1.) for $x^2 - a^2$ and $x^4 - a^4$. That is, let $b_2 = -(x^2+a^2)$, let $b_4 = 1$, and the remaining coefficients equal $0$. Could we not do this for many of the terms of the form $b_{2k}(x^{2k} - a^{2k})$, producing many nontrivial solutions to the equation?

I feel as though I'm misunderstanding something fundamental about working with polynomial spaces. How do I determine the dimension of this subspace, and what role does the value of $x$ have to do with respect to the dimension of the subspace?
Comment: Since $\dim S=n$, not $n-1$, there is something wrong here. Are you sure that your definition of $P_n(\mathbb R)$ is the correct one?
Comment: Perhaps there is a typo in the textbook. The answer in the back of the book states $n-1$. My definition of $P_n(R)$ is "The vector space of polynomials of degree less than or equal to $n$."
Answer: Consider the following linear map $\phi$ from $P_n(x)$ to $R$:
\begin{equation}
\phi(f)=f(a).
\end{equation}
Then $\text{ker}(\phi)=S$ and $\dim(\text{im}(\phi))=1$. By Rank-Nullity Theorem,
\begin{equation}
\dim(\text{ker}(\phi))=\dim(P_n(x))-\dim(\text{im}(\phi))=n+1-1=n.
\end{equation}
Answer: Hint
$S$ is the subspace of polynomials $f \in P_n(\mathbb R)$ such that $x-a$ divides $f$. To obtain this result consider the Euclidean division of $f$ by $x-a$.
Therefore $\dim S= n$. And a basis of $P_n(\mathbb R)$ is $x-a, (x-a)x, \dots, (x-a)x^{n-1}$.
Comment: I'm sorry, I'm not understanding how one goes from $b_1(x-a) + b_2(x^2 - a^2) + b_3(x^3 - a^3) + \cdots + b_n(x^n - a^n)$ to the statement that "$S$ is the subspace of polynomials $f \in P_n(R)$ such that $x-a$ divides $f$. Or is my work incorrect/unnecessary in coming to that conclusion?
Comment: You can prove that $x^k-x^k$ can be divided by $x-a$ for all $p$. But an easier way is to consider the Euclidean division of $f$ by $x-a$.


Why is there no JRE for android?

Question: I understand that android does not use a JRE and Google has build a platform only for android. But an android device is not really different from e.g a Raspberry PI. So why is it not possible to just install Oracles JVM on a rooted android device?
Comment: Android may use its own JVM. But why is it not possible to use the official oracle JVM?
Comment: Umm... Android already uses Java and it's own JVM, APK's are compiled Java applications
Comment: If you are looking for a technical answer, I don't have one, that is beyond my knowledge of Android, I just know it doesn't work. Probably because regardless of most people, Android is NOT Linux and it is different. There are Java Emulators for Android such as JBED, JBlend, or NetMite although they do require root access and some tweaking, but most were developed for Android 2.X and I can't speak to whether they work in modern devices. Perhaps someone else can give you a better answer (which is why I am purely in comments and not providing an official answer)
Answer:
Why is it not possible to just install Oracles JVM on a rooted android device?

You simply don't just install something on Android. Installing apps requires a bunch of stuff.
Also: You can't just install ordinary applications, frameworks etc like on a PC (there are apps that allow this in their own container).
There is an ongoing dispute between Oracle (Java) and Google (Android) about Java APIs and code. (https://en.wikipedia.org/wiki/Oracle_America,_Inc._v._Google,_Inc.)
You are already running a Java virtual machine that is integrated into the system (DalvikVM, Android Runtime ART) and is able to run basically all non-proprietary Java code (no sun package).
If you really want to run Java code, make a simple one button app that calls the code you want.

Why is there no JRE for android?


Unifying ToolstripButtons and ToolstripMenuItems

Question: Almost in all cases, ToolStripItems do just what their equivalent MenuStripItem do. In these cases, ToolTip, icon and text of these two commands are the same. So, is there any way (preferably a .NET native way) to synchronize and unify these two items? This might be a way to define commands somewhere else and just put them into various strips.
Comment: I am not clear on what you mean by unifying the items and what exactly you want to achieve. They both inherit from ToolStripItem, so that is a common point
Answer: You should take a look at the command pattern which will allow you to encapsulate the logic that you want to call from both the ToolStripButton and MenuStripItem.
This Stackoverflow post provides some examples of implementing the command pattern in .net and this answer I provided shows how to provide a generic way of binding commands to buttons (this can be very easily adapted to work with other controls such as ToolStripItem).
There is an ICommand interface for use with WPF but there is no reason why you cant use it in your Windows Forms application.
Finally, if you want to provide other common properties for the command such as command text or an image I would suggest deriving a new interface from the ICommand interface (for eaxample, called IUICommand) which provides these properties. It won't take much effort to enhance the CommandBinding class shown in the link to set the appropriate properties in your ToolStripItem.


Algorithms to get intent of an article?

Question: I am currently working on a project where my job is to intent analysis of an article. Suppose i am given with the article and i want to classify that what kind of article it is?. Any suggestions, Which kind of model would be best to apply?
Comment: Find embeddings of the query and the documents, then perform similarity search. Use pre-trained embeddings, if possible. Welcome to the site!
Answer: I think the easiest way would be to cluster them with wordvectors.
The "20 Newspaper" dataset would be a good test for the algorithm
http://qwone.com/~jason/20Newsgroups/
On the Sklearn Website, you will find some easy example for using wordvectors and classification:
http://scikit-learn.org/stable/datasets/twenty_newsgroups.html
If you go deeper into this space you could start using LSTM networks and neural networks, but this is a little bit harder to develop. So first, try to use the problem statistically. If you want to analyze the text semantically you will need LSTM.
I hope I could help you.
Comment: @kanavanand: If you know more about what you are looking for, please put that into the question. You asked for "any suggestions" with no details other than you want to classify articles. Your comment here implies you don't even actually want to classify the articles, but find similar articles in your dataset. Please have a think about what it is you really want and edit your question to include that information. This is important, because writing answers takes time and effort, no-one wants to do that if it isn't even useful to the person asking.
Comment: Hi Christian thanks for your answer but i am looking more like the keyword based model. for example if you i give some particular keywords , my model look from set of of some articles and give the best articles(keyphrase extraction)
Answer: It sounds like you are trying to classify each article based on a set of tags that are inherently generated from each of the articles.
As an alternative to Christian's solution (which I think does serve the purpose that you had described), you could consider using an N-Gram model and Parts-of-Speech (POS) tagging in order to do the following (in this order):

Calculate the frequency of recurring, common phrases within a document / corpus
Apply POS tagging to classify nouns (proper and common), verbs, adjectives... etc.
(Optional) Apply some sort of rule to only select the top Y most frequent terms

Using a standard language model, you can compute the relative probabilities of those words occurring within each document to then weight which article is most likely to mention a certain tag.
You can learn about creating frequency tables, POS tagging, calculating relative frequencies with the attached links (in python).

Algorithms to get intent of an article?


iOS 6 app hangs at splashscreen JQTouch + Phonegap

Question: I have a weird problem with an App i'm developing with jQTouch and Phonegap. The App works fine most of the time, but sometimes (seems random) the App is stuck at the SplashScreen. Sometimes it still opens after a few minutes. It does nothing more than just load the HTML, CSS and JS files (no Ajax request or whatever). Is anyone familiar with this problem, or any ideas how to debug it?
Thanx!
Answer: Me too. I think we need to upgrade phonegap for our app.


How to make Linux Fedora stop updating VirtualBox with OS updates

Question: When my computer updates Fedora, among others, it tries to update VirtualBox. But for some reason, it can't access the repository in VirtualBox.org and so it cannot update my OS. How do I make VirtualBox updates be only manual?
Answer: More appropriate solution is to disable the repo. In /etc/yum.repos.d/virtualbox.repo, there is line enabled=1. You can change it to enabled=0 and your virtualBox will not get updated automatically.
Comment: Posting the "some problem" would help ....
Comment: I tried that, and Fedora said that there was some problem with the file... as if I put something wrong in. I have checked and rechecked it, I only have changed that one number. Should I do what Icaro said and entirely get rid of it?
Answer: Just remove the .repo file from the /etc/yum.repos.d folder.
The content should be like this http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo .
Answer: Apparently at some point my OS got messed up. I just installed Fedora 23 and there is not a problem. There were a lot of other problems with my computer at that time but after I reinstalled Fedora, now it is working.


Sass development workflow issues

Question: I've been trying to adopt Sass into my development workflow. I do primarily front-end development and as such, I am updating stylesheets quite frequently. After endless searching, I have yet to find the answer to what I feel should be a simple question.
I use both Coda and Textmate, so a solution for either would suffice. When developing locally, I open the terminal, get my .scss file watched, then go to town. I save my .scss file, it happily updates my .css file... and then I'm left with the slight annoyance of having to manually select the .css and publish it to the remote server. Its not the end of the world but having to pause my usual dev workflow to manually upload a file I'm not actively in is becoming a nuisance. In Coda, it doesn't detect when a file has been updated outside of Coda, so it isn't marked for publishing. Its driving me crazy. I just need a way to save the .scss file and have the .css file easily/automatically uploaded to the remote server. Any help would be greatly appreciated!
Comment: IMHO Grunt/Gulp or any task runner with remote publishing plugins would be the best answer to such inconvenience now, three years later.
Answer: The typical way Sass is used is to design on your local computer while using Sass, and to only upload the CSS (and probably the Sass as well) to the server once you're finished. Another alternative would be to run sass --watch on the server so that it compiles the uploaded Sass files.
Answer: I have had a rake task that calls rsync for this kind of cases. That still needs to be run each time but because it uses rsync only the changed files are moved. Now, while reading this I got an idea that shouldn't there be 'rsync watch' somewhere and indeed there seems to be: http://code.google.com/p/lsyncd/
Answer: Here's an interesting approach I just read about, installing compass into a small local ruby env, inspired by python virtualenv:
http://rhodesmill.org/brandon/2011/adding-compass/
YMMV (I haven't even tried this myself).
Answer: The Sublime SFTP/FTP Plugin can monitor and auto-upload the .css output file whenever it's updated by the SCSS compiler.

Map your project directory to your server
Check it's woking correctly by browsing remote
Right click on your .css output file, and choose 'Monitor File (Upload on External Save)'
Keep the file's tab open in Sublime to ensure it stays monitored/uploaded.

For extra points, have a look at Browsersync or LiveReload.

Sass development workflow issues


Change XFCE desktop font color?

Question: I'd like to change the text color(under icons) on my desktop. I already tried editing the .gtkrc-2.0 file but it doesn't seem like there's one.
Comment: I use version 4.10
Answer: As Xfce 4.10, the .gtkrc-2.0 file still has some influence over the text color for desktop icons.
First, open .gtkrc-2.0 file in your text editor of choice. Or, if the file does not exist, create an empty file named .gtkrc-2.0 in your Home directory.
Then, add the following code to the file:
style "xfdesktop-icon-view" {
XfdesktopIconView::label-alpha = 0
fg[NORMAL] = "#ffffff"
fg[SELECTED] = "#ffffff"
fg[ACTIVE] = "#ffffff"
}
widget_class "*XfdesktopIconView*" style "xfdesktop-icon-view"

As noted from this article on blog, you will have to change the hexadecimal codes by replacing the #ffffff instances. I'd suggest you to use a color scheme application such as agave to find the hexadecimal codes for the color you want.
Compatibility: As Xfce 4.10, the line containing fg[ACTIVE] seems no longer valid and brings no effect to any visible changes (at least on my side). It used to work for the previous release Xfce 4.8.
Tested working in Xubuntu 14.04 (Xfce 4.10).
Answer: Xfce uses a file called themerc in which you can specify a whole list of settings, including the font color you are asking about.
If no color is defined in the themerc, it falls through and will look for a color in the gtkrc or gtk.css instead.
So you just need to add a line specifying the font color in the themerc, and likely also change the background color and inactive color.  On Mint 19, this is located in /usr/share/themes/theme name/themerc .
A complete list of the settings you can put into the themerc file is found at:
https://wiki.xfce.org/howto/xfwm4_theme
in the section GTK color pickup.
To change the background color of the title bar is not as obvious:  You need to change the color in the .xpm files in the theme directory.  There are 120 or so files to change, so it would be laborious to do manually, so I suggest using the command line to change them all at once.:
Use the find command to find all *.xpm files with the -exec option and the command you use on each file is sed -i (for changing a file in place) and then the color to change (with the octothorpe, which only occurs in color definitions in an .xpm, such as #4b4b4b) and the new color (with the octothorpe, example: #24248f)
To find the 6 digit hexedecimal number of a color you can use one of the color picker programs that comes with linux, such as pick, Gpick, or Color Picker.  I use Color Picker from the Mint repository.

Change XFCE desktop font color?


How to deal with the previous DM's broken homebrew items?

Question: I joined a campaign around the start of paragon tier and now at level 17 the DM is unfortunately moving away. I'm the only one who's DMed before so I was chosen to take over after he's gone. The biggest problem is that he has introduced a fair number of outrageously powerful homebrew items. As an example last encounter we got a staff that gave +20 attack and +7 damage and ignored all resistances. The distribution of these items also hasn't been equal, the ranger has gotten nothing but enchanted arrows while the bard quite literally has more than 2000 health at level 17. Our attack values range from +20 to +70 and the defenses have a similar ranges. The previous DM basically made every encounter feature gods that have attack and defense in the 100+ range then openly talked about he had to nerf them down to our level. I have no idea how to make encounters work with these numbers but don't want to make the characters that rely heavily on these mechanics have to completely rebuild their character's item set. Is there any good way to handle this?
Comment: Yeah; I was going to suggest "Okay guys, lets start a new campaign." myself.
Comment: Do you actually *want* to DM this campaign?
Comment: I enjoy DMing and would like to get back into it, I just am struggling to figure out how to get the campaign under control.
Answer: Talk to your players as people

"Hey guys, so I'm taking over to finish out this campaign.  You know
  and I know that this game is already complicated enough, and the
  previous DM did a lot of game design with math the books don't support
  at all, and I'm not going to be able to match or meet that.  So here's
  what we're gonna do - I'm going to downstat the items to powerful but
  within tolerances for what the books support.   This also means if
  you're fighting gods or whatever they, too, will not have +100 Attack
  Bonuses or 10,000 hitpoints or so on. It'll be proportional, and I'll
  try to get you some fun encounters and a good story.  That's what I
  can do."

If the players aren't happy with that, then everyone can save each other's time - you can't run on the previous GM's weird math, even if you tried, and they won't have a good time watching you flail in the dark on how to do so.  If the players are only there because "More hitpoints = more awesome" I don't really think there was much of a game to begin with.
Tell them what you're facing and if they're ok with it, you can have a great game continuing onward, it's just going to work better when you've got math the books support, the forums and all the other players out there with expertise, can give you advice on.
"Nerfing" down-stat-ing, etc.
You can basically pull weapons from the DMG and use those stats.  Given how over the top the game has been, I would consider maybe giving items an extra feature or allow it to do something really powerful but a limited amount of times.

"Ok, so the staff is using the highest magical weapon stats you'd
  normally get, and I'm giving it a daily power to ignore resistances
  for 3 combat rounds.  Not all the time, but you can figure out when
  you want to use it and it's still really powerful!"

Party Balance!
If some of the characters are vastly underpowered compared to others after you've done the downstats, which, by the way, you can now compare using the core rules now that everything isn't in super-high math mode, you can look at what kinds of weapons/armor/etc. will even out the party.
They've been fighting Gods, I'm pretty sure they can find, have gifted, or something other magic items to round that out.
Monsters! Threats!
There's a lot of people who have written about "reskinning" monsters in 4E.  "Reskin" basically means you change the description of the monster, but keep the same math.  The example I remember was someone having demons that were simply using the math and stats for goblins.  "I'm fighting hordes of demons!" etc.
You're going to do the same thing here for the gods or whatever the players face next.
If you want to change anything to keep the epic feel, I'd consider downgrading the hardness/hitpoints for inanimate objects and scenery.  Instead of epic gods doing 300 points of damage, they can do the appropriate 17th level damage but things like castle walls, giant boulders, etc. might have 1/2 or 1/4th their normal hitpoints - meaning the monsters and the uber weapons the characters are wielding all blow through these things and keep that feeling of mythical damage and power without having to make you design new math for the game.
What makes fights fun in 4E is great environments and staged monster fights with fun gimmicks, not bigger numbers.   So focus on those things and that's where you'll find more fun to be had.
Comment: +1 for talking to other people at the table like actual people :)
Answer: So, a lot of people mentioned this in comments but it doesn't appear to be adequately covered in the answers yet:
Start a new campaign!
You will save yourself immense amounts of headache.  You should, of course, have a conversation with your former party members who are now your players about this, but you almost certainly can't take over the other GMs campaign.  This isn't just because his campaign has weird items, it because his campaign isn't yours.  Having taken over campaigns myself, and having trained others to do so for me, I can tell you that getting this to work well is never a sure thing and practically requires that the GM stepping down sit down with the new GM and talk them through stuff.  If the leaving GM is taking an active role in your preparations, then you may be able to actually take over the campaign with just a few modifications (you should still talk this over with your players, though).  If not, you are going to have several other problems as soon as you try to actually run the campaign, many of which (unless you've done this before) you won't expect beforehand:
Iconic NPCs won't work right and/or will upset some players
The way the previous GM ran important NPCs is going to be different than how you run them.  The common personality types, dialogue patterns, etc are all going to change.  This isn't really a problem, except in the case of NPCs the party frequently interacts with that are far from the kinds of characters you normally run.  These NPCs will seem very 'out of character' or 'forced' when you run them, leading the players of characters with strong ties to said NPC to become upset and/or you (as a former player) to become upset yourself.
The things your new players liked best about the game will probably not be as good as it was before
Unless you are unilaterally superior as a GM to your predecessor (which is possible), the thing your previous GM was best at they were probably better at than you.  You are going to struggle with meeting the players' inflated expectations in the former GM's specialty.
Dropped megaplots
This is likely a non-issue given the nature of the previous game but if the previous game did contain some kind of overarching plot (or, worse, several incomplete plotlines of differing lengths) you will have trouble tying up all the loose ends.  Generally this isn't a problem until someone notices one, and even then you can just admit that some things got fuzzy when you took over, but is a frequent issue nonetheless, and requires a lot of GM work.
You won't have fun
For a lot of GMs, the thing that makes GMing fun is getting to come up with all the cool stuff that the other people play in.  If that's the case, you, personally, might not be able to take over another GMs campaign at all.  A significant minority of the GMs I've had involved in these sorts of things run the campaign they take over just fine for a bit, but hated doing it because they were stuck running things "in someone else's world".
All of the above concerns can be mitigated (and might not even apply to you), but you should really consider whether or not they are worth mitigating.  Why not start a new campaign?  It will probably be a lot easier and, unless the game is crying out for closure, you will almost certainly be better served making a new one than continuing the old one.
Answer: You've definitely landed yourself in a pretty crappy situation there.  The only definite way you're going to keep everyone happy is to continue DMing like the last guy did, which you're clearly not okay with.  There are two solutions that I see to your problem.
Make them want to give up the items
Just outright taking the items and telling your players "Hey, these were incredibly broken and don't work in a normal game, we're not using them anymore" is a really good way to get your players angry with you.  Instead, give your players a good reason to want to get rid of the items using in-game justifications.
For example, maybe you could invent a ritual that will consume these items, but give the person who sacrifices their item a really cool utility power.  Maybe introduce new items that are also really awesome, but don't mess with numbers quite so much.  It's way easier to have a mostly-sane game of 4e where the fighter can slide 10 once per encounter, rather than one where he has a +20 sword.
This works even better if you can get player buy-in, and maybe let the players help design these new items.  You may also want to offer full or partial re-specs to allow players to make their characters work better with these new items.
Alternately, let players trade their items for roleplaying rewards.  Maybe that awesome staff is something that a great archmage wants, and he offers the party ten free teleports to wherever they want in exchange.  Maybe the bard can sacrifice some of his health items in exchange for a dukedom in his favorite country.
End this game quickly ,and start a new one.
If you don't think your players will go along with getting rid of their items, your only real alternative is to play a different campaign.  However, it's likely that your players are invested in their current characters, and it sucks when a character you like doesn't get a good end to their story.  Spend the next several sessions wrapping up as many plotlines as you can, and do your best to give the game a satisfactory conclusion.  You may have to do a lot of handwaving on the combat stats of monsters during this time, since it's clear that your previous DM was doing the same.  Once you feel you can end the campaign in a way that your players will be mostly satisfied with, finish it.  I find that it helps to give each character their own denouement, where you let the player describe what their character would do after the campaign, and embellish a bit on the character getting their wish.  I tend to ask "What does your character do after the campaign ends?", and then describe more fully what the player tells me.
This way, your players will feel more fulfilled with the end of the campaign, and less likely to revolt when you take away their shinies.  You can even start the next campaign in the same world, to make your players more invested in their new characters.  Since you'll have a whole new campaign, you'll be able to keep the magic items sane to start with.
Answer: No, there isn't.
Option 1: Power Everybody Up
You can give everybody gear to bring them up to parity with the most overpowered character: everybody has a god-like attack bonuses, defenses, damage, and health (with variances for stats and classes, of course).
Option 2: Nerf Everybody
Take away all of the shinies, and replace them with level-appropriate gear (or, at least, to parity with the least-powerful character's kit).
Option 3: New Campaign
Start a new campaign.
Pros and Cons
Option 1 lets the players keep their numbers high, and lets you add a static +X to all NPC attacks and defenses, with a *Y multiplier for HP. What's the difference between player ACs ranging between 5 and 15 vs. 55 and 65? A +50 bonus on NPC attacks.
Option 1 unfairly gives really awesome stuff to the characters that have contributed the least to the party getting to where it is ("what do you mean, the Ranger gets a +40 bow; he never hits anything, anyway, and I need another +5 for these gods"). It also "just" makes all of the numbers higher for the sake of being higher.
Option 2 brings the party power level back in line with what the system expects, allowing you to bring in external modules, standard monsters, etc., all without having to figure out what the "Horrifically Overpowered PC" bonus needs to be in order to maintain balance. It also dings everybody.
Option 2 nerfs everybody: even the ranger, with his measly +20, is going to drop down to a +18 (and, the loss of those awesome arrows is likely to hurt, too). Plus, "why should I have to give up my +50 Sword of Smiting just because you can't figure out how to run a campaign with it?".
Option 3 lets the current god-like characters retire into glory (potentially becoming gods in their own rights), and lets the players imagine how those characters will continue to effect the cosmos.
Option 3 forces the players to give up the characters in which they've invested so much time and creative energy, just as the story is reaching the "next level" (the level 20-30 tier).
Conclusion
Of all of the options, the least bad is likely to be 3: run a session or two which get the characters clearly set on the path to glory, then wrap up the campaign with some great narration about how they become gods or something. Then, start a whole new story (possibly set a hundred years later, letting the players deal with the fall-out of their past characters' actions) and keep the power level reasonable.
... well, that or start the next session with "rocks fall, everybody dies" and move on to a new system for a while ...
Answer: Replace them, after telling them you're going to do so and why. Note to them that any complaints you get about doing so will reinforce your decision to remove them, but note that the repalcements will be of the same effective level as items.


Dynamically change About dialog text in RCP based application

Question: Are is possible to dynamically change About dialog text in RCP based application? I want to replace aboutText value when About dialog opens by dynamically changing some part of it's text. Problem is that I has a client/server application, where information about client can be static, but server information (at least version string) may change independently and I don't know when it will happen. aboutText itself is static text. about.mapping approach also not work, because this file is packed into application JAR and because of this is read-only too. Are there is a possibility to subclass aboutText or update it in another way before About dialog show it? I not want to rewrite the all Eclipse About dialog class from scratch.
Answer: You can use system properties in about.mappings to achieve this:
Create an about.mappings file at the root of your app plugin
Add lines such as 0=$net.dnorth.about.text$
Reference {0} in the aboutText set in plugin.properties
Now call System.setProperty("net.dnorth.about.text", "your dynamic text here") in some code at start-up.
Reference: https://bugs.eclipse.org/bugs/show_bug.cgi?id=172692
Answer: The about text of the IDE is instance specific i.e if you are running a RCP application then at that time you cant change the About text.It is only possible if you update your RCP with via Check for updates link or if you install another IDE over the present one.
I these two cases only you can change your about text.


A problem on determining coriolis force on frames

Question: First of all I am defining x axis in east of object and y to be in the north of object . Let us suppose a body is falling from a height; then after falling a certain height indeed gain some velocity in the direction which I am defining in the local height of the observer in z direction.  indeed in a rest frame outside Earth it would not have velocity in y or x direction  but in a frame standing still on earth (perhaps moving with earth) it will gain a velocity in the east direction and y direction so when I determine the coriolis force for a certain moment then to determine the coriolis force while doing the matrix of 2$m\omega \times v$should I put $\vec v$ is equal to $\dot x\hat{i} + \dot y \hat{j} + \dot z \hat{k}$ as in the in the earth rotating frame it has velocity in the x and y directions but in the rest frame outside earth it never has velocity in x or y direction. So should I put  $\vec v$ =$0\hat{i} +0\hat{j} + \dot z\hat{k}$ ?  Show my exact question is that what should I take as the velocity to detect the velocity as the perception as in perception of a rest frame outside Earth or should I take the velocity of a observer who is in the earth frame who can't perceive his own rotation so sees the ball shifting.
Comment: I think this could be a good question but it's not exactly clear what you're asking. Can you clean up your question a little bit?
Comment: @ZackHutchens when an object falls down in earth which is a rotating frame then it would have some velocity in z direction or in local height of object but after subsequently falling it gains some velocity in x and y direction.  So while determining coriolis force.  $\2m \omega \times v$ should the v represented as earth standing observers perception or in rest frane perception outside earth. I think you may be able to understand the question now and you are welcome to suggest edits to clarify the question.
Comment: @ZackHutchens is it clear now ?
Comment: I think so. I posted an answer. If it does not help, then you can ask questions and I will try again.
Answer: The equivalent of the Newton's second law in the noninertial frame is expressed as
$$m\ddot{\vec r} = \vec{F}' - 2m \vec{\omega} \times\vec{v}.$$
Here everything is written in terms of the rotating coordinate system. $F'$ is the actual net force on the system, but it is written to be a function of the rotating coordinates. It also absorbed the centrifugal force, so in your case $\vec{F}' = m\vec{g}$ but $|\vec{g}| \neq 9.8$ N/kg.
So, the point here is that $\vec{v}$ is taken to be in the rotating coordinates -- is the viewpoint of an observer fixed on the Earth.
Thus for the initial velocity you have $\vec{v}_0 = \dot{z}\hat{k}$. As the object begins to fall, it will become deflected from the Coriolis effect, and this velocity will in accordance with $\vec{v} \times \vec{\omega}$. However for the Earth, $\omega$ is quite small at $\sim 10^{-4}$ s$^{-1}$. Thus, to a first approximation:
$$m\ddot{\vec r} = \vec{F}' - 2m \vec{\omega} \times\vec{v}_0,$$
which will allow you to calculate the longitudinal deflection (in the x-direction).
As given in Goldstein p. 174, if you have that text, the corresponding inertial frame is a coordinate system which is stationary with respect to "local stars".
Comment: Ok so i see you are saying $\vec v$ should be taken in perception of the rest frame observer outside earth .( Probably stars' can be regarded as rest frame as their rotation is negligible. ) . Please justify this comment.
Comment: It's a good approximation to neglect the deflection $v$ because otherwise it's a really hard differential equation to solve. And yes, the local stars are a good approximation to an inertial coordinate system because their rotation is negligible.
Comment: if v is taken in perception of outside earth observer (who is in a rest frame) then it has velocity in z direction only ; it never really deflects in other direction. So you'd never need to estimate or neglect anything. There's the problem.
Comment: Correct. This may help: https://www.youtube.com/watch?v=49JwbrXcPjc
Comment: neglect the previous point. I think i got it. You are saying $\vec v$ is taken in rotating frame. But the invariance is shown with stars frame.


electronic dc voltage regulator controlled by arduino

Question: i am new to the electronic things so please help me figure out a solution.
I am looking for a way to control voltage by Arduino of my 60volt 10 amp dc power supply i.e to get any voltage from 0 to 60 accurately.I need to control temp of equipment by controlling the voltage.I looked for digital potentiometer the do not support high power uses.So i need help.
Comment: Is there a reason why you cannot use PWM and must instead use a variable voltage? And there are lots of closed-loop PID control modules available, very cheap. You should be able to just buy a solution without the Arduino and the rest. Look for "digital PID temperature controller".
Comment: What does "accurately" mean to you exactly? Please provide a link to the manufacturer's user manual for the power supply or specify precisely how you think it can be controlled by some external signal.
Answer: For temperature control the standard practice is to use pulse-width modulation (PWM). By varying the width of the pulses the average power can be adjusted.

Figure 1. PWM signal transitioning from high pulse width (75%) to low (25%) and back again. Note amplitude remains constant. This will result in 75% power, 25% power and 75% power again.
To control the power you use a transistor or MOSFET to do the switching. A web search for "Arduino PWM switching" will give you plenty of examples.
Comment: Thanks, Spehro. I'm not sure we're ready for that.
Comment: +1 Might be worth explicitly mentioning that controlling voltage gives a **nonlinear** heater power proportional to voltage squared for a fixed heater resistance, whereas PWM, as you say, gives linear power with duty cycle.
Comment: i actually looked for pwm controller but they all have a mechanical potentiometer for voltage control but i have to control that electronically.How could i do that?
Comment: You do the PWM with the microcontroller and use that to switch a transistor or MOSFET or, if your frequency is very slow (>= 5 s duty cycle) you can use a relay.
Answer: i think you might actually want a pwm controller, not an arduino. not to say that arduino cant do that, but youll need additional hardware: mosfet, maybe inductor/transformer, when i think your task probably already has a commercially available solution. depending on the application you might be able to calibrate something like a motor speed controller, or here is something specfic to temp control, i know ive seen others better suited to what little you have described so far
Comment: i actually looked for pwm controller but they all have a mechanical potentiometer for voltage control but i have to control that electronically.How could i do that?
Comment: @saurabhkumar depending on cost and what you have available you could use an arduino and a servo :p yea thats not ideal. it would depend on the specfic controller in question, you might be able to simply replace the whole thing (pot that is) with digital signals. are you sure you need to have the voltage vary? ive never seen a heating system work like that, its almost always pulses of one set voltage at some percentage duty cycle. transforming voltage on the fly like you are describing would require either several dozen transformers of varying sizes, or would be HORRIBLY inefficient


Tactics versus new "updated" engineers

Question: With the new engineer update, some old tactics seem to no longer work against certain sentries.  Specifically I'm talking about a level one with a shield.  The only ways we found to bring them down was to send a spy in to sap then have an ubered demo lay a stickie nest around it and blow it all away.  Soldiers and heavies straight on ubered seemed useless unless they got on top of the sentry or we had a scout or something distract it.  Anyone else find anything that works?
Comment: @Corv1nus: Please do me a big favor: correct the spelling mistake in the title. :-) "udpated" *really* grates!
Comment: this is similar to: http://gaming.stackexchange.com/questions/1/in-team-fortress-2-what-is-a-good-strategy-to-deal-with-lots-of-engineers-turtli
Comment: @marco - this other question tend to focus more on handling the amount of engineers caused by the update, more than specifically countering the new weapons.
Comment: @Gnoupi your are right, maybe is better to specify in title, instead of new (it is true till the next engy items or update), the weapons the question is referring to.
Comment: Updated for clarity
Comment: Done :)  (15char)
Answer: If the Wrangler is your main problem, I would recommend the same tactic as against the heavy/medic combo: shoot the little guy to take away the big guy's advantage.
Focus on shooting the engineer first, as opposed to earlier when only killing his sentry mattered. This is the main difference.
Also, move fast. remember that with the Wrangler, the sentry's accuracy depends only on the engineer, so on a human. If you make a rocket/sticky jump, for example, he will have difficulties to follow. Same for a scout.
Comment: +1, but to be honest you should always target the engineer first even if he doesn't use the Wrangler.
Comment: That kind of renders heavies useless against them.  Bummer, that's my main class.
Comment: A good sniper or spy who focuses on the Wrangling engineer first can work wonders.  Especially since their attention is on aiming, not on watching their back, and the sentry itself will power down for a time, letting the spy go to work on sapping.
Answer: Since you're playing a heavy mostly, your best bet vs a wrangler engineer is tanking. Team up with a medic out of range but in sight and start building up ubercharge. This will prompt the engineer to start attacking in your general direction, because you're a direct threat to what the sentry is defending.
While you do that and sustain some damage, you should let your teammates finish the job. The bane of a wrangling engineer is the sniper. Usually the main reason for your continued wrangling is you need to cover an area that is too large for the standard sentry range to safely cover. Most maps are indeed arranged this way. A wrangler allows the engineer to overcome this and gain moderate long range capabilities.
However, that means exposing yourself to snipers. The engie can deliver a fast stream of low DPS damage in the sniper's general direction (the sentry's aim assist helps here) while the sniper can zoom in and go for the headshot, or the charged bodyshot. One shot one kill. Once the engie is gone, the same sniper can easily destroy the exposed, shieldless sentry. As you can see, one good sniper can get rid of an unwary engineer quite effectively.
Since the sniper usually takes cover in dark corners as far as possible from the sentry, this usually spells doom for an engie; he just has to rely on his teammates to take them out, or he has to notice them, in which case the engineer must defend his sentry, rather than the point.
This covers long range engineers; for smaller areas, there's really no need for wranglers except in a few situations:

Scouts using bonk. Sentries just love to target them; a wrangler helps regain control of that. The counter is that the scout should take this opportunity to get in melee range of the engineer, where he can deal big damage, then shoot down the sentry in the two seconds period of post-wrangling sentry inactivity.
Long range stickies. Using a sentry's fire to remove those is something that hardly ever can be done in time (the demoman usually notices you noticed and detonates immediately) but can otherwise be more effective than using a pistol or, worse, a shotgun, thanks to the higher rate of fire (less chance of missing).
Countering ubers. There's not really much an engineer can do to counter a heavy uber, or worse, a kritzkrieg soldier uber. The options are wrenching the sentry while it takes damage, hoping not to die in the process, or wrangling the sentry to give it much more effective hitpoints while firing towards other vulnerable enemies joining in the party. Again, kill the engineer first and the battle will be won.

Other stuff that can be effective against wranglers is stealthy backburner pyros. If you're wrangling you're usually doing tunnel vision to the area you're trying to cleanse. A pyro can just run in and burn everything down in seconds.
So, we've covered the heavy, the medic, the sniper, the scout, the demoman, the pyro, the soldier, what's missing? Um, ah, yeah, the engineer, but there's really not much to say about that. Just place a nearby teleport 3 and eventually everything will sort itself out.
So that about wraps it up! As you can see a wrangler engineer doesn't really have an easier life than before. He's still awfully vulnerable to all other players and will fall at the first mistake. So long as you're playing a real cla—
Respawn in: 12 seconds
Bah. So, yes. The spy. The wrangler is useful for the extremely paranoid engineer, who can just fire his sentry blindly all over the place, perhaps get lucky and hit a cloaked spy and get an achievement for it. However, the engineer must remember that a sentry, while wrangler, fires at twice the rate. That means it consumes ammo, and thus metal, twice as fast. Basically you can't be firing forever.
This means that you can use the wrangler to spycheck, but only if the spy's visible in some way. In this case a non-dead ringer spy doesn't really hold a chance. A dead ringer spy has to move away from you, due to his loud decloak sound, so at least you can reliably fend him off

Tactics versus new "updated" engineers


Parent to child on trigger update

Question: I have two object X and Y. Y is child of X. Object X is having a field called Title (Long Text Area). I want to show this field on Y also. Cross-reference formula field will not work since Title is a Long Text Area field. I don't want to write a trigger on object X since there are many triggers on X and it might hit governor limits. Is there any way to do so? Any thoughts?
Comment: You can try creating a custom VF page that pulls the Title field's data and add this page to your child object's page layout.
Comment: Sounds like it's time to clean up your triggers on object x
Answer: Option 1) Trigger on the parent object X to monitor for changes to title and cascade to child object Y
Option 2) Inline visualforce page on child Object Y that queries the Long Text Area from parent object X (from @Vijay_Prakash)
Regarding option 1, this is typically a pretty light weight operation, you just need N query rows, N dml rows, 1 query, and 1 dml, where N is the number of child Object Y related to parent Object X.  If you're ensuring your trigger only processes changes for a particular parent Object X if the Long Text Area changes (see this answer for more discussion).
Comment: I am doing that which is working fine but suppose later on someone changes Title on X then how to accommodate that change. In that case I would have to write a trigger on X?
Comment: Just fixed some typos in my answer, which may clarify things (object x and y is a little confusing, i added parent/child to clarify).  You don't want a trigger on the child object Y, you want it on the parent object X.  Since object Y is the master source for the field in that case you'll want to make the field on the child object X read only.
Answer: I suggest to write a trigger, it will work in all condition.
<code>trigger UpdateFieldInChild on Parent(after insert, after update) {

List<Child> conList = new List<Child>();

for(Parent acc: Trigger.new)
{
    String newValueInUpdateChecking = acc.Update_Checking__c;
    for(Child con: acc.Childs)
    {
        Child conObj = new Child();
        conObj.Id = con.Id;
        conObj.Update_Checking__c = newValueInUpdateChecking;
        conList.add(conObj);
    }

}
Update conList;
</code>
}
Hope this will help you.
Thanks.
Comment: Welcome to SFSE! This is a very old question, and there have likely been updates to the best practices in the past 5 years. There are a few things I'd like to mention about your answer. First, OP (**O**riginal **P**oster of the question) clearly stated that they did not want to write a trigger, so it'd be a good idea to mention _why_ you think a trigger is necessary (even though OP doesn't want to use one). Second, this trigger won't work as written because trigger context variables don't contain any data on related records (such as child records). You'll need to query for that information.
Comment: Finally, this answer is what's known as a "code dump" (the majority of the answer is just code, with no explanation of what it does or how it works). Code dumps tend to generate a lot of back-and-forth in the comments along the lines of "that didn't work" and "try this instead", and are therefore not high-quality answers.
Comment: When writing answers, I like to keep in mind that other people, with similar (but different) issues will be looking at my answer for help as well. Providing a solution that can be copy/pasted also means that the person copying the solution is unlikely to have learned anything (part of the goal of this site is to help others grow as programmers/admins). Wrapping things up here, a good answer will tend to cover some common points: 1) _What_ is the problem? 2) _Why_ it is a problem 3) _How_ to fix the problem and 4) _Why_ the fix works.

Parent to child on trigger update


How to handle queue of background tasks in Android?

Question: I am new to Android programming and my scenario goes like this.
I have several tasks which are in queue like this:
Name.       Time.(sec)   and some other attributes
Task 1      0
Task 2      1.5
Task 3      3.5
Task 4      6.5
Task 5      9.5
Task 6      10.5
Task 7      11.5
Task 8      12
...

This table basically says that execute Task 1 at 0th second, Task 2 at 1.5 second, Task 3 at 3.5 second and so on. I am using Task 1 as the starting time i.e. 0th second. It may be possible that there are multiple tasks running in parallel i.e Task i may still be running when it is time to schedule Task j. All of these tasks are network-intensive.
As I said I am not familiar with Android and I'm trying to figure out the best way to tackle this in Android.
I am thinking of using one AsyncTask(let's say Queue) that loops through all the tasks and see if it is time to schedule any task. If it is not time to schedule any task then sleep till next schedule time i.e nextTaskTime - currentTime. If it is time to schedule then create Runnable instance(or may be another AsyncTask) for the Task and start the execution. So, basically Main thread will create AsyncTask named Queue which may in turn create other threads for Tasks.
Is this correct way to approach this problem?
If there are other ways then please let me know.
Thank you.
Comment: Using a handler would be my ideal choice! You can keep pushing your messages to the message queue of the handler and it would take care of it.
Comment: @AadiDroid : Thanks for the reply. Do you mean push messages to handler from AsyncTask (Queue in my case)?
Answer: You will the Serial executor it will execute the Background task serially likewise queue...
DownloadImageTask o1 = new DownloadImageTask();
o1.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);


The Twelve Bells missing beer style

Question: I'm stuck at getting Banshee's Tear, now I know that there are 23 competitors for every style, except one. But I only have 23 styles, is there anything I'm missing? Please help.
Answer: There are 24 different Beer Styles in Fiz. The 23 shown on the competition report for the Twelve Bells simply doesn't list one of them, and it's highly probable, at this point in the game, that you do have a recipe for it, and you just need to spot it in your list. Make a single beer of the missing style, and you'll complete the challenge. (Hurry though! The missing beer changes monthly!)
If, by some odd fluke, you do only have 23 of the styles available to you, you'll need to learn more recipes; the easiest way to do this is to keep brewing other stuff and smashing mice. You'll gain Recipe fragments that you can use to learn new brews.
Also, if you have any other open events, complete them. Some will award recipes!
Answer: Every month, there is one beer type missing from the competition list. But that changes every month, so you'll have to go through the list of beer types that Fiz has and see which one's missing, and hope that you can make and sell it that month.
Here are the 24 types of beer that Fiz has:

Amber
American Wheat
Barleywine
Belgian Blonde Ale
Belgian Wit
Brown Ale
Doppelbock
Dunkel
German Pilsner
Hefeweizen
Helles
Imperial IPA
IPA
Irish Red Ale
Lager
Maibock
Oktoberfest
Pale Ale
Porter
Rauchbier
Russian Imperial Stout
Saison
Special Bitter
Stout

One beer type will be missing from the above list. Sell that beer to the Banshee and you're good to go. It would probably be helpful to buy the speediest equipment you can and dump craft points for your batch into speed.

The Twelve Bells missing beer style


size of /root and /home partition

Question: I'm using linux for the first time.
I will not use it as my primary os till i get the hang of it.
So i have made my /root: 14GB, swap: 6GB, /home: 9.5 GB.
Is my set up enough for experimental usage?
Comment: Hard to say ... If you're going to download 3 sizable movies home will be full. If you're only going to do python development it may work like this forever.  That said: swap is rather large, how much RAM do you have?
Comment: I have heard that swap partition should be double the size of ram or 1.5 times is ok, i have 4gb ram. So i have made the swap partition 6 GB
Answer: If you are using Linux mint, I'd suggest you this:
Your root / partition will have almost all the binaries, configs, and almost everything that your systems needs to live. I usually spend 50GB on my root partition just to be sure that I'll have all the space that I could possibly need.
Your swap partition usually (not always) needs to be at least the same as your RAM, I have 12Gb from RAM, I have a 10Gb swap partition, this way I'm almost secure that if I suspend my laptop the ram will go to my swap partition and no information will be lost.
The last part, /home is where all your personal info is going to be, this means all your files, photos, movies, etc... I use 700Gb for that, and currently, I have almost 200Gb of free space... so you will need a big /home if you want to have it as your primary os.
Hope this will help you to make an idea of how to make your partition.
PS. just if you want to know... I have 3 distros, one Gentoo, one Arch and one Kali, Kali and Arch are both a single root (/) partition from almost 50Gb, and the Gentoo is 50Gb from root and the rest goes to /home and the three share the same swap partition

size of /root and /home partition


Is Qt 4 a programming language?

Question: Is Qt 4 a programming language? Can it be viewed as a substitute for Java and Python? Can it be used for developing user interactive software in Linux?
Answer: Qt is not a programming language at all.
"Qt is a cross-platform application development framework for desktop, embedded and mobile", says the official site. I hate the word "framework" though, as it can refer to too many things, not as much as the word "system", but enough to make things pretty confusing. The "t" in "Qt" stands for "toolkit", which describes it much better. It is in fact a set of tools. It is also written as "Qt", not "QT". The latter stands for Apple QuickTime and has very little to do with programming, although even Qt users often make this mistake.
If describing Qt as a toolkit doesn't really clarify things much more than the word "framework", here is a non-exhaustive list of tools that Qt consists of:

The main component is a set of libraries, written natively in C++. These libraries include: the core library providing the most important stuff, the GUI library surprisingly providing the GUI components, the networking library, the XML library and something more.
The MOC tool which is a program to generate some boilerplate code in C++ to use with conjunction with some macros provided by the core library. This extends C++ a little bit, adding nice features like more powerful RTTI, the signals/slots mechanism similar to events/delegates in C# allowing typesafe callbacks, the plugin/interface mechanism which provides a way to extend applications by implementing a pre-defined interface.
The GUI designer tool and the UIC. Qt Designer is a graphical tool to create GUIs visually and save them to XML files, and the UIC is a command-line tool to translate those XML files to C++ code.
The tools to internationalize applications, namely Qt Linguist, the lupdate tool and the lrelease tool. lupdate extracts text strings to be translated from C++ code into an XML file, Qt Linguist is a graphical tool for translator to edit those XML files and provide translations, and lrelease compiles the translated texts into a binary file to be loaded by a Qt application at run time.
The resource compiler tool, used to integrate various data files (like pictures and sounds) into an executable file, forming a virtual file system inside it.
The qmake tool, used to automate build process, so you don't have to run MOC, C++ compiler, UIC and other things manually.
The Qt Creator, a graphical IDE to integrate all the stuff described above into a single environment.

Programs written in portable C++ and using Qt can be recompiled with no changes for any platform supported by Qt. This includes Windows (at least XP and later), Linux (pretty much any distribution), Mac, various Unices like FreeBSD, HP-UX, Solaris and much, much more.
The native language of Qt is C++, but bindings are provided for other languages, many of them. Some of these bindings are provided by Trolltech (well, now it's Nokia), some by third parties. Bindings are not alternative implementations of Qt for other languages, but rather special add-ons to those languages allowing to use C++ Qt binaries. This can lead to many troubles, differences in interface and various inefficiencies, but that doesn't mean that they can't or shouldn't be used. It's just that C++ remains the main language of Qt.
Answer: QT is an application framework.  It allows you to create user interfaces that run on multiple platforms.  It can be used with several different programming languages, using language bindings.
See here for more info: http://en.wikipedia.org/wiki/Qt_(framework)
Comment: what is an application framework??...i went through wiki but didn't understand about the deal
Comment: An application framework is just a toolkit that allows you to implement things like windows and buttons in a standard way.
Answer: Qt is an application framework. It's written in, and primarily used with, the C++ language.
Comment: You definitely can from Python -- there are at least PyQt and Pyside (PySide is the official Nokia Python binding for Qt). There is also a QtJava to use it from Java, but I've never used it so I can't really comment on it.
Comment: Than doesn't this languages(PYTHON or JAVA) have their own GUI library..??i guess both of tham have...
Comment: @coolmego: Yes, there are other graphics libraries for both. For example, Java has both AWT and Swing. IMO, there's almost no comparison though: Qt embodies a lot of work at providing native look and feel, and responsive applications. Swing (and AWT), by contrast, produce results that are almost uniquely ugly and unresponsive.
Comment: @Jerry FUD and performance issues of Swing in 2011. Like everything it can be done poorly or correctly, depending on the programmer. There are plenty of applications that use Swing and are very snappy in their responsiveness. AWT is antiquated and for all practical purposes deprecated.
Comment: @fuzzy lollipop: Snappy Swing programs may be possible, but none of Sun/Oracle's programs is even close, so even if it's possible, the knowledge about how to do it is so carefully guarded that it's irrelevant. There were "plenty" of people who happily used Windows ME (far more than applications using Swing), but that hardly means it wasn't a POS.
Answer: QT is a framework(like .Net) that you can use on Mac OS X, WIndows, and Linux. It uses the C++ language and has a nice GUI builder.
Answer: NO. That's as concise as I can put it.
Comment: It would help if you explained *why* it is not a language.

Is Qt 4 a programming language?


How do I use Iron Sights on a laptop in Modern Combat 5?

Question: I just got a new laptop and downloaded Modern Combat 5: Blackout on it. I'm trying to figure out how to zoom/aim in the game. I don't have a mouse just a basic laptop setup w/ a mouse pad. Can somebody help me please??
Comment: "I don't have a mouse" that is problem 1, you really should get a mouse.
Answer:
You probably need a proper mouse to play the game effectively. Or a joypad controller. However even with a mouse pad you should be able to right click on the mouse pad, and look down the sights.

https://moderncombat.fandom.com/wiki/Modern_Combat_5:_Blackout_controls "Controls can be mapped to specific keys via the options menu." A lot of PC games have the ability to remap the keys as needed. So you should be able to change the key bindings from the mouse to one of the available keys on your keyboard. You might even be able to remap the mouse controls for looking around to the up down left right arrow keys, which might be more effective than trying to use a touchpad.


Heroku SSL - Updating DNS Entries

Question: I've recently added SSL Endpoint plugin for Heroku in order to enable SSL.  I've purchased and uploaded certificates successfully, which I've verified by heroku certs command:
Endpoint                  Common Name(s)                     Expires               Trusted
------------------------  ---------------------------------  --------------------  -------
app-1234.herokussl.com    mydomain.com mydomain.com.au       2013-08-09 12:26 EST  True

The step where I got stuck is configuring DNS (I'm using Zerigo DNS provider/plugin for Heroku):
Currently, I have the following DNS config:
Host: www.mydomain.com
Type: CNAME
Data: proxy.heroku.com
On top of that I have a number of A records for mydomain.com which point to various IP addresses.  All the configuration was auto generated by executing the following command:
heroku domains:add mydomain.com

Any tips on the DNS config for this scenario would be appreciated.
Answer: You want the CNAME to point to app-1234.herokussl.com not proxy.heroku.com

Heroku SSL - Updating DNS Entries


Downloading a local copy of One Note from Office 365 Online

Question: I have a One Note notebook saved through Office 365 Online. I would like to download a local copy but am having trouble. I've tried going to One Drive and downloading it through there, but it downloads a zip with a text file saying it cannot be downloaded. How can I get a local copy of a one note notebook I have on office online?
Answer: Just to add that there is a distinction between OneDrive for personal use, and for corporate use. Business accounts do not allow to download notes in any way, none of the posts on this page were able to overcome this limitation.
From Microsoft help pages on OneNote app:

Exporting and importing notebooks through OneNote for the web is only
  available for notebooks stored on personal OneDrive accounts, not for
  notebooks stored on OneDrive for Business or SharePoint. For
  information about exporting notebooks to PDF files from OneNote 2016
  for Windows, see Export notes from OneNote as a PDF.
Comment: As pointed out by Mauricio, if you have an Office for Business subscription, the option 'Export Notebook' does not appear. This is most likely relevant to the author, who comments that there is no option for export. Those concerned by this may wish to vote for backup options to be added to OneNote for Mac here:
https://onenote.uservoice.com/forums/327165-onenote-for-mac/suggestions/7053264-backup-option-for-onenote-for-mac
Comment: Why does it not apply to the author? There's no indication of whether it's personal or not, only that they can 't download it. This is the most correct answer so far
Comment: The help page you quoted doesn't apply to the author
Comment: I think it was corporate use IIRC
Answer: Open OneNote, then open the OneNote file in the online location. Then click File > Export > Notebook and export the notebook to a local folder.

This copy will no longer be in sync with the online copy of the notebook.
Comment: This didn't work as there's no option to export. This isn't just synced, this is Office online.
Comment: I added a screenshot with the export option. You need to open OneNote for Desktop, not online.
Comment: Even in desktop, if you open an "online" notebook, you get no export options.
Comment: Yes, it works. You need OneNote for desktop. And the exported one will be a single file. When you open it, it needs to be extracted first. But to be honest, it is quite slow and tedious. Not a good experience.
Answer: You said you downloaded from onedrive but there's also an option on onenote online, so, for now, I'll treat it as if you had only tried onedrive but not the other (Microsoft is confusing, am I right?).
Onenote online provides an option to export onenote notebooks, but it is well hidden for some weird reason.

This answer is based on one of Microsoft's support articles:
  https://support.office.com/en-us/article/export-and-import-onenote-notebooks-a4b60da5-8f33-464e-b1ba-b95ce540f309?ui=en-US&rs=en-US&ad=US.

Go to https://www.onenote.com/notebooks and sign in with your Microsoft credentials.
You will see your notebooks. Right click the one you want to export.
There is an option Export notebook. Click that.
A popup window appears and you can click export to download locally (it also lets you choose where to save it).

Hope this helps, although I'm a little late.
Comment: Currently there is no right click menu on that site. Just the standard browser right click menu
Comment: Neither chrome nor edge give me a context menu https://1drv.ms/u/s!And9v01YScXW0nxlq5rLyC4b1Vhg?e=HJpMRU https://1drv.ms/u/s!And9v01YScXW0ns9WEmqKmEr6dm7?e=ZhFSNo
Comment: From the support article linked in the answer: "Note: Exporting and importing notebooks through OneNote for the web is only available for notebooks stored on personal OneDrive accounts, not for notebooks stored on OneDrive for Business or SharePoint."
Comment: Doesn't work on Mac if you are using One Drive version of it.
This post https://superuser.com/a/1318304/362814 has useful suggestion if you happen to have a Windows Machine along with you.
Comment: @ElectricLlama I'm using chrome and I see no problem right clicking on any of the notebooks I have. Maybe try another browser if it doesn't work?
Comment: This works for me and is a great solution to backup my onenote data as Mac user.
Answer: Here's what I do for my class notebooks (stored on OneDrive for business).  This works for Windows 10, not sure which update made it possible, but I've been doing it for at least 2 years:

make sure both your personal onedrive and onedrive for business are syncing to your computer through the trey apps.
in OneNote 2016 (not the UWP app) make sure your notebook is fully synced; says 'up to date' and is not open on any other computer or app.
right click on the notebook title, select properties, select 'change location'
pick a location in your personal onedrive. This creates an extra copy, it does not move the original. I suggest renaming the personal copy on onedrive so it's distinguishable easily.
Give it time and make sure it is done and didn't experience sync issues

You could also do the 'export' from OneNote 2016, but my large notebooks tend to fail.
FYI you can still download OneNote 2016, just google that and follow the links.
Answer: I too was struggling with it for a long time(i wanted a pdf copy), at last i got it-

Open the desktop app view of office 365.
Click on the button with 3dots in the upper extreme right of the screen and select print.
A new window opens up, now select the option you want(3 given-includes pdf,XPS doc writer and onenote) on the left just below where printer is written.
Click on Print and select a location of your choice where you want to save.
Answer: This may or may not be the issue the original poster had but I'm posting this here to help anyone else.
This is with regards to the default online notebook you get when running OneNote. There is no export option and you can't find the file anywhere.
I needed to copy my notebook to a new account. This is what I did

Go to <oldcompany>-my.sharepoint.com
Pick My Files
In the root you'll find your notebook file
Right click/open in app. You need to log in and stuff
Hopefully your existing company notebook is open. Now you can right click on each tab and copy to the new company notebook
Answer: For some reason, SharePoint online hides the ability to download the contents of a One Note file.
I have no idea why they do that but they do.
But you can still download the file with a special method.

Go to the folder that contains the workbook in SharePoint Online document library

Example: https://mysharepointenant.sharepoint.com/Shared%20Documents
And open the one note file:

Each Section in your notebook equates to a .one file. We need to get the OneNote section filename. To do this, right click on the section and click Copy Link to Section.

Paste the link in a text editor and it will look like this: https://mysharepointtenant.sharepoint.com/_layouts/15/Doc.aspx?sourcedoc={3ba9f666-69c3-48cc-861e-a249524ba8f3}&action=edit&wd=target(Untitled Section.one|211abf0a-d9b5-498d-a9bf-e8c8c1545c7b%2F)&wdorigin=717
You can extract the filename from target wrapper, in this case Untitled Section.one.
You now have what you need to download the one note file.
The URL is {URL to folder in document library}/{NameOfNotebook}/{NameOfSection}.one
Example in my case:
https://mysharepointtenant.sharepoint.com/Shared Documents/MySuperCoolNotebook/Untitled Section.one
Comment: You got me hopeful, but this didn't work for me. Got a straight "404 NOT FOUND".
Comment: make sure if there is a sub-folder you are including it in that final url. these steps definitely work for the situation I have. so there's just something slightly different with yours that is causing the issue
Comment: No subfolder, but the notebook has a space in the name, unlike `SuperCoolNotebook`.
Comment: replace the spaces with `+` maybe?
Comment: Will try +. Tried space, but didn't work.
Answer: I finally found a completely localized solution that does not require onedrive or any cloud sync. Note: My OneNote version: 16.0.15601.20680 thats part of the Microsoft Office 365 for enterprise suite.
Steps to Export your current notebook as single onenote pkg file ( .onepkg ):

Create a Backup folder on your C Drive to store the .onepkg files. Say C:\Bak\
Click on your notebook that you want to export. Then from File menu pick export
Under "Export current" section Choose Notebook
Under the "Select Format" option choose 1st option - OneNote Package(*.onepkg)
Click Export and now it will offer you to pick a folder to save the file under.
Navigate to C:\Bak folder  and click save
If you open C:\Bak in file explorer it will contain a single file with ext .onepkg.
Repeat for each notebook in your Onenote app.

Steps to import the .onepkg file in a new PC using OneNote:

Create a Folder C:\MyNotebooks on your new PC. This is where the .onepkg will be imported to.
Copy the C:\Bak folder to the new PC using a USB drive or mapping a folder.
Open one note and click File - open.
Find the browse option (under other locations)
Navigate to the folder C:\Bak
Just above the open button there is a dropdown to select file type. Pick OneNote Single file Package.
Now select the .onepkg file
Click open and it will open the "Unpack notebook" dialog box where it will present you with the option to rename the notebook and also change its default location to a drive on your local PC.
Navigate (using browse button) to C:\MyNotebooks and click on Create. And you should now see your notebook open on the new pc.
Onenote will automatically create a new sub-folder under C:\MyNotebooks and it will have a bunch of files (.one. onetoc2 etc ... ). This folder is portable ! You can just copy that folder to a another PC and open it using File-Open menu. No need to export.

Verify:

Click on File --> Info and it should show you the locations for each Notebook on your PC. Ensure that it is pointing to the new folder: C:\MyNotebooks.
Answer: Select the notebook you want to download from onedrive online.
On the header, you'll see the function "Open" with the OneNote symbol next to it.  Click the dropdown arrow.  Select "Open in OneNote".
For this to work, make sure that your browser is the same bit as your OneNote in your computer.  For example, if you're using OneNote 64 bit in your computer, then your browser needs to be 64 bit.  Otherwise, it won't work.