This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# go back to a commit and remove commits ahead | |
git reset --hard 203b24f | |
git push origin HEAD --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stop MySQL Service | |
sudo systmctl stop mysql | |
# Make service directory and give permission to mysql to write | |
sudo mkdir /var/run/mysqld | |
sudo chown mysqld: /var/run/mysqld | |
# Start MySQL manually | |
sudo mysqld_safe --skip-grant-tables --skip-networking & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove utf-8 BOM from ressource "res" | |
// res.charCodeAt(0) === 0xFEFF | res.charCodeAt(0) === 65279 | |
if (res.charCodeAt(0) === 0xFEFF) { | |
res = res.substr(1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -d "releases/${execution.to_revision.revision}" ] && [ "${execution.refresh}" = "true" ]; then echo "Removing: releases/${execution.to_revision.revision}" && rm -rf releases/${execution.to_revision.revision}; fi | |
if [ ! -d "releases/${execution.to_revision.revision}" ]; then echo "Creating: releases/${execution.to_revision.revision}" && cp -dR deploy-cache releases/${execution.to_revision.revision}; fi | |
echo "Checking if packages need to be updated" | |
cmp --silent ./releases/${execution.to_revision.revision}/package.json ./current/package.json || INSTALL_PACKAGES=true | |
if [ $INSTALL_PACKAGES == true ]; then cp -f ./releases/${execution.to_revision.revision}/package.json .; fi | |
if [ $INSTALL_PACKAGES == true ]; then echo "Installing packages" && npm install --production; fi | |
echo "Linking revision packages to cached packages" && cd ./releases/${execution.to_revision.revision} && ln -sfn /var/www/api/node_modules . | |
echo "Linking current to revision: ${execution.to_revision.revision}" | |
rm -f current | |
ln -s releases/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redis | |
docker run --name some-redis -p6379:6379 -d redis redis-server --appendonly yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://levelup.gitconnected.com/the-definite-guide-to-handling-errors-gracefully-in-javascript-58424d9c60e6 | |
class CustomError extends Error { | |
constructor(code = 'GENERIC', status = 500, ...params) { | |
super(...params) | |
if (Error.captureStackTrace) { | |
Error.captureStackTrace(this, CustomError) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias'); | |
if(preg_match('/node\/(\d+)/', $path, $matches)) { | |
$node = \Drupal\node\Entity\Node::load($matches[1]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# https://stackoverflow.com/questions/17750143/catching-stripe-errors-with-try-catch-php-method | |
try { | |
// Use a Stripe PHP library method that may throw an exception.... | |
\Stripe\Customer::create($args); | |
} catch (\Stripe\Error\Base $e) { | |
// Code to do something with the $e exception object when an error occurs | |
echo($e->getMessage()); | |
} catch (Exception $e) { | |
// Catch any other non-Stripe exceptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\Core\Form\FormBase; | |
use Drupal\Core\Form\FormStateInterface; | |
class CustomUserForm extends FormBase { | |
public function buildForm(array $form, FormStateInterface $form_state) { | |
$form['#parents'] = []; | |
$entity = \Drupal::service('entity_type.manager')->getStorage('user')->create(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @codingStandardsIgnoreFile | |
/** | |
* @file | |
* Local development override configuration feature. | |
* | |
* To activate this feature, copy and rename it such that its path plus | |
* filename is 'sites/default/settings.local.php'. Then, go to the bottom of |