text:
Q: Aggregating data between microservices in twitter-like application I'm developing a Twitter-like app and I have some doubts about my service oriented architecture.
I have a User Service with a REST endpoint POST /users/{userId}/follow
so the "connected" user starts following the user userId. After that, this service publish an event UserStartedFollowing with a payload like this:
{ "followerId": "1234",  "followedId": "77638" }

Then, I have a Timeline Service that listens this events and build the timeline (the comments, aka tweets) asynchronously. This service exposes an endpoint GET /messages that returns all the messages (aka tweets) of people that you are following (previously posted using another endpoint POST /messages). The response is like this:
[{
  userId: "786387",
  content: "This is an example of a message"
}]

Problem comes here. In the app, I need to show the message author's name. But I don't have that information in the Timeline Service, but only the ID. What is the better way to do this?
I have thought about fetching each user name from her ID from the User Service (from some kind of API gateway), caching the data. But maybe it is too heavy.
Another option could be to include the followed user name in the UserStartedFollowing event and store it in the Timeline Service, too. So then it will be included in the /messages response.
What do you think?

A: What you have here is not bad at all.  You will find; however, that the user interface has different needs than a proper API.  There are several ways to address this.  The one that Facebook chose to employ was GraphQL, which when combined with React allows you to assemble all this information together.  See also: Intro Tutorial.
What GraphQL allows the front end to do is to package up it's needs into one query to the GraphQL Server.  With intelligent design in how you implement that for your application, the infrastructure can consolidate the requests.  Lets say you have a feed that looks like this:
[{
  userId: "786387",
  content: "This is an example of a message"
},{
  userId: "786387",
  content: "The same user said something else"
}]

You can create a query that will get everything you need and GraphQL will only request the User information for the user id 786387 one time.  That optimizes the load on the back-end, and lets you think about where you would implement caching should you need it.
Another benefit here is that GraphQL does allow you to customize the size and shape of your data.  If you only care about displaying the user's name on screen, you can specify that in your request and you won't receive any other user information.

GraphQL is not the only solution, but it is a pretty decent generic solution for problems like this.  Another alternative is to create your own custom federation service that acts as an interface between the front-end and the micro-service.  Falcor was created by NetFlix with many of the same use cases as GraphQL.  I remember hearing that NetFlix has since moved to GraphQL, but my sources could be wrong.
As a dissenting opinion, I have another blog article that shows that GraphQL is not a panacea.  The first part of the article actually paints a really good picture for why you would want to use it:

*

*Schema stitching allows each microservice to have a GraphQL endpoint, and a master to tie it all together

*It's strongly typed

*There's bindings for almost every language you use

*You can use multiple front-end frameworks, so you aren't stuck with React

*Schemas support versioning

But then it also points out some deficiencies as well:

*

*Queries can get complex

*It's harder to rate-limit because not every query has the same impact

