Questions

How can I explicitly free memory in Python?

I wrote a Python program that acts on a large input file to create a few million objects representing triangles. The algorithm is: 1. read an input file 2. process the file and create a list of tri...

25 Nov at 20:26

Testing if a checkbox is checked with jQuery

If the checkbox is checked, then I only need to get the value as 1; otherwise, I need to get it as 0. How do I do this using jQuery? `$("#ans").val()` will always give me one right in this case: ``...

Replacing some characters in a string with another character

I have a string like `AxxBCyyyDEFzzLMN` and I want to replace all the occurrences of `x`, `y`, and `z` with `_`. How can I achieve this? I know that `echo "$string" | tr 'x' '_' | tr 'y' '_'` would wo...

15 Feb at 17:40

How can I stop the browser back button using JavaScript?

I am doing an online quiz application in PHP. I want to restrict the user from going back in an exam. I have tried the following script, but it stops my timer. What should I do? The timer is stored in...

14 Dec at 22:53

How to change color of SVG image using CSS (jQuery SVG image replacement)?

This is a self Q&A of a handy piece of code I came up with. Currently, there isn't an easy way to embed an SVG image and then have access to the SVG elements via CSS. There are various methods of usi...

14 Sep at 01:26

Meaning of @classmethod and @staticmethod for beginner

What do `@classmethod` and `@staticmethod` mean in Python, and how are they different? should I use them, should I use them, and should I use them? As far as I understand, `@classmethod` tells a cl...

How to check whether a pandas DataFrame is empty?

How to check whether a pandas `DataFrame` is empty? In my case I want to print some message in terminal if the `DataFrame` is empty.

20 Oct at 14:25

How to make PDF file downloadable in HTML link?

I am giving link of a pdf file on my web page for download, like below ``` <a href="myfile.pdf">Download Brochure</a> ``` The problem is when user clicks on this link then - - But I want it alwa...

9 Feb at 10:22

Force browser to clear cache

Is there a way I can put some code on my page so when someone visits a site, it clears the browser cache, so they can view the changes? Languages used: ASP.NET, VB.NET, and of course HTML, CSS, and j...

21 Dec at 11:27

Call a stored procedure with parameter in c#

I'm able to delete, insert and update in my program and I try to do an insert by calling a created stored procedure from my database. This button insert I made works well. ``` private void btnAdd_Clic...

What is "with (nolock)" in SQL Server?

Can someone explain the implications of using `with (nolock)` on queries, when you should/shouldn't use it? For example, if you have a banking application with high transaction rates and a lot of dat...

14 Mar at 04:52

How to iterate over columns of pandas dataframe to run regression

I have this code using Pandas in Python: ``` all_data = {} for ticker in ['FIUIX', 'FSAIX', 'FSAVX', 'FSTMX']: all_data[ticker] = web.get_data_yahoo(ticker, '1/1/2010', '1/1/2015') prices = DataF...

10 Jan at 00:51

git recover deleted file where no commit was made after the delete

I deleted some files. I did NOT commit yet. I want to reset my workspace to recover the files. I did a `git checkout .`. But the deleted files are still missing. And `git status` shows: ``...

13 Oct at 10:59

Using Pandas to pd.read_excel() for multiple worksheets of the same workbook

I have a large spreadsheet file (.xlsx) that I'm processing using python pandas. It happens that I need data from two tabs (sheets) in that large file. One of the tabs has a ton of data and the other ...

1 Aug at 22:34

How to truncate a foreign key constrained table?

Why doesn't a on `mygroup` work? Even though I have `ON DELETE CASCADE SET` I get: > ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (`mytest`.`instance`, CONSTRAI...

JavaScript loop through JSON array?

I am trying to loop through the following json array: ``` { "id": "1", "msg": "hi", "tid": "2013-05-05 23:35", "fromWho": "hello1@email.se" }, { "id": "2", "msg": "there", "tid": "2013-0...

1 Apr at 16:18

Function vs. Stored Procedure in SQL Server

When should I use a function rather than a stored procedure in SQL, and vice versa? What is the purpose of each?

Simple way to repeat a string

I'm looking for a simple commons method or operator that allows me to repeat some string times. I know I could write this using a for loop, but I wish to avoid for loops whenever necessary and a simp...

5 Nov at 12:42

How to open a URL in a new Tab using JavaScript or jQuery?

How to open a URL in new tab instead of new window programatically?

23 Jul at 14:50

What is a JavaBean exactly?

I understood, I think, that a "Bean" is a Java-class with properties and getters/setters. As much as I understand, it is the equivalent of a C `struct`. Is that true? Also, is there a real differenc...

Replace a value in a data frame based on a conditional (`if`) statement

In the R data frame coded for below, I would like to replace all of the times that `B` appears with `b`. ``` junk <- data.frame(x <- rep(LETTERS[1:4], 3), y <- letters[1:12]) colnames(junk) <- c("...

26 Apr at 11:17

Is there an R function for finding the index of an element in a vector?

In R, I have an element `x` and a vector `v`. I want to find the first index of an element in `v` that is equal to `x`. I know that one way to do this is: `which(x == v)[[1]]`, but that seems excessiv...

7 Apr at 08:4

Received fatal alert: handshake_failure through SSLHandshakeException

I have a problem with authorized SSL connection. I have created Struts Action that connects to external server with Client Authorized SSL certificate. In my Action I am trying to send some data to ban...

Why am I getting "IndentationError: expected an indented block"?

``` if len(trashed_files) == 0 : print "No files trashed from current dir ('%s')" % os.path.realpath(os.curdir) else : index=raw_input("What file to restore [0..%d]: " % (len(trashed_files)-1)...

6 Feb at 09:26

Check if element is visible in DOM

Is there any way that I can check if an element is visible in pure JS (no jQuery) ? So, given a DOM element, how can I check if it is visible or not? I tried: ``` window.getComputedStyle(my_element)['...

9 Dec at 09:44