java – List of the last 3 elements (or all if less than 3) in a list of tables

Write a code to return the last 3 elements of a list, if the list contains 3 or more elements, otherwise return all the elements of the list.

But the code seems really bad.
What is the best way to write the same code?

   public void test_arrayListItems() {
        ArrayList arrayList = new ArrayList<>();
        arrayList.add("item1");
        arrayList.add("item2");
        arrayList.add("item3");
        arrayList.add("item4");
        arrayList.add("item5");
        arrayList.add("item6");
        arrayList.add("item7");
        arrayList.add("item8");

        String items = "";
        int j = 0;
        int k = 0;

        if (arrayList.size() <= 2) {
            j = arrayList.size() - 1;
        } else if (arrayList.size() > 2) {
            j = arrayList.size() - 1;
            k = arrayList.size() - 3;
        }
        for (int i = k; i <= j; i++) {
            items = items + "- " + arrayList.get(i) + " ";
        }
        logger.info(items);
    }

Thank you

java – How to access an activity and modify its content by clicking on an element of the list?

I've created an activity with a list, and set its onItemClickListener to open another activity and pass it the item's position.
In this other activity, they have a text view whose content changes depending on the position of the element.
However, I can not retrieve the position of the article! See my desperate attempts:
// Get the position, but get fixed the second entry
int position = getIntent (). getIntExtra ("position", 0);
// Get a table, but when iterates, the application closes
int () position = getIntent (). getExtras ();
// In all the documents I've seen recommend this method, but it does not work on my idea
int position = getIntent (). getExtra ("position");
I hope someone can help me out.

USA – Why has Myanmar been removed from the list of countries of the international driving license issued by the AAA between 2016 and 2019?

Why has Myanmar been removed from the list of countries of the International Driving Permit issued by the American Automobile Association (AAA)?

Myanmar was in the international driving licenses issued in 2016, but not with the international driving licenses currently issued (2019-10-14).

Here is the list of countries in international driving licenses currently issued (2019-10-14):

enter the description of the image here

Here is the list of countries in international driving licenses issued in 2016: Myanmar is present in the list.

enter the description of the image here

The International AAA Online Driving Permit application form still mentions Myanmar: https://web.archive.org/web/20191015015350/https://www.aaa.com/vacation/application2a. pdf

Shared list of SharePoint team pages

The short answer is that it is not possible. If you have a list in site A and site B users need to access the list in site A, create a link on site B that points to the site list A, and grant permissions to site users B on the site A list. Your users change sites but do not really notice it. You can also use workflows to keep the two lists "synchronized", but that would certainly be more complex.

pagination – Best options for finding a dynamic update list

We have a list of very dynamic elements. New items are frequently added to the list (maybe one every few seconds).

Articles can also be rearranged (say that they have been sorted by "last updated" and that any of them is updated by the system).

Our problem comes with pagination of this list. If the user sorts it by "last" and that it examines the 20 most wanted items, for example, for 20 seconds, then scrolls down the screen – 5 to 10 items have may have been created.

If we naively query the database to get the items "20-40" (the next "page", although it actually acts as a scroll), we will get items in double.

We put a lot of effort into our back end to be able to query our list from a specific date – we send a message "Get me items 20-40 FROM THIS TIME" to the back end.

However, it's a pretty difficult requirement for the database schema and back-end, we can not support some things we want because we have to try to keep duplicate records for this " historical".

Are there generally accepted strategies for dealing with this kind of situation?

Extract the first component from the values ​​in the list

If I use FactorInteger, for example.

FactorInteger[255]

the result is a list like

{{3, 1}, {5, 1}, {17, 1}}

How to extract values ​​3, 5 and 17 and assign them to a list variable for later use? TIA.

plot – How to get a thick, black outline line in a 2D list outline?

I just want my contour curves to be thick and black at the same time.

I have tried

ContourStyle -> [Black, Thick]

and

BaseStyle -> Thick, ContourStyle -> Thick

and many other ways.

However, they all give me thick and gray curves.

Like that

enter the description of the image here

How can I make contour curves as black as frame lines?

Can any one please list the IP addresses to get UTXO for testnet bitcoin addresses that are reliable?

Need UTXO for tx.addInput () from the transactionBuilder library

"Bigint" binary list of bytes in addition to the two's complement in Python

I am playing with the idea of ​​writing a "bigint" library in 6502
assembler capable of handling integers of variable length up to 255 bytes
long. To help me understand the problems of representation that I have come to
with a function in Python that takes a decimal integer and deposits
in memory (emulated) as its binary representation: as a length
byte followed bytes of value from least to most
important. (The 6502 is a little bitten.)