*It can be harder to apply caching to the GraphQL layer (but you can still apply it to the backing REST calls

At the end of the day, it's worth a look to see if it solves the needs you have.  The alternative is to create your own custom layer that is specific to your website.  That would be quicker to get up and running because it's a lower learning curve, but you lose the advantages of decoupling your back-end from your frond-end code.

A: I think you have a conflict of priorities of normalized vs. denormalized data. Simply put, for storage and consistency you want to have a users table (userid and name) and a messages table (messageid, userid and message) and a user to user table (userid, userid followed) where you track who is following whom. You don't want to permanently store 100 copies of a message when a user has 100 subscribers.
(I know you have SoA and not one database, stay with me, this is more of a conceptual view)
For presentation, you do want a denormalized view for the most recent data, for example the last day's feed for each user or even just the user's first page load. Most services of this kind have an infinite scrolling feature where the user can get more data displayed, but likely it's not as effective on the back-end of their service, as few users will dig days into their news feed hence the designers can afford to do less caching or be less efficient about retrieving the data.


text:
Q: Java8 filter arraylist with custom object on field date I have to filter List<Card> on the field, issueDate(type String), where cards to be shown till last 7 years date.
The solution that I've tried is to parse issueDate field from String to Date and then apply date.after(startDate) and date.before(endDate) as below:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
cardList.stream()
        .map(s->s.getIssueDate())
        .filter(dt -> sdf.parse(dt).after(sdf.parse("2020-06-08")) &&
                      sdf.parse(dt).before(sdf.parse("2020-08-12")))
        .collect(Collectors.toList());

Even can't apply for loop as there can be hundreds of cards issued, and it impacts performance by iterating on each card issue date(string to date and check year)
Can anyone suggest a good solution to this problem?

A: There are many problems with your code:

*

*The java.util date-time API and their formatting API, SimpleDateFormat are outdated and error-prone. It is recommended to stop using them completely and switch to the modern date-time API* .

*You should declare issueDate as LocalDate (or Date if you still want to stick to the legacy API) instead of String. However, for any reason, if you still want to keep it as String, you can change your code to parse it to a date-type object only once during Stream processing (currently, you are doing it twice).

*You are parsing 2020-06-08 and 2020-08-12 inside Stream processing whereas they are static values and therefore they should be parsed outside the Stream processing. In fact, if these static dates are not as String, you can create date-type objects directly e.g. LocalDate start = LocalDate.of(2020, 6, 8).

These suggestions have been incorporated in the following code:
LocalDate start = LocalDate.parse("2020-06-08");
LocalDate end = LocalDate.parse("2020-08-12");

List<LocalDate> dates =
        cardList.stream()
                .map(card -> LocalDate.parse(card.getIssueDate()))
                .filter(ld -> ld.isAfter(start) && ld.isBefore(end))
                .collect(Collectors.toList());

If you want to collect the Stream into a list of cards, you can do it as follows:
List<Card> cards =
        cardList.stream()
                .filter(card -> {
                    LocalDate ld = LocalDate.parse(card.getIssueDate());
                    return ld.isAfter(start) && ld.isBefore(end);
                })
                .collect(Collectors.toList());

* For any reason, if you have to stick to Java 6 or Java 7, you can use ThreeTen-Backport which backports most of the java.time functionality to Java 6 & 7. If you are working for an Android project and your Android API level is still not compliant with Java-8, check Java 8+ APIs available through desugaring and How to use ThreeTenABP in Android Project. Learn more about the modern date-time API from Trail: Date Time.

A: Not sure you need to parse the dates here. All of your dates are String and have the same yyyy-MM-dd format.
In this particular case you could simply compare the strings lexicographically:
String from = "2020-06-08";
String to = "2020-08-12";

List<Card> filteredCardList =
    cardList.stream()
            .filter(card -> card.getIssueDate().compareTo(from) > 0)
            .filter(card -> card.getIssueDate().compareTo(to) < 0)
            .collect(toList());

or you do the same with plain old loop:
List<Card> filteredCardList = new ArrayList<>();
for(Card card : cardList) {
    String date = card.getIssueDate();
    if(date.compareTo(from) > 0 && date.compareTo(to) < 0) {
        filteredCardList.add(card);
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Lottie widget not animating because parent is a stateful widget I have an app with a Stateful Widget which contains an AnimatedContainer() which has another Stateful widget as it's child but it's basically just a wiget that has the Lottie.asset() widget as it's child along with it's controller. There's also another problem where the Lottie.asset() widget flashes but I think that's because it is rebuilding over and over. I think I need to prevent the Lottie Animation from rebuilding but I'm not sure how to do so.
Here is my Lottie animation: https://drive.google.com/file/d/193ZDqagSDg_U2m6OlZDTj3mY8RtKLcpR/view?usp=sharing
Here's what it looks like in the app: https://drive.google.com/file/d/1PcGS8h3ab6fIvMqemByZ5STTCa72w4Bi/view?usp=sharing
As you can see, it just cuts and doesn't animate, how can I fix this?
Here is my code: https://gist.github.com/HadyMash/d038c2b41957a6e61126eb5f75cb6354
Thanks!

A: I fixed this by completely eliminating the Check() widget as it was easier to control it from the Todo(). To fix the flickering I gave it a GlobalKey(). Then I just added a controller to Todo() and made it go forward() or reverse() accordingly.
The final result looks something like this: https://cln.sh/EqRyRc


text:
Q: Make  options "click" automatically Let's say I've got a drop down like this:
<div class="selector">
    <select name="perPage">
        <option value="5">5</option>
        <option value="10">10</option>
        <option value="15">15</option>
        <option value="25">25</option>
    </select>
</div>

I'm know PHP and Javascript (jQuery) so a solution in either would be just fine. But I've got a submit button underneath it, and instead of that, I was wondering if there's a way to click the drop down, pick your value, then have it send that automatically with OUT having to hit a submit?

A: You could use the 'onchange' element of the select:
<select name="dropdown" id="dropdown" onchange="this.form.submit()">

This only uses javascript without the need of loading the whole JQuery library - unless you use JQuery for other functions on the site.

A: You can listen to the change event using jQuery and submit the parent form automatically. Something like this:
$('.selector select[name=perPage]').on('change', function(e) {
    $(e.currentTarget).closest('form').submit();
});

A: Assign an id to to select, e.g. selectID, then add jQuery of the form:
$('#selectID').change(function(){
    this.form.submit()
});

A: $('select[name="perPage"]').on('change', submitForm);

where submitForm is a function that submits the form.


text:
Q: Spring mvc Resource not found I am trying to develop a basic login application using Spring MVC.When i try to run the project it gives 404(Resourse not found) on start up.Here is my code:
spring-dispatcher-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<mvc:default-servlet-handler />
<bean id="HandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<bean name="/welcome.html" class="com.sumanth.org.HelloController" />

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/WEB-INF</value>
    </property>
    <property name="suffix">
        <value>*.jsp</value>
    </property>
</bean>

Here is web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>logInSpring</display-name>
<welcome-file-list>
<welcome-file>HelloPage.jsp</welcome-file>

<servlet>
    <servlet-name>spring-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>spring-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

Controller:
package com.sumanth.org;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class HelloController extends AbstractController {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
    HttpServletResponse response) throws Exception {
        ModelAndView modelandview = new ModelAndView("HelloPage");
        modelandview.addObject("WelcomeMessage","hi");

        return modelandview;
    }
}

I strongly believe there is some configuration problem.Please Let me know how can i solve this issue. Tried seeing various posts on stackoverflow and other sites but nothing helped me out.

A: Your servlet mapping seems to be wrong.Should be spring-dispatcher-servlet rather than spring-dispatcher
Try this :
   <servlet>
    <servlet-name>spring-dispatcher-servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-dispatcher-servlet.xml</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>spring-dispatcher-servlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

A: Once check your folder structure..
all spring jars should be copied in lib folder that is in Web-INF and import from there


text:
Q: Unnecessary recomposition happening on IconButton I have this simple IconButton, but when i try to inspect the recomposition the number goes up when scrolling on LazyColumn, whereas the IconButton is unaffected. I've tried to pass empty lambda on the onClick, no recomposition happened though.
IconButton(
    onClick = onBackArrowClick,
    content = {
        Icon(
            imageVector = Icons.Default.ArrowBack,
            contentDescription = null,
        ),
    }
)

A: Well, it obviously looks like something is happening with your onBackArrowClick labmda that's causing it to recompose. Try passing a non-variable labmda, and see what happens. Something like:
onClick = { Log.d("***", "OnClick triggered") }


text:
Q: Combining Promise.all with rate-limited calls to an API I'm writing Javascript in a client-only environment, calling an API of a service that is rate-limited.  My environment only lets me load JS libraries by using LazyLoad.js which doesn't work for everything.  I have successfully been able to use throttled-queue to rate limit my API requests.  But I have not been able to combine using that with leveraging Promise.all to check when a series of API calls have been completed.  It works if I leave out the throttling, but not with it.
How can I combine these two?  The only approach I've come up with so far, which seems very clunky, is to manually rate limit using setTimeout for each call.  Then I found I need to wait the total amount of time (e.g. 200ms for each call) before I check Promises.all, otherwise it resolves too quickly with the first few Promises.  Here's what I have:
var deferreds = [];
$.each(evalTempQuestions, function(idx, evalTempQuestion){
  setTimeout(function(){
    deferreds.push(knackAPI('POST', 116, 75, evalTempQuestion.payload));
  }, 200 * idx);
});

setTimeout(function(){
  Promise.all(deferreds).then(function(r) {
    console.log('done');
  }).catch(function(err){
    console.log(err);
  });
}, 200 * evalTempQuestions.length);

How can I do this better?

A: I understand you want to resolve deferreds sequentially. If it is that, you can do it in several ways. One of them is using for and await:
// Helper to await for setTimeout
const delay = async (millis) =>
  new Promise(resolve => setTimeout(resolve, millis));

// Construct `deferreds` using `map` on `evalTempQuestions`
const deferreds = evalTempQuestions
  .map( evalTempQuestion =>
    // Wrap each request into a function, which will be called
    // sequentially and rate-limited

    // If you want to have both the payload and its results
    // available during post-processing, you can do something like:
    // () => {
    //   const {payload} = evalTempQuestion;
    //   return {
    //     payload,
    //     result: knackAPI('POST', 116, 75, payload)
    //   }
    // }
    () => knackAPI('POST', 116, 75, evalTempQuestion.payload) );

const result = [];
for (const next of deferreds) {
  try {
    // Call the wrapper function, which returns `knackAPI` Promise,
    // which probably is the Promise returned by a `fetch`
    const value = await next();
    // If you use the payload+result way, you'll need something like this:
    // const value = await next.result();
    result.push(value);
  } catch(err) {
    console.log(err);
    result.push(null); // <- Depends on what you need to do
  }

  // Rate limit
  await delay(200);
}
console.log('done');

You can see more examples here and here (or many others found in search engines).


text:
Q: Laptop immediatly goes to sleep after disconnecting power I've Lenovo S400 laptop, dual boot with windows 7 and ubuntu 13.04.
The problem is that whenever I disconnect the power adapter, ubuntu shows that battery level is critically low and goes to sleep. When I resume it from sleep, it runs fine on battery power.
The problem might be the lenovo power management installed in Windows. When I set it to battery health mode, the battery doesn't charge over 60% and is good for battery health.
If I use the laptop mostly connected to power, and that's when it causes the sleep problem. When it is set to battery full charge mode, ubuntu just shows a warning of low battery for a moment but then runs fine.
In either case, the battery meter never works (shows 1% battery charge) while connected to power.
It looks like ubuntu takes a couple of seconds to detect the correct battery level and that's creating all the problem.
Lenovo doesn't provide any driver for ubuntu. A faulty battery meter (only when connected) is not an issue but the sleep problem is a bummer.
What can I do?


text:
Q: Problem with apt-get and CUDA installation I have a problem An error occured, please run Packer Manager from the right click menu.
sudo apt-get check
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda-libraries-dev-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but it is not installed
 cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but it is not installed
 cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution)

It started when I do all this thing below
I get a computer to work. I don't know what people do in that computer. I have account with administrator permissions. I have Ubuntu in version:
$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:    bionic

I have a problem with CUDA installation. I need CUDA for molecular modelling.
I installed CUDA this tutorial which works on two other computers.
[MEDIA=youtube]FK1y7XQuhp0[/MEDIA]
I did these steps:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
gcc -v
make -v
lspci | grep -i nvidia

I dont see anything after I wrote this!!!!! I think that there is a problem with that.
Only this show me informations
sudo lshw -c video
[sudo] password for kuba:
  *-display UNCLAIMED
       description: VGA compatible controller
       product: GP107 [GeForce GTX 1050]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list
       configuration: latency=0
       resources: memory:f6000000-f6ffffff memory:e0000000-efffffff memory:f0000000-f1ffffff ioport:e000(size=128) memory:c0000-dffff

Then I wrote
gcc --version

Then installation from this site
[URL unfurl="true"]https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal[/URL]
Installation Instructions:
sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.168-418.67_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

I have errors installation, but it installed
I also added to bashrc
export PATH=/usr/local/cuda-10.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH

Then I check CUDA, but its not installed properly
$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
cudaGetDeviceCount returned 100
-> no CUDA-capable device is detected
Result = FAIL

I try to uninstall CUDA, but I can't find deinstallation files
[URL unfurl="true"]https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#runfile-uninstallation[/URL]
I try to use purge, but my apt-get isn't working
sudo apt-get --purge remove cuda-10.1
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
cuda-libraries-dev-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but it is not going to be installed
cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but it is not going to be installed
cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but it is not going to be installed
nvidia-361 : Depends: nvidia-367 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

But this apt --fix-broken install didn't work
dpkg: error processing archive /var/cuda-repo-10-1-local-10.1.168-418.67/./libcublas-dev_10.2.0.168-1_amd64.deb (--unpack):
trying to overwrite '/usr/lib/x86_64-linux-gnu/libcublas_static.a', which is also in package nvidia-cuda-dev 9.1.85-3ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cuda-repo-10-1-local-10.1.168-418.67/./libcublas-dev_10.2.0.168-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)


text:
Q: In process of making snake game, Can't figure out how to make the movement right Im currently making a snake game in jgrasp only using the standard draw movement and static methods to create this game, So far this is the code I have because i just started yesterday. But I'm currently stuck on how to make the snakes movements so it can only be up and down and side to side and for the movement to be constant. At the moment all i have is that the arrow keys move the snake but it can still move diagonally and isn't constant
import java.awt.event.KeyEvent;
public class snake
{
   static double squareX = .5;
   static double squareY = .5;
   static double squareR = .02;

   public static void drawScene()
   {
      StdDraw.clear();
      StdDraw.filledSquare(squareX, squareY, squareR);
      StdDraw.show(1000/24);

   }

   public static void updateMotion()
   {

      if (StdDraw.isKeyPressed(KeyEvent.VK_UP))
      {
         squareY += .01;
      }
      if (StdDraw.isKeyPressed(KeyEvent.VK_DOWN))
      {
         squareY -= .01;
      }
      if (StdDraw.isKeyPressed(KeyEvent.VK_LEFT))
      {
         squareX -= .01;
      }
      if (StdDraw.isKeyPressed(KeyEvent.VK_RIGHT))
      {
         squareX += .01;

      }
   }

