Skip to content

Instantly share code, notes, and snippets.

@abubelinha
abubelinha / dspace6-post-item-rest.md
Created November 27, 2023 13:15 — forked from alanorth/dspace6-post-item-rest.md
POSTing items to the DSpace 6 REST API

POSTing an item to /collections

First log in to get the JSESSIONID cookie and then post the item (I'm using httpie instead of curl):

$ http -f POST https://dspacetest.cgiar.org/rest/login email=aorth@mjanja.ch password=fuuuu
$ http https://dspacetest.cgiar.org/rest/status Cookie:JSESSIONID=EABAC9EFF942028AA52DFDA16DBCAFDE
$ http POST https://dspacetest.cgiar.org/rest/collections/f10ad667-2746-4705-8b16-4439abe61d22/items Cookie:JSESSIONID=EABAC9EFF942028AA52DFDA16DBCAFDE < item-object.json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
@abranhe
abranhe / crown.edited.svg
Last active July 12, 2022 08:45
Colored Font Awesome Icon on READMEs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
library(tidyverse)
# 2017 monthly
x <- tempfile("col")
dir.create(x)
download.file("https://download.catalogueoflife.org/col/monthly/2017-02-27_dwca.zip", file.path(x, "dwca.zip"))
unzip(file.path(x, "dwca.zip"), exdir = x)
fs::dir_ls(x)
taxa <- readr::read_tsv(file.path(x, "taxa.txt"), guess_max=1e6, quote="", col_types = readr::cols(.default = "c"))
taxa %>% filter(specificEpithet == "sapiens", taxonomicStatus == "accepted name", genus=="Homo")
@rsimon
rsimon / annotorious-opencv-find-contours.js
Last active March 1, 2024 08:00
Sample code for AnnotoriousOSD that automates polygon selection by tracing contours in the selected image section.
import OpenSeadragon from 'openseadragon';
import * as Annotorious from '@recogito/annotorious-openseadragon';
import '@recogito/annotorious-openseadragon/dist/annotorious.min.css';
/*************************************************************************
*
* Basic concept for this is from the official OpenCV docs:
* https://docs.opencv.org/3.4/dc/dcf/tutorial_js_contour_features.html
*
@alanorth
alanorth / dspace6-post-item-rest.md
Last active November 27, 2023 18:08
POSTing items to the DSpace 6 REST API

POSTing an item to /collections

First log in to get the JSESSIONID cookie and then post the item (I'm using httpie instead of curl):

$ http -f POST https://dspacetest.cgiar.org/rest/login email=aorth@mjanja.ch password=fuuuu
$ http https://dspacetest.cgiar.org/rest/status Cookie:JSESSIONID=EABAC9EFF942028AA52DFDA16DBCAFDE
$ http POST https://dspacetest.cgiar.org/rest/collections/f10ad667-2746-4705-8b16-4439abe61d22/items Cookie:JSESSIONID=EABAC9EFF942028AA52DFDA16DBCAFDE < item-object.json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
@guss77
guss77 / Makefile
Created September 22, 2020 20:57
MariaDB update table with UUID
COMPOSE := docker-compose -p demouuid
start:
$(COMPOSE) up -d
sleep 3
while $(COMPOSE) ps | grep -q database; do \
$(COMPOSE) logs 2>/dev/null| grep -q 'MySQL init process done.' && break;\
$(COMPOSE) logs 2>/dev/null| grep -i error && break;\
$(COMPOSE) ps | grep -q Exit && break;\
done
from docx import Document
from docx.shared import Cm, Pt
article_1 = """Bayern Munich came out on top in a thrilling German Cup final, beating Bayer Leverkusen 4-2 to secure its 20th title and remain on course for an historic treble.
David Alaba's stunning free kick and Serge Gnabry's clinical finish gave Bayern a commanding lead heading into half time and Hans-Dieter Flick's side seemingly already had one hand on the trophy.
However, Leverkusen responded well early in the second half and had a golden opportunity to halve the deficit through substitute Kevin Volland."""
article_2 = """(CNN)Liverpool got its Premier League title-winning celebrations back on track with a 2-0 win over Aston Villa, just days after being on the receiving end of a record-equaling defeat.
Many had suggested Jurgen Klopp's side was suffering from something of a hangover during Thursday's 4-0 demolition at the hands of Manchester City -- the joint-heaviest defeat by a team already crowned Premier League champion -- but Liverpool re
@rsimon
rsimon / annotorious-firebase.html
Last active December 16, 2023 20:19
Using Firebase as Annotation Backend for Annotorious
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Annotorious | Firebase Demo</title>
<link href="https://fonts.googleapis.com/css?family=Lato&display=swap" rel="stylesheet">
<style>
html, body {
padding:20px;
margin:0px;
@nickynicolson
nickynicolson / ih-download.py
Created March 24, 2020 15:26
Use the Index Herbariorum API to download data into a simple pandas dataframe
import pandas as pd
from pandas.io.json import json_normalize
import requests
# IH API documented here: https://github.com/nybgvh/IH-API/wiki
url='http://sweetgum.nybg.org/science/api/v1/institutions'
def main():
response = requests.get(url)
results = response.json()
# The JSON format record for an IH record has nested sections - the
@phpfiddle
phpfiddle / fiddle_053877.php
Created September 18, 2019 15:24
[ Posted by Expangea ] PHP preg_match_all xml tags
<?php
$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. <code>Donec sed erat</code> vel diam ultricies commodo.
Nunc venenatis tellus eu quam suscipit quis fermentum <code>dolor vehicula.</code> fin";
$regex='';
$regex = '#<\s*?code\b[^>]*>(.*?)</code\b[^>]*>#s';
$code = preg_match_all($regex, $text, $matches);
echo $text."<hr>";
echo var_export($matches,true);
?>