What and where are the stack and heap?

Programming language books explain that value types are created on the stack, and reference types are created on the heap, without explaining what these two things are. I haven't read a clear...

What is the ideal growth rate for a dynamically allocated array?

C++ has std::vector and Java has ArrayList, and many other languages have their own form of dynamically allocated array. When a dynamic array runs out of space, it gets reallocated into a larger...

64 bit int arthimetic on 32bit x86 (from c )

Is there a fast way of using 64bit ints on 32 x86 machines (in c (added: and c++) language compilers)? 32 bit x86 support 64 bit operations in some extent (there is some movq instruction in old...

Modules in Javascript with eval();

Every javascript developer knows; eval is evil But since i am looking for the ultimative module technology in javascript, i read something very interesting about someone using eval as a module...

Google Script to Submit Form to Calendar Event

School teacher using my personal Google account to create forms and publish calendars to my class web site. Trying to make it fast and easy as possible for kids (with no access to Google Apps) to...

increasing code performance of codility

today i heard about this website called codility where a user can give various programming test to check their code's performance. When I started, they presented me with this sample test, Task...

Open web in new tab Selenium + Python

So I am trying to open websites on new tabs inside my WebDriver. I want to do this, because opening a new WebDriver for each website takes about 3.5secs using PhantomJS, I want more speed... I'm...

Scala: Can there be any reason to prefer `filter+map` over `collect`?

Can there be any reason to prefer filter+map: list.filter (i => aCondition(i)).map(i => fun(i)) over collect? : list.collect(case i if aCondition(i) => fun(i)) The one with collect (single...

How to play a video in real time using python Opencv

I am wanting to play a video at its correct speed. When I play the current video it is very slow. The faster the frame rate of the video I play the slower it goes. I was wondering if there is a...

In GraphQL what's the meaning of "edges" and "node"?

I am consuming a particular GraphQL endpoint and although I am supplying a clean JSON structure as a query, when I get the results I get "edges" and "node" tags. It seems as if it is polluting my...

Looking for a fast prime-counting function

I need to calculate the number of primes less than or equal to some N, which is the prime-counting function or the PI function. I have this one but it works too slowly: function PI(x) { var...

Need Faster way to remove leading Zero from Dates in Excel Output

We have an internal software that exports data reports to Excel, and several of the columns contain dates in the MM/DD/YYYY format. I have a spreadsheet setup where I will copy these exported...

What happens if you use the 32-bit int 0x80 Linux ABI in 64-bit code?

int 0x80 on Linux always invokes the 32-bit ABI, regardless of what mode it's called from: args in ebx, ecx, ... and syscall numbers from /usr/include/asm/unistd_32.h. (Or crashes on 64-bit...

Row-wise iteration like apply with purrr

How do I achieve row-wise iteration using purrr::map? Here's how I'd do it with a standard row-wise apply. df <- data.frame(a = 1:10, b = 11:20, c = 21:30) lst_result <- apply(df, 1,...

How to copy paste multiple lines of code into rails console (e.g. copy paste from a script)

I discovered from here that if you have a script you want to run in the rails console, you sometimes have to copy paste it line by line (copy pasting it all at once doesn't always work) This is...

Fast way to md5 a numpy array

I am woring with a numpy's 1d array with thousands of uint64 numbers in python 2.7. What is the fastest way to calculate the md5 of every number individually? Each number has to be converted to...

What is the difference between "npm install" and "npm ci"?

I'm working with continuous integration and discovered the npm ci command. I can't figure what the advantages are of using this command for my workflow. Is it faster? Does it make the test...

Performant way to find out if an element or any of its ancestor elements has display: none

I need to find a very performant way to find out if a custom element or any of its parent elements has display: none; First approach: checkVisible() { let parentNodes = []; let el = this; ...

Remote interpreter and local plot in PyCharm?

I'm using PyCharm with a remote interpreter. My code is showing a scatter figure using matplotlib. I can see the figure normally and interact with (zoom and rotate), but the interaction is too...

how to make cv2.videoCapture.read() faster?

My question : I was working on my computer vision project. I use opencv(4.1.2) and python to implement it. I need a faster way to pass the reading frame into image processing on my Computer(Ubuntu...

Generating moves in Othello with bitboards

I have made two very similar Othello AIs. In the first one, the board is represented as an array of length 100 where the 8x8 board is represented by the "middle" of the board and the rest is...

Avoid accumulation of data in udp socket or read newest data from udp socket

I am trying to send data continuously from a c++ code to a python code. I used udp sockets to send the data. The rate of sending is at a faster rate than the receiving rate as it is a simple...

laravel repository - why need to call to interface instead of calling directly to repository file?

I've read about repository pattern.So, I created UserRepositoryInterface.php file namespace App\Interfaces; use Prettus\Repository\Contracts\RepositoryInterface; interface UserInterface extends...

Alternative to chrome native messaging

I want my chrome addon to connect to redis server. One of the option explored is chrome native messaging since addon/browser cannot directly connect to redis. Browser/addon can only communicate...

How to use scss without css modules in nextjs

I can configure webpack to allow includes of scss. *Note: Working with classNames on the original html is faster when copying code between static html to React components, which is why I want to...

How to find peaks of FFT graph using Python?

I am using Python to perform a Fast Fourier Transform on some data. I then need to extract the locations of the peaks in the transform in the form of the x-values. Right now I am using Scipy's fft...

Defeating the time complexity of Python Dictionary

I have a Python dictionary whose keys are Strings consisting of lower-case English alphabets and values are ints. Moreover, there are exactly 5e6 unique keys, all of them are Strings with lengths...

Store Grid N*N into an Adjacency Graph? Position and Neighbors

Updating this Post. I cannot wrap my head around this, I cannot picture this clearly in my head. I have a grid, I can loop two 2D arrays, one for vertical, and one for horizontal. Both are 2D...

Counting the occurence based on overlapping intervals (HH:MM) in Pandas

I have a dataset with the exact time and quantity of e-vehicles charging at a charging station and its charging power in kW. What I am trying to do is to calculate how many e-vehicles are charging...

Fast idiomatic Floyd-Warshall algorithm in Rust

I am trying to implement a reasonably fast version of Floyd-Warshall algorithm in Rust. This algorithm finds a shortest paths between all vertices in a directed weighted graph. The main part of...