Skip to content

Instantly share code, notes, and snippets.

View iamshanto's full-sized avatar

Samiul Amin Shanto iamshanto

View GitHub Profile
@iamshanto
iamshanto / gist:08a27cac74a3d4a4ef5ab6ea8ec56978
Created September 29, 2020 04:36
FIND AND KILL LOCKS ON POSTGRES TABLES.md
Source: https://jaketrent.com/post/find-kill-locks-postgres/
# LISTING LOCKS
select pid
from pg_locks l
join pg_class t on l.relation = t.oid
where t.relkind = 'r'
and t.relname = 'TABLE_NAME';
# MATCHING QUERIES WITH LOCKS

You can connect your external hard disk, SSD, or USB stick to any of the USB ports on the Raspberry Pi, and mount the file system to access the data stored on it.

By default, your Raspberry Pi automatically mounts some of the popular file systems such as FAT, NTFS, and HFS+ at the /media/pi/ location.

To set up your storage device so that it always mounts to a specific location of your choice, you must mount it manually.

Mounting a storage device

SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "dev_rides"
ORDER BY (data_length + index_length) DESC;
SELECT
tb.COLUMN_NAME AS 'Field Name',
tb.COLUMN_TYPE AS 'Data Type',
tb.IS_NULLABLE AS 'Allow Empty',
tb.EXTRA AS 'PK',
tb.COLUMN_COMMENT AS 'Field Description'
FROM
`INFORMATION_SCHEMA`.`COLUMNS` as tb
WHERE
TABLE_NAME = '__TABLE_NAME__'
@iamshanto
iamshanto / Audit.php
Created August 26, 2019 09:58
AuditLogService
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
class Audit extends Model
{
protected $table = 'audits';
@iamshanto
iamshanto / xdebug_devilbox_phpstorm_postman.md
Created July 19, 2019 12:21 — forked from marcandreappel/xdebug_devilbox_phpstorm_postman.md
Using Xdebug on Devilbox with PhpStorm and Postman

Host OS

Tested on:

  • openSUSE 15.1 Leap
  • Fedora 30

Check before setup:

  • Accept in the firewall the port 9000 TCP

Docker

@iamshanto
iamshanto / switch-php-version.sh
Created June 10, 2019 08:01
switch-php-version
#!/bin/bash
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
BACKTITLE="PHP version switch"
TITLE=$BACKTITLE
MENU="Available PHP version"
OPTIONS=(1 "PHP 5.6"
-- https://blog.bubble.ro/how-to-make-multiple-updates-using-a-single-query-in-mysql/
UPDATE mytable
SET (title='Great Expectations' WHERE id='1'),
(title='War and Peace' WHERE id='2');
#!/bin/bash
`for file in /DIRECTORY/*
do
printf "$file\n";
done`
function sanitizeMobileNumber($mobile, $prefix = '0')
{
$mobile = ltrim(trim($mobile), '.+80');
$mobile = str_replace([' ', '-', '.', '+'], '', $mobile);
$mobile = strrev(substr(strrev($mobile), 0, 10));
if (!in_array(substr($mobile, 0, 2), ['15', '16', '17', '18', '19', '13']) || strlen($mobile) != 10) {
return null;
}