Skip to content

Instantly share code, notes, and snippets.

View johannez's full-sized avatar

Johannes Schmidt johannez

View GitHub Profile
@johannez
johannez / composer.json
Created August 31, 2020 22:10
Tendril Composer Starter
{
"name": "CLIENT/SITE",
"description": "Custom Wordpress site using Tendril.",
"repositories":[
{
"type":"composer",
"url":"https://wpackagist.org"
}
],
"require": {
@johannez
johannez / allow_email_login.php
Last active February 24, 2021 01:07
Drupal 8 - Allow login by email
<?php
/**
* Implements hook_form_alter().
*/
function MODULE_form_user_login_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
// Allow login with email.
array_unshift($form['#validate'], 'MODULE_user_login_form_validate');
// Change the field label.
$form['name']['#title'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Email or Username');
@johannez
johannez / linux_commands.sh
Created February 26, 2014 18:32
Administration
# Add a user
adduser USERNAME
# Set primary group
usermod -g www-data USERNAME
# Create ssh key
ssh-keygen -t rsa -C "[email protected]"
# Create HTTP password protection
@johannez
johannez / svn_commands.sh
Created February 26, 2014 18:30
Subversion examples
# Remove all .svn folders
rm -rf `find . -type d -name .svn`
@johannez
johannez / git_commands.sh
Created February 26, 2014 18:22
Git commands
# Checkout branch for tracking old school.
git checkout --track -b dev origin/dev
# Undo local commits
git reset --hard
# Tag your release version and push it remote
git tag -a release-1.0 -m "Creating the first official version."
git push --tags origin master
<?php
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$headers = "From: [email protected]\r\n" .
"X-Mailer: php";
if (mail($to, $subject, $body, $headers)) {
echo("<p>Message sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
@johannez
johannez / drupal_local_settings.php
Created October 11, 2013 06:46
Include local settings file for Drupal
<?php
/**
* Include a local settings file if it exists.
*/
$local_settings = dirname(__FILE__) . '/settings.local.php';
if (file_exists($local_settings)) {
include $local_settings;
}
@johannez
johannez / wget_whole_site
Last active August 4, 2016 11:58
Wget a whole site
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains website.org \
--no-parent \
www.website.org/tutorials/html/
@johannez
johannez / wp-gitignore
Last active December 23, 2015 20:39
Wordpress .gitignore file
*~
.DS_Store
*.bak
*.swp
Thumbs.db
wp-config.php
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
@johannez
johannez / laravel-4-check_last_query.php
Last active December 22, 2015 14:48
Check last query in Laravel 4
<?php
$queries = DB::getQueryLog();
$last_query = end($queries);