   public static void main(String[] args)
   {
       while(true)
       {
         snake.drawScene();
         snake.updateMotion();
         if (squareX + squareR >= 1 )
         {
            //TODO: show "you lose" message / stop on edge of square
            break;
         }
         if (squareX - squareR <= 0)
         {
            //TODO: show "you win" message / stop on edge of square
            break;
         }
         if (squareY + squareR >= 1 )
         {
            //TODO: show "you lose" message / stop on edge of square
            break;
         }
         if (squareY - squareR <= 0)
         {
            //TODO: show "you win" message / stop on edge of square
            break;
         }

       }
   }
}

A: In this method, changing your if statements to else ifs should fix your issue.
  if (StdDraw.isKeyPressed(KeyEvent.VK_UP)){
     squareY += .01;
  }else if (StdDraw.isKeyPressed(KeyEvent.VK_DOWN)){
     squareY -= .01;
  }else if (StdDraw.isKeyPressed(KeyEvent.VK_LEFT)){
     squareX -= .01;
  }else if (StdDraw.isKeyPressed(KeyEvent.VK_RIGHT)){
     squareX += .01;
  }

What seemed to be your problem from what you described was the snake was traveling diagonally. This would occur from your program taking in a vertical and horizontal input. This segment of code will now only take in one direction per frame making it so the snake can only travel up, down, left, and right.
To make your snakes movement speed constant you need to limit the frames per sec. You can do this with the simplest Thread.sleep(10); call in each of your while loops or a swing timer. Your issue isn't your movement speed, its the fluctuating frame rate.
public static void main(String[] args) throws InterruptedException
{
    while(true)
    {
     snake.drawScene();
     snake.updateMotion();
     if (squareX + squareR >= 1 )
     {
        //TODO: show "you lose" message / stop on edge of square
        break;
     }
     if (squareX - squareR <= 0)
     {
        //TODO: show "you win" message / stop on edge of square
        break;
     }
     if (squareY + squareR >= 1 )
     {
        //TODO: show "you lose" message / stop on edge of square
        break;
     }
     if (squareY - squareR <= 0)
     {
        //TODO: show "you win" message / stop on edge of square
        break;
     }
     Thread.sleep(20);
   }
}

adding a line to limit your frames like this will make your snake move at a constant speed. As a note, there are different ways as apposed to using Thread.sleep() like swing timers that you can look into, but this should fix your general problem.


text:
Q: Error (10686): SystemVerilog error at file.sv(8): InstAddress has an aggregate value I am trying to compile the following SystemVerilog, and I get the following error "Error (10686): SystemVerilog error at InstRom.sv(8): InstAddress has an aggregate value."
module InstRom#(parameter A = 16, parameter W = 9)
(
input InstAddress[A-1:0],
output logic InstOut[W-1:0]
);
    logic[W-1:0] instr_rom[2**(A)];
    always_comb InstOut = instr_rom[InstAddress];

    initial begin
        $readmemb("cordic.txt", instr_rom);
    end
endmodule

What am I doing wrong?

A: InstAddress is an unpacked array of bit, not a bit vector (i.e. a packed array). The same applies to InstOut. Change the declaration to
input logic [A-1:0] InstAddress,
output logic [W-1:0] InstOut

and your code should work.


