google sheets – Limit to only include data from latest two entries

Question is related to this Google Sheet:
https://docs.google.com/spreadsheets/d/1U13dvWPk8-hMybmhE1RKZ66y7RXXGPWt91_BNFWIup4/edit?usp=sharing

How can I limit column A and B to only include Formdata of the last 2 entries by that person (limit by character name). Example, Jesper has made 3 form submits, but I would like to limit this to only include the latest 2. How can I do this?

How does Youtube Music add entries to Google Chrome menu?

I was listening music on Youtube Music, and noticed a new entry on Google Chrome’s menu offering to Install Youtube Music....

Playing a music video in Youtube Music on Google Chrome, with the browser's menu showing a "Install Youtube Music..." entry

This option does not appear on non-Youtube Music pages, or in an incognito session.

Youtube homepage with Google Chrome's menu, showing there's no such "Install Youtube Music" or similar entry available

Playing the same music video in Youtube Music on Google Chrome's incognito mode, the browser doesn't show the menu entry

The entry isn’t available in Firefox, either:

Playing the same music video in Youtube Music on Mozilla Firefox, the browser doesn't show any menu entry regarding an app installation

Does the website declare the availability of that menu entry somehow? Can my own website add any such entry to Google Chrome’s menu? Are there any other such entries that can be shown in Google Chrome?

The screenshots are all on macOS, but this entry shows up in Google Chrome for Windows, too (haven’t tried incognito or other browsers in Windows).

Filter behavior with new entries

The filter rules should definitely be applied, otherwise look at the data will give the impression that the filter does not work correctly.

However, you are right to be cautious as immediately hiding the record might make the user think that it hasn’t added correctly and they might try to do it again and add a duplicate.

I would suggest that you handle this by making it clear that the new record has been added by showing the user a confirmation message.

Also, I would suggest that your application logic checks if the new record is hidden by the filter or not. If it is hidden by the filter, then your confirmation message should also recommend that the user adjusts their filter settings in order to see the new record.


Confirmation Message Design

I can’t really advise on how to design this confirmation message without seeing your application layout, however this could simply be a block of text that appears below the table (near where the user enters the data).

For example, the confirmation message could say (depending on filter) settings:

Message to display when a new record is included in filtered results:

A new contact record has been added for Helen.

Message to display when a new record is not include in filtered results:

A new contact record has been added for Helen. You will need to adjust your filter settings to include this new record in the results.


Summary

Ensure the filter settings are applied correctly, but inform the user that the new record has been added and they may need to adjust their filter settings before they can see it.

How to find the size of gaps between entries in an array so that the first and last element of the array is filled and the gaps are all of equal size?

I have an array a of n entries. I need to place a token on the first and last position of that array, so a(0) = 1 and a(n-1) = 1.

I now want to place additional tokens into that array with a distance inbetween each index i where a(i) = 1 that is greater than 2 (so placing a token on every index is invalid as well as alternating using and not using an entry is invalid). Phrazed differently: I want that sum(a) < n/2 . The gap inbetween each token should be the same, so say with an array of size 16,

a(0) = 1, a(3) = 1, a(6) = 1, a(9) = 1, a(12) = 1, a(15) = 1

would be a solution with a gap size of 2 (distance of 3).

How do I find all gap sizes that are possible to fill said array with the given constraints?

Imagine a street inbetween two crossroads where a lamppost should be placed on each crossroad and then additional lampposts should be placed equidistant to each other and for some reason only natural number distances are allowed.

(The actual problem I want to solve is where to place Sea Lanterns in my Minecraft Project so do not disregard this problem as an assignment question I want a solution for.)

google cloud platform – how to filter log entries by timestamp in gcloud logging command line

Any one knows how to filter log entries by timestamp in gcloud logging command line? From google cloud site – https://cloud.google.com/logging/docs/reference/tools/gcloud-logging, I learned to read logs by command

gcloud logging read “resource.type=gce_instance AND logName=projects/[PROJECT_ID]/logs/syslog AND textPayload:SyncAddress” –limit 10 –format json

I want to know how to filter by timestamp. I need to read logs in a particular period.

thanks

powershell – How to remove duplicate entries in CSV

The code is running properly. But this is creating the multiple duplicate entries in CSV file and Parent properties i am not getting the values.

