Skip to content

Instantly share code, notes, and snippets.

aws s3 ls s3://${BUCKET} --recursive | awk '{print "http://${DOMAIN_NAME}/"$4 }'
// Not valid JSON due to comments.
// The majority of the fields are missing.
{
"messageHeader": {
"id": "9e8f3cfc-29c2-11e7-93ae-92361f002671",
// Values here are different from the documentation.
"messageType": "MetadataRecordCreate"
@alanmackenzie
alanmackenzie / scrape_datacite_doi.py
Created March 20, 2017 16:22
DOI to institution look up
"""
Credits: Carl Wilson (Open Preservation Foundation)
Using the search root for datacite: https://search.datacite.org/data-centers?member-id=bl&page=
I iterate through the data centres (in this case those that are BL assigned), then for each data centre I visit the
works page, e.g. https://search.datacite.org/data-centers/bl.ads and cycle through the works. I stop
(usually on the first) when I can scrape the doi from something like
https://doi.org/10.15124/19B43AA8-744A-404B-A8FF-7B0F931BF6D3 where the 3rd part of the URL is the DOI, in this case
for York University.
python -t -t -m py_compile file.py
@alanmackenzie
alanmackenzie / linux-kconfig-grep
Last active January 5, 2016 23:47
Hate it when you can't find the right menu tree for an option in gconfig.
grep -A 25 -R --include='Kconfig' 'LOCALVERSION_AUTO' *
@alanmackenzie
alanmackenzie / delete-git-branch-and-tags.sh
Last active August 29, 2015 14:05
Delete git branches or tags based on string matching.
# Example: ./delete-git-branch-and-tags.sh sprint
# @TODO: Handle multiple remote repositorys.
SEARCH="${1}"
for i in $(git tag | grep "${SEARCH}");
do
git tag -d "${i}"
git push origin ":refs/tags/${i}"
done
@alanmackenzie
alanmackenzie / drupal-user-support-query.sql
Last active August 29, 2015 14:05
Editorial friendly user support SQL query for the standard Drupal 7 database schema.
SELECT
uid,
name,
mail,
FROM_UNIXTIME(created) AS 'account created',
FROM_UNIXTIME(access) AS 'last access',
FROM_UNIXTIME(login) AS 'last login'
FROM users
WHERE mail = 'example@example.com'\G
@alanmackenzie
alanmackenzie / drupal-theme-registry-template-search.sh
Last active December 31, 2015 03:49
Search a Drupal installations theme registry for matching template files
drush php-eval "print_r(theme_get_registry());" | grep "${TEMPLATE_SEARCH_MATCH}"
@alanmackenzie
alanmackenzie / info-str-replace.sh
Created December 11, 2013 15:12
Drupal info file string replace.
for i in $(find . -name *.info); do sed -i 's/target/replace/g' $i; done
@alanmackenzie
alanmackenzie / search-api-example.php
Created November 14, 2013 15:26
Drupal Search Api Custom Search Example
<?php
$server = search_api_server_load('acquia_search_solr_server');
$index = search_api_index_load('node_index');
$query = new SearchApiQuery($index);
$query->condition('type', 'article');
$results = $query->execute();