Skip to content

Instantly share code, notes, and snippets.

@botris
botris / .env.local
Created Sep 18, 2020
Drupal/legacy table to Symfony Doctrine entity
View .env.local
DATABASE_URL=mysql://db:db@localhost/db?sslmode=disable&charset=utf8mb4&serverVersion=5.7
DATABASE_DRUPAL_URL=mysql://db:db@localhost/legacy?sslmode=disable&charset=utf8mb4&serverVersion=5.7
@botris
botris / entity.php
Created Sep 10, 2020
API Platform - handle 2 endpoints on the same entity
View entity.php
<?php
/**
* @ApiResource(
* itemOperations={
* "get"={
* "path"="/entity/{id}",
* "openapi_context" = {
* "parameters" = {
* {
@botris
botris / README.txt
Last active Jan 8, 2019
Ubuntu 18.10 switch php7.1 and php7.2
View README.txt
ATM php7.2 is current to Ubuntu.
Add php7.1 through:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
sudo apt-get install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-dev php7.1-curl php7.1-xml
Switch with script
@botris
botris / install.md
Last active Oct 15, 2018
Install Contenta.
View install.md

Installing https://www.contentacms.org/ on OS X.

Check current composer version

composer --version

If lower then 1.7 update:

composer self-update
@botris
botris / test_mysql.md
Created Mar 2, 2018
Testing MySQL speed on OS X
View test_mysql.md
  • Install sysbench:
brew install sysbench
  • Create a new database called "dbtest"
  • Find the test file:
mdfind oltp_read_only.lua
  • Prepare test:
@botris
botris / gist:0ce3477e0f129d98604d
Created Feb 3, 2015
Get table sizes of MySQL DB, sorted by biggest to smallest
View gist:0ce3477e0f129d98604d
SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "DATABASENAME"
ORDER BY (data_length + index_length) DESC;
View addsqlite.sh
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git
@botris
botris / gist:9ec9cb7023ebfd4c3551
Created Nov 28, 2014
Drupal to Drupal migrate, migrate associated terms
View gist:9ec9cb7023ebfd4c3551
<?php
/*
* Extending DrupalNode5Migration (or 6) migrating the correct terms
* - Add the source migration and source tid
* - Declare default value
*/
$this->addFieldMapping('field_tags', '3')
->sourceMigration('Tags');
$this->addFieldMapping('field_tags:source_type')
->defaultValue('tid');