$List = $web.Lists
$ctx.Load($List)
#$ctx.Load($List.ContentTypes)
$ctx.ExecuteQuery()
$ResultCollection = @()
foreach($CT in $List)
  {
        
 
        $ctx.Load($CT.ContentTypes)
        $ctx.ExecuteQuery()
        
        
        foreach($cc in $CT.ContentTypes)
        {
        #Write-Host $cc.Name
        #Write-Host $cc.DocumentTemplate
       # Write-Host $cc.DocumentTemplateUrl
       # Write-Host $cc.Description 
        #Write-Host $cc.Group  
       # Write-Host $cc.Id
        #Write-Host $cc.Parent
        

$Result = New-Object PSObject


                        $Result | Add-Member -type NoteProperty -name "SourceURL" -value $Url
                        $Result | Add-Member -type NoteProperty -name "WebURL" -value $Subweb.Url
                        $Result | Add-Member -type NoteProperty -name "ContentTypeName" -value $cc.Name
                        $Result | Add-Member -type NoteProperty -name "CTDocumentTemplate" -value $cc.DocumentTemplate
                        $Result | Add-Member -type NoteProperty -name "CTDocumentTemplateUrl" -value $cc.DocumentTemplateUrl
                        $Result | Add-Member -type NoteProperty -name "CTGroup" -value $cc.Group 
                        $Result | Add-Member -type NoteProperty -name "CTDescription" -value $cc.Description
                        $Result | Add-Member -type NoteProperty -name "ContentTypeID" -value $cc.Id
                        $Result | Add-Member -type NoteProperty -name "CTParentType" -value $cc.Parent
                        
                        $ResultCollection+=$Result;
  
     }
     #$FileName = $SiteCollectionName + "_DocuTemplateInfo"
     $ResultCollection | Export-Csv -path "C:UserDataz00476kpDocumentsExportItemsCTTemplateInfo_Modified.csv" -Append -Encoding UTF8  -notypeinformation
                     
        
        
     }Write-Host "CSV Exported"

python – Rewriting code so functions don’t require super long entries

I have 2 scripts, one is a tkinter GUI script where the user gives specific inputs, the 2nd script takes those inputs, does some modification, and then sends it back to the GUI script to be written/results printed. However, in dealing with multiple user inputs, the entries for the functions started getting longer and longer, and uglier. As you’ll see in the GUI script, when I use the function I imported, it has 7 entries which make it quite long. Is there a better way to call user inputs from one script to another?

#GUI Script (NOTE: I'm not posting all the global and input functions, since they are basically the same thing. Don't want to be reptitious)
#basic tkinter setup root=tk.Tk() with the loop and everything setup

#globals where filenames and directories to files are saved, to be called on in the functions
sparta_file=()
sparta_directory=()
seq_file=()
seq_directory=()
#browse options to choose files
def input_file():
    fullpath = filedialog.askopenfilename(parent=root, title='Choose a file')
    global sparta_directory
    global sparta_file
    sparta_directory=os.path.dirname(fullpath)
    sparta_file= os.path.basename(fullpath)
    label2=Label(root,text=fullpath).grid(row=0,column=1)

def input_seq():
    fullpath = filedialog.askopenfilename(parent=root, title='Choose a file')
    global seq_file
    global seq_directory
    seq_directory=os.path.dirname(fullpath)
    seq_file= os.path.basename(fullpath)
    label3=Label(root,text=fullpath).grid(row=1,column=1)
#All the user inputs are designed more or less the same, user browses, clicks on file, and files directory and filename are saved as globals. 

#function that will be run to use user inputs, modify them, and then write modifications
def sparta_gen_only():
        from sparta_file_formatter import check_sparta_file_boundaries
        os.chdir(save_directory)
        with open(save_file_sparta,'w') as file:
            for stuff_to_write in check_sparta_file_boundaries(seq_file,seq_directory,mutation_list1,mutation_list2,sparta_file,sparta_directory,seq_start):
                file.write(stuff_to_write+'n')

So right off the bat, you can see the exact issue I’m having (check_sparta_file boundaries has a lot of inputs).

#2nd sparta_file_formatter
import re
import os



def create_seq_list(seq_file,seq_directory,seq_start):
    os.chdir(seq_directory)
    amino_acid_count=(0+seq_start)-1
    sequence_list=()
    with open(seq_file) as sequence_file:
        for amino_acid in sequence_file:
            stripped_amino_acid=amino_acid.strip().upper()
            for word in stripped_amino_acid:
                amino_acid_count+=1
                sequence_list.append(str(amino_acid_count)+word)
    return sequence_list

def format_sparta(sparta_file,sparta_directory):
    os.chdir(sparta_directory)
    sparta_file_list1=()
    proline_counter=0
    with open(sparta_file) as sparta_predictions:
        for line in sparta_predictions:
            modifier=line.strip().upper()
            if re.findall('^d+',modifier):
                A=modifier.split()
                del A(5:8)
                del A(3)
                A(0:3)=("".join(A(0:3)))
                joined=" ".join(A)
                proline_searcher=re.search('BP',joined)
                if proline_searcher != None:
                    proline_counter+=1
                    if proline_counter<2:
                        proline_count=re.search('^d+',joined)
                        sparta_file_list1.append(f'{proline_count.group(0)}PN'+' 1000'+' 1000')
                    else:
                        if proline_count == 4:
                            proline_count=re.search('^d+',joined)
                            sparta_file_list1.append(f'{proline_count.group(0)}PHN'+' 1000'+' 1000')
                            proline_counter=0
                sparta_file_list1.append(joined)
    return sparta_file_list1

