algorithm – (Java) Read .txt and organize activities for hours / minutes

Doubts in logic to generate the output file according to the example
I need that even if he reaches the total_min <720 condition he continues to travel the lines. 720 is the total number of minutes before lunch, when reached, it should separate the activities that should be performed after lunch (lunch must be inserted manually).

  • I need to make a system that reads a TXT file (intput.txt).
  • This file has several lines.
  • Each line an activity with execution time (30min, 45min, 60min)
  • Activities should start at 9 am.
  • Half day (12:00) lunch break
  • Generate a TXT with organized activities (output.txt)

intput.txt

Correr 60min
Estudar 30min
Ler 45min
Escrever 60min
Caminhar 45min
Jogar 30min

Example how the output.txt file should look

09:00 Correr 60min
10:00 Estudar 30min
10:30 Ler 45min
11:15 Caminhar 45min
12:00 Almoço 60min
13:00 Jogar
(...)

My code:

    public static void main(String() args) throws IOException {
    // TODO code application logic here

    ArrayList<String> antes_almoco = new ArrayList<String>();
    ArrayList<String> depois_almoco = new ArrayList<String>();

    int total_min = 540;
    int horas = total_min / 60;
    int minutos = total_min % 60;
    String trinta = "30min";
    String quarentaCinco = "45min";
    String sessenta = "60min";
    boolean trinta_min = false;
    boolean quarentaCinco_min = false;
    boolean sessenta_min = false;
    String path = "C:\input.txt";
    String outputDir = "C:\output.txt";

    FileReader arq = new FileReader(path);
    BufferedReader lerArq = new BufferedReader(arq);
    String linha;

    //Output   
    File file2 = new File(outputDir);
    FileWriter arq_output = new FileWriter(file2, true);
    PrintWriter gravarArq = new PrintWriter(arq_output);

    if (!file2.exists()) {
        file2.createNewFile();
    }

    while ((linha = lerArq.readLine()) != null) {

        trinta_min = linha.toLowerCase().contains(trinta.toLowerCase());
        quarentaCinco_min = linha.toLowerCase().contains(quarentaCinco.toLowerCase());
        sessenta_min = linha.toLowerCase().contains(sessenta.toLowerCase());

        if (sessenta_min == true) {
            total_min += 60;
            if (total_min < 720) {
                antes_almoco.add(linha);
            } else if (total_min > 720) {
                depois_almoco.add(linha);
            }
        }

        if (trinta_min == true && total_min < 720) {
            total_min += 30;
            if (total_min < 720) {
                antes_almoco.add(linha);
            } else if (total_min > 720) {
                depois_almoco.add(linha);
            }
        }

        if (quarentaCinco_min == true && total_min < 720) {
            total_min += 45;
            if (total_min < 720) {
                antes_almoco.add(linha);
            } else if (total_min > 720) {
                depois_almoco.add(linha);
            }
        }

        if (total_min == 720) {
            total_min += 60;
            antes_almoco.add("12:00 Almoço");
        }
    }

    for (String cont : antes_almoco) {
        System.out.println(cont);
        gravarArq.printf("%d:%02d %s n", horas, minutos, cont);
    }
    for (String cont : depois_almoco) {
        //System.out.println(cont);
        gravarArq.printf("%d:%02d %s n", horas, minutos, cont);
    }
    lerArq.close();
    gravarArq.close();
    arq.close();
}

Middle-earth adventures – Can a scholar repeat the healing of the hands every 10 minutes?

In adventures in the Middle Earth RPG, the learned class has the ability "Hands of a healer":
"If you can hit a creature, you can spend one healing die per action, instantly granting them 1d8 hit points plus your wisdom modifier … If you instead hold the creature for at least 10 minutes … then you can multiply 1d8 by your skill modifier … "

My question is: can a scientist repeat the healing hands every 10 minutes, spending more healing dice?

java – In my Spring MVC project, Tomcat takes 3 to 4 minutes to start / restart, how can it be improved?

I am using two databases MySql and MongoDB with the Spring MVC project. I checked my console and my log, it is taking too long for the MongoDB connection.

1.MySql connection code

@Bean
public DataSource restDataSource() {
    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
    dataSource.setUrl(env.getProperty("jdbc.url"));
    dataSource.setUsername(env.getProperty("jdbc.user"));
    dataSource.setPassword(env.getProperty("jdbc.pass"));
    return dataSource;
}

@Bean
@Autowired
public HibernateTransactionManager transactionManager(final SessionFactory sessionFactory) {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}

2.MongoDB connection code

