Skip to content

Instantly share code, notes, and snippets.

@marcelozarate
marcelozarate / sanctum-api.php
Created October 24, 2021 18:13
Basic Auth Sanctum REST API for Laravel
// routes/api.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
Route::post('/register', [AuthController::class, 'register']);
Route::post('/login', [AuthController::class, 'login']);
Route::middleware('auth:sanctum')->get('/whoami', [AuthController::class, 'whoami']);
@marcelozarate
marcelozarate / alpine-js-consuming.api.html
Created July 21, 2022 10:58
Alpine.JS first time use (consuming API)
<!DOCTYPE html>
<html lang="en" data-theme="coffee">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link
href="https://cdn.jsdelivr.net/npm/daisyui@2.6.0/dist/full.css"
rel="stylesheet"
type="text/css"
@marcelozarate
marcelozarate / simplealertdialog.py
Created November 28, 2021 13:16
PyQt simple message box - Custom alert dialog
import sys
from PyQt5.QtWidgets import QMessageBox, QApplication, QWidget
def showMessageBox(title, text, icon="NoIcon", buttons=False, buttonsText=[],callback=None):
qmb = QMessageBox()
qmb.setText(text)
qmb.setWindowTitle(title)
if icon == "NoIcon":
qmb.setIcon(QMessageBox.NoIcon)
if icon == "Information":
@marcelozarate
marcelozarate / sqlitepython.py
Last active October 1, 2021 17:47
sqlite python tutorial
import sqlite3
import pandas as pd
def create_connection(db):
conn = None
try:
conn = sqlite3.connect(db)
conn.execute("PRAGMA foreign_keys = 1")
except sqlite3.Error as err:
print(err)