Skip to content

Instantly share code, notes, and snippets.

View slint's full-sized avatar

Alex Ioannidis slint

View GitHub Profile
@slint
slint / zenodo-restricted-curl.sh
Created April 15, 2019 08:54
Zenodo restricted access REST API usage
# Let's assume you have received via email the secret link:
# https://zenodo.org/record/123456?token=<LONG-TOKEN-HERE>
# Make a curl request, but store the cookies in a file:
$ curl --cookie-jar zenodo-cookies.txt "https://zenodo.org/record/123456?token=<LONG-TOKEN-HERE>"
...HTML output...
# Use the cookie file to make subsequent requests to the api:
$ curl --cookie zenodo-cookies.txt "https://zenodo.org/api/records/123456"
{
@slint
slint / record-v1.0.0.json
Created March 21, 2019 15:03
nested record example
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://zenodo.org/schemas/records/record-v1.0.0.json",
"properties": {
"formats": {
"type": "array",
"items": {
"type": "object",
"properties": {
"width": {
@slint
slint / Vagrantfile
Last active March 13, 2019 10:20
Invenio Bootcamp Vagrant setup
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
# Enable GUI
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
# Create a synced folder
yadayada
alabaster==0.7.10
apipkg==1.4
appnope==0.1.0
attrdict==2.0.0
attrs==17.4.0
Babel==2.5.3
certifi==2018.1.18
chardet==3.0.4
check-manifest==0.36
# Fetch events from DataCite
curl -G https://api.datacite.org/events \
-d source-id=crossref \
-d relation-type-id=references \
-d prefix=10.5281 > datacite-0.json
# Get next page from ".links.next" link
curl "$(jq -r .links.next datacite-0.json)" > datacite-1.json
# Fetch events from Crossref
curl -G https://api.eventdata.crossref.org/v1/events \
  1. Create an access token at "https://zenodo.org/account/settings/applications/tokens/new/" with the "deposit:write" and "deposit:actions" scopes, and keep it somewhere safe (we'll refer to this token as ZENODO_TOKEN)
  2. Create your deposit via the web interface at "https://zenodo.org/deposit/new", fill in the minimum metadata (title, authors, description, access rights and license) and click "Save".
  3. On your browser's URL, you will now see the deposit ID in the form "https://zenodo/deposit/".
  4. Next step is to get the file upload URL. Via curl (or your HTTP client of preference) you can do:
$ # Store the Zenodo token in an envionrment variable
$ read -s ZENODO_TOKEN
$ curl "https://zenodo.org/api/deposit/depositions/222761?access_token=${ZENODO_TOKEN}"
{ ...  
from sickle import Sickle
harvester = Sickle('https://zenodo.org/oai2d')
records_iterator = harvester.ListRecords(
metadataPrefix='oai_datacite', # or 'oai_dc'
set='user-kios-coe')
for record in records_iterator:
print(record.header.identifier)
# oai:zenodo.org:1039010
# oai:zenodo.org:1037132
@slint
slint / sushi-swagger.json
Created July 23, 2018 09:44
SUSHI-Lite Swagger Schema
{
"swagger": "2.0",
"info": {
"title": "COUNTER_SUSHI-Lite API",
"description": "The COUNTER_SUSHI-Lite API represents a RESTful implementation of SUSHI automation intended to returns COUNTER reports and snippets of COUNTER usage in JSON format",
"termsOfService": "",
"contact": {
"name": "NISO SUSHI Standing Committee",
"url": "http://www.niso.com/workrooms/sushi",
"email": "[email protected]"
{
"date_detection": false,
"numeric_detection": false,
"properties": {
"$schema": {
"type": "string",
"index": "not_analyzed"
},
"grants": {
"type": "object",
#!/bin/bash
# TODO: Parse arguments...
GITLAB_PIPELINE_TRIGGER_URL=https://gitlab.cern.ch/api/v4/projects/33605/trigger/pipeline
SERVICE_NAME=asclepias
if [ ! -z $BRANCH_NAME ]; then
# run commands to checkout a branch
echo "Checkout branch ${BRANCH_NAME}"
git checkout $BRANCH_NAME;