Skip to content

Instantly share code, notes, and snippets.

View elfacht's full-sized avatar
🥰
Love code, hate racism

Martin Szymanski elfacht

🥰
Love code, hate racism
View GitHub Profile
@elfacht
elfacht / update-pw.sql
Created January 5, 2022 09:41
Update Craft CMS Admin Password to 'Secret' with Hash #craftcms
UPDATE users SET password='$2y$13$FfVKvo1W1N5Gsba3c19r8uz.x9R5NRQgRu8jmXvOjVCStg1sKGcoW' WHERE id=1;
@elfacht
elfacht / routes-vuejs.php
Created January 5, 2022 09:39
Craft CMS Wildcard Routes for vue.js #craftcms
'<url:(?!api\/).*>' => ['template' => 'index'],
@elfacht
elfacht / countries.js
Created January 5, 2022 09:38
Countries List
countries: [
{
label: 'Afghanistan',
value: 'AF',
default: ''
},
{
label: 'Aland Islands',
value: 'AX',
default: ''
@elfacht
elfacht / craft-routes.php
Created January 5, 2022 09:35
Craft CMS multi-environment routes
$routes = array(
// Default routes
);
$stagingRoutes = array(
'<url:(?!api\/).*>' => ['template' => 'index'],
);
if (strpos(CRAFT_ENVIRONMENT, 'staging') !== false) {
$routes = array_merge($routes, $stagingRoutes);
@elfacht
elfacht / craft-cli.sh
Created January 5, 2022 09:34
Craft CMS CLI Commands #craftcms
# composer install (server)
$ composer install --no-interaction --prefer-dist --optimize-autoloader
# composer nuke
$ rm -rf vendor/ && rm composer.lock && composer clear-cache && composer update
# update
$ ./craft update all
# migrate
@elfacht
elfacht / arrow-fn.twig
Last active January 5, 2022 11:26
Twig Helper #craftcms
{% set over21 = craft.entries.all()|filter(e => e.firstName && entry.age > 21) %}
{% set ages = over21|reduce((curr, prev) => prev|merge(curr.age), []) %}
Over 21: {{ over21|map(e => e.firstName)|join(',') }}
Youngest: {{ ages|min }}
@elfacht
elfacht / general.sh
Last active January 5, 2022 09:19
Asset Version Number with Nitro #craftcms
# /etc/nginx/craftcms/general.conf
location ~ "^/(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$" {
try_files $uri /$1.$3$is_args$args;
}
@elfacht
elfacht / .htaccess
Last active January 5, 2022 09:24
Deny .git Directory
RewriteRule "(^|/)\.(?!well-known\/)" - [F]
@elfacht
elfacht / .htaccess
Last active January 5, 2022 09:23
htaccess Snippets
############################################
# Force download of specific files
############################################
<Files *.xls>
ForceType application/octet-stream
Header set Content-Disposition attachment
</Files>
<Files *.eps>
ForceType application/octet-stream
Header set Content-Disposition attachment
@elfacht
elfacht / composer-hetzner.sh
Created January 5, 2022 09:08
Install Composer on Hetzner Server
php -d allow_url_fopen=On ../../composer.phar install