Skip to content

Instantly share code, notes, and snippets.

Avatar

Tamas Erdelyi terdelyi

View GitHub Profile
@terdelyi
terdelyi / craft_custom_model_validation.php
Last active Jul 11, 2018
CraftCMS 3 - Custom model validation
View craft_custom_model_validation.php
<?php
// CraftCMS3 is using Yii2 framework which doesn't have a decoupled validator class.
// If you create a dummy model filled with the attributes coming from a POST request
// you can use custom validations for the incoming attributes.
$testPostData = [
'name' => 'Tamas Erdelyi',
'email' => 'no-reply@thisisnotavalidemail.com'
];
@terdelyi
terdelyi / craft_validate_public_user_registration.php
Last active Sep 11, 2021
CraftCMS 3 - Extending the validation on the public user registration form
View craft_validate_public_user_registration.php
<?php
use Craft;
use craft\base\Element;
use craft\elements\User;
use craft\events\ModelEvent;
use yii\base\Event;
@terdelyi
terdelyi / craft_default_permissions.sh
Last active Jul 11, 2018
CraftCMS3 - Fixing default directory permissions
View craft_default_permissions.sh
sudo chgrp -R www-data storage public/cpresources public/uploads
sudo chmod -R ug+rwx storage public/cpresources public/uploads
@terdelyi
terdelyi / SleepTimer.scpt
Last active Mar 7, 2022
If you're watching Netflix in a browser (ex. Chrome) and you need a sleep timer this AppleScript is made for you.
View SleepTimer.scpt
display dialog "When do you want to sleep your computer? (in minutes)" default answer "60"
delay (text returned of the result) * 60
tell application "Google Chrome"
quit
end tell
tell application "Finder"
sleep