Questions

How do I show a console output/window in a forms application?

To get stuck in straight away, a very basic example: ``` using System; using System.Windows.Forms; class test { static void Main() { Console.WriteLine("test"); MessageBox.S...

What is the string length of a GUID?

I want to create a varchar column in SQL that should contain `N'guid'` while `guid` is a generated GUID by .NET ([Guid.NewGuid](https://learn.microsoft.com/en-us/dotnet/api/system.guid.newguid)) - cla...

How to make input type= file Should accept only pdf and xls

I used `<input type= "file" name="Upload" >` Now I would like to restrict this by accepting only .pdf and .xls files. When I click the submit button it should validate this. And when I click the fi...

12 Nov at 01:49

*.h or *.hpp for your class definitions

I've always used a `*.h` file for my class definitions, but after reading some boost library code, I realised they all use `*.hpp`. I've always had an aversion to that file extension, I think mainly b...

20 Jul at 19:20

How do I add a newline to command output in PowerShell?

I run the following code using PowerShell to get a list of add/remove programs from the registry: ``` Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall ` | ForEach-Obj...

27 Dec at 14:37

Subtract days from a DateTime

I have the following code in my C# program. ``` DateTime dateForButton = DateTime.Now; dateForButton = dateForButton.AddDays(-1); // ERROR: un-representable DateTime ``` Whenever I run it, I ge...

9 Apr at 18:4

How do I disable a href link in JavaScript?

I have a tag `<a href="#"> Previous </a> 1 2 3 4 <a href="#"> Next </a>` and in some conditions I want this tag to be completely disabled. ``` if (n_index != n_pages) a = a+'<li><a href="#" on...

14 Jun at 10:28

Compare two objects with .equals() and == operator

I constructed a class with one `String` field. Then I created two objects and I have to compare them using `==` operator and `.equals()` too. Here's what I've done: ``` public class MyClass { St...

1 Feb at 12:20

Get properties and values from unknown object

From the world of PHP I have decided to give C# a go. I've had a search but can't seem to find the answer of how to do the equivalent to this. ``` $object = new Object(); $vars = get_class_vars(get_...

10 Nov at 13:11

Difference in months between two dates

How to calculate the difference in months between two dates in C#? Is there is equivalent of VB's `DateDiff()` method in C#. I need to find difference in months between two dates that are years apart...

1 May at 22:24

Not class selector in jQuery

Is there a simple selector expression to not select elements with a specific class? ``` <div class="first-foo" /> <div class="first-moo" /> <div class="first-koo" /> <div class="first-bar second-foo"...

6 Jan at 10:51

Visual Studio Code: How to show line endings

How can I display lineendings (CR,LF) in Visual Studio Code (not in Visual Studio)? At the moment there is only the little statusbar menu which display/change the line ending if the actual file. But s...

29 Oct at 14:58

What is the preferred syntax for initializing a dict: curly brace literals {} or the dict() function?

I'm putting in some effort to learn Python, and I am paying close attention to common coding standards. This may seem like a pointlessly nit-picky question, but I am trying to focus on best-practices...

24 Nov at 04:0

How to make a great R reproducible example

When discussing performance with colleagues, teaching, sending a bug report or searching for guidance on mailing lists and here on Stack Overflow, a [reproducible example](https://stackoverflow.com/he...

19 Aug at 17:12

What's the difference between git clone --mirror and git clone --bare

The git clone help page has this to say about `--mirror`: > Set up a mirror of the remote repository. This implies `--bare`. But doesn't go into detail about how the `--mirror` clone is different fr...

14 Nov at 04:56

How to list all databases in the mongo shell?

I know how to [list all collections in a particular database](https://stackoverflow.com/questions/8866041/how-to-list-all-collections-in-the-mongo-shell), but how do I list all available databases in ...

10 Feb at 05:6

ASP.NET Core Web API exception handling

I am using ASP.NET Core for my new REST API project after using regular ASP.NET Web API for many years. I don't see any good way to handle exceptions in ASP.NET Core Web API. I tried to implement an e...

9 Mar at 18:28

Notice: Undefined offset: 0 in

I am getting this PHP error, what does it mean? ``` Notice: Undefined offset: 0 in C:\xampp\htdocs\mywebsite\reddit_vote_tut\src\votes.php on line 41 ``` From this code: ``` <?php include("confi...

15 Feb at 04:37

Where are the python modules stored?

I have recently started learning Python and I have 2 questions relating to modules. 1. Is there a way to obtain a list of Python modules available (i.e. installed) on a machine? 2. I am using Ubuntu...

24 Dec at 00:13

How to see full query from SHOW PROCESSLIST?

When I issue `SHOW PROCESSLIST` query, only the first 100 characters of the running SQL query are returned in the info column. Is it possible to change MySQL config or issue a different kind of reques...

13 May at 11:44

jQuery click events firing multiple times

I'm attempting to write a video poker game in Javascript as a way of getting the basics of it down, and I've run into a problem where the jQuery click event handlers are firing multiple times. They'r...

How would I get everything before a : in a string Python

I am looking for a way to get all of the letters in a string before a : but I have no idea on where to start. Would I use regex? If so how? ``` string = "Username: How are you today?" ``` Can someo...

14 Feb at 05:9

Explaining Python's '__enter__' and '__exit__'

I saw this in someone's code. What does it mean? ``` def __enter__(self): return self def __exit__(self, type, value, tb): self.stream.close() ``` --- ``` from __future__ i...

How to convert a UTC datetime to a local datetime using only standard library?

I have a python `datetime` instance that was created using `datetime.utcnow()` and persisted in database. For display, I would like to convert the `datetime` instance retrieved from the database to lo...

Apply multiple functions to multiple groupby columns

The [docs](http://pandas.pydata.org/pandas-docs/dev/groupby.html#applying-multiple-functions-at-once) show how to apply multiple functions on a groupby object at a time using a dict with the output co...