Skip to content

Instantly share code, notes, and snippets.

@wouldhide
wouldhide / .Dockerfile
Created June 9, 2022 20:36
Laravel Vapor docker runtime with MS SQL support. msodbc, mssql-tools, sqlsrv, pdo_sqlsrv
FROM laravelphp/vapor:php81
# Add the `unixodbc-dev` library
RUN apk --update add unixodbc-dev
# Download and install MSODBCSQL packages
# https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16#alpine18
RUN curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/msodbcsql18_18.0.1.1-1_amd64.apk
RUN curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/mssql-tools18_18.0.1.1-1_amd64.apk
RUN apk add --allow-untrusted msodbcsql18_18.0.1.1-1_amd64.apk
@wouldhide
wouldhide / external-links-to-new-tab
Created January 7, 2022 18:25
Add target='_blank' to all external links on a page
# My user as owner
sudo chown -R my-user:www-data /path/to/your/laravel/root/directory
# Then both your user and the webserver permissions
sudo find /path/to/your/laravel/root/directory -type f -exec chmod 664 {} \;
sudo find /path/to/your/laravel/root/directory -type d -exec chmod 775 {} \;
# Rights for the web server to read and write to storage and cache. Run it in you laravel project root
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
@wouldhide
wouldhide / meta-tags.md
Created December 7, 2017 11:12 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@wouldhide
wouldhide / mysql-search-in-json-field.sql
Created October 7, 2017 18:37
Search in MySQL JSON field
# select `name` from tags;
# {"en": "Lorem Ipsum", "hu": "Lorem Ispsum"}
select JSON_EXTRACT(`name`, "$.en") as `name`
from tags
where lower(JSON_EXTRACT(`name`, "$.en")) like "%ipsum%";
# feel free to add new rows for other special characters
UPDATE table_to_update SET `slug` = lower(field_to_slugify),
slug = replace(slug, '.', ' '),
slug = replace(slug, ',', ''),
slug = replace(slug, '\'', '-'),
slug = replace(slug, '/', '-'),
slug = replace(slug,'á','a'),
slug = replace(slug,'é','e'),
slug = replace(slug,'í','i'),
slug = replace(slug,'ó','o'),
// put snippet in app/Providers/AppServiceProvider boot method
Blade::extend(function ($value, $compiler) {
$value = preg_replace('/(?<=\s)@switch\((.*)\)(\s*)@case\((.*)\)(?=\s)/', '<?php switch($1):$2case $3: ?>', $value);
$value = preg_replace('/(?<=\s)@endswitch(?=\s)/', '<?php endswitch; ?>', $value);
$value = preg_replace('/(?<=\s)@case\((.*)\)(?=\s)/', '<?php case $1: ?>', $value);
$value = preg_replace('/(?<=\s)@default(?=\s)/', '<?php default: ?>', $value);
$value = preg_replace('/(?<=\s)@break(?=\s)/', '<?php break; ?>', $value);
return $value;
});