Resolution sometimes changes when I switch my monitor back on

I am using Kubuntu 18.04. GPU is a Radeon RX 580. I am using the amdgpu driver. OpenGL renderer string is:

Radeon RX 580 Series (POLARIS10, DRM 3.23.0, 4.15.0-47-generic, LLVM 7.0.0) 

So, since this is the amdgpu driver, Mesa3D and KMS are in use.

I have a 4K monitor connected to the RX 580’s DisplayPort.

Sometimes, when I started Kubuntu the display off, and later turn it back on, the image isn’t the usual 3840×2160 pixels. Instead, sometimes it is 1920×1200, or 640×480 (and shrunken in the vertical direction). In the latter case, I have to turn the monitor off and on again until the resolution is 1920×1200. Then I can go to the display settings and set it back to 3840×2160.

This is very annoying, and I found no indication of any problems anywhere. Does anybody have any idea what is going on?

Magento 2 – Order Item changes

I want to inform customers with email all details of their orders and i want to be able to show difference. For example:

Those items shipped: ... Those items canceled: ... Those items ... 

credit memo, hold, invoice, ship, reorder, create returns... There so many situations. What should be the best way to achieve this?

Still I tried to use events for invoices (sales_order_invoice_save_aftersales_order_invoice_register):

public function execute(\Magento\Framework\Event\Observer $  observer) {     $  order = $  observer->getEvent()->getOrder();     $  stateProcessing = $  order::STATE_PROCESSING;      $  collection = $  order->getItemsCollection();     foreach ($  collection as $  item) {         $  this->logger->info('item = '.$  item->getName());         $  this->logger->info('   qty_invoiced = '.$  item->getData('qty_invoiced'));         $  this->logger->info('   qty_invoicedorig = '.$  item->getOrigData('qty_invoiced'));     }      return $  this; } 

But quantities are same, couldn’t get the difference.

Writing classes to withstand future business logic changes

I have a processor class AbstractProcessor and multiple concrete classes of the same which gets called in order of the business logic.

public Abstract class AbstractProcessor {    public void doProcess(){} } 

The logic in my concrete classes keeps on changing depending on the business requirement. This leads to change in the corresponding test classes and seems to be a tightly coupled approach. Is there a better way to design such classes.

How to implement an active Man-In-The-Middle attack that changes the request URL address

For training purposes, I need some pointers on the tools and tips to implement an active Man-In-The-Middle attack.

The attack scenario that I want to do is a toy example (which has countermeasures by server authentication) is the following:

1) The user request

2) The MITM changes the user request to

3) The user sees in his agent (e.g., browser)

I looked in the web. There is ARPP spoofing, which seems will allow me to sniff on users requests but no manipulate.

What is the easiest way to manipulate the user’s requested address through a MITM attacker who does not have access to the user’s device, but only the communication channel?

As I said, this question is for learning. It is also worth nothing that this is detectable by modern client agents or browsers, and I do not intend to implement it in any ways other than lab learning environment.

Clearing multiple-selection list box choices when another field changes

I have two fields on a form. Category and Sub Category. Category is a drop-down list box and Sub Category is a multiple-selection list box that is filtered by the Category drop-down.

Everything is working (mostly). The problem I’m having is that if I make a Category selection then make a couple of Sub Category choices and then change my mind to a different Category, the previous Sub Category selections are still shown in the list by their lookup IDs.

It’s easier to show than explain. enter image description here

I was thinking I could somehow put a rule on the Category field so that it resets or clears the Sub Category field whenever the Category field is changed. I know I can set a field’s value but I can’t figure out how to clear the Sub Category multiple-selection choices. Thank you for your help!

Designing a WPF / MVVM architecture where view behavior changes in different states

As part of my bachelors thesis, I’m trying to develop something akin to a painting program. That means, I have a toolset, be it selection, drawing, highlighting, etc.

I’ll have a canvas that displays my current model, based on a set of rectangles/spheres/polygons I have already drawn and created.

Some tools require the view to react differently based on the tools. Rough Examples:

I have a “New Line” tool. The view now displays points you can connect from when you hover over them.

I have a “Selection” tool. When I hover over an element, it’s entire color changes.

