Magento 2 : How to get admin user data in observer?

I have observer of backend_auth_user_login_success.

I need the data of the admin user who is login in observer.

Can anyone please help me into this?

Thanks in advance.

sql – How do I extract data from a main table based on this specific scenario?

I am using SQL Server 2014. I have a table (T1) which contains the list of IDs of cancelled bookings and their equivalent re-bookings.

Extract of table T1:

CancelledID       Re-bookingID
  301                754
  387                801
  400                900

Each CancelledID has a unique equivalent in the Re-bookingID column.

I have another table (T2) which contains the list of ALL BookingIDs with additional information related to each ID. An extract of this table is shown below:

BookingID     MonthOfStay      RoomNights
301             2019-03-01        10
387             2019-04-01         7
400             2019-03-01         5
754             2019-08-01        10
801             2019-09-01         3
900             2019-07-01         5
900             2019-08-01         4

I need a t-sql query which will me the following output:

  BookingID       Cancelled_MonthOfStay     Re-booking_MonthOfStay     RoomNights
    301                2019-03-01                                           10
    387                2019-04-01                                            7
    400                2019-03-01                                            5
    754                                           2019-08-01                10
    801                                           2019-09-01                 3
    900                                           2019-07-01                 5
    900                                           2019-08-01                 4

As you can see, a re-booking can span over 2 months with additional room nights.

I am thinking about “Joins” between the 2 tables but I am stuck at the logic to be used for the “Joins” (if that is the right way of tackling the problem).

Any help would be appreciated.

camera settings – “Record location data” gets switched off sometimes, why?

I want to record GPS coordinates for all of the pictures I take with my Nikon D5300.

Unfortunately, from time to time, after coming back from a photographing expedition, I realize that none of the pictures of the last few days have location information. Looking at the camera’s settings, I see that “Record location data” is set to “Off”, even though I am 100% sure I never switched it off.

When that happens, I cry for a few minutes then switch it back on, and hope it will last a bit longer.

I could check the setting every morning, but that would take time and I would rather avoid loosing a day’s worth of location data.

Question: Why does “Record location data” gets switched off?
If it is when a particular event happens, or after a certain number of days, I can try to mitigate the problem.


  • I removed the battery for a night to charge it, and upon putting the battery back into the camera, “Record location data” was still on, so it is probably not the reason.

functions – Keep PODS data (meta table) after wp-ultimo (multisite) template switching

I have a multisite install and using wp-ultimo to manage the subsite duplication, or “template sites” as they call it.

One downside to this approach is that you’d lose any edits you make when you switch the template, because in reality, it’s not a template, it’s an entire subsite that will override your current subsite.

I have extended the site’s pages with PODS, added a couple of simple text fields, they’re basically custom meta fields, you get the data using get_post_meta($id, 'field_name', true).

What I’m trying to achieve is:

  1. Write a function that will retrieve this data before duplication
  2. Pass the data to the search & replace filter that fires after duplication

Relevant Available Hooks:

  • do_action (../inc/duplicate/duplicate.php line 139) ( ‘mucd_before_copy_data’, $from_site_id, $to_site_id );

  • apply_filters (../inc/class-wu-site-hooks.php line 576) (‘wu_search_and_replace_on_duplication’, $search_and_replace_settings, $from_site_id, $to_site_id);

Using search & replace filter example

I don’t know enough PHP to wrap the function properly and pass the values, I’d appreciate any help or a nudge in the right direction.

Thank you <3

linux – restore data from internal storage of android phone

I am struggelling with the file recovery of an internal storage of an android phone.

I made a dd copy of the /dev/sda device which includes the system and userdata and some other partitions of the phone.

bla@bla:/media/Volume$ mmls sda.raw 
GUID Partition Table (EFI)
Offset Sector: 0
Units are in 4096-byte sectors

      Slot      Start        End          Length       Description
