Skip to content

Instantly share code, notes, and snippets.

@scottalan
scottalan / lambda.yml
Created June 11, 2019 22:08
Serverless : Examples
# 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
@scottalan
scottalan / results.js
Last active January 8, 2019 23:56
for...in
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 October 12, 2018 14:47
SQL : Get database size
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 June 7, 2018 17:05
Config Overrides Example

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 15:09
mysql : query
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 April 16, 2018 14:23
Jenkins : Negative lookahead : Ignore branches
^(?!.*develop|.*master|.*wip).*$
:^((?!develop).)*$
# 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
@scottalan
scottalan / commands.sh
Created April 3, 2018 16:16
Docker Inspect
# 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 February 27, 2018 20:18
Updating Lightning from 2.1.5 to 3.0.2
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 August 29, 2017 21:36 — forked from travist/gist:1677353
Determine the diff provided a Story ID.
git log\
| grep "Merge pull request.*{INSERT STORY ID HERE}" -B 5\
| awk '{\
if ($1=="commit") {\
print system("git diff " $2 "^ " $2);\
}\
}'