Grant – Revoke

Przydzielanie, sprawdzanie i wycofywanie uprawnień

CREATE USER bob@'165.129.76.20' IDENTIFIED BY 'superpassword';
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON myDb.* TO bob@'165.129.76.20'
SHOW GRANTS FOR bob@'165.129.76.20';
REVOKE ALL PRIVILEGES ON myDb.* FROM bob@'165.129.76.20';

Czytaj dalej Grant – Revoke

Sortowanie, Limity

$this->paginate = [
   'limit' => 200,
   'maxLimit' => 200,
   'sortableFields' => [
      'date', 'netto', 'brutto', 'termin_platnosci', 'is_payed',
      'Brands.name', 'Projects.number', 'numer', 'position',
      'Companies.name', 'Companies.nip', 'Companies.bank_number',
    ],
   'order' => ['CostInvoices.date' => 'DESC']
];

Różne: Tabela, wyszukiwanie Ajax,

Referer – redirect – queryParams

if($this->request->referer()) {
    return $this->redirect($this->request->referer());
} else {
    return $this->redirect(['action' => 'articles', '?' => $this->request->getQueryParams()]);
}

get Table object

$project = $this->fetchTable("Projects")->get($id);   // załaduj Model

URL

let url = new URL(location.href);

$('#s_brand_id').on('change', function(){
  var s_brand_id = $(this).val();

  if(s_brand_id) {
    url.searchParams.set('s_brand_id', s_brand_id);
  } else {
    url.searchParams.delete('s_brand_id');
  }
  location.href = url.toString();
});
$s_brand_id = (int) $this->request->getQuery('s_brand_id', null);

if($s_brand_id) {   
  $query->where(['brand_id' => $s_brand_id]);
}

$this->set(compact('s_brand_id'));

Wirtualne pola

Pobranie największej/najwcześniejszej lub namniejszej/najpóźniejszej wartości

protected $_accessible = [
   ......
   'schedule_first_date' => true,    // Pierwsza data w harmonogramie
   'schedule_last_date' => true,     // Ostatnia data w harmonogramie
];

// Dla projektu pobiera ostatnią datę z harmonogramu (schedules - tablica powiązanych rekordów)
protected function _getScheduleLastDate()
{
   if (isset($this->_fields['schedule_last_date'])) {
      return $this->_fields['schedule_last_date'];
   }
   if (empty($this->schedules)) { return ; }

   $last_day = (new Collection($this->schedules))->max('date_to')->date_to;
   return $last_day;
}  

// Dla projektu pobiera ostatnią datę z harmonogramu (schedules)
protected function _getScheduleFirstDate()
{
  if (isset($this->_fields['schedule_first_date'])) {
       return $this->_fields['schedule_first_date'];
  }
  if (empty($this->schedules)) { return ; }

  $first_fday = (new Collection($this->schedules))->min('date_from')->date_from;
  return $first_fday;
}

Czytaj dalej Wirtualne pola

Wygasły podpisy repozytorium pakietów

Aktualizacja zwraca błąd:

# apt update

Err:6 https://packages.sury.org/php buster InRelease
The following signatures were invalid: EXPKEYSIG B188E2B695BD4743 DEB.SURY.ORG Automatic Signing Key <deb@sury.org>

Repozytorium pakietów Debiana sury.org zmieniło swój klucz podpisywania pakietów. Aby naprawić błąd, po prostu pobierz nowy klucz:

# apt-key adv --fetch-keys https://packages.sury.org/php/apt.gpg
# apt update && apt upgrade

AI – odnośniki

Gamma App – generowanie prezentacji – gamma.app

Wizard IO – aplikacje na telefon – app.wizard.io/prototypes

Hey Gen Labs – tłumacz

Grog – X (twiter)

Claude 2 – Anthropic

Gemini – Google

 

Skróty klawiszowe

Ctrl + Shift + WIN + Alt – Office

Win + Shift + R – Capture

Win + Shift + S – Capture

Win + Alt + R – Nagrywanie ekranu

Win + G – dostęp do nagrania – Widget / Galeria

Win + D – min/max

 

 

Dodaj / usuń pliki do stage’a

Dodaje wszystkie nienadzorowane pliki

# git add .                        // dodaje wszystko w katalogu
# git add -A                       // dodaje wszystko

Wycofuje ze stage’a wszystko – odwrotne działanie do powyższego

# git reset HEAD -- .

Wycofuje z nadzorowania pojedynczy plik / katalog

# git reset HEAD -- path/to/file

Formatowanie wartości finansowych

Entity – usuwanie spacji, zamiana przecinków na kropki

protected function _setNetto($netto) {
   $netto = str_replace(',', '.', $netto);
   return trim($netto);
}

protected function _setBrutto($brutto) {
   $brutto = str_replace(',', '.', $brutto);
   return trim($brutto);
}

Kontroler  – pobieranie sumy pozycji

$query = $this->Invoices->find();

$query->enableAutoFields()
      ->select([
          'total_netto'  => $query->func()->sum('Positions.netto'),
          'total_brutto' => $query->func()->sum('Positions.brutto'),
          'total_pos'    => $query->func()->count('Positions.id')
       ]);

$query->leftJoinWith('Positions');

$query->group(['Invoices.id']);

$query->order(['Invoices.id' => 'DESC'])
      ->all();

View /

<?= number_format($brutto, 2, ".", " ") ?>

Redis – Node – komunikat z serwera

Konfiguracja redis, redis-connect w node

const {createClient} = require("redis")

let redisClient = createClient({
    url: 'rediss://alice:alicePassword@redis.server:6379',
    logErrors:  true
  })

redisClient.connect().catch(console.error)
const RedisStore = require("connect-redis").default

let redisStore = new RedisStore({
    client: redisClient,
    prefix: "myapp:",
  })

Czytaj dalej Redis – Node – komunikat z serwera