Skip to content

Instantly share code, notes, and snippets.

@nerdstrom
nerdstrom / readbytes.java
Created January 10, 2019 19:18
read file (from downloads directory, or resources) as byte array on android
// reads a files content by a given filename and returns it as a byte[]
// returns null if there are problems reading the file
public byte[] readBytesFromFileInDownloadsDir(String filename) {
if(Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
// we look for the filename in the "Downloads" directory on the sdcard
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS);
File file = new File(path, filename);
@nerdstrom
nerdstrom / valheim.service
Last active January 13, 2022 16:58
Valheim dedicated server systemd unit file
# make sure to adjust ALL paths and user/group in the service file (also the ones under "Security and Sandboxing")
[Unit]
Description=Valheim dedicated server
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target
[Service]
Environment="LD_LIBRARY_PATH=/home/steam/servers/valheim/linux64"