Skip to content

Instantly share code, notes, and snippets.

View wuiler's full-sized avatar
Working from home

Jose Wuiler Pozzi wuiler

Working from home
View GitHub Profile
@wuiler
wuiler / postgres-cheatsheet.md
Created November 25, 2020 20:15 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
<?php
define('BOT_TOKEN', 'XXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXX'); // place bot token of your bot here
function checkTelegramAuthorization($auth_data) {
$check_hash = $auth_data['hash'];
unset($auth_data['hash']);
$data_check_arr = [];
foreach ($auth_data as $key => $value) {
$data_check_arr[] = $key . '=' . $value;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.digest.HmacUtils;
private Boolean isTelegramAccountDataRight(
String telegramAccountData, // data check string
String telegramBotToken // bot token
) {
byte[] data = telegramAccountData.toString().getBytes();
byte[] secret = DigestUtils.sha256(telegramBotToken);
@wuiler
wuiler / paginate.php
Created January 16, 2018 19:17 — forked from vluzrmos/paginate.php
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator