Skip to content

Instantly share code, notes, and snippets.

View achraf-jeday's full-sized avatar
🏠
Working from home

Achraf Jeday achraf-jeday

🏠
Working from home
View GitHub Profile
@achraf-jeday
achraf-jeday / delete_content_entities.d8.php
Created April 7, 2020 15:38 — forked from Jaesin/delete_content_entities.d8.php
Delete all content entities in Drupal 8.
<?php
// Delete all nodes.
entity_delete_multiple('node', \Drupal::entityQuery('node')->execute());
// Delete all files.
entity_delete_multiple('file', \Drupal::entityQuery('file')->execute());
// Delete all taxonomy terms.
entity_delete_multiple('taxonomy_term', \Drupal::entityQuery('taxonomy_term')->execute());
@achraf-jeday
achraf-jeday / module.php
Created April 6, 2020 05:56 — forked from modcab/module.php
Drupal 8 - Get MIME type from file uri.
<?php
$mime = \Drupal::service('file.mime_type.guesser')->guess($uri);
@achraf-jeday
achraf-jeday / Postgres_useful_commands.txt
Last active April 20, 2020 01:58
Postgres useful commands
Connect to the Postgres server:
psql postgres postgres
Create a database:
CREATE DATABASE drupal_legacy;
Connect to a database:
\c drupal_legacy
List all tables:
docker events&
Then run your failing docker run ... command. Then you should see something like the following on screen:
2015-12-22T15:13:05.503402713+02:00 xxxxxxxacd8ca86df9eac5fd5466884c0b42a06293ccff0b5101b5987f5da07d: (from xxx/xxx:latest) die
Then you can get the startup hex id from previous message or the output of the run command. Then you can use it with the logs command:
docker logs <copy the instance id from docker events messages on screen>
@achraf-jeday
achraf-jeday / docker4drupal.txt
Last active January 8, 2020 10:28
We are going to use composer to create a codebase with the latest version of Drupal 8.
We are going to use composer to create a codebase with the latest version of Drupal 8 or 7:
Drupal 8:
composer create-project drupal-composer/drupal-project:8.x-dev docker_drupal --stability dev --no-interaction
Drupal 7:
composer create-project drupal-composer/drupal-project:7.x-dev docker_drupal --no-interaction
Then we are going to clone the latest version of docker4drupal and remove the .git folder from it:
git clone git@github.com:wodby/docker4drupal.git docker_drupal_server
@achraf-jeday
achraf-jeday / PHP_CodeSniffer
Last active February 13, 2020 13:56
PHP_CodeSniffer phpcs How to install PHP_CodeSniffer and to check drupal code (.module)
To install PHP_CodeSniffer and to check drupal code type the following (composer is required system-wide):
First make sure you have the composer bin dir in your PATH. The default value is ~/.composer/vendor/bin/, but you can check the value that you need to use by running:
composer global config bin-dir --absolute
echo $PATH
PATH=$PATH:~/.composer/vendor/bin/
echo $PATH
Add the following to the /home/<user>/.profile file:
@achraf-jeday
achraf-jeday / drush.sh (Drupal 7)
Last active January 7, 2020 14:20
Drupal 7 drush commands.
drush fra -y
drush fr-all --force -y
drush fl
drush cc all
drush mmmff --all
drush rr
drush updb -y
drush uli
@achraf-jeday
achraf-jeday / Login.vue
Created September 23, 2019 14:25
Vuejs Drupal 8 Login
<template>
<div class="login">
<div class="container">
<form id="loginForm" v-on:submit.prevent="login">
<div class="col-12 content-block">
<div class="content-block-text">
<h2>Aanmelden</h2>
</div>
<div class="content-block-text">
<hr>
@achraf-jeday
achraf-jeday / Login.html
Last active September 9, 2019 14:34
Javascript Linkedin Social Login Button for OAuth.io https://oauth.io/, https://www.linkedin.com/developers/
<html>
<header>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdn.rawgit.com/oauth-io/oauth-js/c5af4519/dist/oauth.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-social/4.12.0/bootstrap-social.min.css">
</header>
<body>
@achraf-jeday
achraf-jeday / slave.sh
Last active October 4, 2019 16:01
Jenkins deployment script (Drupal 8 and Vue.js)
#!/bin/bash
cd /home/ubuntu/docker
sudo rm -rf dhm-it-docker-backup/
cp -r dhm-it-docker dhm-it-docker-backup
datetime=$(date +"%Y_%m_%d_%I_%M_%p")
docker exec dhmit_mariadb /usr/bin/mysqldump -u dhmit --password=dhmit123 drupal > /home/ubuntu/docker/dhm-it-docker-backup/docker/etc/mysql/$datetime.sql
cd dhm-it-docker
docker-compose stop
docker-compose rm -f
docker volume rm $(docker volume ls -q)