text:
Q: API Endpoint Authorization does not work via Powershell Script I`m trying to write a simple script which is called by the task scheduler of my server via powershell.
The script looks like this.
$params = @{
    "username" = "name";
    "password" = "password";
}

$token = Invoke-RestMethod -Method POST -Uri "http://localhost:5000/api/login" -Body ($params|ConvertTo-Json) -ContentType "application/json"

echo $token //The token gets printed correctly

$headers = @{
    Authorization = "Bearer " +$token
}

Invoke-RestMethod -Method Post -Uri "http://localhost:5000/api/somemethod" -Headers $headers

The login gets called perfectly - the somemethod with the Annotation
[Authorize(Roles = "admin")]
[HttpPost("somemethod/")]
public async Task<IActionResult> SomeMethod()
{
        //Do something
        return NoContent();
}

on the other hand gets the following console-output.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 POST https:/localhost:5001/api//somemethod application/x-www-form-urlencoded 0
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
      Route matched with {action = "SomeMethod", controller = "Api"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] SomeMethod() on controller Api.Controllers.ApiController (Api).
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
      Authorization failed.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
      Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
info: Microsoft.AspNetCore.Mvc.ChallengeResult[1]
      Executing ChallengeResult with authentication schemes ().
info: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[12]
      AuthenticationScheme: Bearer was challenged.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action Api.Controllers.ApiController.SomeMethod(Api) in 5.637ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 10.6572ms 401

What am i missing here?
Edit: When I debug into the middleware the Requests sends the token as expected. I will dig deeper into that and if needed come back with further informations.

A: I've seen lots of issues when POSTing and content-type hasn't been specified.
Invoke-RestMethod -Method Post -Uri "http://localhost:5000/api/somemethod" -Headers $headers -Body $data -ContentType "application/json"

or whatever content-type you're POSTing.


text:
Q: Woocommerce plugin - How to create two versions of the same plugin with slightly different implementation for different users I am working on the development of a woocommerce plugin and this plugin is shipped to 2 different set of customers. I'd like to manage both of those versions in one git repository. But then ship to each customer their version (I send them a zipped folder of the plugin).
Issue:
It is a hassle to maintain two versions on two separate git branches and there is no complier for example to apply certain changes based on which version of the plugin I am creating
Goal:
I am trying to manage two different versions of a plugin in the same repository
Methods I've tried:
Having the files the are different between both versions in separate folders and making an alias in the cmd that I use to copy the files intended for this version before zipping the folder


text:
Q: MongoDB finding nested elements I am using the MongoDB shell and I need to find some nested elements.
My structure looks like this:
 car : { "$ref" : "cars" , "$id" : { "$oid" : "4e8478ace4b0dea06288ad63"}}

I need to get to the oid = 4e8478ace4b0dea06288ad63
thanks in advance
Here is the structure :
{ "_id" : { "$oid" : "4e7c6b68e4b0dea06288ad22"} ,
  "driver" : "Test Driver" ,
  "category" : "BUSINESS" ,
  "distanceM" : 216.857 ,
  "mileageKmStart" : 121813.943 ,
  "mileageKmEnd" : 122030.8 ,
  "timestampStart" : { "$date" : "2012-01-12T11:20:08Z"} ,
  "timestampEnd" : { "$date" : "2012-01-12T11:21:11Z"} ,
  "car" : {
      "$ref" : "cars" ,
      "$id" : { "$oid" : "4e8478ace4b0dea06288ad63"}
   }
}

A: After a tiny dig around...
mongoexport will represent object ids as "$oid". Are you reading a json file generated by mongoexport? If so that is not the structure of your documents when imported (Or it is, but when you use a client to talk to mongo it does not want you to use this syntax).
Almost certainly, you want:
db.x.find({'car.$id': ObjectId('4e8478ace4b0dea06288ad63')})

If that isn't the case - have a look in the mongo cli - e.g. run:
db.x.findOne()

or
db.x.findOne({'car' : {$exists: true}}) // make sure the one I find has a car

If you've managed to create/inherit data with illegal keys - you'll probably want to migrate their structure so that it is possible to query your data.

DBRefs are a convention for how to create references to different collections - Note specifically "convention". They aren't special (except they are permitted the keys $ref, $id and $db) in any way - they are just another javascript object to mongo.


text:
Q: Magento showing Price Difference in configurable Products I have a Magento website where I have set up many configurable products with the different price.
There configurable options drop-down shows its associated products with the price difference. While I want to show their exact price instead of their price-difference.
You can have a look at my website page "http://www.tuneablestest.com/cds-dvds" and also see below image to understand my problem clearly-

I hope my problem is clear to all and please suggest me anyway to show their actual price.

A: shashank,You have set different additional price from admin which has  been add or deducted from main price on basic  of  variance selection.This price is not calculated as product main price.
Goto your  admin>catalog>Manage Product select any configurable product and goes it Associated Product tab >here you can set additional price for variance wise.
Which is show on product price.Shows when you have cart a configurable product.Using json code and javscript magento is set price with variance wise frontend UI

A: When you create a configurable product it doesn't matter what's the price of simple products -- these prices are ignored completely. So if you want to sell a simple product A which has price $29.99 and a simple product B ($39.99) then you must create a configurable product, set its price to $29.99 and open Associated product tab. Add products you want to associate with this configurable product. After adding them a block named Super product attributes configuration appears which contains options and price differences. Leave product A price empty and put 10 (+$10) to product B price field and voila: different simple product have different price.
There's actually an extension that allows you to use simple product prices instead of price differences, but it's kind of tricky to set up. Since it's free extension, I hope nobody complains about me pasting its link here:
https://github.com/organicinternet/magento-configurable-simple
I hope this will help you.


text:
Q: What is so dangerous about Wormhole affix? In Diablo 3, there is an affix called "Wormhole" that causes you to be moved from one side of a pink circle to another after a second or two of delay.
This seems to be by far the most benign monster affix!  Who cares if you get shifted from one spot to another?  More often than not, it actually takes me out of a dangerous floor covered in fire or acid.  Am I missing some hidden danger here?  Are there some classes and playstyles that are actually threatened by this affix?
See this for reference.

A: The "danger" is entirely situational, depending on what class you're playing, how many enemies there are and where you're tp'd to. But as Humungus said, it's generally more annoying than anything, especially for melee classes.


text:
Q: how to display routing data online (with the lines between points) I have a set of routing data, in both CSV or KML format. It is basically a list of Lat / Lon and some supporting information.
I am looking for a way to display this as a route (e.g. with lines between the points in the order they appear in the list) online. Ideally a free option, as I'm not likely to need it again in the near future.
I have found hundreds (maybe an exageration) of ways of plotting the points, but not one that will include the lines. I'm trying to avoid the long and tedious process of converting one of these to an image and drawing the lines by hand.
Can anyone suggest such a site?

A: This question was asked on a google group for google maps. The user received an answer that pointed him towards the google map API. Given how other apps / web pages do this using google maps (never seen it done any other way) I would imagine this would be the best route to go down as its probably something they have built into the service.
https://groups.google.com/forum/?fromgroups=#!topic/google-maps-js-api-v3/F_iroBiBeww


text:
Q: Css Grid column's Stacking on top of each other I know my HTML and CSS are a bit too much expand, but when I combine things it has worse errors. My code is below all I need is the last bar to fit like the other one. I have tried to change the padding and margins of that row as well as completely redoing my grid.

#grid {
  margin: auto;
  display: grid;
  grid-template-rows: auto;
  width: 100%;
}

#topbar {
  grid-template-columns: repeat(20, 1fr);
  background-color: white;
  grid-row: 1 / 2;
  display: grid;
}

#topbar #pad1 {
  grid-column: 1 / 3;
  background-color: #e0e0df;
}

#topbar #img {
  border-top: 2px solid black;
  border-left: 2px solid black;
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 3 / 5;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #li {
  border-bottom: 1px solid black;
  border-top: 2px solid black;
  border-right: 1px solid black;
  grid-column: 5 / 15;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #acre {
  border-bottom: 1px solid black;
  border-top: 2px solid black;
  border-right: 1px solid black;
  grid-column: 15 / 17;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #pdf {
  border-bottom: 1px solid black;
  border-top: 2px solid black;
  border-right: 2px solid black;
  grid-column: 17 / 19;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #pad2 {
  grid-column: 19 / 21;
  background-color: #e0e0df;
}

/* For each lan div id use #then div name to style */

#plot1 {
  grid-template-columns: repeat(20, 1fr);
  background-color: #cdcdcb;
  grid-row: 2 / 3;
  display: grid;
}

#plot1 #pad1 {
  grid-column: 1 / 3;
  background-color: #deded8;
}

#plot1 #img {
  border-bottom: 1px solid black;
  border-left: 2px solid black;
  border-right: 1px solid black;
  grid-column: 3 / 5;
  color: rgb(179, 9, 50);
  text-align: left;
}

#plot1 #li {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 5 / 15;
  color: rgb(179, 9, 50);
  text-align: left;
}

#plot1 #acre {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 15 / 17;
  color: rgb(179, 9, 50);
  text-align: right;
}

#plot1 #pdf {
  border-bottom: 1px solid black;
  border-right: 2px solid black;
  grid-column: 17 / 19;
  color: rgb(179, 9, 50);
  text-align: center;
}

#plot1 #pad2 {
  grid-column: 19 / 21;
  background-color: #e0e0df;
}

#last {
  grid-template-columns: repeat(20, 1fr);
  background-color: #cdcdcb;
  grid-row: 3 / 4;
  display: grid;
}

#last #pad1 {
  grid-column: 1 / 3;
  background-color: #deded8;
}

#last #img {
  border-bottom: 1px solid black;
  border-left: 2px solid black;
  border-right: 1px solid black;
  grid-column: 3 / 5;
  color: rgb(179, 9, 50);
  text-align: left;
}

#last #li {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 5 / 15;
  color: rgb(179, 9, 50);
  text-align: left;
}

#last #acre {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 15 / 17;
  color: rgb(179, 9, 50);
  text-align: right;
}

#last #pdf {
  border-bottom: 1px solid black;
  border-right: 2px solid black;
  grid-column: 17 / 19;
  color: rgb(179, 9, 50);
  text-align: center;
}

#last #pad2 {
  grid-column: 19 / 21;
  background-color: #e0e0df;
}

Property

Location & Information

Acareage

PDF

Property

Location & Information

Acareage

PDF

            </div

hello

Copyright © 2017 Greater Texas Land Resources LP & Design

The last row is messed up a am trying to copy the row before it so it creates a chart type thing that can hold infromation

A: you did not properly close a div tag.(#pad2 not properly closed )

        </div

beside, id can only be used once, use class instead when you need to apply same style a few times.

#grid {
  margin: auto;
  display: grid;
  grid-template-rows: auto;
  width: 100%;
}

#topbar {
  grid-template-columns: repeat(20, 1fr);
  background-color: white;
  grid-row: 1 / 2;
  display: grid;
}

#topbar #pad1 {
  grid-column: 1 / 3;
  background-color: #e0e0df;
}

#topbar #img {
  border-top: 2px solid black;
  border-left: 2px solid black;
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 3 / 5;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #li {
  border-bottom: 1px solid black;
  border-top: 2px solid black;
  border-right: 1px solid black;
  grid-column: 5 / 15;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #acre {
  border-bottom: 1px solid black;
  border-top: 2px solid black;
  border-right: 1px solid black;
  grid-column: 15 / 17;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #pdf {
  border-bottom: 1px solid black;
  border-top: 2px solid black;
  border-right: 2px solid black;
  grid-column: 17 / 19;
  color: rgb(179, 9, 50);
  text-align: center;
}

#topbar #pad2 {
  grid-column: 19 / 21;
  background-color: #e0e0df;
}

/* For each lan div id use #then div name to style */

#plot1 {
  grid-template-columns: repeat(20, 1fr);
  background-color: #cdcdcb;
  grid-row: 2 / 3;
  display: grid;
}

#plot1 #pad1 {
  grid-column: 1 / 3;
  background-color: #deded8;
}

#plot1 #img {
  border-bottom: 1px solid black;
  border-left: 2px solid black;
  border-right: 1px solid black;
  grid-column: 3 / 5;
  color: rgb(179, 9, 50);
  text-align: left;
}

#plot1 #li {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 5 / 15;
  color: rgb(179, 9, 50);
  text-align: left;
}

#plot1 #acre {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 15 / 17;
  color: rgb(179, 9, 50);
  text-align: right;
}

#plot1 #pdf {
  border-bottom: 1px solid black;
  border-right: 2px solid black;
  grid-column: 17 / 19;
  color: rgb(179, 9, 50);
  text-align: center;
}

#plot1 #pad2 {
  grid-column: 19 / 21;
  background-color: #e0e0df;
}

#last {
  grid-template-columns: repeat(20, 1fr);
  background-color: #cdcdcb;
  grid-row: 3 / 4;
  display: grid;
}

#last #pad1 {
  grid-column: 1 / 3;
  background-color: #deded8;
}

#last #img {
  border-bottom: 1px solid black;
  border-left: 2px solid black;
  border-right: 1px solid black;
  grid-column: 3 / 5;
  color: rgb(179, 9, 50);
  text-align: left;
}

#last #li {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 5 / 15;
  color: rgb(179, 9, 50);
  text-align: left;
}

#last #acre {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  grid-column: 15 / 17;
  color: rgb(179, 9, 50);
  text-align: right;
}

#last #pdf {
  border-bottom: 1px solid black;
  border-right: 2px solid black;
  grid-column: 17 / 19;
  color: rgb(179, 9, 50);
  text-align: center;
}

#last #pad2 {
  grid-column: 19 / 21;
  background-color: #e0e0df;
}

Property

Location & Information

Acareage

PDF

Property

Location & Information

Acareage

PDF

hello

Copyright © 2017 Greater Texas Land Resources LP & Design

A: For anyone who double-checked there are no html errors, stacking can occur because of grid-area. Assigning a grid-area locks the element to the first cell that grid-template-areas defines for it.
The following causes stacking:

.grid {
  display: grid;
  grid-gap: .5em;
  grid-template-columns: auto auto;
  grid-template-areas: "left right";
}

.left {
  grid-area: left;
  border: 2px solid skyblue;
}

.right {
  grid-area: right;
  border: 2px solid seagreen;
}

1,1

1,2

2,1

2,2

3,1

3,2

The same example, without the grid-area assignments fixes the issue:

.grid {
  display: grid;
  grid-gap: .5em;
  grid-template-columns: auto auto;
  /* This should also be taken out since it serves no purpose anymore.
     Leaving it here to show the container property has no bearing on repeats by itself.
     Only when the contents use the assignments */
  grid-template-areas: "left right";
}

.left {
  /*grid-area: left;*/
  border: 2px solid skyblue;
}

.right {
  /*grid-area: right;*/
  border: 2px solid seagreen;
}

1,1

1,2

2,1

2,2

3,1

3,2

For a simple layout like this, all the various grid-row settings for the container I played around with from other posts were completely unnecessary:

*

*grid-auto-rows: auto;

*grid-template-rows: repeat(auto);

*grid-auto-flow: column;
display: grid automatically defaults to repeating rows, unless you specifically define grid-template-areas and assign grid-area to the lock the contents into place.


text:
Q: Perl CGI Functional Programming - generating links I have a Perl CGI script. I'm trying to generate hyperlinks on an HTML page using all the elements in an array. I'm using functional CGI style programming. Here's a minimal representation of my code:
#!/usr/bin/perl
use strict; use warnings;
use CGI qw( :standard);

print header;

print start_html(
    -title => 'Get LINK!'
);

my %HoA = (
    'foo' =>  [ '12', '23', '593' ],
    'bam' => [ '232', '65' ],
);

my @array = ("foo", "bam");
foreach my $i (@array){
    foreach my $j (@{$HoA{$i}}){
        my $link = get_link($i);
        print "$i"."\t"; # this doesn't work!!
    }
}
#-----------------------------------
# this subroutine works!
sub get_link{
    my $id = $_[0];
    my $link = 'http://www.example.com/'.$id;
    return $link;
}
#------------------------------------

Desired Output
foo foo foo bam bam
Any help or suggestions are appreciated.

A:     print "$g"."\t"; # this doesn't work!!

that's because your quotes in your quote end your quote.  You need to escape them:
    print "$g"."\t"; # this doesn't work!!

single quotes work on the inside, too.
As per the comment, qq-style quoting is also available to you, so you can use double quotes and variable interpolation at the same time without the escape characters.

A: There's a few things that don't make much sense.
The code below doesn't work because $link is a ref. Also, you're not using $j anywhere,
which should give you a sign that there's a bit of a "design" issue.
foreach my $i (@array){
    foreach my $j (@{$HoA{$i}}){
        my $link = get_link($i);
        print "$g"."\t"; # this doesn't work!!
    }
}

Why can't this be rewritten like so:
for my $array_ref (keys %HoA) {
    for my $item ( @{ $HoA{$array_ref} } ){
        my $link = get_link($item);
        # print ....
    }
}

How does this sub "work"? $id is an array reference here. Do you just mean to shift onto $id?
#-----------------------------------
# this subroutine works!
sub get_link{
    #my $id = $HoA{$_[0]};
    # with the refactored double for loop, or the way you had it if you fix the
    # `ref` issue, a `shift` should do the trick.
    my $id = shift;
    my $link = 'http://www.google.com/'.$id;
    return $link;
}
#------------------------------------

You also need to escape the quotes in print statement:
print "$g"."\t";

A: Here is another way you can do this ...
use strict;
use warnings;

use CGI qw(:standard);

print header,
      start_html(-title => 'Get LINK!');

my %HoA = (
     foo => [ qw(12 23 593) ],
     bam => [ qw(232 65) ],
);

foreach my $i ( reverse sort keys %HoA )  {
      foreach ( @{$HoA{$i}} )  {
        print a({-href => 'http:/www.google.com/'.$_,
                 -target => '_blank'}, $i) . "\n";
      }
}

Output:
foo foo foo bam bam


text:
Q: Git - easiest way to see diff with previous version if I have the sha A colleague of mine checked in some changes to Git, and I want to see exactly what those changes were.  In other words, the diff between his check-in and its parent.
What seemed logical to me was to run this command:
git diff shaOfHisCheckIn

But this didn't work.  It appears to show the diff between that SHA and my current working copy.
What's the correct command to show the diff between a given SHA and its parent?

A: git show is your friend:
git show shaOfHisCheckIn

A: If you want to view the diff visually in kdiff3, meld, kompare, xxdiff, tkdiff, diffuse…
git difftool --dir-diff shaOfHisCheckIn^!

git difftool --tool=meld --dir-diff shaOfHisCheckIn^!

git difftool -t meld -d shaOfHisCheckIn^!

A: Try this:
git diff shaOfHisCheckIn^ shaOfHisCheckIn

or
git diff shaOfHisCheckIn{^,}

A: git diff shaOfHisCheckIn shaOfHisCheckIn^


text:
Q: Sequential, cumulative operations on Rascal trees Given immutability of data in Rascal, what is the preferred method for these, if later operations depend on the results of earlier ones?
For example, assigning annotation values to every node in a tree, where values of higher nodes depend on values of lower ones.  If you write a single visit statement with multiple cases, then insertion statements at lower levels don't change the tree, so higher level operations may have nothing on which to operate. On the other hand, surrounding each case statement with a visit statement -- and rebinding your tree variable to the new tree after every visit -- is cumbersome and, worse, seems to make the results depend on the order of the statements.

A: Subtle question :-) The visit statement has a subtle semantics especially if you look at it from an OO perspective. While it is actively traversing a value it is also rebuilding a new one. Depending on the strategy (order) of the traversal sequential matches in its case statement "see" different things.
It is sometimes insightful to imagine visit as a code generator which generates a set of mutually recursive functions which take the visited part as argument and return a new value on return. The body of the visit (the cases) turn into a switch statement which is the core of these generated functions. Then, depending on the traversal order, the recursive steps are either positioned before (bottom-up) or after this switch statement (top-down):
// bottom-up visit
x f(value x) {
  newChildren = map(f, children of x);
  x = newX(x, newChildren);
  switch (x) {
    case y : return whatever(y);
  }
}

Hence the code in the switch case for bottom-up visits see the trees produced by recursive calls (although no tree has actually been updated).
Here's an example:
rascal>data T = tee(T, T) | i(int i);
data T = tee(T, T) | i(int i);
ok
rascal>t = tee(tee(i(1),i(2)),tee(i(3),i(4)));
t = tee(tee(i(1),i(2)),tee(i(3),i(4)));
T: tee(
  tee(
    i(1),
    i(2)),
  tee(
    i(3),
    i(4)))
rascal>visit(t) {
>>>>>>>  case i(x)        => i(x+1)
>>>>>>>  case tee(i(x),y) => tee(i(x+1),y)
>>>>>>>}
T: tee(
  tee(
    i(3),   // here you see how 1 turned into 3 by incrementing twice
    i(3)),  // increment happened once here
  tee(
    i(5),   // increment happened twice here too
    i(5)))  // increment happened once here

You can see that some nodes had an increment twice because the second case matched
one a tee after it's child i node was already visited to return a different i node which is already incremented.
Experimenting with the other strategies will give you other results, see http://tutor.rascal-mpl.org/Rascal/Rascal.html#/Rascal/Expressions/Visit/Visit.html . Note that the variables in the scope of the visit statement are shared by all visits on all levels of recursion which gives power to emulate zipper-like behavior (you can always store the previously visited node in a temporary).
As an aside, the language design is trying to avoid the need for more involved "functional programming design patterns" such as zippers because they complicate the type system and the way people interact with it. To make these things work type correctly in a visit which does a recursion over a heterogeneous data-type you need a PhD in polymorphism to understand when it is type correct. Secretly, the visit statement simulates a set of built-in type-safe rank-2 higher-order polymorphic functions, but that's all under the hood.


text:
Q: Need Reminder Application to notify every X minutes during the day Can one advise an application that can notify me each 1 hr 30 minutes during the day (let's say I can specify it to be from 10 AM till 11 PM).
I've tried Alarmed, Beep me, AidaReminder but all of them can not handle this simple task with almost no effort of the user.
The point is: if I want to arrange my everyday life and get used to:

*

*Take pills at certain time

*Smoke just 1 time in 2.5 hr

*Have meals at a certain time

*Take work breaks once in every 45 minutes that are lasting for 10 minutes

*Plan to go to a gym every 3 days

*Go to swimming pool every 2 days

*Pay rent every 15th day of every month

*etc.

I know most there is a calendar and simple alarm for most of those tasks, for productivity at work there is pomodoro technique, for tasks like repeating an event (let's say allowing me to smoke once in 2.5 hr) I still have not found a good solution.
I want everything to be in one place. I need an app that I can say:

*

*Repeat event every 2 hours 25 minutes from 10 AM to 4 PM

*Remind me to pay rent every 15th day at 10 AM

*After every 45 minutes ask me to take an action and go to a 10 minutes break, notify when break is over and ask me to take action to get back to the work or postpone

Is there any good app that meet those exact problems?
Disclaimer: I've read the tour and I've found this question might be considered as falling into category of Questions that are primarily opinion-based, but I want to point this out: I've listed exact application responsibilities, so that's it: the application is meet the requirement or not, no place for subjectivity.

A: Take a look at Due. It has a Mac version as well, and I've not seen a more powerful timer app.

A: Your reminders to Go the the Gym, Pay Rent, Go Swimming, Take Pills and Have Meals can all be done easily using the Calendar while creating a daily or monthly reminder.
You can set an alert to take a break but you need to set the exact time and then when the break should end, e.g. you can set a smoke break for 10am and that break will end at 10:18am; something like that and you can repeat the break every day. However, there isn't a way to repeat the break every 2 hours, etc. You will need to manually enter the start time of the break and then request a daily repeat of the same break using the same time.
Personally, I need a way to set an alert that begins when I start it and lasts for 5 minutes and then repeats every 5 minutes until I stop it manually, but I haven't found anything that can do this.


text:
Q: Pulling Docker Image from Docker Hub : NOt Found I am using docker in windows 10.
MY docker is working properly but when i try to pull Image from docker hub via cmd:
C:\Users\pca90>docker pull hello-world Using default tag: latest Error
response from daemon: Get https://registry-1.docker.io/v2/: Not Found

A: Just issue these commands in a terminal or command window
docker-machine restart default # Restart the environment

eval $(docker-machine env default) # Refresh your environment settings

after running above it will work
If not then please update your question with the output from issuing
docker info


text:
Q: Bootstrap DatePicker Position How can I change position of where the calendar pops up. I am using the below code and the calendar pops up to the far left.

I need it to pop up over the input field.
<!DOCTYPE html>

    <title>Title</title>

    <link href="../css/bootstrap.min.css" type="text/css">
    <link href='../datepicker/bootstrap/css' rel='stylesheet'
    type='text/css'>

    <link href='../datepicker/bootstrap-datepicker/dist/css/bootstrap-
    datepicker.min.css' rel='stylesheet' type='text/css'>

Date Range for Chart

<form method="post" action="mychart2.php">

Start Date: <input type="text" name = "start" data-provide="datepicker"
data-date-format="yyyy-mm-dd">

End Date:   <input type="text" name = "end"   data-provide="datepicker"
data-date-format="yyyy-mm-dd">

<input type="submit" name="submit" value="Submit">
</form>

I not sure I can control the position by using data-provide

A: First, make sure that you use the Bootstrap CSS. It seems that the Bootstrap is not loaded properly.
You can set the HTML property data-date-orientation according to the documentation:

A space-separated string consisting of one or two of "left" or "right", "top" or "bottom", and "auto" (may be omitted); for example, "top left", "bottom" (horizontal orientation will default to "auto"), "right" (vertical orientation will default to "auto"), "auto top". Allows for fixed placement of the picker popup.

Each option attribute has to have the data-date- prefix.
The distance to the input field may be controller by setting the margin.


text:
Q: Update table column in mysql I have a problem to update the specific column. I don't want to specify the ID in  order to update that row. I am using like flag. for example I want to change column 'request' to 1. Initially it is 0. I am using this code and it did changed but not the ID that I want. Let say I click on ID =2 but it will update the column ''request' with ID = 3. What is my problem. Help me. Stuck in 2 days. I know it is simple. I have tried so many times.
$sql = "SELECT column_name FROM table_name";
$query = mysqli_query($con,$sql) or die (mysqli_error($con));
while ($row = mysqli_fetch_array($query))
{
    $column_name = $row['column_name'];

}

$sql2 = "UPDATE table_name SET column_name = 1 WHERE  ID= '$ID'";
$query2 = mysqli_query($con, $sql2) or die (mysqli_error($con));

    ID    Colour   column_name
    1      Red         0
    2      Yellow      1

A: You need all your column_name 0 to 1 then use like this
$sql = "SELECT ID, column_name FROM table_name";
$query = mysqli_query($con,$sql) or die (mysqli_error($con));
while ($row = mysqli_fetch_array($query))
{
 if($row['column_name'] == 0) {
  $sql2 = "UPDATE table_name SET column_name = 1 WHERE ID= ".$row['ID'];
  $query2 = mysqli_query($con, $sql2) or die (mysqli_error($con));
 }
}


text:
Q: Spurious epoll (edge triggered) notifications My understanding of epoll and edge triggered behaviour was that you are notified when a state change occurs for a given file descriptor.  Ie, when data becomes available on the fd, you get notified but you only get notified again after you drain all the data (you get EAGAIN) and data becomes present again.
Based on this understanding, I'd implemented a server which does the following:

*

*Listens for client connections

*For each connections, add fd into epoll

*When data available on fd, spawn a separate thread to read until EAGAIN

*Repeat until data reads are done

Semi pseudo-code:
n = epoll_wait(efd, events, MAXEVENTS, -1);

for (i = 0; i < n; ++i) {
    check for errors;
    if (server_sock == events[i].data.fd) {
        conn = accept( ... );
        make_nonblocking(conn);
        event.data.fd = conn;
        event.events = EPOLLIN | EPOLLRDHUP;
        epoll_ctl(efd, EPOLL_CTL_ADD, conn, &event);
    } else {
        spawn_reader(events[i].data.fd);
    }

With the above code, my expectation was that until the reader thread hits EAGAIN, epoll will not spawn another thread for this fd.  This doesn't seem to be the case and I get many threads being spawned.
Am I using epoll incorrectly?  I shouldn't need to remove the fd via EPOLL_CTL_DEL each time I spawn the reader thread, correct?

A: Yes, its working as it should. epoll allows asynchronous IO programming in a single thread of control (event driven). Using a thread to process reads on an fd does not remove it from the list of monitored fds.


text:
Q: LaTeX3: tokens for curly braces I use a clist of delimiters to define functions that enclose text within the said delimiters.
Here is a MWE:
\ExplSyntaxOn

\clist_new:N \l_delim_clist
\clist_put_right:Nn \l_delim_clist {
  {paren, (, )},
  {curly, \{, \}},
  {brac, [, ]}
}

\clist_new:N \l_delim_specs
\clist_map_inline:Nn \l_delim_clist {
  \clist_clear:N \l_delim_specs
  \clist_put_right:Nn \l_delim_specs {#1}
  \clist_pop:NN \l_delim_specs \l_delim_name
  \clist_pop:NN \l_delim_specs \l_delim_start
  \clist_pop:NN \l_delim_specs \l_delim_end

  \cs_new_nopar:cpx {delim_ \l_delim_name :n} ##1 {\l_delim_start ##1 \l_delim_end}
}

\show\delim_paren:n
\show\delim_brac:n

\ExplSyntaxOff

Now, on compilation, TeX runs out of stack space.  This seems to be because of the curly part.  In particular, removing line 6:
  {curly, \{, \}},

leads to correct compilation with the expected result.    That is, \show\delim_paren:n does yield:
> \delim_paren:n=macro:
#1->(#1)

I would like \delim_curly:n to be the macro #1->\{#1\} which may be used in math mode.  Could someone shed some light on the reason TeX runs into an infinite loop and how I may fix the above code?  Thanks!

A: You can't use \{ and \} inside an x expansion argument, unless you take precautions not to expand them. The same problem doesn't apply with the other delimiters because they're character tokens.
You can exploit the fact that \clist_item:nn returns the item with \exp_not:n around it.
\RequirePackage{expl3}

\ExplSyntaxOn

\clist_new:N \l_arakonam_delim_clist
\clist_set:Nn \l_arakonam_delim_clist
 {
  {paren, (, )},
  {curly, \{, \}},
  {brac, [, ]}
 }

\clist_map_inline:Nn \l_arakonam_delim_clist
 {
  \cs_new_nopar:cpx {delim_ \clist_item:nn {#1} {1} :n} ##1
   {
    \clist_item:nn {#1} {2}
    ##1
    \clist_item:nn {#1} {3}
   }
 }

\cs_show:N \delim_paren:n
\cs_show:N \delim_brac:n
\cs_show:N \delim_curly:n

\ExplSyntaxOff

Here's the output on the terminal:
> \delim_paren:n=macro:
#1->(#1).
<recently read> }

l.24 \cs_show:N \delim_paren:n

?
> \delim_brac:n=macro:
#1->[#1].
<recently read> }

l.25 \cs_show:N \delim_brac:n

?
> \delim_curly:n=macro:
#1->\{#1\}.
<recently read> }

l.26 \cs_show:N \delim_curly:n

?


text:
Q: MYSQL - PHP : getting MySQLi results as array This is the update code
But I got the error : FATAL ERROR (Call to undefined method User::fetch_assoc())
this is my method code
    public function getAllUsers(User $user)
    {
        $stmt = $this->conn->prepare("SELECT u.user_id, u.email, u.name, u.phone, u.picture, s.status
                                      FROM ".$this->table_name." as u, status as s
                                      WHERE u.status_id = s.status_id");
        if($stmt == FALSE)
        {
            die($this->conn->error);
        }
        else
        {

            $stmt->execute();
            $stmt->bind_result($user_id, $email, $name, $phone, $picture, $status);

            while($stmt->fetch())
            {
                $user->setUserId($user_id);
                $user->setEmail($email);
                $user->setName($name);
                $user->setPhone($phone);
                $user->setPicture($picture);
                $user->setStatus($status);
            }

            $stmt->close();
            return $user;
        }
    }

and this is my code in index.php who called the object method.
$app->get('/users', 'authenticate', function()
{
        global $user_id;
        $response = array();

        $user = new User();

        // fetching all users
        $userDB = new UserDb(MySqlDb::getInstance()->connect());
        $result = $userDB->getAllUsers($user);

        $response["error"] = false;
        $response["users"] = array();

        // looping through result and preparing users array
        while ($user = $result->fetch_assoc())
        {

            $tmp = array();
            $tmp["user_id"] = $user->getUserId();
            $tmp["email"] = $user->getEmail();
            $tmp["name"] = $user->getName();
            $tmp["phone"] = $user->getPhone();
            $tmp["picture"] = $user->getPicture();
            $tmp["status"] = $user->getStatus();
            array_push($response["users"], $tmp);
        }

        echoRespnse(200, $response);
});

please check my foreach, is it wrong ?
Thanks :)

A: getAllUsers returns an array of Users
so $result is an array of Users, not a database query result as you may expect.
then you call fetch_assoc() on $result, which is an array of users, and as it doesn't have this method, you get Call to undefined method User::fetch_assoc()


text:
Q: Summing all entries in a csv that contain all or portion of a string Right now I'm trying to sum the number of entries that fall within a given date range of an arbitrary column in this (subarray) of a csv (there are 3 date columns in total and I want to be able to look at any column and there respective entries):
(label:id,Label:invoice number, Label appt date, Label completion date, label: invoice amount last appointment date)
(label 1,  Label 2,    Label 3,            label 4,         label 5, label 6)
18565272,  3548587,    2015-12-30 16:30:00, 2017-01-18 4:01:00,  0,  11/30/2016
22909611,  2000404134, 2016-05-18 14:55:00, 2017-01-26 16:59:00, 0,  NULL
21541501,  1166588,    2016-07-07 17:00:00, 2017-02-14 4:01:00,  84, 4/11/2016
1000141115,1429670,    2016-10-29 0:06:00,  2017-01-18 21:43:00, 49, 3/2/2016

I'd like to be able to define a column and then compute the number of times a date appears that lie within a range-say "January 1-30 2016".  I'm not really experienced with methods related to this (most of my python experience is in the numerical computation side).  I have a few ideas at present (using pandas to remove rows that do not contain a given entry along the row and then summing the row count for instance) but I'm looking for a few that probably work a lot better.

A: Try using pandas.
import pandas as pd

df = pd.read_csv(your_file) # read the data

def date_range_counter(column, start_date, end_date)
    dates_range = pd.date_range(start_date, end_date) # creates list of dates between start_date and end_date
    arr = df[df[column].isin(dates_range)] # will only keep rows of the dataframe that have dates in the range specified
    return len(arr)

for start_date and end_date you can use strings in the format 'YYYY/MM/DD' and the column input should be a string of the column label you want to count dates from e.g 'Label 1'.


text:
Q: vector sort just reversing input with custom comparator I get some strange behavior when sorting a c++ vector with at custom comparator class.
I want to sort a array of indexes based on some values in an other array. But as far as I can see the sort function just reverses my indexes. I've done some logging of the compare function, at it seems to be working just fine.
Is there anyone who can spot what I'm doing wrong?
My code:
template<class T>
class Comparator {
   vector<T> & data;
public:
  bool operator()(int a, int b) {
    return data.at(a) < data.at(b) ? -1 : (data.at(a) > data.at(b) ? 1 : 0);
  }

  Comparator(vector<T> & data) : data(data) {}
};

void sortTest2() {
  //SETUP
  int n = 5;
  vector<int> indexes(n);
  newIdAr(indexes, n); //init to {0,1,2,3,4}
  vector<double> data(n);
  randomData(data, n); //Init to radom data
  Comparator<double> comparator(data);

  //TEST
  print(indexes, data, n); // Prints [0.00125126, 0.563585, 0.193304, 0.808741]
  sort(indexes.begin(), indexes.end(),comparator);
  print(indexes, data, n); // Prints [0.808741, 0.193304, 0.563585, 0.00125126]
  sort(indexes.begin(), indexes.end(),comparator);
  print(indexes, data, n); // Prints [0.00125126, 0.563585, 0.193304, 0.808741]
  cout << "Shuffle" << endl;
  random_shuffle(indexes.begin(), indexes.end());
  print(indexes, data, n);
  sort(indexes.begin(), indexes.end(), comparator);
  print(indexes, data, n);
}

My output:
[0.00125126, 0.563585, 0.193304, 0.808741, 0.585009]
[0.585009, 0.808741, 0.193304, 0.563585, 0.00125126]
[0.00125126, 0.563585, 0.193304, 0.808741, 0.585009]
Shuffle
[0.193304, 0.00125126, 0.585009, 0.563585, 0.808741]
[0.808741, 0.563585, 0.585009, 0.00125126, 0.193304]

Code for the auxiliary functions:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void print(vector<int> & sort, vector<double> & data, int N) {
  cout << "[";
  for (int i = 0; i < N - 1; ++i) {
    cout << data[sort[i]] << ", ";
  }
  cout << data[sort[N - 1]] << "]" << endl;
}

void newIdAr(vector<int> & ar, int N) {
  for (int i = 0; i < N; ++i) {
    ar[i] = i;
  }
}

void randomData(vector<double> & data, int n) {
  for (int i = 0; i < n; ++i) {
    data[i] = ((double) rand()) / RAND_MAX;
  }
}

A: Comparators should return true if the first argument is lower than the second one, or false otherwise. Returning 0, -1 and 1 is invalid in your code.
You could realize this by analizing the comparator's operator() signature:
bool operator()(int a, int b)

I believe your implementation should be:
bool operator()(int a, int b) {
    return data.at(a) < data.at(b);
}


text:
Q: get all database names from oracle 11g Express Edition I can able to connect the Oracle Database.
I have a Task to List out all the Databases Names in the ComboBox or List, array.
I need query to get the result
While searching, i found the list all the tables query.
SELECT table_name
FROM user_tables

I don't have any idea about the Oracle DB.
I'm using the Windows 8 OS for development purpose.

A: There is only one database on 11g XE (unlike SQL Server and MySQL).  You can have multiple schemas which your application might use.
You can list all the schemas with
SELECT username FROM all_users;

Although this will include many built in schemas which you would most likely want to exclude by adding something like
WHERE username NOT IN ('ANONYMOUS', 'APEX_030200', 'APEX_040200', 'APEX_PUBLIC_USER', 'APPQOSSYS', 'AUDSYS', 'CLOUD_ENGINE_USER', 'CLOUD_SWLIB_USER', 'CTXSYS',
        'DBSNMP', 'DIP', 'DMSYS', 'EXFSYS', 'DVF', 'DVSYS', 'FLOWS_030000', 'FLOWS_FILES', 'GSMADMIN_INTERNAL', 'GSMCATUSER', 'GSMUSER',
        'LBACSYS', 'MDDATA', 'MDSYS', 'MGMT_VIEW', 'OJVMSYS', 'OLAPSYS', 'ORDDATA', 'ORDPLUGINS', 'ORACLE_OCM', 'ORDSYS', 'OUTLN', 'OWBSYS',
        'SCOTT', 'SI_INFORMTN_SCHEMA', 'SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'SYS', 'SYSBACKUP', 'SYSDG', 'SYSKM', 'SYSMAN', 'SYSMAN_APM',
        'SYSMAN_MDS', 'SYSMAN_OPSS', 'SYSMAN_RO', 'SYSTEM', 'TSMSYS', 'OWBSYS_AUDIT', 'WKPROXY', 'WKSYS', 'WK_TEST', 'WMSYS', 'XDB', 'XS$NULL');

A: you can use the below query
SELECT DISTINCT OWNER FROM ALL_OBJECTS;

to get distinct values from the database


text:
Q: Green's Theorem in the plane When calculating  $\oint _{ C }^{  }{ \frac { { x }^{ 2 }-{ y }^{ 2 } }{ 2 } dx+\left( \frac { { x }^{ 2 } }{ 2 } +{ y }^{ 4 } \right) dy } $  where $C$ Is the boundary of the region $D=\left\{ \left( x,y \right) \in \mathbb{R}^{ 2 }: 1\le { x }^{ 2 }+{ y }^{ 2 }\le 4,x\ge 0,y\ge 0 \right\} $,
${ C }_{ 1 }:\alpha \left( t \right) =\left( t,0 \right) ,t\in \left[ 1,2 \right] $,
${ C }_{ 2 }:\alpha \left( t \right) =\left( 2\cos { t } ,2\sin { t }  \right) ,t\in \left[ 0,\frac { \pi  }{ 2 }  \right] $,
${ C }_{ 3 }:\alpha \left( t \right) =\left( 0,4-2t \right) ,t\in \left[ 0,1 \right] $, and
${ C }_{ 4 }:\alpha \left( t \right) =\left( \sin { t } ,\cos { t }  \right) ,t\in \left[ 0,\frac { \pi  }{ 2 }  \right] $
are the curves bordering the region $D$. Differs by using Green's theorem, which is the reason for it, unless it calculates the integrals badly. Thanks for your help.

A: Let $P(x,y)= \frac { { x }^{ 2 }-{ y }^{ 2 } }{ 2 }$  and $Q(x,y)= \frac { { x }^{ 2 } }{ 2 } +{ y }^{ 4 }$.
Then
$$
\begin{align*}
\oint _{ C }^{  }{ \frac { { x }^{ 2 }-{ y }^{ 2 } }{ 2 } dx+\left( \frac { { x }^{ 2 } }{ 2 } +{ y }^{ 4 } \right) dy }
&= \iint_D ( Q_x-P_y ) dA \\
&=  \iint_D x+y \: dA \\
&= \int_{0}^{\pi/2} \int_{1}^{2} (r \cos \theta + r\sin\theta)\; rdrd\theta \\
&= \int_{0}^{\pi/2} \int_{1}^{2} r^2 (\cos \theta + \sin\theta) drd\theta \\
&= \int_{0}^{\pi/2}  \dfrac{r^3}{3} (\cos \theta + \sin\theta) \Bigg|_{1}^{2} d\theta \\
&= \int_{0}^{\pi/2}  \dfrac{7}{3} (\cos \theta + \sin\theta) d\theta \\
&= \dfrac{7}{3} (\sin \theta - \cos\theta) \Bigg|_{0}^{\pi/2} \\
&= \dfrac{7}{3}(2) \\
&= \frac{14}{3}. \\
\end{align*}
$$


text:
Q: How to use French-style numbering? I recently saw an MO post https://mathoverflow.net/a/209494/2383 which claimed that LaTeX does not support French-style numbering, where references to (3.7.6) appear as (6) inside Subsection 3.7, as (7.6) inside Section 3, and as (3.7.6) all other places.  Of course, the default reaction to such a claim is "yes it does; you just have to use package …", but I don't know what package to fill in.  To be clear, what I am looking for is, as near as possible, how to make the following a working document:
\documentclass{article}
\usepackage{???} % What to use?
\begin{document}
\begin{section}
\eqref{eq:eq} % => (2.1.1)

\begin{section}
\eqref{eq:eq} % => (1.1)

\begin{subsection}
\begin{equation}\label{eq:eq}
2 = 1 + 1.
\end{equation}
All that wait for \eqref{eq:eq}? % => (1)
\end{document}

I'm illustrating this with equations, but I'd like it to work for all numbered environments.  Bonus points if the answer can really fit the French style, where, for example, the propositions in Subsection 9.6 are numbered only if there is more than one, and otherwise references to the lone proposition in that subsection will be numbered "Proposition 9.6".  (Despite my calling this 'French' style, the first example that comes to mind is Borel's "Linear algebraic groups" https://books.google.com/books?id=MoLTBwAAQBAJ&printsec=frontcover .)
Apologies in advance if this is a duplicate; I can't believe that it's not, but I couldn't find it.  I searched here for "French numbering" and "local numbering", but the former just seemed to turn up accidental coincidences of 'French' and 'numbering' in the same post, and the latter to turn up posts about changing the label format for one particular result, but still having all references to it format the same way.


text:
Q: Create web map tiles from large images I have 70Gb of raster data from drone photography that I need to serve  via Openlayers.
The data is currently provided as georeferenced jpegs each is 175Mgb in size.
What is the best strategy to cut these into manageable tile sizes for serving via the web.
I have access to the gdal suite and was looking at the gdal2tile.py script. Can this be run on a set of tiles to produce a directory of georeferenced smaller tiles?

A: To run gdal2tiles.py on a multiple images, use gdalbuildvrt to build a virual raster from those images first. Then you can run gdal2tiles on the .vrt file.
gdalbuildvrt -o merged.vrt file1.jp2 file2.jp2 ....
gdal2tiles.py merged.vrt output_folder/

If you are running it on large files, check out the enhanced version of the script that uses parallel processing.


text:
Q: Slick slider not changing active slide position I'm working on a slick slider that contains 3 figures with a background image. The first slide works as it should but the following slides all fail to show up. The inspector shows that each of the slides following the first one maintain their inactive slide position given by slick which pushes them offscreen. It does work when I simply use  instead of
 or
. I'd use  if it wasn't for the sizing issues these gave me.
I loop the content so I can easily control the amount of slides

  <?php foreach ($images as $image) { ?>
     <div class="hero__background-image" style="background-image: url('<?php echo $image['url']; ?>');">

  <?php } ?>

And this is the current CSS
&.hero {
  position: relative;
  height: 550px;

  .hero__background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: lightgray;
    z-index: -999;

    hero__background-image {
      background-size: cover;
    }

    .slick-list,
    .slick-track,
    .slick-slide {
      height: 100%;
      margin: 0;
    }
  }
}

And the JS as requested :)
$('.hero__background').slick({
  infinite: true,
  autoplay: true,
  fade: true,
  speed: 600,
  arrows: false,
  dots: false
});

What could be the cause for background images to fail? Any help and advice would be much appreciated.


text:
Q: Parallelism structure about gerund and noun is it correct to say:
lack of understanding and knowledge
because of "and" here which both sides should be parallel. left hand side we have a gerund and right hand side there is a simple noun. is this correct?
thank you in advance.


text:
Q: Is it possible to rotate a div while having a transition on it in CSS?
Im trying to rotate this div, while moving it to the left with a transition, but its not working, any suggestion? or recommendation how to solve it?


text:
Q: Android unzip password protected file from assets I have password protected zip file from assets folder. Android zip library doesn't support password protected file so I was use zip4j library. But I cant extract file from assets.
ZipFile zipFile = new ZipFile("file:///android_asset/db.zip");
zipFile.setPassword("qwe");

A: file:///android_asset is pretty much just for WebView.
If zip4j has a ZipFile constructor that takes an InputStream, you could get a stream on your asset via getAssets().open("db.zip").
Otherwise, you would first need to copy db.zip from assets to a local file (e.g., in getCacheDir()), then use zip4j, then delete the local db.zip file.
Or, since cracking the encryption on a ZIP archive is trivial (last I checked), unZIP the contents into your project's assets/ directory and use them more directly, rather than putting the password-protected ZIP into assets/.


text:
Q: Boolean recursion method So I have been trying to practice recursion so far and I got stuck.
I have to write a method that is type of bool and takes two parameters (array of ints, and int). The method itself should check if numbers in the array are bigger then 1000.
Depending on second parameter it should check only those numbers. So if array is 4, 5, 1001, 1003 and second parameter is 3 then only first 3 values in the array should be checked (4,5,1001). In this case it should return false because 4 and 5 are smaller then 1000. But if first 3 values were bigger then 1000, method should return true.
This is the leftovers of my method. I tried a lot before.
I am a bit confused how should it work with Boolean.
public bool sumofD(int [] x , int n)
{
    if (x[n] < 1000)
        { return false; }
    else
    {
        sumofD(x, n - 1);
        return true;
    }
}

A: It's not a good example for recursion as it would be easier to simply iterate throug the array.
Anyway, you forgot the end-condition for your recursion. You want to stop the recursion if n < 0:
public bool sumofD(int [] x , int n)
{
    // check if you already checked all values
    if (n <= 0) return true;
    if (x[n - 1] < 1000) // use n-1
        { return false; }
    else
        // return if all the leading values are > 1000
        return sumofD(x, n - 2);
}

And your second mistake was to always return true no matter what your recursive call returned.
I changed the code that it returns the result of your recursive call, semantically meaing: "if the current value is greater than 1000, return the result of the check for the leading values".

Update: if n is the number of elements to check, you want to start at x[n-1] since arrays are 0-indexed. And change the other usages of n accordingly (checking n <= 0 before and calling recursivly with n-2).

A: I think this should work;
    public static bool sumofD(int[] x, int n)
    {
        n -= 1;
        if (n < 0) return true;
        return x[n] >= 1000 && sumofD(x, n - 1);
    }


text:
Q: Docker Port Mappings and Hostnames I have got an question, or better to say there are two ones. Both depends on Docker and is related to the understanding of how docker deals with containers hostnames and ports.
Let's say I have two services that are running in a different docker container and exposing port 80 from the container to port 8081 (service1) and port 8082 (service2):
service1 : 8081 : 80
service2: 8082 : 80
Now it is clear to me that from an host perspective I can access these services by using the exposed ports (http://localhost:8081 and http://localhost:8082). But what if I want to access my services by using the containers like http://container1 and http://container2? What I have to do to realize this szenario meaning:

*

*how might be the port forwarding

*and how I know the exact hostname so I could resolve the containers hostnames from the docker host machine?

Thanks for help!

A: As Ijaz Ahmad Khan said. You have to use another container inside that network as proxy eg nginx.
If you are exposing ports from docker-compose to host machine ( your pc ) it's only visible as localhost domain with specific port as you mention. If you run docker-compose.yml like this:
version: "3"
services:
  service1:
    image: something
    name: service1_name
    ports:
      - "8081:80"
  service2:
    image: something
    name: service2_name
    ports:
      - "8082:80"

Docker-compose will create default network named by folder in witch is docker-compose.yml with suffix _default. In this network all  container can see each other. expose command is used for containers inside this network (so they can see each other and communicate), port is used for publishing to host-machine (your pc).
This mean:
service1 is visible on your machine as http://localhost:8081 for others containers in the network as service1:80.
service2 is visible on your machine as http://localhost:8082 for others containers in the network as service2:80.
See that specified container name doesn't have effect on service network address. To test that containers are only visible inside the network try to ping them from another container
docker run --rm --network=your_folder_name_default debian ping service1

To check in which network your containers are running you could use inspect
docker inspect service1_name

Now you have to use the container name