Multiple ARRAYFORMULA inside each other (multi-level loop) in Sheets? - google-sheets

I may be going about this the wrong way, but what I would like to do is, essentially, create a loop to pull "Categories" and "Subcategories" into a single formula.
Parents
| Name |
|----------|
| Cat 1 |
| Cat 2 |
| Cat 3 |
| Cat 4 |
|----------|
Children
| Name |
|----------|
| Sub 1 |
| Sub 2 |
|----------|
Trying to achieve:
Final Output (Option 1)
| Name | Child Of |
|----------|----------|
| Cat 1 | |
| Sub 1 | Cat 1 |
| Sub 2 | Cat 1 |
| Cat 2 | |
| Sub 1 | Cat 2 |
| Sub 2 | Cat 2 |
| Cat 3 | |
| Sub 1 | Cat 3 |
| Sub 2 | Cat 3 |
| Cat 4 | |
| Sub 1 | Cat 4 |
| Sub 2 | Cat 4 |
|----------|----------|
Or, Final Output (Option 2)
| Name | Child Of |
|----------|----------|
| Cat 1 | |
| Cat 2 | |
| Cat 3 | |
| Cat 4 | |
| Sub 1 | Cat 1 |
| Sub 2 | Cat 1 |
| Sub 1 | Cat 2 |
| Sub 2 | Cat 2 |
| Sub 1 | Cat 3 |
| Sub 2 | Cat 3 |
| Sub 1 | Cat 4 |
| Sub 2 | Cat 4 |
|----------|----------|
I've tried concatenating ARRAYFORMULA as well as putting it inside itself, but it simply does not work. I'm not even sure how to search for this specific question (although I gave it my best shot in Google and SO and came up with nothing).

=ARRAYFORMULA(SPLIT({FILTER(A1:A, A1:A<>""); UNIQUE(
TRANSPOSE(SPLIT(REPT(CONCATENATE(B1:B&CHAR(9)), COUNTA(A1:A)), CHAR(9)))&"♠"&
TRANSPOSE(SPLIT(CONCATENATE(REPT(A1:A&CHAR(9), COUNTA(B1:B))), CHAR(9))))}, "♠"))

Related

visualize monthly input and output (flow) rates in a Google Sheet chart

