Skip to content

Instantly share code, notes, and snippets.

@bmichalski
bmichalski / drop_all_mongo_databases_with_prefix.js
Created September 19, 2022 12:43
Drop all mongo databases with prefix
const prefix = '<prefix>';
db.getMongo().getDBNames().forEach((dbName) => {
if (dbName.indexOf(prefix) === 0) {
db.getMongo().getDB(dbName).dropDatabase();
}
});
@bmichalski
bmichalski / kill-all-php-fpm.sh
Created October 28, 2016 09:58
Kill all php-fpm processes
sudo kill -9 `sudo ps -ef | grep php-fpm | grep -v grep | awk '{print $2}'`
@bmichalski
bmichalski / php_limitations_set_time_limit_workaround.php
Last active October 13, 2015 14:50
PHP limitations set_time_limit workaround
<?php
$isDefunct = function ($result) {
return preg_match('/<defunct>$/', $result);
};
$getProcessInfo = function ($pid) {
return exec("ps --pid $pid | tail -n +2");
};
@bmichalski
bmichalski / create_entries.json
Last active September 28, 2015 18:44
ElasticSearch test expression script with aggregation and sub aggregations
{
"color": "black",
"testVal": 25,
"testQuantity": 5
}
@bmichalski
bmichalski / create_entries.json
Created September 28, 2015 18:15
ElasticSearch test expression script with aggregation
{
"testVal": 25,
"testQuantity": 5
}
@bmichalski
bmichalski / SharedDoctrineConnectionsClient
Last active September 13, 2015 12:40
Symfony2 functional testing using Doctrine, sharing connections between requests
namespace BenMichalski\AppBundle\Test\Client;
/**
* Heavily inspired by http://alexandre-salome.fr/blog/Symfony2-Isolation-Of-Tests
*/
class SharedDoctrineConnectionsClient extends BaseClient
{
/**
* @var array
*/
@bmichalski
bmichalski / gist:aa53fc06ac43bfc1229d
Created June 13, 2015 16:14
Load a MySQL dump into a running Docker MariaDB container.
docker run -it \
-v /home/redmine/docker-mariadb-tools/exchange:/root/exchange \
--link redmine-mariadb:redmine-mariadb bmichalski/mariadb-tools \
bash -c "mysql -u root --host redmine-mariadb < /root/exchange/test"