I have a “New Element” tool. When I move my mouse, a shadow of the element follows my cursor until I press the left mouse buttons.

Now, here’s where I’m a little stuck:

All these tools require wildly different behaviour from the view, and not only that, it also requires the view to be dynamic based on calculated properties. I got a few ideas how I could architect my system, but I would rather get nudged into a direction before I do a huge mistake. Here’s my questions and thoughts :

Q: First of all, where would I even put that interactive code? I can’t do it in XML, since it requires calculation, but putting it in the ViewModel is also not correct since the ViewModel is not supposed to know about the View. Thus, do I put it in the Code of the View itself? That also seems kinda strange to me.

Now to my architectural ideas:

Idea 1: I could do a new View + Viewmodel for each tool. When A new tool is selected, the view and viewmodel are simply exchanged in a frame, and all the behaviour is encapsulated inside the new view + ViewModel. However, that seems like it not only tightly couples each View and ViewModel together, it also feels like a lot of boilerplate code.

Idea 2: Each Tool itself has “Command” class based on a ICommand interface that requires a reference to the view as well as every possible option of User Interaction. Then the ViewModel delegates the UserInput onto the current Command, which can then manipulate the given ViewInstance to display things it wants. This however feels very inflexible, as if I’m just delegating the problem from Idea 1 somewhere else, and incapable of future growth. Whenever I want to add a new way for a user to interact, I’d have to go and adjust the interface, and perhaps all underlying commands if I didn’t provide a default implementation.

None of these really satisfy me, and I’m feeling like I’m missing a crucial step for this part of the architecture. I’d gladly appreciate any pointer. Thank you for your time and reading!

Add another cell A2 to the email Template. What code changes required?

function getRowsData(sheet, range, columnHeadersRowIndex) {

columnHeadersRowIndex = columnHeadersRowIndex || range.getRowIndex() – 1; var numColumns = range.getEndColumn() – range.getColumn() + 1; var headersRange = sheet.getRange(columnHeadersRowIndex, range.getColumn(), 1, numColumns); var headers = headersRange.getValues()[0]; return getObjects(range.getValues(), normalizeHeaders(headers)); }

function getObjects(data, keys) { var objects = []; for (var i = 0; i < data.length; ++i) { var object = {}; var hasData = false; for (var j = 0; j < data[i].length; ++j) { var cellData = data[i][j]; if (isCellEmpty(cellData)) { continue; } object[keys[j]] = cellData; hasData = true; } if (hasData) { objects.push(object); } } return objects; }

function normalizeHeaders(headers) { var keys = []; for (var i = 0; i < headers.length; ++i) { var key = normalizeHeader(headers[i]); if (key.length > 0) { keys.push(key); } } return keys; }

