awk print question

Can you please explain what this code does? I know 'awk NR==2{print $4} means the 2nd line 4th field of the ${x}_${y}.dat file.

T= 'awk 'NR==2 {print $4*100}'  ${x}_${y}.dat'

java – Recursively traversing a tree to print values within a range

I have the following question:

Given a Binary Search Tree and two numbers – a & b, return all the nodes in the tree that lie in the range (a .. b). Your method should return an ArrayList with the data of the qualifying nodes inserted in ascending order.

This is the provided solution code, with my comments expressing my “theory” on why the recursion is written that way:

public  ArrayList<Integer> rangeList = new ArrayList<Integer>();

public void printRange(TreeNode root, int a, int b) {
    if(root == null){return ;}

    //check if there's something lower that needs to be added first
    //go down root.left
    if( >= a){
        printRange(root.left, a, b);

    //if within the range, add it to result list 
    if( >= a && <= b){

    if( <= b){
        printRange(root.right, a, b);

I cannot figure out third portion of the code. Why do we traverse the right subtree if <= b?

It seems to me it is unnecessary to do so because we already know <= b.

Anything > b would be ineligible to be put into our answer array. Yet we traverse down the right subtree.

Can anyone clarify?


here is an example test case and solution:

     2   8  
       5  10                  

Range (2,8) ==> (2, 4, 5, 8)

Range includes 2 & 8

Start Making Money with Print on Demand Stores




Link image:

python – Usar la función print() dentro de un bucle For

tengo una función para eliminar una línea especifica de un archivo .txt en Python3.8 . El problema me surge al querer imprimir un mensaje por pantalla dependiendo de si la acción que se realiza es una u otra, entiendo que en un bucle FOR el comando print() se ejecutara tantas veces como iteraciones tenga la acción. Mi pregunta es: hay alguna manera para que el mensaje solo se muestre 1 vez al realizar la acción?


def elimina_telefono(self, fichero, persona):
    self.fichero = 'agenda.txt'
    with open(fichero, 'r+') as archivo:
        nuevo_archivo = archivo.readlines()
        for line in nuevo_archivo:
            if persona not in line.split('n'):
            if persona in line.split('n'):
                print('Contacto Borrado')
            elif persona not in line.split('n'):
                print('Contacto no Encontrado')


Contacto Borrado # el ‘nombre’ estaba en la línea

Contacto no encontrado # el ‘nombre’ no esta en la línea

Contacto no encontrado # “
Contacto no encontrado # “

how to install drivers or software for startek fm 220 u finger print scanner in ubuntu 20.04.2?

if there is a ppa or something, please let me know.

Do I need to install wine and then install the windows drivers?

darkness – Which paper has to be used to print a photo, which is low contrast and mostly grey?

Generally glossy papers will have a deeper black point than matte. The exact ideal depends on the type of printer. If using photographic prints, then it depends on the characteristics of the photo paper itself. If using inkjet based (either die or preferably pigment) then the ink system is also going to matter a lot for having not only deep blacks, but fine detail.

That said, your image honestly does not appear all that difficult to print for a good printer. I don’t know much about whitewall, but I could personally print this without issue on my Pixma Pro-1. The image doesn’t even have any deep blacks, so paper type probably doesn’t matter in this case, just the level of detail in the color that can be produced by the ink system or photographic pigments.

I might actually try it on a matte or luster paper more to go with the feel of the image, which I don’t think would look right with glossy due to the highlights from light falling on it. You want something subdued and probably with a nice texture. The traditional problem with matte paper is that you lose deep blacks, but you don’t need them here, so it actually makes it easier.

Can I print the Print Date or Save Date in Google Documents?

Yes, it is possible. However, it is not something that is really possible utilizing the existing API. Really the lack of fields and the associated capabilities like in Word is a major disability for document automation.

Something like this will insert a footer on document open and reopen, but it is ultimately not a good solution.

function onOpen() {
    var time = new Date();
    time = Utilities.formatDate(time, "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'");
    var doc = DocumentApp.getActiveDocument();
    var s;

    if (!doc.getFooter()) {
        var footer = doc.addFooter();
        var footerText = footer.appendParagrap(time);
    } else {
        var footer = doc.getFooter();
        var footerElements = footer.getNumChildren();
        var para = footer.getParagraphs();
        s = para(footerElements-1).getText();
        var footerText = footer.replaceText(s , time);

EDIT: How to add the script.

This code as I have presented above really should be in its own function called from the OnOpen() function rather than in there wholesale, but all good for example purposes.

If you go the Tools menu of an open document then down to Script Manager, when it loads check that it is currently empty, if has a records there, you are on your own for placement of the code.

Close the script manager, back to the Tools Menu and select Script Editor. Now if you had nothing in your script manager, select all the code and delete it. You can then paste in the code provided above and then save it.

Close the document and re-open and you should find there is now a Time Date in the footer. It should update on every open of the document, nothing fancy but will get you going.

Now for those of you who have code already associated with your document. Adding the code above minus the first and last lines into the onOpen() function will also work, but it may not due to code already present conflicting.

Hope this gets you going.

How do I print a specific number of A based on a value from a cell in Google Sheets

There’s a cell that would contain the number of times a letter would be printed in a cell.


cell a1 = 3. b1 should look as “A A A”

my rough script is:

for(var arow=0; arow<4; arow++) {
  var numberofo = actsheet.getRange(arow+1,1).getValue();
     for(i=0; i<=numberofo;i++) {
         var test = actsheet.getRange(i+1,2).setValue("o");

Sorry the code looks rough. Haven’t coded for the last 7 years.

plugin development – Print Current User Display Name

I am trying to print the current user display name with the following. Any help how to make it work?

function filter_product_pwb_brand($value, $post_id, $form_data){
//$value is the post field value to return, by default it is empty. If you are filtering a taxonomy you can return either slug/id/array. in case of ids make sure to cast them integers.(see for more information.)
//$post_id is the ID of the post to which the form values are being mapped to
// $form_data is the submitted form data as an array of field-name=>value pairs
return $value;

resolution – Would a professional restorer be able to do a better job restoring a print if he were to scan the print at 2400 ppi vs 1200 ppi?

According to one answer on this question at Genealogy and Family History, a restorer of prints will often ask a customer to scan a print for restoration at the customer’s scanner’s highest resolution, usually 1200 ppi or 2400 ppi.

However, my scanner has a maximum optical resolution of 1200 ppi.

The question I have is, if I came upon a print showing signs of age/damage, is it even worth it to invest in a scanner that scan at a higher resolution than my current scanner, so that I could scan at 2400 ppi?

Would a professional restorer be able to produce a better print had I decided to scan the old/damaged print at 2400 ppi vs 1200 ppi? My inclination is to say yes, but I realize that there are diminishing returns when scanning at higher resolutions, after a certain point.

I’m mainly talking about analog family photographs and portraits, rather than scanning 8mm film/slides, which would require specialized scanners.