Rails: Cache or not Cache

I'm trying to use cache but I want to know if is possibile to cache data that change frequently. If data change often is caching a good strategy? If I cache a posts list with fragment cache, and a user edit his post, cache is upload automatically? ...
more »

2017-11-05 16:11 (1) Answers

How to Restore ViewPager from savedInstanceState

So I have a problem that I can't seem to solve. I have a ViewPager in one of my activities, say MainActivity. I am implementing all the required methods to save and retrieve instance state when the activity gets killed in the background. But when the...
more »

2017-11-04 08:11 (3) Answers

Laravel duplicated queries from blade directive

I am getting duplicated queries from using a Blade directive. I am checking a user's role, and then displaying data in a table, so the query repeats itself over and over, slowing down the app. I have registered a Blade service provider, and in the b...
more »

2017-11-01 23:11 (3) Answers

Reduce the DOM search frequency in Javascript

I'm in the process of getting rid of Jquery from a small project and re-writing the script with vanilla js. In the current code there's a jquery implementation to search a DOM element and then use jquery 'find'to search specific elements within the e...
more »

2017-10-31 14:10 (1) Answers

Python for loop better way

We all know that the common way of executing a statement certain number of times in Python is to use a for loop. The general way of doing this is, # I am assuming iterated list is redundant. # Just the number of execution matters. for _ in range(co...
more »

2017-10-29 03:10 (3) Answers

SQL UDF speed in subquery vs in declare

I've created an UDF that get the last business day and it runs in less than 1s. SELECT BlackWidow.dbo.LastBusinessDay('2015-12-31',DEFAULT) I've also created an UDF that returns a table and it runs in 1s. SELECT * FROM BlackWidow.dbo.Tu...
more »

2017-10-27 19:10 (1) Answers

Fast subset/lookup/filter in large datasets

I need to repeatedly look up "closest" row in a large (many GB) table with factor and numeric columns. Using dplyr, it looks like this: df <- data.frame(factorA = rep(letters[1:3], 100000), factorB = sample(rep(letters[1:3], 100000),...
more »

2017-10-24 19:10 (2) Answers

Better way to read the values from JSONObject

Please tell the better way to read the value from JSONObject: // #1 String offerSubCategory = offeringJson.getJSONObject("offeringSubCategory").getString("code"); // #2 String offerSubCategory = offeringJson.getJSONObject(Constants.offeringSubCat...
more »

2017-10-21 11:10 (1) Answers

Why do people use JQuery with Reactjs?

So I go through the questions on stack overflow often and I have been noticing that so many people are using jQuery with Reactjs. I know that JQuery allows the client-side to interact with the user, alter the document content, communicate asynchronou...
more »

2017-10-19 16:10 (0) Answers

Parse large stdin ruby

I need to write script for parse large input data (30GB). I need extract all numbers from stdin text and output it by order desc. Example of usage: cat text_file_30gb.txt | script Now I use for parse: numbers = [] $stdin.each_line do |line| num...
more »

2017-10-14 22:10 (1) Answers

Input string without knowing the size

What's the way when i want to store string that i don't know the size. I do like this: #include <stdio.h> #include <conio.h> int main () { char * str; str = (char *)malloc(sizeof(char) + 1); str[1] = '\0'; int i = 0...
more »

2017-10-12 11:10 (4) Answers

Why is groupby so fast?

This is a follow up question to this one, where jezrael used pandas.DataFrame.groupby to increment by a factor of some hundreds the speed of a list creation. Specifically, let df be a large dataframe, then index = list(set(df.index)) list_df = [df.l...
more »

2017-10-10 17:10 (1) Answers

Cassandra read performance

What causes Cassandra cluster to be 20% slower in read operations than a single-node cluster? I have set up a Cassandra cluster with 3 nodes and tested read performance. I used Cassandra's integrated stress test tool. For comparison, there is one s...
more »

2017-10-09 11:10 (1) Answers

Xcode 9 - High CPU usage - Fan max speed

Ever since I upgraded to Xcode 9, my fan goes crazy when I'm working on Xcode. This is especially happening when I use Storyboards and Interface Builder. Xcode sometimes takes up to 100% of the CPU and the process named "Interface Builder Cocoa Tou...
more »

2017-10-08 18:10 (0) Answers