I have a sheet with ticket data - one ticket in each row. Each ticket has an opened date. When a ticket is closed it gets a closed date.
Looking at a month view we have:
input rate = how many new tickets are opened each month
output rate = how many tickets are closed each month
open tickets = how many tickets are/were open each month
I'll use this as example data:
| opened date | opened month | closed date | closed month |
|:-----------:|:------------:|:-----------:|:------------:|
| 2019-04-03 | 2019-04 | | |
| 2019-03-12 | 2019-03 | | |
| 2019-03-09 | 2019-03 | | |
| 2019-02-12 | 2019-02 | 2019-03-06 | 2019-03 |
| 2019-01-06 | 2019-01 | 2019-05-09 | 2019-05 |
| 2019-01-09 | 2019-01 | | |
| 2019-01-12 | 2019-01 | | |
| 2019-03-09 | 2019-03 | 2019-04-09 | 2019-04 |
| 2019-02-09 | 2019-02 | | |
| 2019-04-12 | 2019-04 | 2019-06-12 | 2019-06 |
| 2019-02-12 | 2019-02 | | |
| 2019-04-03 | 2019-04 | 2019-07-09 | 2019-07 |
| 2019-01-12 | 2019-01 | 2019-03-03 | 2019-03 |
| 2019-03-09 | 2019-03 | 2019-05-12 | 2019-05 |
| 2019-04-12 | 2019-04 | | |
| 2019-03-12 | 2019-03 | | |
| 2019-04-03 | 2019-04 | 2019-07-09 | 2019-07 |
| 2019-03-12 | 2019-03 | 2019-07-03 | 2019-07 |
| 2019-01-09 | 2019-01 | | |
| 2019-01-09 | 2019-01 | 2019-05-09 | 2019-05 |
| 2019-02-12 | 2019-02 | | |
| 2019-03-09 | 2019-03 | 2019-06-06 | 2019-06 |
| 2019-04-03 | 2019-04 | 2019-05-09 | 2019-05 |
| 2019-04-03 | 2019-04 | | |
| 2019-02-03 | 2019-02 | | |
| 2019-04-03 | 2019-04 | 2019-06-03 | 2019-06 |
| 2019-03-12 | 2019-03 | | |
| 2019-01-03 | 2019-01 | 2019-02-06 | 2019-02 |
If I manually combine the opened dates, with the closed dates, I get this:
| month | type |
|:-------:|:------:|
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-01 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | opened |
| 2019-02 | closed |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | opened |
| 2019-03 | closed |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-04 | opened |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-05 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-06 | closed |
| 2019-08 | closed |
I can put this in a pivot to get:
| month | closed | opened |
|:-------:|:------:|:------:|
| 2019-01 | | 7 |
| 2019-02 | 1 | 5 |
| 2019-03 | 1 | 8 |
| 2019-04 | | 8 |
| 2019-05 | 6 | |
| 2019-06 | 5 | |
| 2019-08 | 1 | |
This shows me how many were opened and closed each month. I can use this as the source for a chart:
But this doesn't show how many were open each month - a running total of new opens, plus old opens, minus closed. If I do the math manually I get:
| month | closed | opened | open |
|:-------:|:------:|:------:|:----:|
| 2019-01 | | 7 | 7 |
| 2019-02 | 1 | 5 | 11 |
| 2019-03 | 1 | 8 | 18 |
| 2019-04 | | 8 | 26 |
| 2019-05 | 6 | | 20 |
| 2019-06 | 5 | | 15 |
| 2019-08 | 1 | | 14 |
So, I am wondering if there is a way to take my source data and generate the pivot table/chart I am after automatically - showing how many opened per month, closed per month, and how many are open each month.
try this double running total:
=ARRAYFORMULA(IF(A2:A<>"",
IF(A2:A, MMULT(TRANSPOSE((ROW(C2:C)<=
TRANSPOSE(ROW(C2:C)))*C2:C), SIGN(C2:C)), IFERROR(1/0))-
IF(A2:A, MMULT(TRANSPOSE((ROW(B2:B)<=
TRANSPOSE(ROW(B2:B)))*B2:B), SIGN(B2:B)), IFERROR(1/0)), ))
UPDATE:
=ARRAYFORMULA(QUERY(SPLIT(QUERY(IF({B2:B; D2:D}<>"", {B2:B&"♦opened"; D2:D&"♦closed"}, ),
"where Col1 is not null", 0), "♦"),
"select Col1,count(Col1) group by Col1 pivot Col2 format Col1'yyyy-mm'", 0))
=ARRAYFORMULA({""; IF(F3:F<>"",
IF(F3:F<>"", MMULT(TRANSPOSE((ROW(H3:H)<=
TRANSPOSE(ROW(H3:H)))*H3:H), SIGN(H3:H)), IFERROR(1/0))-
IF(F3:F<>"", MMULT(TRANSPOSE((ROW(G3:G)<=
TRANSPOSE(ROW(G3:G)))*G3:G), SIGN(G3:G)), IFERROR(1/0)), )})

Column1+Column2 on google spreadsheet

I would like to ask on how to do this in google spreadsheet without using script. Apologies for the title, it is my first time posting a question here. Thank you very much :)
Example:
| 1 | A | A-1 |
| 2 | B | A-2 |
| 3 | C | A-3 |
| | | B-1 |
| | | B-2 |
| | | B-3 |
| | | C-1 |
| | | C-2 |
| | | C-3 |
Assuming 1 is in A1, drag down from Row1:
=OFFSET(B$1,INT((ROW()-1)/3),)&"-"&OFFSET(A$1,MOD((ROW()-1),3),)

How to enable wiringpi GPIO control inside a Docker container

