while loop – How to read a file using scanner, and initializing to String arrays, then calculating ints and floats depending on column?

            System.out.print("Input file name desired to be read: ");
            String fileName = userInput.nextLine();
            final int SIZE = 12;
            String() fileData = new String(SIZE);
            int i = 0;
            File file = new File(fileName);
            Scanner inputFile = new Scanner(file);

            if (file.exists())
                while(inputFile.hasNext() && i < fileData.length)
                    fileData(i) = inputFile.nextLine();

This is what I have so far, and I am confused on how I would read a file, such as

Jan 4128 4.59 4421 4.79

Feb 4130 4.59 4822 4.79

Mar 4126 4.59 5210 4.79

Apr 4075 4.69 5143 4.79

May 4250 4.69 4538 4.79

Jun 4133 4.69 4458 4.79

Jul 4211 4.79 5135 4.89

Aug 4958 4.79 4620 4.89

Sep 4823 4.79 4714 4.89

Oct 4989 4.89 4689 4.99

Nov 4088 4.89 5163 4.99

Dec 4906 4.89 5314 4.99

and assign to an array of 12. Then calculate the addition of the second column, third column, forth column, and fifth column accordingly. I am also not sure if the array is even supposed to be a string to read the individual columns of the file, so any revision would be appreciated. In java please.

sql server – SQL rolling back all iterations of a while loop when each iteration has its own explicit transaction

For the past few days I’ve been trying to write a query for an automated process that will delete records from a log table within a specified date range (a month) to another table, so they can then be dumped to disk and the records deleted from the database. A first, naïve approach, á la

DELETE FROM <sometable>
OUTPUT DELETED.* INTO (<sometable>_{year}_{month})
WHERE DATEPART(YEAR, (DateTime)) = {year} AND DATEPART(MONTH, (DateTime)) = {month}

of course blew up the transaction log. I then tried doing the same, but now in batches of 1m rows, as shown below

    DELETE TOP (1000000) FROM <sometable>
    OUTPUT DELETED.* INTO (<sometable>_{year}_{month})
    WHERE DATEPART(YEAR, (DateTime)) = {year} AND DATEPART(MONTH, (DateTime)) = {month}

but that did nothing to change the transaction log growth. Next, I tried using an explicit transaction within the loop.


    DELETE TOP (1000000) FROM <sometable>
    OUTPUT DELETED.* INTO (<sometable>_{year}_{month})
    WHERE DATEPART(YEAR, (DateTime)) = {year} AND DATEPART(MONTH, (DateTime)) = {month}


Again. No difference. What’s worse, if I cancel this query and do a ROLLBACK to release the table, it rolls back everything. Not just the last iteration, as one would expect, but the whole thing. Why aren’t the individual transactions within the loop being treated as such? Surely there must be a way to move huge amounts of rows around the database without SQL throwing a hissy fit and blowing up on its user(s)?

Gitlab docker error on database migration after update (restart loop)

I just updated my gitlab docker instance, running using docker-compose on a host machine. I am experiencing the following error:

