Skip to content

Instantly share code, notes, and snippets.

View laceysanderson's full-sized avatar

Lacey-Anne Sanderson laceysanderson

View GitHub Profile
@laceysanderson
laceysanderson / cloner.sh
Last active May 30, 2024 21:53
Provides the git commands for cloning the repos I work with most.
##
## Helps with managing dockers for coding and review.
##
repoKey=$1
issueNum=$2
shortDescrip=$3
branch=$4
@laceysanderson
laceysanderson / dockerBuddy.sh
Last active May 30, 2024 21:53
Provides a number of docker commands for the repos I develop.
##
## Helps with managing dockers for coding and review.
##
action=$1
repoKey=$2
suffix=$3
drupalVer=${4:-10.2.x-dev}
phpVer=${5:-8.3}
#! /bin/bash
## This script will create a docker image and then run it.
## Use the args to set the image/container name.
## Expects to run from the directory you want
## the image build from and to be mounted in the container
repoKey=$1
githubNum=$2
drupalVer=${3:-10.2.x-dev}
phpVer=${4:-8.3}
@laceysanderson
laceysanderson / README.md
Last active December 18, 2023 18:07
Setup a Tripal4 site with test data

The chado data as mapped to content types currently included in the database dump are:

  • Gene: 50
  • mRNA: 75
  • Organism: 6
  • Contact: 7
  • Analysis: 7 (two are of type Genome Assembly and 2 are of type genome annotation)
  • Project: 2 (both of type Genome Project)
  • Publication: 4 (1 is the null pub)
  • Protocol: 3
@laceysanderson
laceysanderson / commands.php
Last active December 11, 2023 18:02
Inserting test data vie drush:php-cli
// First get access to the chado database connection.
$chado = \Drupal::service('tripal_chado.database');
// Create a function to make random strings.
$randomString = function($len = 10) {$word = array_merge(range('a', 'z'), range('A', 'Z')); shuffle($word); return substr(implode($word), 0, $len);};
// Insert a set number of organisms
$total = 5;
$subspecies = 2868; // cvterm_id
for ($i = 1; $i <= $total; $i++) {
@laceysanderson
laceysanderson / commands.php
Created December 4, 2023 22:04
Playing with Tripal entities in drush php:cli
<?php
/**
* These commands are expected to be used in the drush php:cli
* but could likely be wrapped into a drush script or used elsewhere.
*/
// Load all Tripal Content Entities of type gene.
$entities = \Drupal::entityTypeManager()->getStorage('tripal_entity')->loadByProperties(['type' => 'gene']);
git clone https://github.com/tripal/tripal tripal-testing4Stan
cd tripal-testing4Stan
docker build --tag=tripalproject/tripaldocker:drupal10.1.x-dev --build-arg drupalversion='10.1.x-dev' ./
docker run --publish=9001:80 --name=t4 -tid --volume=$(pwd):/var/www/drupal/web/modules/contrib/tripal tripalproject/tripaldocker:drupal10.1.x-dev
docker exec t4 service postgresql start
@laceysanderson
laceysanderson / README.md
Last active July 17, 2023 19:38
Build Docker images for Tripal or Tripal Cultivate

How to use this script

Save a copy of this script somewhere on your computer. I suggest creating a Dockers directory in your home directory to keep everything organized.

cd ~/
mkdir Dockers
cd Dockers
wget https://gist.githubusercontent.com/laceysanderson/9000a2ca2c68a3a9b9eb20f2f5630986/raw/0089f2b37523010d38d494cd5d901566bffa218e/build_testing_tripalDocker.sh
@laceysanderson
laceysanderson / README.md
Last active June 21, 2023 17:21
Build TripalDocker images

How to use this script

Save a copy of this script somewhere on your computer. I suggest creating a Dockers directory in your home directory to keep everything organized.

cd ~/
mkdir Dockers
cd Dockers
wget https://gist.githubusercontent.com/laceysanderson/24f987c942242c2570a1f17f210e24ab/raw/5a1e1cfc3826922476b87656996fc6b6f50b3b78/build_testing_tripalDocker.sh
@laceysanderson
laceysanderson / README.md
Created May 18, 2023 22:03
Checking Chado/Drupal Performance Stats

Checking for Sequential Scans

We want to limit sequential scans which return lots of rows as they are very slow. When you see a high number of sequential scans on a table it lets you know that you are missing an important index.

To check this we are going to look at the pg_stat_all_tables PostgreSQL table which contains one row for each table in the current database and shows statistics about accesses to that specific table. I'm still looking into how to tell the time period over which these stats were collected.

SELECT
 schemaname as schema,