Relative imports in Python 3
I want to import a function from another file in the same directory. Usually, one of the following works: ``` from .mymodule import myfunction ``` ``` from mymodule import myfunction ``` ...but the ...
- Modified
- 29 Aug at 12:4
Check if an element is present in an array
The function I am using now to check this is the following: ``` function inArray(needle,haystack) { var count=haystack.length; for(var i=0;i<count;i++) { if(haystack[i]===needle){r...
- Modified
- 21 Dec at 09:47
How can I get a list of user accounts using the command line in MySQL?
I'm using the MySQL command-line utility and can navigate through a database. Now I need to see a list of user accounts. How can I do this? I'm using MySQL version 5.4.1.
- Modified
- 5 Aug at 20:10
How can I read a large text file line by line using Java?
I need to read a large text file of around 5-6 GB line by line using Java. How can I do this quickly?
- Modified
- 18 Dec at 15:6
How can I compare two lists in python and return matches
I want to take two lists and find the values that appear in both. ``` a = [1, 2, 3, 4, 5] b = [9, 8, 7, 6, 5] returnMatches(a, b) ``` would return `[5]`, for instance.
How do I make calls to a REST API using C#?
This is the code I have so far: ``` public class Class1 { private const string URL = "https://sub.domain.com/objects.json?api_key=123"; private const string DATA = @"{""object"":{"...
Set a default parameter value for a JavaScript function
I would like a JavaScript function to have optional arguments which I set a default on, which get used if the value isn't defined (and ignored if the value is passed). In Ruby you can do it like this:...
- Modified
- 30 Jun at 14:30
gcc makefile error: "No rule to make target ..."
I'm trying to use GCC (linux) with a makefile to compile my project. I get the following error which is can't seem to decipher in this context: ``` "No rule to make target 'vertex.cpp', needed by ...
How to force cp to overwrite without confirmation
I'm trying to use the `cp` command and force an overwrite. I have tried `cp -rf /foo/* /bar`, but I am still prompted to confirm each overwrite.
- Modified
- 18 Jan at 00:11
How to rebase local branch onto remote master
I have a cloned project from a master branch from remote repository `remote_repo`. I create a new branch and I commit to that branch. Other programmers pushed to `remote_repo` to the master branch. I ...
- Modified
- 29 Jul at 15:36
How can I deserialize JSON with C#?
I have the following code: ``` var user = (Dictionary<string, object>)serializer.DeserializeObject(responsecontent); ``` The input in `responsecontent` is JSON, but it is not properly deserialized in...
- Modified
- 15 Jun at 15:26
How do I display a decimal value to 2 decimal places?
When displaying the value of a decimal currently with `.ToString()`, it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 deci...
Make iframe automatically adjust height according to the contents without using scrollbar?
For example: ``` <iframe name="Stack" src="http://stackoverflow.com/" width="740" frameborder="0" scrolling="no" id="iframe"> ... </iframe> ``` I want it to be able to adjust its height acc...
- Modified
- 3 Oct at 13:45
How to delete rows from a pandas DataFrame based on a conditional expression
I have a pandas DataFrame and I want to delete rows from it where the length of the string in a particular column is greater than 2. I expect to be able to do this (per [this answer](https://stackove...
Best way to convert an ArrayList to a string
I have an `ArrayList` that I want to output completely as a String. Essentially I want to output it in order using the `toString` of each element separated by tabs. Is there any fast way to do this? Y...
Behaviour of increment and decrement operators in Python
How do I use pre-increment/decrement operators (`++`, `--`), just like in C++? Why does `++count` run, but not change the value of the variable?
Extracting extension from filename in Python
Is there a function to extract the extension from a filename?
- Modified
- 16 Sep at 19:11
href="tel:" and mobile numbers
If I use `tel:` I should write the international phone code, like that. ``` <a href="tel:+6494461709">61709</a> ``` So far, so good, but I can't find information on how to write a cell phone number...
How can I make git accept a self signed certificate?
Using Git, is there a way to tell it to accept a self signed certificate? I am using an https server to host a git server but for now the certificate is self signed. When I try to create the repo th...
- Modified
- 14 Jul at 11:33
Avoiding NullPointerException in Java
I use `x != null` to avoid [NullPointerException](https://docs.oracle.com/javase/9/docs/api/java/lang/NullPointerException.html). Is there an alternative? ``` if (x != null) { // ... } ```
- Modified
- 10 Jul at 23:18
Convert String to double in Java
How can I convert a `String` such as `"12.34"` to a `double` in Java?
- Modified
- 30 Dec at 19:48
What is the difference between varchar and nvarchar?
Is it just that `nvarchar` supports multibyte characters? If that is the case, is there really any point, other than storage concerns, to using `varchars`?
- Modified
- 19 Sep at 19:37
Identify if a string is a number
If I have these strings: 1. "abc" = false 2. "123" = true 3. "ab2" = false Is there a command, like `IsNumeric()` or something else, that can identify if a string is a valid number?
Check if inputs are empty using jQuery
I have a form that I would like all fields to be filled in. If a field is clicked into and then not filled out, I would like to display a red background. Here is my code: ``` $('#apply-form input')...
- Modified
- 1 Sep at 11:14