Generating a LOT of unique tokens in Ruby

I needed to generate a lot of unique codes, for two lists of codes, that cannot match with each other and be unique codes. It has to be seven characters in length. BUT I'm not satisfied with my final solution, that I had to let run all night. I wo...
more »

2017-09-15 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

Perfomance of map vs starmap?

I was trying to make a pure-python (without external dependencies) element-wise comparison of two sequences. My first solution was: list(map(operator.eq, seq1, seq2)) Then I found starmap function from itertools, which seemed pretty similar to me....
more »

2017-09-12 10:09 (2) 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 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. = || function() { return new...
more »

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

PHP MySQL - Update 6.5m rows performance issues

I am working with a MySQL table and I need to increment a value in one column for each row, of which there are over 6.5m. The col type is varchar and can contain an integer or a string (i.e. +1). The table type is MyISAM. I have attempted this wi...
more »

2017-09-06 13:09 (3) 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 (3) Answers

Load files from one CDN or multiple CDNS

On a typical webpage I load the following, all from CDNs: jQuery Angular Bootstrap Icomoon a few Angular plugins Is it better to load these from 1 CDN (if possible), or from different CDNs? Are there best practices for this, or does it not make ...
more »

2017-09-04 16: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

MySQL/PostgreSQL Column Sizes, Why?

I'm developing a program and ran into a bug where inserting a value in a tables column, that has the type int, and the value is larger than Integer.MAX_VALUE it spits out an error saying the number is too large. I read that the fix for this is to qui...
more »

2017-09-02 05:09 (3) 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