I've used the answer to this question to enable control of my Raspberry Pi GPIO pins from within a Docker container, which runs Alpine.
$ docker run --device /dev/gpiomem whatever
This works with the Python RPi.GPIO module, but not with wiringPi.
Python and its dependencies takes up about the same space as Alpine itself, so I'd like to use wiringPi to save on install time and SD card space, and to keep things simple.
Running wiringPi v2.46 in Raspbian directly (installed using apt-get install wiringpi) works fine, and I can successfully configure and trigger digital output pins.
Running wiringPi v2.26 in the Alpine container (installed using apk add wiringpi) fails when trying to configure a pin:
$ gpio -g mode 26 out
Unable to determine hardware version. I see: Hardware : BCM2835,
- expecting BCM2708 or BCM2709. Please report this to projects#drogon.net
Is there anything I can do to expose the SOC to the container, so that wiringPi recognises it correctly? What else might be required to get this working?
Warning: Thar be hacks ahead.
The fundamental problem, as I noted in my comment, is that your containerized wiringPi is simply too old. Older Pi harwdare (like the Pi 2) used the BCM2708/BCM2709 processors, but newer hardware uses the BCM2835. WiringPi needs to know what processor is in use in order to correctly locate the GPIO control registers.
It's possible that there isn't a substantial difference between the older and newer processors as far as GPIO goes. If -- and only if -- this is the case, you can "trick" your containerized wiringPi into working.
Create a version a /proc/cpuinfo with the desired processor name:
sed s/BCM2835/BCM2709/ < /proc/cpuinfo > /proc/cpuinfo
Bind mount that onto /proc/cpuinfo inside the container. You'll also need to provide /dev/mem, and you'll need to run with --privileged:
docker run -it --rm --privileged --device /dev/mem -v /tmp/cpuinfo:/proc/cpuinfo alpine sh
This gives us:
/ # gpio -v
gpio version: 2.26
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Model 2, Revision: 1.1, Memory: 1024MB, Maker: Sony [OV]
/ # gpio readall
+-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 0 | 3 || 4 | | | 5V | | |
| 3 | 9 | SCL.1 | IN | 0 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 0 | 7 || 8 | 0 | IN | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 0 | IN | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 0 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 0 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 0 | 27 || 28 | 0 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 0 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 0 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
You would want to experiment to see if this actually works as intended.
Or just run a Raspbian image instead of an Arch image.
Thanks to larsks for pointing out the difference in version numbers.
Version 2.46 of wiringPi is available for Alpine, but I'd failed to notice it's only in the edge branch of the community repository
To use this version I had to modify the file /etc/apk/repositories, replacing the existing community entry with the edge version.
Since I'm using Docker, I had to do this as part of the image build process, so I added the following to my Dockerfile:
RUN sed -i "s/v[0-9.]*\/community/edge\/community/" /etc/apk/repositories \
&& apk update && apk add wiringpi

Cloud Foundry setup become unresponsive after few hours

