Skip to content

Instantly share code, notes, and snippets.

View mikehins's full-sized avatar

Mike Hins mikehins

  • Trinary
  • Mont-Tremblant
  • 17:03 (UTC -04:00)
View GitHub Profile
git config core.filemode false
select concat(fks.constraint_schema, '.', fks.table_name) as foreign_table,
'->' as rel,
concat(fks.unique_constraint_schema, '.', fks.referenced_table_name)
as primary_table,
fks.constraint_name,
group_concat(kcu.column_name
order by position_in_unique_constraint separator ', ')
as fk_columns
from information_schema.referential_constraints fks
join information_schema.key_column_usage kcu
// order array diachritic
$collator = new Collator('fr_FR');
$collator->asort($results);
@mikehins
mikehins / lateral
Last active November 15, 2022 12:39
# https://sqlfordevs.com/for-each-loop-lateral-join
SELECT customers.*, recent_sales.*
FROM customers
LEFT JOIN LATERAL (
SELECT *
FROM sales
WHERE sales.customer_id = customers.customer_id
ORDER BY created_at DESC
LIMIT 3
@mikehins
mikehins / port
Last active September 26, 2023 13:03
kill -9 $(lsof -ti:4321)
lsof -i tcp:8080
kil PID
# wmysql PID
ps -ef | grep mysql
* * * * * cd /var/www/dev/cashier && php artisan schedule:run >> /dev/null 2>&1
sudo mkdir /mnt/music
sudo mount -t drvfs '\\192.168.68.2\music' /mnt/music
# https://sqlfordevs.io/delete-duplicate-rows
WITH duplicates AS (
SELECT id, ROW_NUMBER() OVER(
PARTITION BY firstname, lastname, email
ORDER BY age DESC
) AS rownum
FROM contacts
)
DELETE contacts
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if ($found) {
cd /var/www/.git chown -R mike:mike objects