Skip to content

Instantly share code, notes, and snippets.

View J535D165's full-sized avatar

Jonathan de Bruin J535D165

View GitHub Profile
@J535D165
J535D165 / tasks.json
Last active March 22, 2024 09:46
Start ASReview LAB development environment
{
"version": "2.0.0",
"tasks": [
{
"label": "startBackendServer",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": ["-m",
"flask",
"run",
@J535D165
J535D165 / keyword_abstract_ris.py
Created October 26, 2022 13:58
Add keywords to the abstract field of a RIS file
import rispy
entries_new = []
with open('test.ris', 'r') as bibliography_file_in:
entries = rispy.load(bibliography_file_in)
for entry in entries:
entry_new = entry.copy()
if "keywords" in entry:
@J535D165
J535D165 / datapublisher_from_doi.py
Last active August 10, 2022 13:37
Get the publisher (or any variables) from a DOI via DataCite
import xml.etree.ElementTree as ET
import requests
# curl -LH "Accept: application/vnd.datacite.datacite+xml" https://doi.org/10.34894/KEIQRD
def get_datapublisher_from_doi(doi):
"""Get the publisher from the DOI.
Arguments
@J535D165
J535D165 / url_from_doi.py
Created August 10, 2022 12:30
Resolve the URL of the DOI
import requests
def get_url_from_doi(doi):
"""Get the url from the DOI.
Arguments
---------
doi: str
The DOI to find the url for.
@J535D165
J535D165 / run_asreview_simulations_v0.sh
Last active May 22, 2022 15:05
Run simulations with ASReview LAB v0 and v1 with different models
DATASET="van_de_schoot_2017"
QUERY_STRATEGIES=('max_random' 'max_uncertainty' 'max' 'uncertainty' 'random')
# ('max_random' 'max_uncertainty' 'max' 'uncertainty' 'random' 'cluster')
for qs in "${QUERY_STRATEGIES[@]}"
do
asreview simulate benchmark:${DATASET} -q $qs --seed 535 --init_seed 535 -s ${DATASET}_${qs}.h5
asreview plot recall ${DATASET}_${qs}.h5 -o ${DATASET}_${qs}_recall.png
@J535D165
J535D165 / gitignore.md
Last active July 28, 2020 08:54
Git clean repo with respect to gitignore

Clean repo with respect to .gitignore file:

git rm -r --cached .
git add . 
git commit -m "Clean with respect to .gitignore"

Configure a global .gitignore file:

git config --global core.excludesfile ~/.gitignore_global
@J535D165
J535D165 / crop_resize.py
Created January 7, 2018 11:28
crop and resize numpy array
from scipy import interpolate
def crop_and_resample_2darray(arr, x_crop, y_crop, resample, *args, **kwargs):
"""Crop a 2darray and resize the data"""
len_x_crop = x_crop[1]-x_crop[0]
len_y_crop = y_crop[1]-y_crop[0]
arr_crop = arr[x_crop[0]:x_crop[1], y_crop[0]:y_crop[1]]
f = interpolate.interp2d(np.arange(len_y_crop),
@J535D165
J535D165 / flickr_download.py
Created January 26, 2020 21:23
Simple Python3 script to download all your photos from your Flickr profile
"""Flickr photo downloader.
Get credentials for the Flickr API from
https://github.com/alexis-mignon/python-flickr-api/wiki/Flickr-API-Keys-and-Authentication
# a = flickr_api.auth.AuthHandler()
# perms = "read" # set the required permissions
# url = a.get_authorization_url(perms)
# <rsp stat="ok">
@J535D165
J535D165 / .gitconfig
Last active November 11, 2019 08:01
Git alias configuration
[alias]
st = status
cm = commit -m
co = checkout
master = checkout master
br = branch
branches = branch -a
remote-tags = ls-remote --tags origin
@J535D165
J535D165 / release.sh
Last active October 21, 2019 11:21
Build a release of the latest software version
echo "Give a new version number (without v prefix)"
read version_tag
# create git tag
git tag -a "v${version_tag}" -m "Version ${version_tag}"
git push origin --tags
# reader pdf from markdown README.
pandoc README.md -o README.pdf