Skip to content

Instantly share code, notes, and snippets.

@lamperez
lamperez / cs35l41_spi.md
Last active November 11, 2024 11:16
CS35L41 amplifiers in an ASUS Zenbook on linux

Asus Zenbook UX3402 speakers on Linux

Important

THIS IS NOW OBSOLETE WITH KERNEL VERSIONS ≥ 6.7.0

A recent announcement in the kernel mail list by Cirrus developers will solve the problem described here. Therefore, the proposed solutions will be soon obsolete. See this comment (thanks, @flukejones, for the tip).

I got the speakers working on my Asus Zenbook 14 OLED UX3402, the one with Intel CPU and the two CS35L41 audio amplifiers connected over SPI (not the UM3402YA, with AMD and I²C). The amplifiers are supported by the snd_hda_scodec_cs35l41 module in recent kernel versions, but they require some model-specific configuration paramaters, that should be provided by

@Akiyamka
Akiyamka / api-example.md
Last active June 28, 2023 08:31
reatom 2 - Обзор с примерами

Асинхронный эффект в атоме

Разберем как сделать асинхронный запрос в апи для получения курса валюты. На react c useEffect это выглядит так:

import { useEffect, useState } from 'react';
@simenandre
simenandre / 0-runtypes-openapi-clients.md
Last active September 22, 2022 02:49
Generate clients based on Runtypes (and other awesome tech) from OpenAPI

OpenAPI 👉 Typescript / Runtypes / Rest Client

  • Status: proposed (not all options are fully evaluated)
  • Date: 2021-03-29

OpenAPI (formerly Swagger) is a way to describe a REST API. It has slowly become a business standard, used by large tech companies as well as small. The Open Source community has built the OpenAPI specification to improve the reliability of REST APIs, with it you can define types and methods of an API. The community has also built tools to generate server and client code for these APIs.

The benefits of code generators are obviously having to write less code. There are many alternatives to generate clients, based on OpenAPI – most of them have issues. The issues are typically unorganized source code, being unmaintaned, outdated targets (the generated Typescript code is outdated) or being unfinished. These issues are the fundation of this proposal, which is essentially rewriting/building a OpenAPI to Typescript client generator.

Context and Problem Statement

Краткая характеристика:

  1. У него много сторов и сторы могут зависеть друг от друга, а не один большой стор и селекторы. То есть он ближе к Эфектору, чем в Редаксу/MobX. Всё ради tree shaking.
  2. Он ближе к стору прямых измений. В публичном API нет экшенов. Но всё-таки value = 1 на манер MobX запрещены — значения можно менять только через спец. методы. И в синхронизации состояния с сервером экшены есть (просто скрыты из публичного API).

Плюсы:

  1. Может работать без Логакса, чисто как стейт-менеджер.
  2. API специально создан, чтобы хранить в сторах бизнес-логику, чем разгружать компоненты и упрощать переносимость приложения между фреймворками.
  3. От 157 байт (!) в вашем JS-бандле.
  4. Расчитан на агрессивный tree shaking, чтобы в JS-бандле был только код того состояния, которые используются в текущих страницах.
  5. Очень ленивый — сторы на которых никто не подписан выгружаются из памяти, а их бизнес-логика останавливается.

Rendering Interactive HTML using Preact

It's possible to render HTML in Preact using the dangerouslySetInnerHTML prop, however doing so bypasses the Virtual DOM entirely. This may be reasonable for static HTML, but interactivity can be a little painful to graft on without VDOM.

There is another technique available that melds HTML to Virtual DOM without such limitations.

Enter DOMParser

@ityonemo
ityonemo / test.md
Last active October 25, 2024 15:24
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

declare const IS_ACTION_FETCH: unique symbol
/**
* Fetch fabric with statuses actions
* @param {(payload: Payload) => Promise<Result>} fetcher
* @param {{
* onDone?: (result: Result, store: Store) => void
* onFail?: (error: unknown, store: Store) => void
* }} hooks
* @returns {{
@theKashey
theKashey / prefetchWorker.js
Created October 11, 2019 02:24
cloudflare HTTP(not HTML!) prefetch
// see cloudflare workers - https://workers.cloudflare.com
addEventListener('fetch', event => {
event.respondWith(fetchAndStream(event.request))
})
async function fetchAndStream(request) {
let streamResponse = fetch(request); // dont await, as majority of CF examples do
let { readable, writable } = new TransformStream()
const { createServer } = require('http');
createServer((req, res) => {
res.writeHead(200, {
Connection: 'Transfer-Encoding',
'Content-Type': 'text/html; charset=utf-8',
'Transfer-Encoding': 'chunked'
});
res.write(`