Skip to content

Instantly share code, notes, and snippets.

View ValentinFunk's full-sized avatar
👋

Valentin ValentinFunk

👋
  • InnoVint, Inc
  • Tarifa, Spain
View GitHub Profile
@ValentinFunk
ValentinFunk / sh2_uart_hal.cpp
Created August 30, 2023 08:22
SHTP BOM085 UART HAL port attemt
#include <stdio.h>
#include <string.h>
#include "sh2_uart_hal.hpp"
#include "sh2_hal.h"
#include "sh2_err.h"
#include "driver/uart.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
@ValentinFunk
ValentinFunk / fixes.md
Created March 4, 2023 12:09
Angular 15 upgrade issues and solutions

Solutions to Angular 15 upgrade issues

I'm documenting upgrade issues and solutions to them in case someone else runs into the same issue.

Module parse failed: Duplicate export 'renderModule'

This is because of angular/angular-cli#23866, the migration somehow didn't fix it for me.

To fix the issue go into your main.server.ts file and remove the line that exports from '@angular/platform-server'.

You can also search for '@angular/platform-server' in files and remove the line that looks like this:

/*
This code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
@ValentinFunk
ValentinFunk / undiscriminate.ts
Created March 3, 2020 15:48
Undiscriminiate in Typescript
type DiscriminateMessageType<
A,
T extends BookingMessageNotification['bookingMessageType']
> = A extends BookingMessageNotification ?
T extends A['bookingMessageType'] ? A : never
: never;
asMsg<T extends BookingMessageNotification['bookingMessageType']>(type: T): DiscriminateMessageType<BookingMessageNotification, T> {
return this._entry as any;
@ValentinFunk
ValentinFunk / README.md
Created December 7, 2019 16:22 — forked from peak-load/README.md
Headless A2DP Audio Streaming on Raspbian Stretch

About

This gist will show how to setup Raspbian Stretch as a headless Bluetooth A2DP audio sink. This will allow your phone, laptop or other Bluetooth device to play audio wirelessly through a Rasperry Pi.

Motivation

A quick search will turn up a plethora of tutorials on setting up A2DP on the Raspberry Pi. However, I felt this gist was necessary because this solution is:

  • Automatic & Headless - Once setup, the system is entirely automatic. No user iteration is required to pair, connect or start playback. Therefore the Raspberry Pi can be run headless.
  • Simple - This solution has few dependencies, readily available packages and minimal configuration.
  • Up to date - As of December 2017. Written for Raspbian Stretch & Bluez 5.43

Prerequisites

@ValentinFunk
ValentinFunk / README.md
Last active December 7, 2019 16:23 — forked from peak-load/README.md
Headless A2DP Audio Streaming on Raspbian Stretch

About

This gist will show how to setup Raspbian Stretch as a headless Bluetooth A2DP audio sink. This will allow your phone, laptop or other Bluetooth device to play audio wirelessly through a Rasperry Pi.

Motivation

A quick search will turn up a plethora of tutorials on setting up A2DP on the Raspberry Pi. However, I felt this gist was necessary because this solution is:

  • Automatic & Headless - Once setup, the system is entirely automatic. No user iteration is required to pair, connect or start playback. Therefore the Raspberry Pi can be run headless.
  • Simple - This solution has few dependencies, readily available packages and minimal configuration.
  • Up to date - As of December 2017. Written for Raspbian Stretch & Bluez 5.43

Prerequisites

@ValentinFunk
ValentinFunk / retry.ts
Created August 8, 2019 12:25
Retry rate limited request on node using bluebird-retry
import * as retry from 'bluebird-retry';
function isRateLimitOrTempError(err: Error & { statusCode?: number }) {
return err.statusCode && (
err.statusCode == 429 // Rate Limit
|| err.statusCode == 502 // Temporary error, retry again
);
}
function retryOnRateLimited<T>(request: () => Promise<T>): Promise<T> {
return retry(request, {
@ValentinFunk
ValentinFunk / discriminate.ts
Created April 9, 2019 16:51
discriminated union discriminate out
export type Discriminate<
Union,
Prop extends keyof Union,
Discriminator extends Union[Prop],
> = Union extends { [T in Prop]: Extract<Union[Prop], Discriminator> } ? Union : never;
export type DiscriminateByType<
Union extends { type: any },
D extends Union['type']
> = Discriminate<Union, 'type', D>;
@ValentinFunk
ValentinFunk / README.md
Created January 18, 2019 09:58
Fixes SVG Gradients for Safari by changing fill URLs to the current pathname. Also fixes xlink:href URLs.

Snippet to fix SVG issues in Angular (2+) with Safari, Firefox and Chrome

This listens to Angular route changes and on route change does the following:

  1. Replaces the link in <use xlink:href="#some-id"></use> by a path prefixed version
  2. Replaces the fill property in referenced SVGs by a path prefixed version
  3. Replaces the style in <svg style="fill: url(#gradient)"> with a prefixed version

Adapted from Gist by Leon Derijke

<html>
<head>
<style>
.rounded-corners-gradient-borders {
width: 300px;
height: 80px;
border: double 2px transparent;
border-radius: 80px;
background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff);
background-origin: border-box;