Skip to content

Instantly share code, notes, and snippets.

View w2sv's full-sized avatar

Janek Zangenberg w2sv

  • Berlin, Germany
View GitHub Profile
@w2sv
w2sv / LoggingPFragment.kt
Created November 1, 2025 21:31
Logging processing PFragment for debugging purposes
import android.content.res.Configuration
import android.graphics.Point
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.fragment.app.FragmentActivity
import processing.android.CompatUtils
@w2sv
w2sv / ProcessingSketch.kt
Last active November 1, 2025 21:27
Incorporating a processing sketch in jetpack compose
import android.view.View
import android.widget.FrameLayout
import androidx.compose.runtime.Composable
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.commitNow
import processing.android.PFragment
import processing.core.PApplet
@w2sv
w2sv / UnpaddedSwitch.kt
Last active June 12, 2024 11:44
Padding-less material3 Switch in Jetpack Compose
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@w2sv
w2sv / Script.java
Created January 8, 2023 12:23
Periodically output averaged FPS in processing PApplet
import processing.core.PApplet;
import com.google.common.collect.EvictingQueue;
public class Sketch extends PApplet{
private final EvictingQueue<Integer> fpsValues = EvictingQueue.create(100);
private int lastFpsOutputSec = -1;
public void draw(){
fpsValues.add((int) frameRate);
@w2sv
w2sv / GetTreeUriPath.kt
Created January 6, 2023 14:14
Get document path corresponding to treeUri on Android
/**
* Way 1
*/
fun treeUriPath(contentResolver: ContentResolver, treeUri: Uri): DocumentsContract.Path? =
DocumentsContract.findDocumentPath(
contentResolver,
DocumentsContract.buildChildDocumentsUriUsingTree(
treeUri,
DocumentsContract.getTreeDocumentId(treeUri)
)
@w2sv
w2sv / install.sh
Last active September 16, 2022 13:58
Setting up tensorflow-gpu on Ubuntu 22.04
# $$$$$$$$$$ Pre-Installation $$$$$$$$$$$$$$$
# Ensure presence of cuda-compatible GPU
lspci | grep -i nvidia # should output something like '01:00.0 3D controller: <YOUR_NVIDIA_GPU_KIND> (rev a1)'
# Ensure gcc being installed
gcc --version
# Optional: install the nvidia cuda toolkit
sudo apt-get update