Skip to content

Instantly share code, notes, and snippets.

View sawirricardo's full-sized avatar
👋

Ricardo Sawir sawirricardo

👋
View GitHub Profile
@sawirricardo
sawirricardo / index.html
Created February 14, 2024 05:20
web libraries
<!DOCTYPE html>
<html>
<head>
<meta name="charset" content="utf-8"/>
<meta name="csrf-token" content={ CSRF(ctx) }/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/unpoly@3.7.3/unpoly.min.css"/>
@sawirricardo
sawirricardo / install_packages.sh
Last active February 5, 2024 04:39
go almost must use libraries
go get -u github.com/joho/godotenv;
go get -u github.com/a-h/templ;
go get -u github.com/manifoldco/promptui;
go get -u github.com/go-chi/chi/v5;
go get -u gopkg.in/gomail.v2;
go get -u github.com/amacneil/dbmate/v2/pkg/driver/postgres;
go get -u github.com/jackc/pgx/v5/pgxpool;
go get -u github.com/gorilla/sessions;
go get -u github.com/gorilla/csrf;
go get -u github.com/google/uuid;
@sawirricardo
sawirricardo / select_types_postgres.sql
Created January 20, 2024 08:31
Select types for postgresql
select
t.typname as name,
n.nspname as schema,
t.typtype as type,
t.typcategory as category,
(
(
t.typinput = 'array_in'::regproc
and t.typoutput = 'array_out'::regproc
)
@sawirricardo
sawirricardo / select_views_postgres.sql
Created January 20, 2024 08:24
Select views for postgresql
select
viewname as name,
schemaname as schema,
definition from pg_views
where
schemaname not in ('pg_catalog', 'information_schema')
order by
viewname;
@sawirricardo
sawirricardo / select_tables_for_postgres.sql
Last active January 20, 2024 08:41
get all tables postgreSQL
select
c.relname as name,
n.nspname as schema,
pg_total_relation_size (c.oid) as size,
obj_description (c.oid, 'pg_class') as comment
from
pg_class c,
pg_namespace n
where
c.relkind in ('r', 'p')
@sawirricardo
sawirricardo / HasPeriodColumns.php
Last active December 19, 2023 15:16
HasPeriodColumns
<?php
namespace App\Support\Traits;
use Carbon\CarbonInterface;
use Illuminate\Contracts\Database\Eloquent\Builder;
trait HasPeriodColumns
{
public function scopeOverlapping(Builder $query, CarbonInterface $start, CarbonInterface $end, string $startColumn, string $endColumn): Builder
@sawirricardo
sawirricardo / TransactionEncapsulation.php
Last active November 22, 2023 13:33
It captures responses, handles DB transactions, and allows custom error messages.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class TransactionEncapsulation
{
@sawirricardo
sawirricardo / app.blade.php
Created September 4, 2023 15:56
Handle 419 token expired
<meta http-equiv="refresh" content="{{ config('session.lifetime')*60 }}" />
@sawirricardo
sawirricardo / app.js
Created August 8, 2023 03:40
make livewire send timezone on each request
import './bootstrap';
window.addEventListener('livewire:init', () => {
Livewire.hook('request', ({ options }) => {
options.headers["X-Timezone"] = Intl.DateTimeFormat().resolvedOptions().timeZone;
})
})
@sawirricardo
sawirricardo / session-timezone.blade.php
Created August 4, 2023 03:56
Update timezone using Laravel Livewire Volt
<?php
$updateTimezone = fn($timezone) => session()->put('timezone', $timezone);
?>
<div x-init="$wire.updateTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone)"></div>