As a background, the M or Machine object here is the emulated processor
and RAM, with RAM as an array of unsigned integers 0-255. he
offers a deposit(addr, list) method to put values ​​in memory,
byte(addr) enter a single byte, and bytes(addr, len) at
recover multiple bytes. (It's actually an envelope around a
py65.devices.mpu6502 from py65; all the code is in my 8bitdev
repo if you are curious.)

from    testmc.m6502 import  Machine, Registers as R, Instructions as I
import  pytest

@pytest.fixture
def M():
    M = Machine()
    M.load('.build/obj/objects')
    return M

def depint(M, addr, value):
    ''' Deposit a bigint in locations starting at `addr`.
        `addr` contains the length of the following bytes,
        which hold the value from LSB to MSB.
    '''

    next = addr + 1             # Skip length byte; filled in at end

    if value >= 0:              # Positive number; fill byte by byte
        while next == addr+1 or value > 0:
            value, byte = divmod(value, 0x100)
            M.deposit(next, (byte))
            next += 1
        if byte >= 0x80:        # MSbit = 1; sign in additional byte
            M.deposit(next, (0x00))
            next += 1

    else:                       # Negative: fill with two's complement values
        value = abs(value+1)    # two's complement = -(n+1)
        while next == addr+1 or value > 0:
            value, byte = divmod(value, 0x100)
            byte = 0xFF - byte  # two's complement
            M.deposit(next, (byte))
            next += 1
        if byte < 0x80:         # MSbit = 0; sign in additional byte
            M.deposit(next, (0xFF))
            next += 1

    #   Store the length
    M.deposit(addr, (next - (addr + 1)))

@pytest.mark.parametrize('value, bytes', (
    (0,             (0x00)),
    (1,             (0x01)),
    (127,           (0x7F)),
    (128,           (0x80, 0x00)),
    (255,           (0xFF, 0x00)),
    (256,           (0x00, 0x01)),
    (0x40123456,    (0x56, 0x34, 0x12, 0x40)),
    (0xC0123456,    (0x56, 0x34, 0x12, 0xC0, 0x00)),
    (-1,            (0xFF)),
    (-128,          (0x80)),
    (-129,          (0x7F, 0xFF)),
    (-255,          (0x01, 0xFF)),
    (-256,          (0x00, 0xFF)),
    (-257,          (0xFF, 0xFE)),
    (0-0x40123456,  (0xFF-0x56+1, 0xFF-0x34, 0xFF-0x12, 0xFF-0x40)),
    (0-0xC0123456,  (0xFF-0x56+1, 0xFF-0x34, 0xFF-0x12, 0xFF-0xC0, 0xFF)),
    ))
def test_depint(M, value, bytes):
    print('DEPOSIT', value, 'expecting', bytes)
    addr = 30000                    # arbitrary location for deposit
    size = len(bytes) + 2           # length byte + value + guard byte
    M.deposit(addr, (222) * size)   # 222 ensures any 0s really were written
    depint(M, addr, value)
    bvalue = M.bytes(addr+1, len(bytes))
    assert (len(bytes),   bytes,  222) 
        == (M.byte(addr), bvalue, M.byte(addr+size-1))

    #   Test against Python's conversion
    assert list(value.to_bytes(len(bytes), 'little', signed=True)) 
        == bvalue

Things you might consider when reviewing:

  • Is this really correct? Do the tests provide sufficient coverage?
    (FWIW, in this particular implementation, I do not feel the need to
    test the overflow because all the input values ​​would be entirely under my
    control.)
  • Is there a clearer way to describe the tests?
  • the next == addr+1 state in the while the curls it's a little
    embarrassing; Is there a better way to handle this? The obvious thing
    would be to use a do loop (the first time I remember wanting a
    in one long time), but Python does not have them.
  • Maybe it would make more sense to just use Python
    to_bytes() manage the conversion. But it would take a good way
    manage the length.
  • Regarding how useful this is, I figured I'll probably
    want a reading routine (in 6502 assembler) to do the same thing in ASCII
    decimal → bigint conversion, which would mean that I could just do a unit test
    using Python to_bytes() and use this routine in unit tests
    to add, multiply, etc. routines. The only problem could be that
    could be much slower in 6502 emulation than using the native Python
    library would be.

sharepoint online – HillbillyCascade Index as a list of modern style?

I have a HibillyCascade Index functions in standard list forms that allow users to search for values ​​on an entry (HTML selection) to search for values ​​on a selected filtered value on a previous entry.

That's what I read, that's what it's called HillbillyCascade Index.

My problem is that I can not add or link this code to a modern SharePoint experience. I've read that it's not implemented in the modern list.

Is it possible to implement this in a list of modern experiments? (like the JSON formatting column, etc.)

I can only work in client mode.