Skip to content

Instantly share code, notes, and snippets.

View ChronSyn's full-sized avatar

Scott Pritchard ChronSyn

View GitHub Profile
@ChronSyn
ChronSyn / Readme.MD
Last active February 20, 2024 15:40
ESPHome sound monitor with ESP32 and KY-037

ESPHome sound monitor using ESP32 and KY-037

I read a lot of reports online of these sensors being unreliable, or being difficult to tune. The latter part is partly true, but there's a lot of misunderstanding about how to interpret the data. Once you understand how you should interpret it, it becomes much clearer how you should calibrate it and how to configure your ESPHome device to use the data it provides.

My first thought was higher measured voltage = louder noise. After all, every sensor I'd worked with worked in this way, but most of them reported the 'human friendly' value - e.g. temperature, CO2, humidity, etc.

Sound is different. You probably know that sound is made up of waves, and you've probably seen a waveform corresponding to audio.

Louder sounds aren't represented by just a higher peak, but by a higher deviation. For example, your baseline is set at 0. When a sound happens, the waveform starts and you have values that are positive and negative - so shouting might be represented as many po

@ChronSyn
ChronSyn / README.md
Last active January 24, 2024 20:38
Spicetify - Remove Smart Shuffle, Remove DJ

I'm not the only person who is increasingly frustrated with Spotify and their determination to ignore the community while they COMPLETELY FUCK UP THE USER EXPERIENCE of their apps.

Some time ago, they added 'Smart Shuffle'. The community has clearly voiced their dislike of this feature, and yet still it remains in the app. Smart shuffle wouldn't be so bad if it wasn't combined with the regular shuffle button.

They also recently introduced the 'DJ' playlist which has no reliable way to be removed and is adding extra clutter we didn't ask for.

This is the third revision which removes the default shuffle button and replaces it with one which is visually identical but which only toggles shuffle functionality without smart shuffle.

  1. Install Spicetify
  2. If you want to remove smart shuffle: Place the contents of the remove-smart-shuffle.js file below in a file in your Spicetify extensions folder. For example, on Windows, place this file at %APPDATA%/spicetify/Extensions/remove-smart-shuffle.js. Run `spice
@ChronSyn
ChronSyn / vscode-tabs.jsonc
Last active August 19, 2022 18:10
Customise VSCode tabs using the CustomiseUI extension
{
"customizeUI.stylesheet": {
// Sets the styles for the active tab, such as background color and border
".monaco-workbench .part.editor>.content .editor-group-container>.title .tabs-container>.tab.sizing-fit.active": {
"background": "linear-gradient(to right, #ff6f00, #ffca28) !important;",
"border-bottom": "2px dotted #6200ea !important;",
"border-top": "2px dotted #6200ea !important;",
"color": "black !important;",
},
".monaco-workbench .part.editor>.content .editor-group-container>.title .tabs-container>.tab.sizing-fit.active.dirty": {
@ChronSyn
ChronSyn / example.sh
Created July 24, 2022 02:48
Hasura - allow only select access to root queries
# SourceNameGoesHere = the name as it appears in Hasura dashboard
# See example: https://twitter.com/ChronSyn/status/1551035751512657921/photo/1
curl --location --request POST 'https://[your-hasura-address-dot-com]/v1/metadata' \
--header 'x-hasura-admin-secret: <your hasura admin secret>' \
--header 'X-Hasura-Role: admin' \
--header 'Content-Type: application/json' \
--data-raw '{
"type" : "pg_create_select_permission",
"args" : {
@ChronSyn
ChronSyn / filter-data.sql
Last active March 14, 2022 23:38
Filtering JSONB data in Postgres
-- Postgres: How to find a matching element in a JSON array
--
-- Definitions:
-- - animal_size_in_mm: int = 50
-- - var_animal_type: string = "fish"
--
-- Data example:
--
-- [
-- { "animal_type": "fish", "name": "Bob", "animal_size": 48 },
@ChronSyn
ChronSyn / main.go
Created December 8, 2021 03:51 — forked from satishbabariya/main.go
supabase + gorush notification middleware service
package main
import (
"fmt"
"net/http"
"os"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/sirupsen/logrus"
@ChronSyn
ChronSyn / ComponentExample.tsx
Last active November 5, 2021 22:00
MobX - useStores hook (Context)
import React from "react";
import { TouchableOpacity, Text } from "react-native";
import { observer } from "mobx";
import { useStores } from "../stores/StoresProvider";
const ExampleComponent: React.FC = () => {
const { UIStore } = useStores();
return (
@ChronSyn
ChronSyn / ShadowView.js
Created May 28, 2021 01:13 — forked from lletfrix/ShadowView.js
ShadowView.js
import React from 'react';
import { View, StyleSheet, Text, Dimensions, Platform } from 'react-native';
import Svg, { Circle, Rect, Defs, Use, Symbol, ForeignObject, LinearGradient, RadialGradient, Stop, G} from 'react-native-svg';
import { LinearGradient as LGradient } from 'expo-linear-gradient';
const Gauss = (x, sigma) => 1/(sigma * Math.sqrt(2*Math.PI)) * Math.exp( - (x**2) / (2*sigma**2 ))
const dot = (v1, v2) => v1.reduce( (acc, comp, idx) => (acc + comp*v2[idx]), 0)
const convolutions = (img, ker) => {
@ChronSyn
ChronSyn / babel.config.js
Last active May 1, 2024 05:51
Expo - Alias path example
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["module-resolver", {
"alias": {
@ChronSyn
ChronSyn / useTheme.ts
Last active February 15, 2021 01:41
React Native - useTheme hook
import { ITheme } from "@Themes/interfaces";
import { DarkTheme } from "@Themes/theme.dark";
import { LightTheme } from "@Themes/theme.light";
import React from "react";
import { useColorScheme } from "react-native-appearance";
export const useTheme = (): [ITheme] => {
const scheme = useColorScheme();
const [currentTheme, setCurrentTheme] = React.useState<ITheme>(DarkTheme);