Recipe: gitlab::database_migrations
  * bash(migrate gitlab-rails database) action run
    (execute) rake aborted!
              PG::ConnectionBad: could not connect to server: No such file or directory
                Is the server running locally and accepting
                connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
              /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:48:in `block (3 levels) in <top (required)>'
              /opt/gitlab/embedded/bin/bundle:23:in `load'
              /opt/gitlab/embedded/bin/bundle:23:in `<main>'
              Tasks: TOP => gitlab:db:configure
              (See full trace by running task with --trace)
    Error executing action `run` on resource 'bash(migrate gitlab-rails database)'
    Expected process to exit with (0), but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20200707-23-1sorsih" ----
    STDOUT: rake aborted!
    PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:48:in `block (3 levels) in <top (required)>'
    /opt/gitlab/embedded/bin/bundle:23:in `load'
    /opt/gitlab/embedded/bin/bundle:23:in `<main>'
    Tasks: TOP => gitlab:db:configure
    (See full trace by running task with --trace)
    ---- End output of "bash"  "/tmp/chef-script20200707-23-1sorsih" ----
    Ran "bash"  "/tmp/chef-script20200707-23-1sorsih" returned 1
    Resource Declaration:
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb
     55: bash "migrate gitlab-rails database" do
     56:   code <<-EOH
     57:     set -e
     58:     log_file="#{node('gitlab')('gitlab-rails')('log_directory')}/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log"
     59:     umask 077
     60:     /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}
     61:     STATUS=${PIPESTATUS(0)}
     62:     chown #{account_helper.gitlab_user}:#{account_helper.gitlab_group} ${log_file}
     63:     echo $STATUS > #{db_migrate_status_file}
     64:     exit $STATUS
     65:   EOH
     66:   environment env_variables unless env_variables.empty?
     67:   notifies :run, "execute(clear the gitlab-rails cache)", :immediately
     68:   dependent_services.each do |svc|
     69:     notifies :restart, svc, :immediately
     70:   end
     71:   not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
     72:   only_if { node('gitlab')('gitlab-rails')('auto_migrate') }
     73: end
    Compiled Resource:
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:55:in `from_file'
    bash("migrate gitlab-rails database") do
      action (:run)
      default_guard_interpreter :default
      command nil
      backup 5
      interpreter "bash"
      declared_type :bash
      cookbook_name "gitlab"
      recipe_name "database_migrations"
      code "    set -en    log_file="/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log"n    umask 077n    /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}n    STATUS=${PIPESTATUS(0)}n    chown git:git ${log_file}n    echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-8411f47246fn    exit $STATUSn"
      domain nil
      user nil
      not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-8411f47246f) && (cat /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-8411f47246f | grep -Fx 0)"
      only_if { #code block }
    System Info:
    ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) (x86_64-linux)

Running handlers:
There was an error running gitlab-ctl reconfigure:

bash(migrate gitlab-rails database) (gitlab::database_migrations line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with (0), but received '1'
---- Begin output of "bash"  "/tmp/chef-script20200707-23-1sorsih" ----
STDOUT: rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:48:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
---- End output of "bash"  "/tmp/chef-script20200707-23-1sorsih" ----
Ran "bash"  "/tmp/chef-script20200707-23-1sorsih" returned 1

Running handlers complete
Chef Client failed. 9 resources updated in 18 seconds
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=13.1.3-ce.0

Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:

  docker exec -it gitlab vim /etc/gitlab/gitlab.rb
  docker restart gitlab

For a comprehensive list of configuration options please see the Omnibus GitLab readme

If this container fails to start due to permission problems try to fix it by executing:

  docker exec -it gitlab update-permissions
  docker restart gitlab

I have seen this question but neither answer solved my issue.

If any more information is needed, feel free to comment.

boot loop – Cant flash my firmware on my huawei p8 lite ( Model Num: ALE-UL00___Build num: ALE-UL00C00B230) Also cant find firmware avalable anywhere?

I have been at this for almost 2 days straight now, Here is the scenario: I bought a phone off of E-bay, but it has a wierd firmware on it which didnt allow me to connect to wifi, but instead had a Wlan only option, and no wifi to be found anywhere. It also had all these wierd chinese apps on it with tons of ads bombarding my screen. and no wifi to be found anywhere.

So i decided to load a different version firmware off of an SD card, and not only did the new firmware not work, but it overwrote the old firmware aswell. Now i’m stuck in a bootloop. I have tried about 10 different firmware’s by now and i cant get my device to successfully install it. So then i turned to Windows Powershell.

I followed online instructions, my computer detects my phone in Fastboot mode, but i cant for the love of GOD get my commands applied, it keeps saying:”” FAILED (remote: Command not allowed)“” ‘. Another note, before this whole mess, i enabled USB debugging, but i couldnt find an “”Enable OEM “” slider, I also cant find my exact Firmware anywhere. (So i just played around with simar titled Frimwares. )

**(My Model Number is: ALE-UL00)

(And my Build number is: ALE-UL00C00B230)**

**So now my phone is stuck with no OS/Firmware, and i cant use POWERSHELL because i dont have OEM enabled. SOME PLEASE TELL ME WHAT I CAN DO TO FIX THIS. My current fastboot screen sais : PHONE locked ** does that have something to do with the OEM setting and is that why i cant apply my Powershell Commands? please advise me, IM BEGGING YOU INTERNET!!!

mysql – Determinar quando o Loop WHILE deve parar PHP

Estou com o seguinte problema,

Tenho um sistema em PHP que faz um WHILE em uma coluna da base de dados que contém determinados valores sendo que preciso que o WHILE pare num valor que eu determine.

A primeira coluna com os ID’s e a segunda com os valores, preciso que meu WHILE execute uma função qualquer até que o valor total dos somas dos quantidades seja menor ou igual a 850 e depois pare.

inserir a descrição da imagem aqui

Código abaixo:

$resultado = $PDO->query("SELECT * FROM teste");
//Percorrendo e exibir registros 
# Cria e abre o arquivo .txt para salvar os registros da consulta
$arquivo_total = '../imprimir/xereta.prn';
$fppp = fopen($arquivo_total, 'w');

//Percorrendo e exibir registros
while ($registro = $resultado->fetch(PDO::FETCH_ASSOC)) {
    $id = $registro('id');
    $quantidade = ceil($registro('quantidade')*10/100 + ($registro('quantidade'))+20). "rnn";
        # Escreve no arquivo .txt o registro atual da consulta
        # Início primeira etiqueta 

            fwrite($fppp, $quantidade);

        # Final Segunda etiqueta 
        } # << Fim do while        
        # Fecha o arquivo .txt

Alguém sabe como me ajudar.

rom flashing – Stuck in Boot Loop After Trying to Flash Android 11 Beta GSI to Intrinsyc HDK8150/Snapdragon 855 Mobile HDK

Preface: I’m a newbie at flashing Android. I’ve provided screenshots at the bottom of this post. Let me know if you need any additional information. I cross posted this question to /u/AndroidGSI on reddit.

I have an Intrinsyc HDK8150 (SM8150P)/Snapdragon 855 Mobile HDK that is currently running Android 10. This specific device launched with Android 9. I’m attempting to flash the Android 11 Beta GSI to the device. I’m using an Ubuntu 20.04 host machine with the platform tools from April 2020. I’ve contacted Intrinsyc support and they were unable to provide any info on how to flash Android 11 to the device.

I attempted to flash the vbmeta.img and system.img after downloading the new Android 11 Beta GSI from the Android website. In the Android 10 files provided by Intrinsyc, the system.img is packed inside a super.img. I was able to unpack the super.img, re-pack the original images and flash all images with the original super.img successfully. I did this to make sure my method was correct. But, when I unpacked, then swapped the old system.img for the new system.img from the GSI, and flashed all images with the new vbmeta.img in place of the old vbmeta.img, the device got stuck in a bootloop at the “android” boot screen. Not sure if this is an important detail, but the vbmeta.img with the GSI is 4.1 kB in size and the original vbmeta.img is 8.2 kB.

I also attempted the dynamic systems update to get Android 11 Beta on the device. Again, the device couldn’t get past the “android” boot screen.

GSI Compliance check and attempt at Dynamic System Update: https://imgur.com/a/PMEHway

Settings > About phone > Android version: https://imgur.com/a/I3VYUO4

Script and files provided by Intrinsyc that are needed to flash Android 10 to the device (including images in unpacked super.img): https://imgur.com/a/K7gZKXq

Contents of fastboot getvar all command when loaded with Android 10 provided by Intrinsyc: https://imgur.com/a/0gFmA3k

My questions:

Could you provide any guidance on how to get Android 11 on to this device? If you don’t think that Android 11 can be flashed to this device, do you know of any dev boards that can have Android 11 successfully flashed?

Thank you for reading!

boot loop – OnePlus 6 bootloop no such partition (recovery_b)

Long story short, I did wanna install Snapchat, but my phone was rooted with magisk, so I did wanna do an reinstall of the latest OP6 10 andr. version.
But now I get in a bootloop the issue I see now when I try with ADB on Windows laptop is the following: “FAILED (remote: Failed to load/authenticate boot image: Load Error)”.

My commands I tried:

PS C:adb> fastboot flash recovery_a C:adbtwrp-3.4.0-1-enchilada.img
target reported max download size of 805306368 bytes
sending 'recovery_a' (31072 KB)...
OKAY ( 0.792s)
writing 'recovery_a'...
FAILED (remote: (recovery_a_b) No such partition)
finished. total time: 0.819s
PS C:adb> fastboot flash recovery_b C:adbtwrp-3.4.0-1-enchilada.img
target reported max download size of 805306368 bytes
sending 'recovery_b' (31072 KB)...
OKAY ( 0.793s)
writing 'recovery_b'...
FAILED (remote: (recovery_b_b) No such partition)
finished. total time: 0.834s
PS C:adb> fastboot boot C:adbtwrp-3.4.0-1-enchilada.img
downloading 'boot.img'...
OKAY ( 0.794s)
FAILED (remote: Failed to load/authenticate boot image: Load Error)
finished. total time: 0.833s
PS C:adb>

Help… I know how to unbrick this device, but I can’t lose the WhatsApp data etc, I didn’t back up.

algorithms – Runtime Complexity of finding a loop in an array

Having a hard time understanding the runtime complexity of the following algorithm:

public class Solution {
    public boolean circularArrayLoop(int() nums) {
        int n = nums.length;
        if(n < 2){
            return false;
        for(int i = 0; i < n; i++){
            if(nums(i) == 0){
            int slow = i, fast = advance(nums, i);
            while(nums(slow) * nums(fast) > 0 && nums(advance(nums, fast)) * nums(slow) > 0){
                if(slow == fast){
                    //one element loop does not count
                    if(slow == advance(nums, slow)){
                    return true;
                 slow = advance(nums, slow);
                 fast = advance(nums, (advance(nums,fast)));
            //loop not found, set all the elements along the way to 0
            slow = i;
            int val = nums(i);
            while(nums(slow) * val > 0){
                int next = advance(nums, slow);
                nums(slow) = 0;
                slow = next;
        return false;
    public int advance(int() nums, int i){
        int n = nums.length;
        return i + nums(i)  >= 0 ? (i+nums(i)) % n : n + ((i + nums(i)) %n);

Been told that the complexity should be $O(n)$ because each node is visited at most four times by slow, by fast, be marking zero, be zero checking. Cannot quite agree, because even it is marked zero, the rest of the nodes still have to check whether it is zero or not. So you have to check it at least $n-1$ times.

python 3.x – Calculating a unique count within a rolling time window without an explicit loop

I have a pandas DataFrame that contains a row per member per day, expressing member interaction with a website. Members interact only on some days, each member is identified with an ID. Here is a simulated example:

import pandas as pd
import numpy as np

# Generate data.

ids = np.repeat(np.arange(100), np.random.randint(100, size = 100))

test = (
        index = pd.Series(pd.date_range('2020-01-01', '2020-02-01').values).sample(ids.shape(0), replace = True)



2020-01-01     4
2020-01-01    65
2020-01-01    95
2020-01-01    40
2020-01-01    88
dtype: int32

I’d like to calculate a unique count of members within a 7 day rolling window. After some experimentation and research on Stack Overflow (including pandas rolling/groupby function), I arrived at an explicit loop and slicing:

# Calculate rolling 7 day unique count.

unique_count = {}

for k in test.index.unique():

    unique_count(k) = test.loc(k - pd.Timedelta('7 days'):k).nunique()

# Store as a dataframe and truncate to a minimum period.

unique_count = pd.DataFrame.from_dict(unique_count, orient = 'index', columns = ('7_day_unique_count')).iloc(7:)



2020-01-28                  98
2020-01-29                  98
2020-01-30                  98
2020-01-31                  97
2020-02-01                  97

This seems to work correctly and performs OK. But is it possible to do this without the explicit loop (with resample/groupby/rolling functions)? And if so, is that more efficient?