Questions

How to comment out a block of code in Python

Is there a mechanism to comment out large blocks of Python code? Right now, the only ways I can see of commenting out code are to either start every line with a `#`, or to enclose the code in triple ...

6 Nov at 21:6

Generic htaccess redirect www to non-www

I would like to redirect `www.example.com` to `example.com`. The following htaccess code makes this happen: ``` RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/...

How to restart a single container with docker-compose

I have a `docker-compose.yml` file that contains 4 containers: `redis`, `postgres`, `api` and `worker`. During the development of the `worker` container, I often need to restart it in order to apply c...

20 Jun at 11:17

Find unused npm packages in package.json

Is there a way to determine if you have packages in your `package.json` file that are no longer needed? For instance, when trying out a package and later commenting or deleting code, but forgetting to...

20 Oct at 13:10

How do I create a list with numbers between two values?

How do I create an ascending list between two values? For example, a list between 11 and 16: ``` [11, 12, 13, 14, 15, 16] ```

17 Jul at 09:1

If my interface must return Task what is the best way to have a no-operation implementation?

In the code below, due to the interface, the class `LazyBar` must return a task from its method (and for argument's sake can't be changed). If `LazyBar`s implementation is unusual in that it happens t...

Type definition in object literal in TypeScript

In TypeScript classes it's possible to declare types for properties, for example: ``` class className { property: string; }; ``` How do declare the type of a property in an object literal? I've ...

19 Jun at 16:30

How to implement a tree data-structure in Java?

Is there any standard Java library class to represent a tree in Java? Specifically I need to represent the following: - - - Is there any available structure for this or do I need to create my own ...

16 Mar at 23:4

heroku - how to see all the logs

I have a small app on heroku. Whenever I want to see the logs I go to the command line and do ``` heroku logs ``` That only shows me about 100 lines. Is there not a way to see complete logs for ...

9 Sep at 22:34

How to programmatically take a screenshot on Android?

How can I take a screenshot of a selected area of phone-screen not by any program but from code?

30 Apr at 13:43

How do you find the row count for all your tables in Postgres

I'm looking for a way to find the row count for all my tables in Postgres. I know I can do this one table at a time with: ``` SELECT count(*) FROM table_name; ``` but I'd like to see the row count...

7 Mar at 10:48

How do I find the time difference between two datetime objects in python?

How do I tell the time difference in minutes between two `datetime` objects?

20 Dec at 20:47

What is the best way to implement "remember me" for a website?

I want my website to have a checkbox that users can click so that they will not have to log in each time they visit my website. I know I will need to store a cookie on their computer to implement this...

16 Aug at 12:20

How to convert a column number (e.g. 127) into an Excel column (e.g. AA)

How do you convert a numerical number to an Excel column name in C# without using automation getting the value directly from Excel. Excel 2007 has a possible range of 1 to 16384, which is the number ...

2 Mar at 08:31

How to change the status bar color in Android?

First of all it's not a duplicate as in [How to change the background color of android status bar](https://stackoverflow.com/questions/9044970/how-to-change-the-background-color-of-android-status-bar)...

Private properties in JavaScript ES6 classes

Is it possible to create private properties in ES6 classes? Here's an example. How can I prevent access to `instance.property`? ``` class Something { constructor(){ this.property = "test"; }...

Convert Python dict into a dataframe

I have a Python dictionary like the following: ``` {u'2012-06-08': 388, u'2012-06-09': 388, u'2012-06-10': 388, u'2012-06-11': 389, u'2012-06-12': 389, u'2012-06-13': 389, u'2012-06-14': 389, ...

16 Nov at 21:3

Java 8 Iterable.forEach() vs foreach loop

Which of the following is better practice in Java 8? Java 8: ``` joins.forEach(join -> mIrc.join(mSession, join)); ``` Java 7: ``` for (String join : joins) { mIrc.join(mSession, join); } ```...

4 Oct at 01:40

Is it a good practice to use try-except-else in Python?

From time to time in Python, I see the block: ``` try: try_this(whatever) except SomeException as exception: #Handle exception else: return something ``` I do not like that kind of progr...

20 Nov at 19:44

What is the difference between origin and upstream on GitHub?

What is the difference between `origin` and `upstream` on [GitHub](http://en.wikipedia.org/wiki/GitHub)? When a `git branch -a` command is executed, some branches it displays have a prefix of `origin`...

3 Jul at 22:46

Logical operator in a handlebars.js {{#if}} conditional

Is there a way in handlebars JS to incorporate logical operators into the standard handlebars.js conditional operator? Something like this: ``` {{#if section1 || section2}} .. content {{/if}} ``` I...

13 Jan at 15:59

Python datetime to string without microsecond component

I'm adding UTC time strings to Bitbucket API responses that currently only contain Amsterdam (!) time strings. For consistency with the UTC time strings returned elsewhere, the desired format is `2011...

3 Nov at 18:49

Mongod complains that there is no /data/db folder

I am using my new mac for the first time today. I am following the get started guide on the mongodb.org up until the step where one creates the /data/db directory. btw, I used the homebrew route. So...

16 Jul at 17:19

Untrack files from git temporarily

I have setup a local git on my machine. When I initialized git, I added pre-compiled libs and binaries. However, now during my development I don't want to check in those files intermittently. I dont w...

30 Jun at 05:47

Join/Where with LINQ and Lambda

I'm having trouble with a query written in LINQ and Lambda. So far, I'm getting a lot of errors here's my code: ``` int id = 1; var query = database.Posts.Join(database.Post_Metas, ...

29 Dec at 00:29