000:  Meta      0000000000   0000000000   0000000001   Safety Table
001:  -------   0000000000   0000000005   0000000006   Unallocated
002:  Meta      0000000001   0000000001   0000000001   GPT Header
003:  Meta      0000000002   0000000002   0000000001   Partition Table
004:  000       0000000006   0000000015   0000000010   padding0
005:  001       0000000016   0000016399   0000016384   recovery
006:  002       0000016400   0000032783   0000016384   boot
007:  003       0000032784   0001011727   0000978944   system
008:  004       0001011728   0001026063   0000014336   apppreload
009:  005       0001026064   0001041423   0000015360   cota
010:  006       0001041424   0015447055   0014405632   userdata
011:  007       0015447056   0015450106   0000003051   reserve0
012:  -------   0015450107   0015450111   0000000005   Unallocated

I am able to mount some partitions:

bla@bla:/media/Volume$ sudo fsstat -b 4096 -o 32784 sda.raw 
File System Type: Ext4
Volume Name: system
Volume ID: 7019a2b4b48a33b92c4409cbe0a229c7

Last Written at: 2020-05-28 21:04:07 (CEST)
Last Checked at: 2019-07-22 16:11:16 (CEST)

Last Mounted at: 2020-05-28 20:55:42 (CEST)
Unmounted properly
Last mounted on: /system

Source OS: Linux
Dynamic Structure
Compat Features: Journal, Ext Attributes, Resize Inode, Dir Index
InCompat Features: Filetype, Extents, Flexible Block Groups, 
Read Only Compat Features: Sparse Super, Large File, Huge File, Extra Inode Size

Journal ID: 00
Journal Inode: 8


But not the userdata partition. Are there any tricks I missed so far?

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <>

Disk sda.raw - 63 GB / 58 GiB - CHS 7694 255 63
     Partition               Start        End    Size in sectors
>P MS Data                   262272    7971615    7709344 (system)
 P MS Data                  8093824    8208511     114688
 D MS Data                  8208512    8331391     122880
 D MS Data                  8331390  123576413  115245024 

Outputs for userdata:

bla@bla:/media/Volume$ sudo fsstat -b 4096 -o 1041424 sda.raw
Cannot determine file system type

Thanks for any hints in advance!


amazon rds – Storing Analytic Data for Multi-Tenet SaaS with AWS Aurora

I have an app that a user can upload an excel sheet of analytics data to S3. I am wanting to trigger a Lambda function on upload to do some data processing and then write the analytics to a client’s organization’s database (I am using Aurora). Eventually we will be capturing live clickstream data but for now we are just using generated reports.

My question is is this best practice to just have all the analytics in a database with thousands and thousands of events in as many rows? I can see that your table supports a maximum of … a little over 4.29 billion rows. but does that mean I can just pile them into a giant table until then? If I am potentially getting 50k rows per month should I just not think worry about it until I see a performance hit (if I even ever see one)? Or am I, as a newbie, just worrying over nothing?

Ideally I don’t just want to make this thing work, I want to learn how to make something that lasts and scales. And reading the docs on Aurora it sounds like this shouldn’t be an issue but I don’t know if I am just not seeing something that will become an issue.

Thanks for any advice and feedback!

subtypes – How to relate summary to detail data objects?

First thoughts

Inheritance is meant for generalisation and specialisation. But a CustomerSummary is not some kind of Customer, nor is a Customer some kind of a CustomerSummary. So forget using inheritance here.

Composition would be a better choice: both an IndividualCustomer and BusinessCustomer have a CustomerSummary that can be used for similar purposes. But that’s not the end of the story.

OO design vs DB design

If you have a hammer in your hand, every problem looks like a nail.

Similarly, if you have tables and columns in your mind, every class design will look like properties bundled in a POJO. And this might be misleading: redundant columns does not look very normal to an RDBMS expert ;-). And one mental trap leads to another: you’ll quickly feel the need to partition theses columns between non-overlapping classes… OUCH! Wait a moment! Didn’t we say object-oriented?

