Skip to content

Instantly share code, notes, and snippets.

@shsdev
shsdev / wdclient.py
Created October 21, 2024 10:16
Webdav client for Nextcloud
"""
This Python module sets up a WebDAV client using the 'webdavclient3' library.
Follow these steps to set up the environment and run this module:
1. Create a new directory for the project:
$ mkdir wdclient
2. Navigate into the directory:
$ cd wdclient/
@shsdev
shsdev / CSIPSTR2_issue.md
Last active October 10, 2024 08:01
CSIPSTR2 issue

An issue was reported by stakeholders concerning requirement CSIPSTR2:

CSIPSTR2: The Information Package root folder SHOULD be named with the ID or name of the Information Package, that is the value of the package METS.xml's root `<mets>` element's `@OBJID` attribute.

Enforcing that the name must be the same as the attribute may cause file system interoperability issues because certain characters used in identifiers may cause errors in specific file systems.

There is a need to make sure that the translation of the packages' identifier into a file or folder name is conformant with constraints in different types of commonly used file systems, such as NTFS or FAT32 on Windows, Ext4 or XFS on Linux etc.

Our recommendation is to use Kunze's section 3 of the pair tree specification as the starting point:

@shsdev
shsdev / simple_pseudonymization.py
Last active November 19, 2024 08:40
Simple pseudonymization of a column with name values in a pandas dataframe
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Requires pandas and numpy
# pip3 install pandas numpy
# and the Faker package:
# pip3 install Faker
from faker import Faker
import numpy as np
@shsdev
shsdev / ConcurrentExecutionUsingFutures.scala
Created March 12, 2015 14:03
Use execution context to execute concurrent processes using futures. Number of threads is defined in a fixed thread pool. Blocking for a maximum number of minutes, see http://docs.scala-lang.org/style/naming-conventions.html for non-blocking alternative.
import java.util.concurrent.Executors
import scala.concurrent.Await
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.concurrent.duration.DurationInt
/**
* Use execution context to execute concurrent processes using futures.
* Number of threads is defined in a fixed thread pool.
* Blocking for a maximum number of minutes, see http://docs.scala-lang.org/style/naming-conventions.html
@shsdev
shsdev / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@shsdev
shsdev / CsvCreator.java
Created April 29, 2014 07:20
Using jackson-dataformat-csv to create CSV file out of POJOs
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;