#Each function the entries get longer and longer as they start using the outputs of the previous functions
def add_mutation(mutation_list1,mutation_list2,sparta_file,sparta_directory):
    sparta_file_list2=()
    if mutation_list1==() or mutation_list2==():
        for amino_acids in format_sparta(sparta_file,sparta_directory):
            sparta_file_list2.append(amino_acids)
    else:
        for mutations,mutations2 in zip(mutation_list1,mutation_list2):
            for amino_acids in format_sparta(sparta_file,sparta_directory):
                if re.findall(mutations,amino_acids):
                    splitting=amino_acids.split()
                    mutation=re.sub(mutations,mutations2,splitting(0))
                    mutation_value=re.sub('d+.d+',' 1000',splitting(1))
                    mutation_value2=re.sub('d+.d+',' 1000',splitting(2))
                    mutation_replacement=mutation+mutation_value+mutation_value2
                    sparta_file_list2.append(mutation_replacement)
                else:
                    sparta_file_list2.append(amino_acids)
    return sparta_file_list2

def filter_sparta_using_seq(seq_file,seq_directory,mutation_list1,mutation_list2,sparta_file,sparta_directory,seq_start):
    sparta_file_list3=()
    sparta_comparison=create_seq_list(seq_file,seq_directory,seq_start)
    for aa in add_mutation(mutation_list1,mutation_list2,sparta_file,sparta_directory):
        modifiers=aa.strip()
        splitter=modifiers.split()
        searcher=re.search('^d+(A-Z)',splitter(0))
        compiler=re.compile(searcher.group(0))
        sparta_sequence_comparison=list(filter(compiler.match,sparta_comparison))
        if sparta_sequence_comparison != ():
            sparta_file_list3.append(aa)

    return sparta_file_list3


def check_sparta_file_boundaries(seq_file,seq_directory,mutation_list1,mutation_list2,sparta_file,sparta_directory,seq_start):
    temp_list=()
    temp_counter=0
    sparta_filtered_list=filter_sparta_using_seq(seq_file,seq_directory,mutation_list1,mutation_list2,sparta_file,sparta_directory,seq_start)
    for checker in sparta_filtered_list:
        temp_modifier=checker.strip()
        temp_split=temp_modifier.split()
        temp_finder=re.search('^d+',temp_split(0))
        temp_list.append(temp_finder.group(0))
        temp_counter+=1
        if temp_counter==5:
            if int(temp_finder.group(0))==int(temp_list(0)):
                break
            else:
                del sparta_filtered_list(0:4)
                break
    if len(sparta_filtered_list)%6 != 0:
        del sparta_filtered_list(-5:-1)

    return sparta_filtered_list

Edit:

In terms of exactly what sparta is and what my code is doing. I won’t go into too much detail regarding sparta, outside of it is a text file with information we want. This is the format:

REMARK SPARTA+ Protein Chemical Shift Prediction Table
REMARK  All chemical shifts are reported in ppm:
....

   3    Y   HA     0.000     4.561     4.550     0.018     0.000     0.201
   3    Y    C     0.000   175.913   175.900     0.021     0.000     1.272
   3    Y   CA     0.000    58.110    58.100     0.017     0.000     1.940
   3    Y   CB     0.000    38.467    38.460     0.011     0.000     1.050
   4    Q    N     3.399   123.306   119.800     0.179     0.000     2.598
...