Accelerated OO design primer for data oriented developers

To avoid this mental trap, you need to abstract and embrace the law of demeter. The CustomerSummary is no longer a bundle of properties: it’s a black box that can contain anything that summarizes a customer. For example a graphical picture such as a QR-Code or a DataMatrix, or a sound to be incorporated in your latest latest voice user interface (“Hey Siri, which customers shall I visit?”).

As long as you do not decide anything about its properties, your mind will remain free. So focus on how a CustomerSummary could be used and how it would interact with the other classes. You’ll end up with a nicely thought and robust interface.

Then you stay free: you can start with one implementation of the interface (the common fields), you may prefer to specialize the implementation (the legal form really makes sense for a business customer), or you may decide to have different summary implementation based on the kind of interface you’re targeting. Dependency injection can even help you to make this dynamic.

At this moment in the thought process, you’d realize that it makes no sense to make the properties of the customer dependent of the content of the black box. This is how you’ll get a BusinessCustomer and IndividualCustomer completely decoupled from a CustomerSummary If there is a dependency for populating the object, it would rather be Customer Summary that would be populated from a Customer object and not directly from the DB.

amazon s3 – Using AWS to capture and store data (Python)

i have one script(Python) that get data from an specific web page, do the ETL and save the archive as .CSV on my desktop.

I need to put this code inside AWS Amazon (I believe it must be AWS Glue), set a trigger to do this operation 00:00 everyday and store the collected data on the AWS s3.

Someone here already did something like that? Im struggling to do it, but im unsucessfull until now. Every direction that some of you can provide is accepted.

typescript – subscribe to the data content for a datasource angular material table , how to make the pagination server calls from angular

introducir la descripción de la imagen aquí

Hi, I’m block with 2 points and need some of help with my development first it’s how to get data from backend with the pagination server procedure, i see multiple examples but nothing with the backend results of the httpclient get call.

The api to use data works with this:


1.- I get the values but i don’t know really how to implements the HttpParams to get the values with the angular material table paginator.

