Skip to content

Instantly share code, notes, and snippets.

View unwelt's full-sized avatar
🏠
Working from home

Sergey unwelt

🏠
Working from home
View GitHub Profile
@unwelt
unwelt / pre-commit
Created January 26, 2023 07:37
Run laravel pint w/ sail before commit
#!/bin/bash
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".php\{0,1\}$")
ERROR_FILES=();
# Disable if it's a merge
git merge HEAD &> /dev/null
IS_MERGE_PROCESS=$?
if [ $IS_MERGE_PROCESS -ne 0 ]
@unwelt
unwelt / mysql-docker.sh
Created September 17, 2021 10:16 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@unwelt
unwelt / custom.php
Last active July 29, 2021 04:01
UMI.CMS Подключение custom класса из папки шаблонов.
<?php
class custom extends def_module
{
private const COMPONENTS_CUSTOM_CLASS_NAME = 'CustomCustom';
private const MODULES_CUSTOM_CLASS_NAME = 'custom_custom';
public function __construct()
{
parent::__construct();
@unwelt
unwelt / axios-catch-error.js
Created January 10, 2021 09:22 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