Return NSError or Error from Javascript

Uncategorized
Question: I am working on an ios app which uses Firebase as database. The app can upload some data to firebase via cloud functions, but the data might not be valid, so there is a chance that the cloud functions will reject the request. The problem is that my app needs to receive an Error?, so that it can know if the request is rejected, and what causes the rejection. So, how can I return an Error?/NSError? type from javascript, or there is another way to do this. Answer: Read more
Read More

RegExp to read txt and filter and only read first match

Uncategorized
Question: I'm reading a txt file that has multiple lines like below. lastname australia enter name j.jonhs enter name j.cause enter name f.london enter I'd like to use regexp to read the first line that matches name only and stop reading, can someone help me modify the line below? output=output.split("n").filter(/./.test, /name/).join("n").replace("name", "").replace("enter", ""); Answer: after spiting you got an array. Why don't just target index 0 as- output=output .split("n")[0] .replace("name", "") .replace("enter", ""); edit after question modification as you have specific matching on name, you can use substring as- const s = `lastname australia enter name j.jonhs enter name j.cause enter name f.london enter`; let ns = s.split("n").find((item) => item.substring(0, 4) === 'name') if(ns){ // found do something here. }else{ // not found } Read more
Read More

I am not familiar with this type of printf() statement . Why my output look like this ? thanks

Uncategorized
Question: #include int main() { int i=43; printf("%d",printf("%d",printf("%d",printf("%d",i)))); return 0; } what the use of nested printf()? I used value 43 but how other values showing in output? Output: 43211 Answer: Consider this as a simpler version of your code:int main(){ int i = 43; int a = printf("%d", i); int b = printf("%d", a); int c = printf("%d", b); printf("%d", c); return 0; } It's clear why 43 is printed. As for the other digits, they are the return value of printf: On success, the total number of characters written is returned. So, what you should have been getting (considering this was your exact code) is: 43211 43 is the first print 2 is the number of digits printed before ('4' + '3') 1 is the number of digits…
Read More

keeping settings in DB for quartz, reschedule scheduler

Uncategorized
Question: I am trying to build clear mechanism of adding new job’s with Quartz. I am keeping whole needed data for trigger’s etc in database. I build an abstract class that extracts Job interface, with needed content. Now I try to do some class or interface for triggers. Then I just have to create somewhere these objects and at the end add them to QuartzSchedulerApp class (and of course add this to scheduler object). Is this good logic? Also I have a technical question: I guess, when I change something about triggers (delta time for example) Do I have to reschedule the scheduler? How should I do this? Please for some ideas. :) Answer: Read more
Read More

How to set active sheet as variable in below recorded macro for excel 2013?

Uncategorized
Question: I recorded a macro in excel. I have do this with excel to generate report every week. Position and number of columns remains same. But, Number of rows change every week. Same way file name and sheet name changes. This recorded macro is recorded for sheet named "2017_08_13". I have to change the sheet name manually in this macro every time. Same way cell selection Goes to row number 101. Everytime I have to manually enter the last row number to get it working. Can anyone help me to make this two things work for every sheet automatically. 1) It will run on activesheet so, instead of sheet name, we can make it to go with active sheet. 2) It should go upto last cell to select. In line…
Read More

Tuning Storm-Crawler to fully use available resources

Uncategorized
Question: I have a node fully dedicated to my Storm-Crawler based crawler. I have at disposal 20 dual-core CPUs, 130 Gb of RAM and 10Gb/s Ethernet connection. I reduced my topology to: CollapsingSpout -> URLPartitionerBolt -> FetcherBolt. The spout is reading from an Elasticsearch index (with ~50 M records). Elasticsearch is configured with 30 GB RAM and 2 shards. I use a single worker with roughly 50 GB of RAM dedicated to the JVM. Playing with the different settings (total number of threads, number of threads per queue, max pending spout, some related to Elasticsearch such as number of buckets and bucket size mainly) I can reach an overall fetching speed of 100 MB/s. However, looking at ganglia reports, it corresponds to only 10% of the bandwidth available to me.…
Read More

Resizing dynamic TableLayout in android

Uncategorized
Question: I have created a dynamic TableLayout in Android. The problem is, there is an unnecessary gap in the column. I'd like to remove it, I've been changing the code a few times but the results are astonishing. Here is the best that I can get at the moment. TableLayout Image As you can see, there is a gap in the header and also in the row if the row consisting 2+ lines. I want to make the first column (which is Items) have the longest width while the other column just wraps the content with the header. here is the XML And here is the code to make dynamic row private void init() { // Array for item String[] valuesItem = new String[] { "Room asd", "Room qwewq", "Room…
Read More

C++11 support in NativeLibrary for Android

Uncategorized
Question: I'm trying to create a native library in C++, which I can use in Android. I've created a project in Visual Studio 2017: Dynamic Shared Library (Android), and added my cpp code. Though some of the code is running C++11, and I'd really like to keep it that way. When I compile, I get the error:This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. So I first tried going to Project->Properties->C/C++->Language->C++ Language Standard, and set the options as following: ' When I compile now, I get exactly the same error. So I tried manually adding the -std=c++11 flag under additional options, though still getting the error. Why is the…
Read More