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 / .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 / .htaccess
Last active January 5, 2022 09:24
Deny .git Directory
RewriteRule "(^|/)\.(?!well-known\/)" - [F]
@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 / 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 / countries.js
Created January 5, 2022 09:38
Countries List
countries: [
{
label: 'Afghanistan',
value: 'AF',
default: ''
},
{
label: 'Aland Islands',
value: 'AX',
default: ''
@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 / 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 / related-entries.twig
Created January 5, 2022 09:44
Related Entries in Craft CMS #craftcms
@elfacht
elfacht / craft-rss.twig
Created January 5, 2022 09:47
Craft CMS RSS Template #craftcms
{% header "Content-Type: application/rss+xml" %}
{% if not craft.app.config.general.membersOnly %}
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
@elfacht
elfacht / base.js
Created January 5, 2022 09:53
Handlebars Helper
/**
* Returns the base path of the environment
*
* @type {Function}
* @return {String}
*/
var path = require('path');
module.exports = function (context) {
return path.dirname(path.relative(context.data.file.history.toString(), context.data.file.base.toString())) + '/';