We only care about the lines with the numbers, so I use a regex search to only extract that. Now the info I want is the first 3 columns, with the 4 column. I want each data formatted 3YHA 4.561 (2nd function). Now every number should have 6 values associated with it, those that are P, will only have 4, so I add 2 extra values (you may note in the above, the format is HA,C,CA,CB,etc. So I add the values so the format of P is N,HA,C,CA,CB.

Sometimes the user will wish to change a specific letter (mutation). So they indicate which letter, the number, and what to change it to (3rd loop).

Finally, these files can sometimes have extra info we don’t care about. The user specifies the range of info they want by using a seq file (1st and 4rd loop).

As stated, every letter should have 6 values. However, the first letter will always have 4. The last letter will also only have 5. So these need to be removed (loop 5).

Here is some sample input files as examples:

seq_number=1
#seq.txt
MSYQVLARKW
#sparta_pred.tab
   3    Y   HA     0.000     4.561     4.550     0.018     0.000     0.201
   3    Y    C     0.000   175.913   175.900     0.021     0.000     1.272
   3    Y   CA     0.000    58.110    58.100     0.017     0.000     1.940
   3    Y   CB     0.000    38.467    38.460     0.011     0.000     1.050
   4    Q    N     3.399   123.306   119.800     0.179     0.000     2.598
   4    Q   HA     0.146     4.510     4.340     0.039     0.000     0.237
   4    Q    C    -2.091   173.967   176.000     0.097     0.000     0.914
   4    Q   CA    -0.234    55.623    55.803     0.092     0.000     1.065
   4    Q   CB     3.207    32.000    28.738     0.092     0.000     1.586
   4    Q   HN     0.131     8.504     8.270     0.173     0.000     0.484
   5    V    N     0.131   120.091   119.914     0.078     0.000     2.398
   5    V   HA     0.407     4.575     4.120     0.080     0.000     0.286
   5    V    C     0.162   176.322   176.094     0.109     0.000     1.026
   5    V   CA    -1.507    60.840    62.300     0.078     0.000     0.868
   5    V   CB     0.770    32.625    31.823     0.052     0.000     0.982
   5    V   HN     0.418     8.642     8.190     0.057     0.000     0.443
   6    L    N     7.083   128.385   121.223     0.130     0.000     2.123
   6    L   HA    -0.504     4.085     4.340     0.415     0.000     0.217
   6    L    C     1.827   178.814   176.870     0.195     0.000     1.081
   6    L   CA     3.308    58.271    54.840     0.205     0.000     0.772
   6    L   CB    -1.005    41.051    42.059    -0.005     0.000     0.890
   6    L   HN     0.241     8.694     8.230     0.097    -0.164     0.437
   7    A    N    -4.063   118.812   122.820     0.092     0.000     2.131
   7    A   HA    -0.337     4.023     4.320     0.067     0.000     0.220
   7    A    C     0.433   178.071   177.584     0.090     0.000     1.158
   7    A   CA     2.471    54.552    52.037     0.073     0.000     0.665
   7    A   CB    -0.332    18.690    19.000     0.036     0.000     0.795
   7    A   HN    -0.517     7.889     8.150     0.063    -0.219     0.460
   8    R    N    -4.310   116.247   120.500     0.096     0.000     2.191
   8    R   HA    -0.056     4.313     4.340     0.048     0.000     0.196
   8    R    C     2.152   178.488   176.300     0.060     0.000     0.991
   8    R   CA     1.349    57.485    56.100     0.060     0.000     1.075
   8    R   CB     0.834    31.147    30.300     0.023     0.000     1.040
   8    R   HN     0.244     8.408     8.270     0.109     0.172     0.526
   9    K    N     0.144   120.608   120.400     0.108     0.000     2.283
   9    K   HA    -0.130     4.148     4.320    -0.069     0.000     0.202
   9    K    C     0.691   177.214   176.600    -0.129     0.000     1.048
   9    K   CA     2.415    58.707    56.287     0.008     0.000     0.948
   9    K   CB    -0.114    32.430    32.500     0.074     0.000     0.742
   9    K   HN    -0.617     7.728     8.250     0.159     0.000     0.458
  10    W    N    -4.007   117.283   121.300    -0.016     0.000     2.846
  10    W   HA     0.195     4.850     4.660    -0.009     0.000     0.391
  10    W    C    -1.455   175.056   176.519    -0.013     0.000     1.011
  10    W   CA    -1.148    56.191    57.345    -0.011     0.000     1.832
  10    W   CB     0.166    29.622    29.460    -0.007     0.000     1.151
  10    W   HN    -0.634     7.728     8.180     0.377     0.045     0.582
  11    R    N     1.894   122.475   120.500     0.134     0.000     2.483
  11    R   HA    -0.096     4.293     4.340     0.083     0.000     0.329
  11    R    C    -1.368   174.959   176.300     0.045     0.000     0.961
  11    R   CA    -0.713    55.431    56.100     0.073     0.000     1.041
  11    R   CB     0.187    30.506    30.300     0.033     0.000     0.930
  11    R   HN    -0.880     7.272     8.270     0.107     0.182     0.413
  12    P   HA    -0.173     4.278     4.420     0.051     0.000     0.257
  12    P    C    -1.027   176.281   177.300     0.014     0.000     1.162
  12    P   CA     0.741    63.865    63.100     0.040     0.000     0.762
  12    P   CB     0.046    31.768    31.700     0.036     0.000     0.753
  13    Q    N     1.152   120.951   119.800    -0.001     0.000     2.396
  13    Q   HA     0.193     4.514     4.340    -0.032     0.000     0.220
  13    Q    C     0.275   176.261   176.000    -0.024     0.000     0.900
  13    Q   CA     0.394    56.181    55.803    -0.027     0.000     0.925
  13    Q   CB     2.516    31.223    28.738    -0.051     0.000     1.065
  13    Q   HN     0.012     8.472     8.270     0.002    -0.188     0.535