My other problem its the object its a container but i can’t access into the content of the data to retrieve the values of users.

  "content": ({
        "id": 343,
        "name": "name1",
        "email": "",
        "imageUrl": null,
        "emailVerified": true,
        "sapUserId": "adangesslo",
        "provider": "google",
        "providerId": null,
        "createdBy": "Admin",
        "updatedBy": "Admin",
        "createDate": "2020-05-05T12:15:42.744+0000",
        "updateDate": "2020-05-05T12:15:42.744+0000",
        "lastLoginDate": null,
        "roles": ({
          "id": 9,
          "name": "site_prod_shift",
          "type": "site_prod_shift",
          "description": "site_prod_shift",
          "createdBy": "Admin",
          "updatedBy": "Admin",
          "createDate": "2020-05-04T18:37:58.302+0000",
          "updateDate": "2020-05-04T18:37:58.302+0000"
        "plants": ({
          "plantId": 4,
          "name": "asdf (asdf e asdf)",
          "code": "MG",
          "smartsheetLink": "",
          "type": {
            "id": 1,
            "name": "asf Plant"
          "createDate": "2020-05-04T18:02:15.333+0000",
          "updateDate": "2020-05-04T18:02:15.333+0000",
          "createdBy": "Admin",
          "updatedBy": "Admin",
          "opcoId": 1

  "pageable": {
    "sort": {
      "unsorted": true,
      "sorted": false,
      "empty": true
    "offset": 0,
    "pageNumber": 0,
    "pageSize": 20,
    "unpaged": false,
    "paged": true
  "totalPages": 104,
  "totalElements": 2065,
  "last": false,
  "size": 20,
  "number": 0,
  "sort": {
    "unsorted": true,
    "sorted": false,
    "empty": true
  "numberOfElements": 20,
  "first": true,
  "empty": false

My user.service:

import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { User } from '../model/user';
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { environment } from './../../environments/';
import { ToasterService } from 'angular2-toaster';
import { AddDialogComponent } from '../main/users/dialogs/add/add.dialog.component';
import { map } from 'rxjs/operators';

  providedIn: 'root'
export class UserService {

  dataChange: BehaviorSubject<User()> = new BehaviorSubject<User()>(());
  // Temporarily stores data from dialogs
  dialogData: any;
  apiurl = environment.apiUrl;
  items: any;
  AddDialogComponent: AddDialogComponent;
  AllDataObj: any;
  AllData_Arr: string;

  constructor(private httpClient: HttpClient) { }

  get data(): User() {
    return this.dataChange.value;

  getDialogData() {
    return this.dialogData;

  /** CRUD METHODS http://localhost:8080/users?size=1&page=1  */

  getAllUsers(): void {
    this.httpClient.get<User()>(this.apiurl + "/users?",
        params: new HttpParams()
          .set('size', "5")
          .set('page', "5")
        //}).subscribe((data: User()) => {
        }).subscribe(data => {;
        (error: HttpErrorResponse) => {
          console.log( + ' ' + error.message);
  // getAllUsers(): void{
  //   this.httpClient.get<User()>(this.apiurl+"").subscribe((data: User())=> {
  //     console.log(data);
  //     //this.AllDataObj = data;
  //     //this.AllData_Arr= JSON.stringify(this.AllDataObj);
  //     //console.log(this.AllData_Arr);
  //     },
  //     (error: HttpErrorResponse) => {
  //     console.log ( + ' ' + error.message);
  //     });
  // }

  // DEMO ONLY, you can find working methods below
  addUser(user: User): void { + "/createuser", user).subscribe(data => {
      this.dialogData = user;
      // this.toasterService.pop('Successfully added');
      (err: HttpErrorResponse) => {
        console.log( + ' ' + err.message)
        //this.ToasterService.pop('Error occurred. Details: ' + + ' ' + err.message);

  updateUser(user: User): void {
    this.dialogData = user;

  deleteUser(id: number): void {

  getConfig(): Observable<User()> {
    return this.httpClient.get<User()>(this.apiurl + "");


/* REAL LIFE CRUD Methods I've used in my projects. ToasterService uses Material Toasts for displaying messages:

    addItem(kanbanItem: KanbanItem): void {, kanbanItem).subscribe(data => {
      this.dialogData = kanbanItem;
      this.toasterService.showToaster('Successfully added', 3000);
      (err: HttpErrorResponse) => {
      this.toasterService.showToaster('Error occurred. Details: ' + + ' ' + err.message, 8000);

     updateItem(kanbanItem: KanbanItem): void {
    this.httpClient.put(this.apiurl +, kanbanItem).subscribe(data => {
        this.dialogData = kanbanItem;
        this.toasterService.showToaster('Successfully edited', 3000);
      (err: HttpErrorResponse) => {
        this.toasterService.showToaster('Error occurred. Details: ' + + ' ' + err.message, 8000);

  deleteItem(id: number): void {
    this.httpClient.delete(this.apiurl + id).subscribe(data => {
        this.toasterService.showToaster('Successfully deleted', 3000);
      (err: HttpErrorResponse) => {
        this.toasterService.showToaster('Error occurred. Details: ' + + ' ' + err.message, 8000);

my user.component.ts

import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { UserService } from '../../services/user.service';
import { HttpClient } from '@angular/common/http';
import { MatDialog } from '@angular/material/dialog';
import { MatPaginator, PageEvent } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { User } from '../../model/User';
import { DataSource } from '@angular/cdk/collections';
import {AddDialogComponent} from './dialogs/add/add.dialog.component';
import {EditDialogComponent} from './dialogs/edit/edit.dialog.component';
import {DeleteDialogComponent} from './dialogs/delete/delete.dialog.component';
import {BehaviorSubject, fromEvent, merge, Observable} from 'rxjs';
import {map} from 'rxjs/operators';

  selector: 'app-users',
  templateUrl: './users.component.html',
  styleUrls: ('./users.component.scss')
export class UsersComponent implements OnInit {
  displayedColumns = ('id', 'Name', 'email', /*'imageUrl',*/ 'createdate', 'sapUserId', 'roles', 'actions');
  exampleDatabase: UserService | null;
  dataSource: ExampleDataSource | null;
  index: number;
  id: number;
  newid: number;

    public httpClient: HttpClient,
    public dialog: MatDialog, 
    public userService: UserService) {}

  @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
  @ViewChild(MatSort, {static: true}) sort: MatSort;
  @ViewChild('filter',  {static: true}) filter: ElementRef;

  ngOnInit() {

  //  this.dataApi.getAllUsers()
  //  .subscribe(users => console.log(users)); }

  refresh() {

  addNew(user?: User) {
    const dialogRef =, {
      data: {user: user} 

    dialogRef.afterClosed().subscribe(result => {
      if (result === 1) {
        // After dialog is closed we're doing frontend updates
        // For add we're just pushing a new row inside userService

  startEdit(i: number, id: number, name: string, email: string, imageUrl: string, createdate: Date,  sapUserId: string, roles: ()) { = id;
    // index row is used just for debugging proposes and can be removed
    this.index = i;
    const dialogRef =, {
      data: {id: id, name: name, email: email, imageUrl: imageUrl, createdate: createdate, sapUserId: sapUserId, roles: roles}

    dialogRef.afterClosed().subscribe(result => {
      if (result === 1) {
        // When using an edit things are little different, firstly we find record inside userService by id
        const foundIndex = this.exampleDatabase.dataChange.value.findIndex(x => ===;
        // Then you update that record using data from dialogData (values you enetered)
        this.exampleDatabase.dataChange.value(foundIndex) = this.userService.getDialogData();
        // And lastly refresh table

deleteItem(i: number, id: number, name: string, email: string, imageUrl: string, createdate: string, sapUserId: string, roles: ()) {
  this.index = i; = id;
  const dialogRef =, {
    data: {id: id, name: name, email: email, imageUrl: imageUrl, createDate: createdate, sapUserId: sapUserId, roles: roles}

  dialogRef.afterClosed().subscribe(result => {
    if (result === 1) {
      const foundIndex = this.exampleDatabase.dataChange.value.findIndex(x => ===;
      // for delete we use splice in order to remove single object from DataService
      this.exampleDatabase.dataChange.value.splice(foundIndex, 1);

private refreshTable() {
  // Refreshing table using paginator
  // Thanks yeager-j for tips

  /*   // If you don't need a filter or a pagination this can be simplified, you just use code from else block
    // OLD METHOD:
    // if there's a paginator active we're using it for refresh
    if (this.dataSource._paginator.hasNextPage()) {
      // in case we're on last page this if will tick
    } else if (this.dataSource._paginator.hasPreviousPage()) {
      // in all other cases including active filter we do it like this
    } else {
      this.dataSource.filter = '';
      this.dataSource.filter = this.filter.nativeElement.value;

    public loadData() {
      this.exampleDatabase = new UserService(this.httpClient);
      this.dataSource = new ExampleDataSource(this.exampleDatabase, this.paginator, this.sort);
      fromEvent(this.filter.nativeElement, 'keyup')
        // .debounceTime(150)
        // .distinctUntilChanged()
        .subscribe(() => {
          if (!this.dataSource) {
          this.dataSource.filter = this.filter.nativeElement.value;

export class ExampleDataSource extends DataSource<User> {
  _filterChange = new BehaviorSubject('');

  get filter(): string {
    return this._filterChange.value;

  set filter(filter: string) {;

  filteredData: User() = ();
  renderedData: User() = ();

  constructor(public _exampleDatabase: UserService,
              public _paginator: MatPaginator,
              public _sort: MatSort) {
    // Reset to the first page when the user changes the filter.
    this._filterChange.subscribe(() => this._paginator.pageIndex = 0);

  /** Connect function called by the table to retrieve one stream containing the data to render. */
  connect(): Observable<User()> {
    // Listen for any changes in the base data, sorting, filtering, or pagination
    const displayDataChanges = (


    return merge(...displayDataChanges).pipe(map( () => {
        // Filter data
        this.filteredData = User) => {
          const searchStr = ( + + + user.imageUrl + user.createdate + user.sapUserId + user.roles).toLowerCase();
          return searchStr.indexOf(this.filter.toLowerCase()) !== -1;

        // Sort filtered data
        const sortedData = this.sortData(this.filteredData.slice());

        // Grab the page's slice of the filtered sorted data.
        const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
        this.renderedData = sortedData.splice(startIndex, this._paginator.pageSize);
        return this.renderedData;

  disconnect() {}

  /** Returns a sorted copy of the database data. */
  sortData(data: User()): User() {
    if (! || this._sort.direction === '') {
      return data;

    return data.sort((a, b) => {
      let propertyA: number | string = '';
      let propertyB: number | string = '';
      let propertyC: Date | string = '';

      switch ( {
        case 'id': (propertyA, propertyB) = (,; break;
        case 'lastname': (propertyA, propertyB) = (,; break;
        case 'email': (propertyA, propertyB) = (,; break;
        case 'photoURL': (propertyA, propertyB) = (a.imageUrl, b.imageUrl); break;
        case 'createdate': (propertyC, propertyC) = (a.createdate, b.createdate); break;
        case 'sapid': (propertyA, propertyB) = (a.sapUserId, b.sapUserId); break;

      const valueA = isNaN(+propertyA) ? propertyA : +propertyA;
      const valueB = isNaN(+propertyB) ? propertyB : +propertyB;
      const valueC = isNaN(+propertyC) ? propertyC : +propertyC;

      return (valueA < valueB ? -1 : 1) * (this._sort.direction === 'asc' ? 1 : -1);


my user.ts model

export class User {
    id: number;
    name: string;
    email: string;
    imageUrl?: string;
    emailVerified?: boolean;
    sapUserId: string;
    provider?: string;
    providerId?: string;
    createdBy?: string;
    createdate?: string;
    updatedBy?: string;
    createDate?: string;
    updateDate?: string;
    lastLoginDate?: string;
    roles: string;
    totalPages?: number;
    totalElements?: number;

2.- The other point its how to slice or filter the content () into the json response to load the datatable.


air travel – Historical flight data outside of the USA?

What do you want to know about these flights? The websites shown in the other question are advertised as flight trackers more than providers of historical data about flights. It is hard to tell from your question what kind of data you expect, so here are some websites and their sources.

As @CGCampbell points out, FlightStats claims to “collect flight and airport information from a multitude of global sources” without telling which ones. FlightAware also mentions around 50 government sources in Europe, Oceania, North America. It also uses a network of ADS-B receivers, basically some kind of radars tracking planes. FlightRadar24 says it uses first the same ADS-B technology and secondarily the FAA data.

Also, if you want to track a flight, most airports have a list of live flights, most likely relying on their own radars. So if you have a specific airport in mind, you’d better go on its website to check.

Open data portals such as or did not result in very relevant data sets or apps. The only one I found was a World Bank data set showing the number of flights from or to a country from 1970 until now, but I expect that by historical flight data you mean detailed information about a specific flight.

Some other websites show some incomplete flight data like OpenFlights that partially relies on OurAirports which in turn relies on FAA or previously DAFIF for its data.

OpenData.SE has a question on the topic and show a lot of sources but few might interest you.

In more specific and curious data, as pointed out by an Aviation.SE question, The Aviation Herald reports incidents and accidents about commercial flights.

I recommend you to visit and even ask on these other StackExchange websites, as some more knowledgeable people may be able to answer your more specific question.