Questions

Interface vs Abstract Class (general OO)

I have recently had two telephone interviews where I've been asked about the differences between an Interface and an Abstract class. I have explained every aspect of them I could think of, but it seem...

15 Sep at 14:30

Convert a python dict to a string and back

I am writing a program that stores data in a dictionary object, but this data needs to be saved at some point during the program execution and loaded back into the dictionary object when the program i...

17 Feb at 01:46

In C#, what is the difference between public, private, protected, and having no access modifier?

All my college years I have been using `public`, and would like to know the difference between `public`, `private`, and `protected`? Also what does `static` do as opposed to having nothing?

28 Nov at 19:19

Difference between Constructor and ngOnInit

Angular provides life cycle hook `ngOnInit` by default. Why should `ngOnInit` be used, if we already have a `constructor`?

Finding duplicate values in MySQL

I have a table with a varchar column, and I would like to find all the records that have duplicate values in this column. What is the best query I can use to find the duplicates?

27 Mar at 04:22

Setting a backgroundImage With React Inline Styles

I'm trying to access a static image to use within an inline `backgroundImage` property within React. Unfortunately, I've run up dry on how to do this. Generally, I thought you just did as follows: ```...

10 Aug at 20:45

Angular File Upload

I'm a beginner with Angular, I want to know how to create Angular 5 , I'm trying to find any tutorial or doc, but I don't see anything anywhere. Any idea for this? And I tried [ng4-files](https://git...

7 Jul at 06:0

What is the difference between <section> and <div>?

What is the difference between `<section>` and `<div>` in `HTML`? Aren't we defining sections in both cases?

2 Jan at 09:56

C char array initialization: what happens if there are less characters in the string literal than the array size?

I'm not sure what will be in the char array after initialization in the following ways. 1.`char buf[10] = "";` 2. `char buf[10] = " ";` 3. `char buf[10] = "a";` For case 2, I think `buf[0]` sh...

20 Dec at 12:7

React JSX: selecting "selected" on selected <select> option

In a React component for a `<select>` menu, I need to set the `selected` attribute on the option that reflects the application state. In `render()`, the `optionState` is passed from the state owner t...

5 Dec at 00:12

Yes or No confirm box using jQuery

I want yes/No alerts using jQuery, instead of ok/Cancel button: ``` jQuery.alerts.okButton = 'Yes'; jQuery.alerts.cancelButton = 'No'; jConfirm('Are you sure??', '', function(r) { ...

22 Apr at 22:41

Flexbox: 4 items per row

I'm using a flex box to display 8 items that will dynamically resize with my page. How do I force it to split the items into two rows? (4 per row)? Here is a relevant snip: (Or if you prefer jsfiddl...

26 Dec at 21:47

JavaScript: Is there a way to get Chrome to break on all errors?

I am looking for an equivalent in Chrome to the "break on all errors" functionality of Firebug. In the Scripts tab, Chrome has a "pause on all exceptions", but this is not quite the same as breaking o...

How to print HTML content on click of a button, but not the page?

I want to print some HTML content, when the user clicks on a button. Once the user clicks on that button, the print dialog of the browser will open, but it will not print the webpage. Instead, it will...

3 Jun at 10:28

How do you pass a function as a parameter in C?

I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?

29 Jul at 19:9

Filtering Pandas DataFrames on dates

I have a Pandas DataFrame with a 'date' column. Now I need to filter out all rows in the DataFrame that have dates outside of the next two months. Essentially, I only need to retain the rows that are ...

How can I inject a property value into a Spring Bean which was configured using annotations?

I have a bunch of Spring beans which are picked up from the classpath via annotations, e.g. ``` @Repository("personDao") public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao { ...

25 Jan at 15:5

Capture HTML canvas as GIF/JPG/PNG/PDF?

Is it possible to capture or print what's displayed in an HTML canvas as an image or PDF? I'd like to generate an image via canvas and be able to generate a PNG from that image.

11 Feb at 20:18

"Connect failed: Access denied for user 'root'@'localhost' (using password: YES)" from php function

I wrote some function used by a php webpage, in order to interact with a mysql database. When I test them on my server I get this error: ``` "Connect failed: Access denied for user 'root'@'localhost'...

11 Mar at 06:46

How do I add an extra column to a NumPy array?

Given the following 2D array: ``` a = np.array([ [1, 2, 3], [2, 3, 4], ]) ``` I want to add a column of zeros along the second axis to get: ``` b = np.array([ [1, 2, 3, 0], [2, 3, 4, ...

30 Jul at 08:33

How to delete a localStorage item when the browser window/tab is closed?

My Case: localStorage with key + value that should be deleted when browser is closed and not single tab. Please see my code if its proper and what can be improved: ``` //create localStorage key + valu...

6 Dec at 06:45

Android "Only the original thread that created a view hierarchy can touch its views."

I've built a simple music player in Android. The view for each song contains a SeekBar, implemented like this: ``` public class Song extends Activity implements OnClickListener,Runnable { privat...

10 Dec at 17:10

How to pass parameters in GET requests with jQuery

How should I be passing query string values in a jQuery Ajax request? I currently do them as follows but I'm sure there is a cleaner way that does not require me to encode manually. ``` $.ajax({ ...

23 May at 12:26

python .replace() regex

I am trying to do a grab everything after the `'</html>'` tag and delete it, but my code doesn't seem to be doing anything. Does `.replace()` not support regex? ``` z.write(article.replace('</html>.+'...

3 Jan at 17:8

Calculating the difference between two Java date instances

I'm using Java's `java.util.Date` class in Scala and want to compare a `Date` object and the current time. I know I can calculate the delta by using getTime(): ``` (new java.util.Date()).getTime() - ...