function normalizeHeader(header) { var key = ”; var upperCase = false; for (var i = 0; i < header.length; ++i) { var letter = header[i]; if (letter == ‘ ‘ && key.length > 0) { upperCase = true; continue; } if (!isAlnum(letter)) { continue; } if (key.length == 0 && isDigit(letter)) { continue; // first character must be a letter } if (upperCase) { upperCase = false; key += letter.toUpperCase(); } else { key += letter.toLowerCase(); } } return key; }

function isCellEmpty(cellData) { return typeof(cellData) == ‘string’ && cellData == ”; }

function isAlnum(char) { return char >= ‘A’ && char <= ‘Z’ || char >= ‘a’ && char <= ‘z’ || isDigit(char); }

function isDigit(char) { return char >= ‘0’ && char <= ‘9’; }

function sendEmails() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var dataSheet = ss.getSheets()[0]; var dataRange = dataSheet.getRange(2, 1, dataSheet.getMaxRows() – 1, 4);

var templateSheet = ss.getSheets()[1]; var emailTemplate = templateSheet.getRange(‘A1’).getValue();

var objects = getRowsData(dataSheet, dataRange);

// For every row object, create a personalized email from a template and send // it to the appropriate person. for (var i = 0; i < objects.length; ++i) { // Get a row object var rowData = objects[i]; var file = DriveApp.getFilesByName(‘2019_MA_BenefitsGuide.pdf’) var file1 = DriveApp.getFilesByName(‘List of Acceptable Documents.pdf’)

var emailText = fillInTemplateFromObject(emailTemplate, rowData); var emailSubject = 'Mail Merge Test';  MailApp.sendEmail(rowData.emailAddress, emailSubject, emailText, {attachments: [,]} ); 

} }

function fillInTemplateFromObject(template, data) { var email = template; // Search for all the variables to be replaced, for instance $ {“Column name”} var templateVars = template.match(/$ {\”[^\”]+\”}/g);

// Replace variables from the template with the actual values from the data object.

for (var i = 0; i < templateVars.length; ++i) {

var variableData = data[normalizeHeader(templateVars[i])]; email = email.replace(templateVars[i], variableData || ''); 


return email; }

I am currently using the following code to send mails from google sheets. I wanted to know what changes would be required to add another cell ‘A2’ to the template as I have to add an image at the end of the template. Is there any other work around? Or what changes would be required in the code?

Airline changes plane, boarding is done by calling names, my name not called, Service insists that I was late

Today my gf wanted to flight home (Berlin Tegel -> Minsk). She had booked a flight long ago with airbaltic and checked in 1h before depature. When boarding should habe started, there was a plane change all of a sudden. People panicked and where rushing the counters to know what was going on.

In the end, the boarding was done by calling the names on the fligth list one by one. At this point my gf asked one of the service workers there to help her out. She just replied that she needs to wait. So thats what she did.

After all names were called, 5 people were still there. The same service worker insisted that she called all names and therefore these 5 people were obviously late. This obviously was not true.

However, my gf and the other group of 4 called the airline hotline (no counter for airbaltic in Berlin Tegel). To my gf they responded that they will call back. While on phone, the group of 4 left (no traces, so no witnesses that she was indeed at the gate). At some point the hotline called back. Not unsurprisingly they only found, that the Service Workers at the gate had marked them as late and so there is nothig that they can do (ofc they cant -.-)

My gf is crushed. What can we do? The ticket was scanned at the security control but I am afraid thats the only proove we have that she was there in time.

// UPDATE: My gf was lucky and found the group of 4 and will exchange numbers. That at least gives me a bit of hope

Changing states with Minimal UI changes

I’ve been tasked with a design challenge, which apparently seemed so simple for me, but I’ve almost come to a dead end. There are states for an object that need to be represented visually on a page. For instance, the object ( a network group ) need to be modelled first. This is the stage where an admin creates a model of his network. The model then would be queued for the top-brass to approve. Once this is approved, it would move to a synchronized state. At this stage the model and the network are in sync with each other. If the user makes a change to the synchronized state, it would push itself to an updated state, which from there would follow the cycle of Queued and Syncronized again. Phew!.. So essentially, the states starts with MODELLED, once modeling is done, moves to QUEUED, once the queued model has been approved, it moves to SYNCRONIZED. Any changes on a synchronized state would immediately push it to UPDATED, and this when ready to be evaluated to again be moved to QUEUED…

I have to design visual representations for each of these states. The state of an object in it’s initial state (MOdelled) has already been defined earlier.

Modelled Object

The task is to show the rest of the states with minimal pixel changes, should be clear ( since we would have about 3-4000 of these on the canvas at any given point in time .. it is an infinite canvas).. and they should not be dependent on just the color since accessibility is an issue. The stake holders do not want too many icons also involved because that makes the screen look too complex with too many variations …. HELPP

How to compare two fields and highlight only changes

I have such a scenario: When Item is edited on the list an email is sent with information about changes.

Current solution: We created an additional list called Archive that holds information only for comparison. We have a workflow that runs on edit and compares fields between the current version and the one on the Archive list. It generates an email with highlighted fields that changed (IF field ‘not equal’ field_archive). Then the workflow updates archive item for future changes.

Required changes: Currently, this comparison is only stating if anything has changed. We need to highlight exact changes for example: Field1: before change: This is a sample string. after change: This string has been changed. Information in email: This <strong>string has been changed</strong>

Field 2 checkboxes: before change: [x] checkbox1 [x] checkbox2 [ ] checkbox3

after change: [x] checkbox1 [ ] checkbox2 [x] checkbox3

info in email: checkbox1, <strong>checkbox3</strong>

What are the options when using workflows to achieve that – any other solution than sending fields to webservice?