How can I call a function within a class?
I have this code which calculates the distance between two coordinates. The two functions are both within the same class. However, how do I call the function `distToPoint` in the function `isNear`? ``...
Download File to server from URL
Well, this one seems quite simple, and it is. All you have to do to download a file to your server is: ``` file_put_contents("Tmpfile.zip", file_get_contents("http://someurl/file.zip")); ``` Only t...
How to evaluate a math expression given in string form?
I'm trying to write a Java routine to evaluate math expressions from `String` values like: 1. "5+3" 2. "10-4*5" 3. "(1+10)*3" I want to avoid a lot of if-then-else statements. How can I do this?
'console' is undefined error for Internet Explorer
I'm using Firebug and have some statements like: ``` console.log("..."); ``` in my page. In IE8 (probably earlier versions too) I get script errors saying 'console' is undefined. I tried putting th...
- Modified
- 28 Feb at 08:9
Reverse colormap in matplotlib
I would like to know how to simply reverse the color order of a given colormap in order to use it with plot_surface.
- Modified
- 23 Jul at 14:31
How to split a string in shell and get the last field
Suppose I have the string `1:2:3:4:5` and I want to get its last field (`5` in this case). How do I do that using Bash? I tried `cut`, but I don't know how to specify the last field with `-f`.
Replace transparency in PNG image with white background
I have a PNG image with an alpha channel (i.e. transparency), and I need to create versions with the image layer composed onto a white background. I want to use a scriptable command using a CLI tool s...
- Modified
- 16 Dec at 02:41
How to add reference to a method parameter in javadoc?
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulati...
Populate XDocument from String
I'm working on a little something and I am trying to figure out whether I can load an XDocument from a string. `XDocument.Load()` seems to take the string passed to it as a path to a physical XML file...
- Modified
- 12 Mar at 13:36
Move entire line up and down in Vim
In Notepad++, I can use + + / to move the current line up and down. Is there a similar command to this in Vim? I have looked through endless guides, but have found nothing. If there isn't, how c...
Catching an exception while using a Python 'with' statement
I can't figure out how to handle exception for python 'with' statement. If I have a code: ``` with open("a.txt") as f: print f.readlines() ``` I really want to handle 'file not found exception' i...
Is it valid to have a html form inside another html form?
Is it valid html to have the following: ``` <form action="a"> <input.../> <form action="b"> <input.../> <input.../> <input.../> </form> <input.../> </form> ```...
- Modified
- 16 May at 21:45
How to update RecyclerView Adapter Data
I am trying to figure out what is the issue with updating `RecyclerView`'s Adapter. After I get a new List of products, I tried to: 1. Update the ArrayList from the fragment where recyclerView is cre...
- Modified
- 21 Jun at 23:23
How to pass parameters using ui-sref in ui-router to the controller
I need to pass and receive two parameters to the state I want to transit to using `ui-sref` of ui-router. Something like using the link below for transitioning the state to `home` with `foo` and `bar`...
- Modified
- 3 Jun at 14:45
Swift - encode URL
If I encode a string like this: ``` var escapedString = originalString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) ``` it doesn't escape the slashes `/`. I've searched and fo...
How do I send a JSON string in a POST request in Go
I tried working with Apiary and made a universal template to send JSON to mock server and have this code: ``` package main import ( "encoding/json" "fmt" "github.com/jmcvetta/napping" ...
Cannot download Docker images behind a proxy
I installed Docker on my Ubuntu 13.10 (Saucy Salamander) and when I type in my console: ``` sudo docker pull busybox ``` I get the following error: ``` Pulling repository busybox 2014/04/16 09:37:...
Pandas: drop a level from a multi-level column index?
If I've got a multi-level column index: ``` >>> cols = pd.MultiIndex.from_tuples([("a", "b"), ("a", "c")]) >>> pd.DataFrame([[1,2], [3,4]], columns=cols) ``` How can I drop the "a" level of that ...
List all indexes on ElasticSearch server?
I would like to list all indexes present on an ElasticSearch server. I tried this: ``` curl -XGET localhost:9200/ ``` but it just gives me this: ``` { "ok" : true, "status" : 200, "name" : "El ...
- Modified
- 23 Jun at 13:41
Does "display:none" prevent an image from loading?
Every responsive website development tutorial recommends using the `display:none` CSS property to hide content from loading on mobile browsers so the website loads faster. Is it true? Does `display:no...
- Modified
- 7 Sep at 08:8
What XML parser should I use in C++?
I have XML documents that I need to parse and/or I need to build XML documents and write them to text (either files or memory). Since the C++ standard library does not have a library for this, what sh...
- Modified
- 4 Jun at 07:33
How to get body of a POST in php?
I submit as POST to a php page the following: ``` {a:1} ``` This is the body of the request (a POST request). In php, what do I have to do to extract that value? ``` var_dump($_POST); ``` is ...
What's the fastest way to read a text file line-by-line?
I want to read a text file line by line. I wanted to know if I'm doing it as efficiently as possible within the .NET C# scope of things. This is what I'm trying so far: ``` var filestream = new Syst...
- Modified
- 6 Jul at 09:7
Declaring variables inside loops, good practice or bad practice?
Is declaring a variable inside a loop a good practice or bad practice? I've read the other threads about whether or not there is a performance issue (most said no), and that you should always declar...
- Modified
- 9 Jan at 22:19
The remote end hung up unexpectedly while git cloning
My `git` client repeatedly fails with the following error after trying to clone the repository for some time. What could be the issue here? I have registered my SSH key with the GIT hosting provid...
- Modified
- 19 Jun at 02:27