Skip to content

Instantly share code, notes, and snippets.

View alex-moreno's full-sized avatar

Alejandro Moreno alex-moreno

View GitHub Profile
@alex-moreno
alex-moreno / concurrency.php
Created November 27, 2020 09:19
Using promise and concurrency in php to trigger multiple requests
foreach ($listOfSites as $site) {
file_put_contents('/tmp/lockprocess.lock','locked');
$url = $site[0];
// Add loop here to iterate if concurrency is bigger than a threshold.
echo "starting ASYNC request for $url" . PHP_EOL;
$promises[] = $client->requestAsync('GET', $url, [
'headers' => [
'User-Agent' => 'AcquiaScrapperBot/0.1',
@alex-moreno
alex-moreno / drush_clear_all.php
Created November 4, 2020 17:43
Execute drush for a given list of sites
<?php
// clearcacheall.php alias/druh >> cacheclear.log
$list_sites = [];
$drush_alias = $argv[1];
// Iterate on them to execute the drush command.
foreach ($list_sites as $site) {
execDrushCommand($site['alias'], $drush_alias);
/**
* Execute drush to fetch users and roles in a given site.
*
* @param [type] $site_alias
* @param [type] $drush_alias
* @return void
*/
function execDrushUserInfo($site_alias, $drush_alias)
{
$php = "/usr/local/bin/php";
@alex-moreno
alex-moreno / lb-webserver.yaml
Created April 28, 2020 09:53
lb-webserver.yaml
apiVersion: v1
kind: Service
metadata:
name: ddev-load-balancer
spec:
type: LoadBalancer
selector:
# Will deliver external traffic to the pod holding each of our containers
app: ddev
ports:
@alex-moreno
alex-moreno / pod-mariadb.yaml
Created April 28, 2020 09:52
pod-mariadb.yaml
apiVersion: v1
kind: Service
metadata:
name: mysqlservice
spec:
ports:
- port: 3306
selector:
app: ddevdb
clusterIP: None
@alex-moreno
alex-moreno / blockstorage-web.yaml
Last active April 28, 2020 09:55
blockstorage-web.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: webserver-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
@alex-moreno
alex-moreno / pod-ddev-webserver.yaml
Created April 28, 2020 09:48
Deploying your DDEV containers in digitalocean
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: ddev-wb
spec:
selector:
matchLabels:
app: ddev
replicas: 1 # tells deployment to run 1 pods matching the template
template:
@alex-moreno
alex-moreno / blockstorage-web.yaml
Created April 28, 2020 09:42
Deploying your DDEV containers in digitalocean
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: webserver-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
<pre><code class="language-php">
<?php
class FileBlobMigration extends Migration {
public function __construct() {
$query = db_select('legacy_file_data', 'f')
->fields('f', array('attachmentid', 'attachmentblob', 'filename', 'file_ownerid'));
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationFile('file', 'MigrateFileBlob');
$this->addFieldMapping('value', 'attachmentblob');
@alex-moreno
alex-moreno / example_node_id_article.sh
Last active September 3, 2016 17:57
Create a new content in Drupal via rest api
curl --include --request POST --user user:pass --header 'Content-type: application/hal+json' --header 'X-CSRF-Token: <obtained from http://example.com/rest/session/token>' http://local.drupal8.com/entity/node?_format=hal_json --data-binary '{"_links":{"type":{"href":"http://local.drupal8.com/rest/type/node/cruise"}},"title":[{"value":"Example node title"}],"type":[{"target_id":"article"}]}'