@Bean
public MongoDbFactory mongoDbFactory() throws UnknownHostException, java.net.UnknownHostException {
   return new SimpleMongoDbFactory(new MongoClientURI("mongodb://localhost:27017/dbname"));
}

@Bean
public MongoTemplate mongoTemplate() throws UnknownHostException, java.net.UnknownHostException {
    return new MongoTemplate(mongoDbFactory());
}       

Am I doing it the right way or not?

I'm gay. I ran 3 miles in less than 27 minutes with combat boots and did 11 push-ups in 1997 to complete basic army training. Do you know how?

How many conversations do you start with "I'm gay"? Do you also run with a t-shirt that says "I'm gay"? Do you have an "I'm gay" bumper? Start your texts and emails with "I'm gay"?

I bet your colleagues start conversations with you saying "Hey, Llewen, I know you're gay, but ……….."

Notepad ++; I think I clicked on an option for "localization"; now, each time Notepad ++ is updated, it takes 5-10 minutes

I think I clicked on a & # 39; localization & # 39; option in Notepad ++
But I can't find this option now, to cancel it.
Currently, each time Notepad ++ is updated, it takes 5-10 minutes for all local natural languages ​​(for example, German, Serbian, etc.) to be updated.
I only need English.
I would appreciate any suggestion on how to get rid of the need for Notepad ++ to spend time installing or updating other natural languages, when Notepad ++ updates
I do not use any natural language other than English, French and Hebrew.

thank you,

Marc

Excel – Optimization of VBA code, update takes more than 50 minutes

Could you please help me optimize the macro, it takes more than 50 minutes but still not successful.

The For loop is looped up to 1.0 million + lines.
The screen flashes.
I tried Application.ScreenUpdating = True, but it still flickers and the loop takes a very long time.

I download reports from sharepoint and check the file for the last 7 days.

File names:

Fsplit2 = "Provisional inventory tracking – all states" and format (now – i, "mmddyy") & "v1.xlsx"

F4 = "Export inventory" and format (now – i, "yyyy-mm-dd") & "AM.xlsm"

From f4, I update the values ​​in Fsplit2 according to the group name and the conditions mentioned below in the code.

Sub DownloadPastInterimTracker()
    Dim myURL As String
    Dim f1 As String
    Dim f2 As String
    Dim WinHttpReq As Object


    Fsplit1 = "https://share.antheminc.com/projects/Facets-Mig/Plan/Interim%20Inventory%20Tracker/"

     'File handles upto 7 days
   For i = 1 To 7
            Fsplit2 = "Interim Inventory Tracker - All States " & Format(Now - i, "mmddyy") & " v1.xlsx"
             myURL = Fsplit1 & Fsplit2
           Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
           WinHttpReq.Open "GET", myURL, False
          WinHttpReq.Send

          If WinHttpReq.Status = 200 Then
             Set oStream = CreateObject("ADODB.Stream")
             oStream.Open
            oStream.Type = 1
            oStream.Write WinHttpReq.ResponseBody
            oStream.SaveToFile ("C:UsersAG47552DesktopInterim TrackerYesterday's Tracker File" & Fsplit2 & " ")
            oStream.Close
            i = 7

            MsgBox " File Downloaded Successfully  "
        End If   
Next i

Call OpenInterimTracker(Fsplit2)
Call CentralLookup(Fsplit2)
Call NortheastLookup(Fsplit2)
Workbooks("Trackers " & Format(Now, "MMDDYY") & " PM.xlsx").Save
Workbooks("Trackers " & Format(Now, "MMDDYY") & " PM.xlsx").Close
Call DownloadTableauTracker(Fsplit2)

End Sub

Sub OpenInterimTracker(ByVal Fsplit2 As String)

    Application.DisplayAlerts = False
    Application.ScreenUpdating = True

    Dim sPath As String, sFile As String
    Dim wb As Workbook
    Application.ScreenUpdating = True
    sPath = "C:UsersAG47552DesktopInterim TrackerYesterday's Tracker File"
    sFile = sPath & Fsplit2
    Set wb = Workbooks.Open(sFile)

End Sub

Sub CentralLookup(ByVal Fsplit2 As String)

Dim rnge as Range
Dim cl As range


