Questions

How do I check if a variable exists?

I want to check if a variable exists. Now I'm doing something like this: ``` try: myVar except NameError: # Do something. ``` Are there other ways without exceptions?

9 Apr at 09:48

How to kill a process running on particular port in Linux?

I tried to close the tomcat using `./shutdown.sh` from tomcat `/bin` directory. But found that the server was not closed properly. And thus I was unable to restartMy tomcat is running on port `8080`. ...

10 Aug at 10:55

How do I escape a single quote in SQL Server?

I am trying to `insert` some text data into a table in SQL Server 9. The text includes a single quote `'`. How do I escape that? I tried using two single quotes, but it threw me some errors. eg. `inse...

How can I undo pushed commits using git?

I have a project in a remote repository, synchronized with a local repository (development) and the server one (prod). I've been making some commited changes already pushed to remote and pulled from t...

27 Jan at 11:0

How to uncommit my last commit in Git

How can I uncommit my last commit in git? Is it ``` git reset --hard HEAD ``` or ``` git reset --hard HEAD^ ``` ?

28 Jan at 21:41

Enumerations on PHP

I know that PHP doesn't yet have native Enumerations. But I have become accustomed to them from the Java world. I would love to use enums as a way to give predefined values which IDEs' auto-completion...

16 Feb at 07:17

What's the difference between a mock & stub?

I've read various articles about mocking vs stubbing in testing, including [Martin Fowler's Mocks Aren't Stubs](http://martinfowler.com/articles/mocksArentStubs.html), but still don't understand the d...

24 Mar at 17:25

Remove element by id

When removing an element with standard JavaScript, you must go to its parent first: ``` var element = document.getElementById("element-id"); element.parentNode.removeChild(element); ``` Having to g...

12 Jun at 10:5

'Must Override a Superclass Method' Errors after importing a project into Eclipse

Anytime I have to re-import my projects into Eclipse (if I reinstalled Eclipse, or changed the location of the projects), of my overridden methods are not formatted correctly, causing the error: > T...

How to read a text file into a string variable and strip newlines?

I have a text file that looks like: ``` ABC DEF ``` How can I read the file into a single-line string without newlines, in this case creating a string `'ABCDEF'`? --- [How to read a file without n...

9 Aug at 02:24

How can you speed up Eclipse?

For instance: Instead of using a plugin for [Mercurial](http://en.wikipedia.org/wiki/Mercurial), I configure [TortoiseHG](https://en.wikipedia.org/wiki/TortoiseHg) as an external tool.

28 Aug at 09:16

How do I print an exception in Python?

How do I print the error/exception in the `except:` block? ``` try: ... except: print(exception) ```

20 Jun at 06:52

What does the 'b' character do in front of a string literal?

Apparently, the following is the valid syntax: ``` b'The string' ``` I would like to know: 1. What does this b character in front of the string mean? 2. What are the effects of using it? 3. What are...

9 Apr at 10:16

How can I customize the tab-to-space conversion factor?

How do I customize the tab-to-space conversion factor when using Visual Studio Code? For instance, right now in HTML it appears to produce two spaces per press of , but in TypeScript it produces 4.

23 Dec at 13:32

Open link in new tab or window

Is it possible to open an `a href` link in a new tab instead of the same tab? ``` <a href="http://your_url_here.html">Link</a> ```

15 Sep at 11:14

How to perform an integer division, and separately get the remainder, in JavaScript?

In , how do I get: 1. The whole number of times a given integer goes into another? 2. The remainder?

What is the <leader> in a .vimrc file?

I see `<leader>` in many `.vimrc` files, and I am wondering what does it mean? What is it used for? Just a general overview of the purpose and usage would be great.

16 Apr at 08:21

Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loop

We all know you can't do the following because of `ConcurrentModificationException`: ``` for (Object i : l) { if (condition(i)) { l.remove(i); } } ``` But this apparently works some...

20 Oct at 13:4

Redefine tab as 4 spaces

My current setting assumes 8 spaces; how could I redefine it?

20 Aug at 15:0

Using Node.js require vs. ES6 import/export

In a project I am collaborating on, we have two choices on which module system we can use: 1. Importing modules using require, and exporting using module.exports and exports.foo. 2. Importing modules...

What is a mixin and why is it useful?

In [Programming Python](https://rads.stackoverflow.com/amzn/click/com/0596009259), Mark Lutz mentions the term . I am from a C/C++/C# background and I have not heard the term before. What is a mixin? ...

Which version of PostgreSQL am I running?

I'm in a corporate environment (running Debian Linux) and didn't install it myself. I access the databases using Navicat or phpPgAdmin (if that helps). I also don't have shell access to the server run...

29 Dec at 13:16

Run/install/debug Android applications over Wi-Fi?

I thought there was a way to test your applications in development over Wi-Fi. Is this possible? I'd love to be able to untether my phone and develop wirelessly.

5 Jun at 18:20

Get the first element of an array

I have an array: `array( 4 => 'apple', 7 => 'orange', 13 => 'plum' )` I would like to get the first element of this array. Expected result: `apple` One requirement: , so `array_shift` is not a...

3 Feb at 04:9

How to call asynchronous method from synchronous method in C#?

I have a `public async void Foo()` method that I want to call from synchronous method. So far all I have seen from MSDN documentation is calling async methods via async methods, but my whole program i...

14 May at 07:31