get all indexes of value nil in array

I have an array of N elements and this array contains either 0, 1 or nil. I want to get all indexes at which nil is present or sort the array so that all nil comes first. I am looking for an efficient way because the array size can be very large. H...
more »

2017-09-16 06:09 (1) Answers

Track the rows which were updated or encrypted

I want to scrub(or encrypt) the email information from a few tables which are older than a few years. This I am planning to do as part of a job, next time when I run the job how can I omit the rows which are already scrubbed or encrypted. I am look...
more »

2017-09-13 09:09 (2) Answers

Java Streams: distinct() on a pre-sorted stream?

As discussed in this question, the implementation of distinct() is able to use a more efficient algorithm when the stream it operates on is known by the runtime to be sorted. How can we achieve a similar result if we know that the stream is sorted (...
more »

2017-09-12 15:09 (1) Answers

Could CDN be faster way to load resources?

I was setting up the admin panel for a blog today, and I decided just to use the CDN bootstrap link rather than keeping the files local on the server since this was just some initial testing. I figured that I would add the files to the server later i...
more »

2017-09-12 02:09 (4) Answers

How is Underscrore's now method is faster?

I am curious how Underscore's _.now method is faster than just new Date().getTime(). I see the following on their github codebase. // A (possibly faster) way to get the current timestamp as an integer. _.now = Date.now || function() { return new...
more »

2017-09-07 01:09 (2) Answers

Comparing Numpy and Matlab array summation speed

I recently converted a MATLAB script to Python with Numpy, and found that it ran significantly slower. I expected similar performance, so I'm wondering if I'm doing something wrong. As stripped-down example, I manually sum a geometric series: MATL...
more »

2017-09-06 07:09 (2) Answers

Efficient concatenation ignoring suffixes in index

I do have two dataframes like this: import pandas as pd df1 = pd.DataFrame({"c1": range(5), "c2": range(1, 6)}, index=list("ABCDE")) df2 = pd.DataFrame({"c3": range(15, 21), "c4": range(11, 17)}, index=["A_suf1", "B_suf2", "A_suf2", "C_suf2", "B_su...
more »

2017-09-03 19:09 (2) Answers

How to reduce code of multiple if statements

I am trying to validate a large contact form. When the user forgets a required input field then I populate the empty variable with default text. My current solution uses nine if statements. Is there a better way to do it with less code? html: &l...
more »

2017-09-03 09:09 (3) Answers

Would it be efficient to sort with indexes

So I was thinking of a new sorting algorithm that might be efficient but I am not too sure about that. 1) Imagine we have an array a of only positive numbers. 2) We go through the array and find the biggest number n. 3) We create a new array ...
more »

2017-09-02 19:09 (2) Answers

Fast subsetting of a matrix in R

I face the following problem: I need many subsets of a big matrix. Actually I just need views as input for another function f(), so I don't need to change the values. However it seems, that R is terribly slow for this task, or I'm doing something wr...
more »

2017-09-02 18:09 (2) Answers

JavaFX textarea displaying big file

I'm trying to show on screen a textfile content using JavaFX textarea. I success doing it with small files, but with big ones everything becomes too slow. File with size 64KB was read in 1 second, and it takes 2 minutes to display it. There is code: ...
more »

2017-09-01 07:09 (1) Answers