Workbooks("Trackers " & Format(Now, "MMDDYY") & " PM.xlsx").Activate
Worksheets("Central").Activate
lastrow = range("A" & Rows.Count).End(xlUp).Row

   For i = 2 To lastrow
      If Application.WorksheetFunction.IsNA(range("g" & i).Value) Then
         range("g" & i).Value = "Change"
      End If

     If range("g" & i).Value = "Change" Then
        srchval = Trim(range("d" & i).Value)
        chgval = Trim(range("e" & i).Value)

            Workbooks(Fsplit2).Activate
            Sheets("Main Data input").Activate
            On Error Resume Next
             get_row_number = Workbooks(Fsplit2). _
                              Sheets("Main Data input").range("D:D").Find( _
              What:=srchval, _
              LookIn:=xlValues, _
              LookAt:=xlPart, _
              SearchOrder:=xlByColumns, _
              SearchDirection:=xlNext, _
              MatchCase:=True _
              ).Row

        If get_row_number = "" Then
            'do nothing
        Else
            Workbooks(Fsplit2).Activate
            Sheets("Main Data input").range("H" & get_row_number).Value = chgval
            chgval = ""
            chgval.Interior.Color = vbGreen
        End If
        Workbooks("Trackers " & Format(Now, "MMDDYY") & " PM.xlsx").Activate
        Worksheets("Central").Activate
     End If
    Next i
End Sub

Sub NortheastLookup(ByVal Fsplit2 As String)

Dim rnge as Range
Dim cl As range


Workbooks("Trackers " & Format(Now, "MMDDYY") & " PM.xlsx").Activate
Worksheets("Northeast").Activate
lastrow = range("A" & Rows.Count).End(xlUp).Row

   For i = 2 To lastrow
      If Application.WorksheetFunction.IsNA(range("g" & i).Value) Then
         range("g" & i).Value = "Change"
      End If

     If range("g" & i).Value = "Change" Then
        srchval = Trim(range("d" & i).Value)
        chgval = Trim(range("e" & i).Value)

            Workbooks(Fsplit2).Activate
            Sheets("Main Data input").Activate
            On Error Resume Next
             get_row_number = Workbooks(Fsplit2). _
                              Sheets("Main Data input").range("D:D").Find( _
              What:=srchval, _
              LookIn:=xlValues, _
              LookAt:=xlPart, _
              SearchOrder:=xlByColumns, _
              SearchDirection:=xlNext, _
              MatchCase:=True _
              ).Row

        If get_row_number = "" Then
            'do nothing
        Else
            Workbooks(Fsplit2).Activate
            Sheets("Main Data input").range("H" & get_row_number).Value = chgval
            chgval = ""
            chgval.Interior.Color = vbGreen
        End If
        Workbooks("Trackers " & Format(Now, "MMDDYY") & " PM.xlsx").Activate
        Worksheets("Central").Activate
       End If
    Next i
End Sub

Sub DownloadTableauTracker(ByVal Fsplit2 As String)

    Dim myURL As String
    Dim f1 As String
    Dim f2 As String
    Dim f3 As String
    Dim f4 As String

    Dim WinHttpReq As Object

    f1 = "https://share.antheminc.com/sites/EET-Migrations/Migrations%20Tracker/Migrations_Tracker%20_Tableau/"
    f2 = "" & Year(Date) & "https://codereview.stackexchange.com/"
    f3 = "" & Format(Now, "mm mmm yyyy") & "https://codereview.stackexchange.com/"

    For i = 0 To 2

    f4 = "Inventory Export " & Format(Now - i, "yyyy-mm-dd") & " AM.xlsm"

           myURL = f1 & f2 & f3 & f4
           Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
           WinHttpReq.Open "GET", myURL, False
          WinHttpReq.Send

          If WinHttpReq.Status = 200 Then
             Set oStream = CreateObject("ADODB.Stream")
             oStream.Open
            oStream.Type = 1
            oStream.Write WinHttpReq.ResponseBody
            oStream.SaveToFile ("C:UsersAG47552DesktopInterim TrackerTableau Tracker" & f4 & " ")
            oStream.Close
            i = 5

            MsgBox " Tableau Inventory file downloaded "
        End If     
Next i
Call TableauInventoryOpen(f4)
Call FetchTableauStatus(Fsplit2, f4)
End Sub

Sub TableauInventoryOpen(ByVal f4 As String)

    Application.DisplayAlerts = False
    Application.ScreenUpdating = True

    Dim sPath As String, sFile As String
    Dim wb As Workbook
    Application.ScreenUpdating = True
    sPath = "C:UsersAG47552DesktopInterim TrackerTableau Tracker"
    sFile = sPath & f4
    Set wb = Workbooks.Open(sFile)

End Sub

Sub FetchTableauStatus(ByVal Fsplit2 As String, ByVal f4 As String)

