Skip to content

Instantly share code, notes, and snippets.

View tgfrerer's full-sized avatar

Tim Gfrerer tgfrerer

View GitHub Profile
@tgfrerer
tgfrerer / 1-Yubikey_session_lock.md
Last active June 14, 2023 11:05 — forked from jhass/1-Yubikey_session_lock.md
Lock (Gnome) session when removing Yubico U2F key

Setup

  1. Copy 99-u2f_lock_screen.rules to /etc/udev/rules.d.
  2. Copy gnome_lock_all_sessions to /usr/local/bin.
  3. Mark gnome_lock_all_sessions as executable: chmod +x /usr/local/bin/gnome_lock_all_sessions
  4. Reload udev: udevadm control -R

Note

You might have to update the ENV{ID_MODEL_FROM_DATABASE} value in 99-u2f_lock_screen.rules to match the type of Yubikey that you are using. You can query it by issuing:

@tgfrerer
tgfrerer / README.md
Last active December 4, 2023 14:57
Generate bitonic merge sort network based on number of sortable items n, and workgroup size.

This command-line utility generates a bitonic merge sort network based on number of sortable items n, and workgroup size.

Choose workgroup size to be ==n for an ideal sorting network. Number of sortable elements n must be power of two.

In-depth discussion, GPU implementation, and context for this code: https://poniesandlight.co.uk/reflect/bitonic_merge_sort/

#include <iostream>
using namespace std;
#define COMPONENT( x ) \
struct x { \
static constexpr auto type_id = #x; \
}
COMPONENT( ComponentA );
@tgfrerer
tgfrerer / mip.cpp
Created November 27, 2018 17:09
Calculate miplevels for image input data
// Generate mipmap from input data
// adapted from https://github.com/ValveSoftware/openvr/blob/1fb1030f2ac238456dca7615a4408fb2bb42afb6/samples/hellovr_vulkan/hellovr_vulkan_main.cpp#L2271
template <typename PixelType, const size_t numChannels>
static void generate_mipmap( const PixelType *pSrc, PixelType *pDst, uint32_t const nSrcWidth, uint32_t const nSrcHeight, uint32_t *pDstWidthOut, uint32_t *pDstHeightOut ) {
*pDstWidthOut = nSrcWidth / 2;
if ( *pDstWidthOut <= 0 ) {
*pDstWidthOut = 1;
}
*pDstHeightOut = nSrcHeight / 2;
@tgfrerer
tgfrerer / drawfrustum.cpp
Last active February 9, 2018 15:40
simplified method to draw camera frustum in oF
void ofCamera::drawFrustum(const ofRectangle & viewport) const {
ofPushMatrix();
// In World Space, the camera frustum is the "capped pyramid" which
// contains everything which can be seen from a camera.
//
// In Clip Space, the frustum is defined as a box with dimensions: -1, -1, -1 to +1, +1, +1.
//
// Much simpler.
//
@tgfrerer
tgfrerer / main.cpp
Created July 28, 2017 17:04
minimal demo app showing camera frustum drawing
#include "ofMain.h"
class ofApp: public ofBaseApp {
ofEasyCam cam[2];
size_t activeCam = 1;
public:
void ofApp::setup() {
cam[0].setupPerspective( false, 30, 20.f, 500.f );

Keybase proof

I hereby claim:

  • I am tgfrerer on github.
  • I am tgfrerer (https://keybase.io/tgfrerer) on keybase.
  • I have a public key ASCROk4gEgu9DxcKrfoJ5u3A0OOIhkRcZ7Z2hncyv4_l7go

To claim this, I am signing this object:

#include "ofMain.h"
ofPolyline polyline;
uint64_t pointFlags = -1;
class ofApp : public ofBaseApp
{
public:
#include "ofMain.h"
class ofApp : public ofBaseApp {
ofVboMesh mSphere;
ofNode mNode;
ofNode mNode1;
ofNode mNode2;
#include "ofMain.h"
#include "ofApp.h"
class ofApp : public ofBaseApp {
ofEventListener listener;
ofParameter<float> param;
public:
void setup() {