Skip to content

Instantly share code, notes, and snippets.

View dgehriger's full-sized avatar

Daniel Gehriger dgehriger

  • Globus Medical, inc.
  • Lausanne, Switzerland
  • 04:14 (UTC +01:00)
View GitHub Profile
# Minimal GitHub Copilot token generator
# Usage:
# iex (Invoke-RestMethod -Uri 'https://gist.githubusercontent.com/dgehriger/f9fd2fc33b6642fe12da5d85f50f8661/raw/get-copilot-token.ps1')
# Step 1: Start device flow
$deviceCodeResponse = Invoke-RestMethod -Method Post -Uri "https://github.com/login/device/code" -Headers @{
"Accept" = "application/json"
} -Body @{
"client_id" = "01ab8ac9400c4e429b23"
"scope" = "user:email"
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [[[6.62988,46.51945],[6.63629,46.51945],[6.63629,46.51484],[6.62988,46.51484],[6.62988,46.51945]]]
},
"properties": {
"label": "Centre-ville de Lausanne",
"kind": "area",
"precision": "quartier",
@dgehriger
dgehriger / aider_copilot_auth.ps1
Last active December 2, 2025 13:20
Copilot API token for Aider
# GitHub OAuth Token Generator for Aider with Copilot
# This script generates the GitHub OAuth token needed to access Copilot API
#
# Run using `iex (Invoke-RestMethod -Uri ('https://gist.githubusercontent.com/dgehriger/62e0284a5ed55f32bbe22f9a28ddcf39/raw'))`
Write-Host "`n====================================" -ForegroundColor Cyan
Write-Host " Aider Config Script v2.21" -ForegroundColor White
Write-Host "====================================" -ForegroundColor Cyan
# Check if aider is installed
use embassy_sync::channel::{Channel, Sender, Receiver};
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_time::{Duration, Ticker};
use core::sync::atomic::{AtomicUsize, Ordering};
use embedded_hal_async::i2c::{AddressMode, Operation};
// Request ID generator
static REQUEST_ID_COUNTER: AtomicUsize = AtomicUsize::new(0);
fn generate_request_id() -> usize {
@dgehriger
dgehriger / user_config_override.h
Created March 4, 2025 21:20
Tasmota for gPlug-M
#ifndef USE_SCRIPT
# define USE_SCRIPT
#endif
#ifndef USE_SML_M
# define USE_SML_M
#endif
#ifdef USE_RULES
# undef USE_RULES
@dgehriger
dgehriger / sil.txt
Created March 4, 2025 21:07
gPlug-M Meter Script for SIL
>D 48
; Your encryption key
KEY="4cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
; The meter ID
METER_ID="1234567"
; Variables
@dgehriger
dgehriger / gos_nav_proxy.rs
Created February 24, 2025 20:05
Rust SensorHub Proxy
// sensor_hub.rs
use std::sync::Arc;
use std::time::{SystemTime, Duration};
/// Unified event type for all SensorHub notifications
#[derive(Debug, Clone)]
pub enum SensorHubEvent {
Connect(ConnectStatus),
EntityUpdate(Arc<dyn Entity>),
PoseReceived(Arc<dyn Pose>),
@dgehriger
dgehriger / PID.h
Last active February 7, 2025 08:30
Discrete PID implementation with derivative term filtering
#pragma once
#include <algorithm>
class IncrementalPID
{
public:
/**
* @param kp Proportional gain, K_p
* @param ki Integral gain, K_i
* @param kd "Derivative" gain for the incremental form
@dgehriger
dgehriger / mav_movie_definition.v1.schema.json
Last active November 20, 2024 11:37
Schema for Maverick Movie Definition
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
"$schema": {
"type": "string",
"format": "uri",
"const": "https://gist.githubusercontent.com/dgehriger/4486084b0bbbff0a99c4c3918e634e84/raw/mav_movie_definition.v1.schema.json"
},
@dgehriger
dgehriger / option_result.md
Created November 14, 2024 12:51
Option and Result in Rust

For Option<T>

Instead of using unwrap(), you can handle Option types in the following ways:

  1. Using if let:
    let maybe_value: Option<i32> = Some(42);
    
    if let Some(value) = maybe_value {
        println!("Got a value: {}", value);