I have a 5 node Cloud Foundry setup on Azure as part of API provisioning platform.
(3.5GB)3 nodes - Garden container
(1.5GB)1 node - Postgres
(28 GB)1 node - Rest of Cloud Foundry components like cloud controller, haproxy, gorouter, stager, auctioneer etc
boshuser#boshvm:~$ bosh instances --ps
Acting as user 'admin' on deployment 'single-vm-cf-on-azure' on 'bosh'
Director task 184
Task 184 done
+-------------------------------------------------------+---------+-----+----------------------+---------------+
| Instance | State | AZ | VM Type | IPs |
+-------------------------------------------------------+---------+-----+----------------------+---------------+
| cell_api_z1/0 (cf0f2f38-9676-4a25-9716-67255be18006)* | running | n/a | resource_api_z1 | x.x.x.x |
| rep | running | | | |
| consul_agent | running | | | |
| garden | running | | | |
| metron_agent | running | | | |
+-------------------------------------------------------+---------+-----+----------------------+---------------+
| cell_api_z1/1 (4147fa15-98ad-4ba9-a65d-7bd3f0dfafb6) | running | n/a | resource_api_z1 | x.x.x.x |
| rep | running | | | |
| consul_agent | running | | | |
| garden | running | | | |
| metron_agent | running | | | |
+-------------------------------------------------------+---------+-----+----------------------+---------------+
| cell_api_z1/2 (51219434-846c-4edc-a3f7-ad0b28bbc68d) | running | n/a | resource_api_z1 | x.x.x.x |
| rep | running | | | |
| consul_agent | running | | | |
| garden | running | | | |
| metron_agent | running | | | |
+-------------------------------------------------------+---------+-----+----------------------+---------------+
| cf_z1/0 (770622e7-0fbb-407e-904a-cc69f5341cef)* | running | n/a | resource_z1 | x.x.x.x |
| | | | | x.x.x.x |
| consul_agent | running | | | |
| nats | running | | | |
| nats_stream_forwarder | running | | | |
| metron_agent | running | | | |
| etcd | running | | | |
| etcd_metrics_server | running | | | |
| rpc_nfsd | running | | | |
| rpc_mountd | running | | | |
| cloud_controller_ng | running | | | |
| cloud_controller_worker_local_1 | running | | | |
| cloud_controller_worker_local_2 | running | | | |
| nginx_cc | running | | | |
| cloud_controller_worker_1 | running | | | |
| cloud_controller_clock | running | | | |
| nfs_mounter | running | | | |
| route_registrar | running | | | |
| consul_template | running | | | |
| haproxy_config | running | | | |
| haproxy | running | | | |
| doppler | running | | | |
| loggregator_trafficcontroller | running | | | |
| uaa | running | | | |
| gorouter | running | | | |
| statsd-injector | running | | | |
| syslog_drain_binder | running | | | |
| bbs | running | | | |
| auctioneer | running | | | |
| converger | running | | | |
| stager | running | | | |
| nsync_listener | running | | | |
| nsync_bulker | running | | | |
| tps_listener | running | | | |
| tps_watcher | running | | | |
| cc_uploader | running | | | |
| ssh_proxy | running | | | |
| file_server | running | | | |
| route_emitter | running | | | |
+-------------------------------------------------------+---------+-----+----------------------+---------------+
| postgres_z1/0 (40f5d667-81c6-4065-98e5-8e272b17ed7d)* | running | n/a | resource_postgres_z1 | x.x.x.x |
| postgres | running | | | |
| metron_agent | running | | | |
+-------------------------------------------------------+---------+-----+----------------------+---------------+
When I deploy the cloud foundry manifest using BOSH. It gets deployed successfully and everything works fine which it should.
The problem starts after few hours of deployment. The 'cf' commands stop responding and the apps deployed on cloud foundry do not respond when accessed from browser.
As a solution I have to recreate the cloud controller node. The setup works fine for few hours and then fail again.
Earlier the cloud controller node had 8GB RAM. I did some memory usage analysis when the setup became unresponsive. I found that on a 8GB node the memory was getting choked. So I concluded the issue might be happening because of low RAM.
As a solution I updated the cloud controller node from 8GB to 28GB and redeployed the cloud foundry manifest. The setup worked fine and I was able to access the apps from browser.
But again after few hours the 'cf' commands became unresponsive and I was not able to access apps from browser. Out of 28GB only around 8GB is getting used. So there cannot be an issue because of low memory.
Not sure why the setup becomes unresponsive after few hours.
Any help would be very much appreciated.
Thanks

How to not get lost reviewing Gerrit reviews comments?

Hey guys I'm having a problem forgetting to answer gerrit reviews comments. I'm wondering if there is any way to summarize all gerrit comments (from all patch sets with its respective replies). Let me give a example:
Me -> P1
Review1 -> comments 1a, 1b, 1c;
Me -> P2 (without answer any comments)
Me -> P3
Me -> 1a done, 1c done;
Me -> P4
Review1 +1, +2, finished;
How can I see that we forget to address the comment 1b ?
Bye
It's not possible. In Gerrit database, there's no difference between "answered" comments and "not answered" ones.
Take a look at the patch_comments Gerrit table:
+-----------------------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+--------------+------+-----+-------------------+-----------------------------+
| line_nbr | int(11) | NO | | 0 | |
| author_id | int(11) | NO | | 0 | |
| written_on | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| status | char(1) | NO | MUL | | |
| side | smallint(6) | NO | | 0 | |
| message | text | YES | | NULL | |
| parent_uuid | varchar(40) | YES | | NULL | |
| change_id | int(11) | NO | PRI | 0 | |
| patch_set_id | int(11) | NO | PRI | 0 | |
| file_name | varchar(255) | NO | PRI | | |
| uuid | varchar(40) | NO | PRI | | |
| range_end_character | int(11) | YES | | NULL | |
| range_end_line | int(11) | YES | | NULL | |
| range_start_character | int(11) | YES | | NULL | |
| range_start_line | int(11) | YES | | NULL | |
+-----------------------+--------------+------+-----+-------------------+-----------------------------+

Resources