Skip to content

Instantly share code, notes, and snippets.

@scottalan
scottalan / lambda.yml
Created Jun 11, 2019
Serverless : Examples
View lambda.yml
# This demonstrates how you can provide a custom template for the Content-Type.
# In this example this would be a POST of Content-Type: application/xml
functions:
parseXml:
handler: handler.parseXml
memorySize: 128
events:
- http:
path: "/angler"
method: post
View results.js
const seriesResults = [];
// Original.
for (const key in series.data) {
const seriesID = parseInt(series.data[key].athlinks_series_id, 10);
// Load Series information from the db.
seriesResults.push(this._retrieveSerieInfoDynamodb(seriesID));
}
// Option 1
series.data.map(seriesDataItem => {
@scottalan
scottalan / db-size.sh
Created Oct 12, 2018
SQL : Get database size
View db-size.sh
SELECT table_schema "DB Name", ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" \
FROM information_schema.tables \
GROUP BY table_schema;
@scottalan
scottalan / drupal-config-override.md
Last active Jun 7, 2018
Config Overrides Example
View drupal-config-override.md

Drupal 8 doesn't show the $config overrides in the UI or in the database. In order to check the overrides you need to run the following command replacing the name of the $config you are overriding.

  1. Add your $config override to your settings.php or settings.local.php, etc.

$config['search_api.server.solr_server']['backend_config']['connector_config']['host'] = 'my-new-host.com';

  1. Run the following in the CLI to list the configuration object with the override(s)

rig project run drupal "debug:config search_api.server.solr_server --show-overridden"

@scottalan
scottalan / queries.sh
Last active May 25, 2018
mysql : query
View queries.sh
SELECT table_name AS "Tables", ROUND(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = DATABASE() AND (data_length + index_length) > ${SIZE} ORDER BY (data_length + index_length) DESC;
# This will describe all tables at once.
mysql -N -u${DB_USER} -p${DB_PASSWORD} ${DB_URL} --execute="show tables" | while read table; do mysql -u${DB_USER} -p${DB_PASSWORD} ${DB_URL} --execute="describe $table \G"; done
# Dump each table individually with a limit
mysql -N -h ${DB_URL} -u${DB_USER} -p${DB_PASSWORD} ${DATABASE} --execute="show tables" | while read tablename; do mysqldump -h ${DB_URL} -u${DB_USER} -p${DB_PASSWORD} --where="1=1 LIMIT 10" ${DATABASE} $tablename > $tablename.sql; done
# Dump the first $N number of rows from each table in a single dump
docker run --name mysqldump -it --rm --entrypoint=mysqldump outrigger/mariadb:10.2 -h ${DB_URL} -u${DB_USER} -p${DB_PASSWORD} --opt --where="1=1 LIMIT ${N}" ${DATABASE} | gzip > ${DATABASE}_$(date +%Y-%m
@scottalan
scottalan / regex.txt
Created Apr 16, 2018
Jenkins : Negative lookahead : Ignore branches
View regex.txt
^(?!.*develop|.*master|.*wip).*$
:^((?!develop).)*$
View commands.sh
# Varnish v4.0
# Clear varnish cache
varnishadm "ban req.url ~ .*"
# Example debug for vcl file
std.log("X-AH-Redirect is: " + X-AH-Redirect);
# Tail logs for any debug lines in a VCL
varnishlog -i VCL_Log
View commands.sh
# Find db container ID
DB_CONTAINER_ID=$(docker inspect --format"{{.Id}}" CONTAINER_NAME)
# Path to current log file for container
LOG_PATH=$(docker inspect -f '{{.LogPath}}' CONTAINER_NAME)
@scottalan
scottalan / composer-hell.sh
Last active Feb 27, 2018
Updating Lightning from 2.1.5 to 3.0.2
View composer-hell.sh
Add:
{
"type": "composer",
"url": "https://asset-packagist.org"
},
# Remove: "drupal/core": "~8.3"
# Change: "acquia/lightning": "~2.1.0"
# Remove: "drupal/video_embed_field": "^1.5"
# Remove: "drupal/image_widget_crop": "2.1"
@scottalan
scottalan / gist:6be57f9a9d7af0e1d778634c22177872
Created Aug 29, 2017 — forked from travist/gist:1677353
Determine the diff provided a Story ID.
View gist:6be57f9a9d7af0e1d778634c22177872
git log\
| grep "Merge pull request.*{INSERT STORY ID HERE}" -B 5\
| awk '{\
if ($1=="commit") {\
print system("git diff " $2 "^ " $2);\
}\
}'
You can’t perform that action at this time.