Workbooks(Fsplit2).Activate
Worksheets("Main Data input").Activate
lastrow = range("b" & Rows.Count).End(xlUp).Row

   For i = 3 To lastrow

            srchval = Trim(range("d" & i).Value)
            'chgval = Trim(Range("e" & i).Value)

            Workbooks(f4).Activate
            Sheets("Inventory Export").Activate
            On Error Resume Next
             get_row_number = Workbooks(f4). _
                              Sheets("Inventory Export").range("G:G").Find( _
              What:=srchval, _
              LookIn:=xlValues, _
              LookAt:=xlPart, _
              SearchOrder:=xlByColumns, _
              SearchDirection:=xlNext, _
              MatchCase:=True _
              ).Row

             If get_row_number = "" Then
                'do nothing
             Else
          'Finalize Product and Admin Selections

               Workbooks(f4).Activate
               If Sheets("Inventory Export").range("z" & get_row_number).Value = "Complete" Then
                  Workbooks(Fsplit2).Activate
                  Worksheets("Main Data input").Activate
                  If Sheets("Main Data input").range("O" & i).Value = "Incomplete" Or _
                     Sheets("Main Data input").range("o" & i).Value = "Incomplete with Issues" Then
                     Sheets("Main Data input").range("o" & i).Value = "Complete"
                  End If
                End If
           'Implementation Case Status
                  copyval = ""
                  Workbooks(f4).Activate
                If Sheets("Inventory Export").range("o" & get_row_number).Value = "Implementation Completed" Or _
                   Sheets("Inventory Export").range("o" & get_row_number).Value = "NULL" Then
                    'do nothing
                Else
                    Workbooks(f4).Activate
                    copyval = Sheets("Inventory Export").range("o" & get_row_number).Value
                  Workbooks(Fsplit2).Activate
                  Worksheets("Main Data input").Activate
                  Sheets("Main Data input").range("j" & i).Value = copyval
               End If
           'E&B Audit Complete
               Workbooks(f4).Activate
               If Sheets("Inventory Export").range("r" & get_row_number).Value = "Complete" Then
                  Workbooks(Fsplit2).Activate
                  Worksheets("Main Data input").Activate
                  If Sheets("Main Data input").range("l" & i).Value = "Incomplete" Or _
                     Sheets("Main Data input").range("l" & i).Value = "Incomplete with Issues" Then
                     Sheets("Main Data input").range("l" & i).Value = "Complete"
                  End If
                End If
             End If
        Workbooks(Fsplit2).Activate
                  Worksheets("Main Data input").Activate
     Next i

Workbooks(f4).Close
Workbooks(Fsplit2).Saveas "C:UsersAG47552DesktopInterim TrackerToday's Tracker File" & Fsplit2 & " "
End Sub

The current time is delayed by 6 hours 30 minutes when storing in the mongoDB database with Date as the data type in Java

Thank you for responding to Stack Overflow!

  • Make sure you respond to the question. Give details and share your research!

But to avoid

  • Ask for help, clarification or respond to other responses.
  • Make statements based on opinion; save them with references or personal experience.

For more information, see our tips on writing correct answers.

NEW – 7 minutes fitness Reviews: SCAM or LEGIT? | NewProxyLists

7minutes fitness is an app that pays you to watch videos and do easy tasks, and also pays you to finish and do exercises, the app is still new and worth the experience.

Minimum payment: 72000coins = $ 3

To download this app == https://play.google.com/store/apps/details?id=com.smallanglegame.health

Use my reference code to win 300 coins == YANPD866

For proof of payment, I'm not sorry, I will add it if I have received my payment.
Thank you

mac – Every few minutes, all my open windows readjust their content and text layout

Every few minutes, my computer almost shuts down because all the windows have their content readjusted. It seems that all of the text, at least, is being returned. Perhaps the entire contents of the window (text images, etc.) are re-formatted. Of course, I am not sure. All I know is what I see: all the content moves a little, several pixels, then straightens up.

Although visually annoying, the worst part is that my computer almost shuts down. I cannot move windows or choose menus. Often, my Apple Magic mouse loses its Bluetooth connection, then reconnects once the contents of the window have stopped dancing.

This behavior has been going on for months, driving me crazy.

I have never seen this before on any of my many Mac computers.

I am using macOS Mojave 10.14.6 on a Mac mini (2018) with a BenQ 4K 32 "monitor connected via Thunderbolt 3 (Mac) to DisplayPort (monitor). I used the same monitor with Mojave on a MacBook Pro without any problems.

➥ Do you have an idea of ​​the cause of this problem and what could be the solution?

I am willing and able to do a clean installation and move to Catalina if need be.

I am do not Complain about "shear" where the left or right half of the monitor briefly distorts before reappearing normally. I know this happens with 4K monitors, something to do with a 4K screen internally represented as a pair of virtual screens, if I remember vaguely. With my problem, I can see individual windows taking turns rearranging their content.