Questions

How can I check the extension of a file?

I'm working on a certain program where I need to do different things depending on the extension of the file. Could I just use this? ``` if m == *.mp3 ... elif m == *.flac ... ```

30 Sep at 18:47

GCD to perform task in main thread

I have a callback which might come from any thread. When I get this callback, then I would like to perform a certain task on the main thread. Do I need to check whether I already am on the main threa...

19 Dec at 19:10

How do I set up IntelliJ IDEA for Android applications?

How do I set up IntelliJ IDEA for Android applications?

3 Feb at 06:5

How to recursively find the latest modified file in a directory?

It seems that `ls` doesn't sort the files correctly when doing a recursive call: ``` ls -altR . | head -n 3 ``` How can I find the most recently modified file in a directory (including subdirectori...

3 Nov at 07:30

How to convert List to Map?

Recently I have conversation with a colleague about what would be the optimal way to convert `List` to `Map` in Java and if there any specific benefits of doing so. I want to know optimal conversion a...

MySQL Data - Best way to implement paging?

My iPhone application connects to my PHP web service to retrieve data from a MySQL database, a request can return up to 500 results. What is the best way to implement paging and retrieve 20 items at a...

18 Feb at 16:57

Create whole path automatically when writing to a new file

I want to write a new file with the [FileWriter](http://docs.oracle.com/javase/1.5.0/docs/api/java/io/FileWriter.html). I use it like this: ``` FileWriter newJsp = new FileWriter("C:\\user\Desktop\di...

3 May at 10:39

Remove items from one list in another

I'm trying to figure out how to traverse a generic list of items that I want to remove from another list of items. So let's say I have this as a hypothetical example ``` List<car> list1 = GetTheList...

11 Jan at 10:22

Get/pick an image from Android's built-in Gallery app programmatically

I am trying to open an image / picture in the Gallery built-in app from inside my application. I have a URI of the picture (the picture is located on the SD card). Do you have any suggestions?

23 May at 07:48

What is the best way to check for Internet connectivity using .NET?

What is the fastest and most efficient way to check for Internet connectivity in .NET?

7 Aug at 20:50

Using an HTML button to call a JavaScript function

I am trying to use an HTML button to call a JavaScript function. Here's the code: ``` <input type="button" value="Capacity Chart" onclick="CapacityChart();"> ``` It doesn't seem to work correctly ...

23 Jul at 11:44

Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago...

I am trying to convert a timestamp of the format `2009-09-12 20:57:19` and turn it into something like `3 minutes ago` with PHP. I found a useful script to do this, but I think it's looking for a dif...

27 Sep at 09:37

Regular expression for a string that does not start with a sequence

I'm processing a bunch of tables using [this program](http://schemaspy.sourceforge.net/), but I need to ignore ones that start with the label "tbd_". So far I have something like `[^tbd_]`, but that s...

12 Jan at 03:49

Globally catch exceptions in a WPF application?

We have a WPF application where parts of it may throw exceptions at runtime. I'd like to globally catch any unhandled exceptions and log them, but otherwise continue program execution as if nothing ha...

25 Aug at 08:25

Multiple commands in an alias for bash

I'd like to define an alias that runs the following two commands consecutively. ``` gnome-screensaver gnome-screensaver-command --lock ``` Right now I've added ``` alias lock='gnome-screensaver-c...

16 Apr at 15:47

Can you remove elements from a std::list while iterating through it?

I've got code that looks like this: ``` for (std::list<item*>::iterator i=items.begin();i!=items.end();i++) { bool isActive = (*i)->update(); //if (!isActive) // items.remove(*i); ...

27 Feb at 19:8

What really happens in a try { return x; } finally { x = null; } statement?

I saw this tip in another question and was wondering if someone could explain to me how on earth this works? ``` try { return x; } finally { x = null; } ``` I mean, does the `finally` clause reall...

23 Jan at 10:54

What do 'statically linked' and 'dynamically linked' mean?

I often hear the terms 'statically linked' and 'dynamically linked', often in reference to code written in [C](http://en.wikipedia.org/wiki/C_%28programming_language%29), [C++](https://en.wikipedia.or...

How do you normalize a file path in Bash?

I want to transform `/foo/bar/..` to `/foo` Is there a bash command which does this? --- Edit: in my practical case, the directory does exist.

25 Sep at 12:4

Create a date from day month and year with T-SQL

I am trying to convert a date with individual parts such as 12, 1, 2007 into a datetime in SQL Server 2005. I have tried the following: ``` CAST(DATEPART(year, DATE)+'-'+ DATEPART(month, DATE) +'-'+ ...

6 Aug at 13:20

Asyncio.gather vs asyncio.wait

[asyncio.gather](https://docs.python.org/3/library/asyncio-task.html#asyncio.gather) and [asyncio.wait](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait) seem to have similar uses: I h...

Differences between ConstraintLayout and RelativeLayout

What is the difference between `ConstraintLayout` and `RelativeLayout`?

How to use private Github repo as npm dependency

How do I list a private Github repo as a `"dependency"` in `package.json`? I tried [npm's Github URLs](https://docs.npmjs.com/files/package.json#github-urls) syntaxes like `ryanve/example`, but doing ...

25 Feb at 20:10

git with IntelliJ IDEA: Could not read from remote repository

Since a few weeks, I'm not able to pull or push from or to the remote repository. I thought it happend when upgrading to IntelliJ IDEA 14, but I can reproduce the problem with IDEA 13.1.5 as well. Th...

19 Dec at 13:59

Type hinting a collection of a specified type

Using Python 3's function annotations, it is possible to specify the type of items contained within a homogeneous list (or other collection) for the purpose of type hinting in PyCharm and other IDEs? ...