<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Piotr</title>
    <description>The latest articles on DEV Community by Piotr (@finloop).</description>
    <link>https://dev.to/finloop</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F709932%2F7619ab5d-de10-4464-a9a8-b259c007f7e7.jpg</url>
      <title>DEV Community: Piotr</title>
      <link>https://dev.to/finloop</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/finloop"/>
    <language>en</language>
    <item>
      <title>How to (not) run Automerge in React-native</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sat, 02 Aug 2025 00:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/how-to-not-run-automerge-in-react-native-40gm</link>
      <guid>https://dev.to/finloop/how-to-not-run-automerge-in-react-native-40gm</guid>
      <description>&lt;p&gt;TL;DR: I don’t know how how to run &lt;a href="https://automerge.org/" rel="noopener noreferrer"&gt;Automerge&lt;/a&gt; in RN, I’ve tried &lt;a href="https://github.com/cawfree/react-native-webassembly" rel="noopener noreferrer"&gt;⚛️ 🏎 react-native-webassembly&lt;/a&gt; but it’s not yet possible due to technical reasons.&lt;/p&gt;

&lt;p&gt;There is hope. Callstack published new RN library &lt;a href="https://github.com/callstackincubator/polygen" rel="noopener noreferrer"&gt;callstackincubator/polygen&lt;/a&gt; which allows to run webassembly in RN, but I have yet to try it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;I wanted to create an app that has one big note, that is shared and synced between my devices. There are two layers to it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Presentation: A single markdown formatted note, which can be done using &lt;a href="https://github.com/Expensify/react-native-live-markdown" rel="noopener noreferrer"&gt;https://github.com/Expensify/react-native-live-markdown&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Storage and sync: There were no obvious answers here, I didn’t want to relay on cloud providers. I found a nice library: &lt;a href="https://automerge.org/" rel="noopener noreferrer"&gt;https://automerge.org/&lt;/a&gt; which has a nice selling point:

&lt;ul&gt;
&lt;li&gt;Automatic merging: Automerge is a Conflict-Free Replicated Data Type (CRDT&lt;/li&gt;
&lt;li&gt;Network-agnostic: Allows the use of any connection-orientated protocol&lt;/li&gt;
&lt;li&gt;Portable: Imlemented in Javascript-WASM and Rust, with FFI bindings&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Choosing the right tool for the job
&lt;/h2&gt;

&lt;p&gt;This WASM part caught my eye since there are libraries that claim to bring WASM to react-native:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/cawfree/react-native-webassembly" rel="noopener noreferrer"&gt;⚛️ 🏎 react-native-webassembly&lt;/a&gt; - A c++ turbo module that is a wrapper around &lt;a href="https://github.com/wasm3/wasm3" rel="noopener noreferrer"&gt;wasm3&lt;/a&gt; - A fast WebAssembly interpreter and the most universal WASM runtime.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/callstackincubator/polygen" rel="noopener noreferrer"&gt;callstackincubator/polygen&lt;/a&gt; - from the callstack website: “Polygen instead performs Ahead-of-time compilation of WebAssembly modules into C/C++ code using the wonderful &lt;a href="https://github.com/WebAssembly/wabt/blob/main/wasm2c/README.md" rel="noopener noreferrer"&gt;&lt;code&gt;wasm2c&lt;/code&gt;&lt;/a&gt; tool. After that, Polygen generates additional glue code so that the compiled WebAssembly module can be used from JavaScript code.”&lt;/p&gt;

&lt;p&gt;So both projects are essentially wrappers around other libraries. I decided to go with the &lt;code&gt;react-native-webassembly&lt;/code&gt; since it offered Android support, while polygen (as I’m writing it) iOS only.&lt;/p&gt;

&lt;h2&gt;
  
  
  react-native-webassembly
&lt;/h2&gt;

&lt;p&gt;Of course adding this library to the project was not simple &lt;code&gt;npm install react-native-webassembly&lt;/code&gt; failed to compile&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8jjnpmihc71mt2faz3qy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8jjnpmihc71mt2faz3qy.png" width="512" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I got somewhat cryptic error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error: error in backend: failed to perform tail call elimination on a call site marked musttail

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quick google led me to a &lt;a href="https://github.com/llvm/llvm-project/issues/56679" rel="noopener noreferrer"&gt;simmilar issue&lt;/a&gt; on PowerPC, but I’m compiling for android… two searches later I got it: &lt;a href="https://github.com/llvm/llvm-project/issues/57069" rel="noopener noreferrer"&gt;Musttail is causing crash when compiling wasm3 for android armv7-a&lt;/a&gt; so I read through the issue and I saw &lt;code&gt;wasm3&lt;/code&gt; being mentioned&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fteru7fpcup3k9ibv56kf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fteru7fpcup3k9ibv56kf.png" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The issue is with the configuration of &lt;code&gt;wasm3&lt;/code&gt;, I fixed it the same way the @bald-man did, disabling &lt;code&gt;musttail&lt;/code&gt;. Here’s the whole patch, feel free to take it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;diff --git a/node_modules/react-native-webassembly/cpp/m3_config_platforms.h b/node_modules/react-native-webassembly/cpp/m3_config_platforms.h
index 50b86ac..8deaf8d 100644
--- a/node_modules/react-native-webassembly/cpp/m3_config_platforms.h
+++ b/node_modules/react-native-webassembly/cpp/m3_config_platforms.h
@@ -82,7 +82,7 @@
 # endif
 # endif

-# if M3_COMPILER_HAS_ATTRIBUTE(musttail)
+# if M3_COMPILER_HAS_ATTRIBUTE(musttail) &amp;amp;&amp;amp; !defined( __arm__ )
 # define M3_MUSTTAIL __attribute__ ((musttail))
 # else
 # define M3_MUSTTAIL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Open questions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why this is an issue. &lt;a href="https://github.com/llvm/llvm-project/pull/109943" rel="noopener noreferrer"&gt;https://github.com/llvm/llvm-project/pull/109943&lt;/a&gt; is closed in llvm, did the fix not propagate? No idea&lt;/li&gt;
&lt;li&gt;What are the consequences of this fix, what is the &lt;code&gt;musttail&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  wasm
&lt;/h2&gt;

&lt;p&gt;Before I proceed with the steps that I took, I need to explain what is WASM.&lt;/p&gt;

&lt;p&gt;WASM - it’s a low level assembly language, that has both binary and text format. It runs the code in a sandboxed environment. That means that by default it does not have access to any Web APIs. Those are given by providing imports when loading WASM module.&lt;/p&gt;

&lt;p&gt;Here’s the example WASM module in WAT (text) format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(module
  (func $i (import "my_namespace" "imported_func") (param i32))
  (func (export "exported_func")
    i32.const 42
    call $i))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can convert any &lt;code&gt;.wasm&lt;/code&gt; binary into such text format using: &lt;a href="https://webassembly.github.io/wabt/demo/wasm2wat/" rel="noopener noreferrer"&gt;https://webassembly.github.io/wabt/demo/wasm2wat/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How react-native-webassemly loads WASM
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;react-native-webassembly&lt;/code&gt; those imports can be provided like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const module = await WebAssembly.instantiate&amp;lt;{
  exported_func: () =&amp;gt; number;
  // ...
}&amp;gt;(bufferSource, {
  // Define the scope of the import functions.
  my_namespace: {
    imported_func: (value: number) =&amp;gt; console.error(value),
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those functions are then passed to &lt;code&gt;wasm3::module&lt;/code&gt; by the &lt;a href="https://github.com/cawfree/react-native-webassembly/blob/main/cpp/react-native-webassembly.cpp#L385-L412" rel="noopener noreferrer"&gt;c++ turbomodule&lt;/a&gt; somwehere in lines &lt;a href="https://github.com/cawfree/react-native-webassembly/blob/main/cpp/react-native-webassembly.cpp#L367-L411" rel="noopener noreferrer"&gt;367-411&lt;/a&gt; but I don’t quite understand how he gets the callback to call the function he wants (I suspect it has to do something with &lt;code&gt;_doSomethingWithFunction&lt;/code&gt;). My understanding goes like this:&lt;/p&gt;

&lt;p&gt;Imports are passed as callback from the JS side to the &lt;code&gt;RNWebassembly_instantiate&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reactNativeWebAssembly.RNWebassembly_instantiate({
    iid,
    bufferSource: bufferSourceBase64,
    stackSizeInBytes,
    callback: ({ func, args, module }) =&amp;gt; {
        ...
        return maybeFunction(...args.map(parseFloat));
    },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then on the native side the callback is passed to &lt;code&gt;m3_LinkRawFunctionEx&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function callback = params.getProperty(runtime, "callback").asObject(runtime).asFunction(runtime);

std::shared_ptr&amp;lt;facebook::jsi::Function&amp;gt; fn = std::make_shared&amp;lt;facebook::jsi::Function&amp;gt;(std::move(callback));

/* export initialization */
for (u32 i = 0; i &amp;lt; io_module-&amp;gt;numFunctions; ++i) {
    ...
          m3_LinkRawFunctionEx(io_module, M3GetResolvedModuleName(f).data(), functionName-&amp;gt;data(), signature.data(), &amp;amp;_doSomethingWithFunction, static_cast&amp;lt;void*&amp;gt;(id-&amp;gt;data()));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the imported function which needs to be called is called using &lt;code&gt;_doSomethingWithFunction&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m3ApiRawFunction(_doSomethingWithFunction)
{
    ...
    resultDict.setProperty(*context.rt, "module", facebook::jsi::String::createFromUtf8(*context.rt, std::string(_ctx-&amp;gt;function-&amp;gt;import.moduleUtf8)));
    resultDict.setProperty(*context.rt, "func", facebook::jsi::String::createFromUtf8(*context.rt, functionName));
    resultDict.setProperty(*context.rt, "args", ConvertStringArrayToJSIArray(*context.rt, result, length));

    Value callResult = originalFunction.call(*context.rt, resultDict);
    ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Loading automerge in RN
&lt;/h2&gt;

&lt;h3&gt;
  
  
  First try
&lt;/h3&gt;

&lt;p&gt;This was my first attempt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const AutomergeWasm = require('@/assets/automerge.wasm');
type AutomergeModuleType = typeof import("@automerge/automerge/slim");
const module = await WebAssembly.instantiate&amp;lt;AutomergeModuleType&amp;gt;(AutomergeWasm);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Guess what’s wrong? I forgot imports 🫠, just for reference here’s the error that I’ve got:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error unknown value_type
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;not telling me much…&lt;/p&gt;

&lt;h3&gt;
  
  
  Second try
&lt;/h3&gt;

&lt;p&gt;Adding the imports was not that straightforward (or at least I did not know a better way). So I’ve just copied the &lt;code&gt;web/automerge_wasm.js&lt;/code&gt;and exported &lt;code&gt;__wbg_get_imports&lt;/code&gt; which provides those imports for the web.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function __wbg_get_imports() {
    const imports = {};
    imports.wbg = {};
    imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
        takeObject(arg0);
    };
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.npmjs.com/package/@automerge/automerge-wasm" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/@automerge/automerge-wasm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And… again…&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error unknown value_type
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Side note: To check what imports are needed I put the &lt;code&gt;.wasm&lt;/code&gt; file into &lt;a href="https://webassembly.github.io/wabt/demo/wasm2wat/" rel="noopener noreferrer"&gt;https://webassembly.github.io/wabt/demo/wasm2wat/&lt;/a&gt; and looked at the &lt;code&gt;import&lt;/code&gt; statements, then a quick &lt;code&gt;grep -r __wbindgen_object_drop_ref&lt;/code&gt; quickly found the missing functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  (import "wbg" "__wbindgen_string_get" (func $wasm_bindgen::__wbindgen_string_get::hbef6b8ade2155369 (type $t87)))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Debugging time
&lt;/h3&gt;

&lt;p&gt;How to debug this thing? I’ve decided to go straight into modifying the &lt;code&gt;node_modules/react-native-webassembly/cpp/react-native-webassembly.cpp&lt;/code&gt; and then recompiling with &lt;code&gt;npx expo run:android&lt;/code&gt;, which proved to work nicely.&lt;/p&gt;

&lt;p&gt;I added logs and turns out that it didn’t even run the ‘import’ part, it failed on parsing the module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wasm3::module mod = env.parse_module(buffer, decoded.length());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So I went to google once again and found this issue: &lt;a href="https://github.com/wasm3/wasm3/issues/352" rel="noopener noreferrer"&gt;https://github.com/wasm3/wasm3/issues/352&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk3297a6m1l0hlmxm8nn6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk3297a6m1l0hlmxm8nn6.png" alt="Reference Types are not supported yet" width="800" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which is a bummer.&lt;/p&gt;

&lt;p&gt;Question: What are &lt;strong&gt;reference types&lt;/strong&gt;? And how do I know that the &lt;code&gt;.wasm&lt;/code&gt; file has them?&lt;/p&gt;

&lt;p&gt;WASM docs states:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Reference types&lt;/em&gt; classify first-class references to objects in the runtime &lt;a href="https://webassembly.github.io/reference-types/core/exec/runtime.html#store" rel="noopener noreferrer"&gt;store&lt;/a&gt;.reftype::=funcref ∣ externrefThe type &lt;a href="https://webassembly.github.io/reference-types/core/syntax/types.html#syntax-reftype" rel="noopener noreferrer"&gt;funcref&lt;/a&gt; denotes the infinite union of all references to &lt;a href="https://webassembly.github.io/reference-types/core/syntax/modules.html#syntax-func" rel="noopener noreferrer"&gt;functions&lt;/a&gt;, regardless of their &lt;a href="https://webassembly.github.io/reference-types/core/syntax/types.html#syntax-functype" rel="noopener noreferrer"&gt;function types&lt;/a&gt;. The type &lt;a href="https://webassembly.github.io/reference-types/core/syntax/types.html#syntax-reftype" rel="noopener noreferrer"&gt;externref&lt;/a&gt; denotes the infinite union of all references to objects owned by the &lt;a href="https://webassembly.github.io/reference-types/core/intro/overview.html#embedder" rel="noopener noreferrer"&gt;embedder&lt;/a&gt; and that can be passed into WebAssembly under this type. Source: &lt;a href="https://webassembly.github.io/reference-types/core/syntax/types.html#syntax-reftype" rel="noopener noreferrer"&gt;https://webassembly.github.io/reference-types/core/syntax/types.html#syntax-reftype&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;How to spot a &lt;code&gt;reftype&lt;/code&gt; in the text format? Per the &lt;a href="https://webassembly.github.io/reference-types/core/text/types.html#reference-types" rel="noopener noreferrer"&gt;WASM spec&lt;/a&gt;: &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm238ckzzvhyd7qr9fqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm238ckzzvhyd7qr9fqo.png" width="800" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So i went back to the &lt;a href="https://webassembly.github.io/wabt/demo/wasm2wat/" rel="noopener noreferrer"&gt;https://webassembly.github.io/wabt/demo/wasm2wat/&lt;/a&gt; loaded wasm and:&lt;/p&gt;

&lt;p&gt;Bingo!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; (module $automerge_wasm.wasm
  (type $t0 (func))
  (type $t1 (func (result i32)))
  (type $t2 (func (result externref)))
  (type $t3 (func (param i32)))
  (type $t4 (func (param i32) (result i32)))
  (type $t5 (func (param i32) (result i32 i32)))
  (type $t6 (func (param i32) (result i32 i32 i32)))
  (type $t7 (func (param i32) (result i64)))
  (type $t8 (func (param i32) (result f64)))
  (type $t9 (func (param i32) (result externref)))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusions
&lt;/h2&gt;

&lt;p&gt;When I started writing this I had no idea what the WASM was and how to load it into react-native. Even though I failed catastrophically this was a nice learning experience. I’m sharing it here as a future reference for myself and to turn those X hours of fighting to run this thing into something concrete.&lt;/p&gt;

&lt;p&gt;In the future I’ll probably look into some other library like &lt;a href="https://github.com/yjs/yjs" rel="noopener noreferrer"&gt;https://github.com/yjs/yjs&lt;/a&gt; which also offers CRDTs but this time there are some people which got it to work in react-native &lt;a href="https://github.com/yjs/yjs/issues/381" rel="noopener noreferrer"&gt;https://github.com/yjs/yjs/issues/381&lt;/a&gt; which may be easier and I might actually get some work done 😅&lt;/p&gt;

&lt;p&gt;👀 turns out the reference-types are not supported everywhere and at &lt;a href="https://github.com/wasm-bindgen/wasm-bindgen/issues/4211" rel="noopener noreferrer"&gt;some point you had to explicitly enable them&lt;/a&gt; in &lt;code&gt;wasm-bindgen&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>webassembly</category>
    </item>
    <item>
      <title>Podman on debian How to fix podman no services after restart</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sat, 12 Apr 2025 12:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/podman-on-debian-how-to-fix-podman-no-services-after-restart-2f4k</link>
      <guid>https://dev.to/finloop/podman-on-debian-how-to-fix-podman-no-services-after-restart-2f4k</guid>
      <description>&lt;p&gt;I noticed that with static build of podman, services didn’t start after I restarted my server, even though they had &lt;code&gt;Restart=Always&lt;/code&gt; policy.&lt;/p&gt;

&lt;p&gt;This is an issue that can popup when installing podman from a static build &lt;a href="https://garden.piotrk.it/Blog/install-latest-podman-on-debian-ubuntu" rel="noopener noreferrer"&gt;installation on debian&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Turns out that this issue is due to missing &lt;code&gt;podman-restart.service&lt;/code&gt; that starts all the services after boot.&lt;/p&gt;

&lt;p&gt;This file was originally from &lt;a href="https://github.com/containers/podman/tree/main/contrib/systemd/system" rel="noopener noreferrer"&gt;github repo&lt;/a&gt;, but with static podman build it is not present.&lt;/p&gt;

&lt;p&gt;Create directory for&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir -p ~/.config/systemd/user/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create file &lt;code&gt;podman-restart.service&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=Podman Start All Containers With Restart Policy Set To Always
Documentation=man:podman-start(1)
StartLimitIntervalSec=0
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
RemainAfterExit=true
Environment=LOGGING="--log-level=info"
ExecStart=/usr/local/bin/podman $LOGGING start --all --filter restart-policy=always
ExecStop=/usr/local/bin/podman $LOGGING stop --all --filter restart-policy=always

[Install]
WantedBy=default.target

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload units:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl --user daemon-reload; journalctl -f

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable service and timer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl --user enable podman-restart.service

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>podman</category>
      <category>sysadmin</category>
      <category>systemd</category>
    </item>
    <item>
      <title>How to install latest version of podman on debian/ubuntu</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sat, 12 Apr 2025 00:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/how-to-install-latest-version-of-podman-on-debianubuntu-2oc9</link>
      <guid>https://dev.to/finloop/how-to-install-latest-version-of-podman-on-debianubuntu-2oc9</guid>
      <description>&lt;p&gt;I like stability of debian. I use it as my host distro for almost every server I have. But debian repositories (stable) have a very old version of podman. The same goes for debian testing, there’s simply no podman 5&amp;gt;= avaliable. Debian backports don’t work either - there’s no backport of podman.&lt;/p&gt;

&lt;p&gt;That left me with one other option - &lt;a href="https://github.com/mgoltzsche/podman-static" rel="noopener noreferrer"&gt;static build of podman&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation on amd64 host
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Copied from &lt;a href="https://github.com/mgoltzsche/podman-static?tab=readme-ov-file#binary-installation-on-a-host" rel="noopener noreferrer"&gt;https://github.com/mgoltzsche/podman-static?tab=readme-ov-file#binary-installation-on-a-host&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Download the statically linked binaries of podman and its dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL -o podman-linux-amd64.tar.gz https://github.com/mgoltzsche/podman-static/releases/latest/download/podman-linux-amd64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify signature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL -o podman-linux-amd64.tar.gz.asc https://github.com/mgoltzsche/podman-static/releases/latest/download/podman-linux-amd64.tar.gz.asc
gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys 0CCF102C4F95D89E583FF1D4F8B5AF50344BB503
gpg --batch --verify podman-linux-amd64.tar.gz.asc podman-linux-amd64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install binaries on the host:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tar -xzf podman-linux-amd64.tar.gz
sudo cp -r podman-linux-amd64/usr podman-linux-amd64/etc /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install additional binaries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install uidmap nsenter iptables slirp4netns

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add UID/GID mapping
&lt;/h3&gt;

&lt;p&gt;Check &lt;code&gt;/etc/subuid&lt;/code&gt; and &lt;code&gt;/etc/subgid&lt;/code&gt; for mappings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat /etc/subuid
cat /etc/subgid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If theres nothing in here add mapping:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo sh -c "echo $(id -un):100000:200000 &amp;gt;&amp;gt; /etc/subuid"
sudo sh -c "echo $(id -gn):100000:200000 &amp;gt;&amp;gt; /etc/subgid"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Persist containers after logout
&lt;/h3&gt;

&lt;p&gt;Enable linger:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loginctl enable-linger &amp;lt;USERNAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Enable podman socket
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl enable --now --user podman.socket
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Enable automatic restart of services
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl enable podman-restart.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source: &lt;a href="https://github.com/containers/podman/blob/main/contrib/systemd/system/podman-restart.service.in" rel="noopener noreferrer"&gt;https://github.com/containers/podman/blob/main/contrib/systemd/system/podman-restart.service.in&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install podman compose
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install pipx
pipx install podman-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Check if everything is working
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ podman run quay.io/podman/hello

!... Hello Podman World ...!

         .--"--.
       / - - \
      / (O) (O) \
   ~~~| -=(,Y,)=- |
    .---. /` \ |~~
 ~/ o o \ ~~~~.----.~~
  | =(X)= |~ / (O (O) \
   ~~~~~~~ ~| =(Y_)=- |
  ~~~~~~~ | U |~~

Project: https://github.com/containers/podman
Website: https://podman.io
Desktop: https://podman-desktop.io
Documents: https://docs.podman.io
YouTube: https://youtube.com/@Podman
X/Twitter: @Podman_io
Mastodon: @Podman_io@fosstodon.org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>podman</category>
      <category>debian</category>
      <category>ubuntu</category>
      <category>sysadmin</category>
    </item>
    <item>
      <title>Podman on debian How to fix no podman-auto-update.service</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sat, 12 Apr 2025 00:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/podman-on-debian-how-to-fix-no-podman-auto-updateservice-586j</link>
      <guid>https://dev.to/finloop/podman-on-debian-how-to-fix-no-podman-auto-updateservice-586j</guid>
      <description>&lt;p&gt;This is an issue that can popup when installing podman from a static build &lt;a href="https://garden.piotrk.it/Blog/install-latest-podman-on-debian-ubuntu" rel="noopener noreferrer"&gt;Installation on Debian&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To fix it we have to create a update service and timer. These were originally from &lt;a href="https://github.com/containers/podman/tree/main/contrib/systemd/system" rel="noopener noreferrer"&gt;github repo&lt;/a&gt;, but with static podman build they aren’t.&lt;/p&gt;

&lt;p&gt;Create directory for&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir -p ~/.config/systemd/user/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create file &lt;code&gt;podman-auto-update.service&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=Podman auto-update service
Documentation=man:podman-auto-update(1)
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/podman auto-update
ExecStartPost=/usr/local/bin/podman image prune -f

[Install]
WantedBy=default.target

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create file &lt;code&gt;podman-auto-update.timer&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=Podman auto-update timer

[Timer]
OnCalendar=daily
RandomizedDelaySec=900
Persistent=true

[Install]
WantedBy=timers.target

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload units:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl --user daemon-reload; journalctl -f

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable service and timer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl --user enable podman-auto-update.service
systemctl --user enable podman-auto-update.timer

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>sysadmin</category>
      <category>podman</category>
      <category>systemd</category>
    </item>
    <item>
      <title>ZFS Snapshots using sanoid and syncoid</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sun, 06 Apr 2025 00:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/zfs-snapshots-using-sanoid-and-syncoid-126n</link>
      <guid>https://dev.to/finloop/zfs-snapshots-using-sanoid-and-syncoid-126n</guid>
      <description>&lt;p&gt;Proxmox by default backups vms as tar archives/system images, which is not suitable for me, as I want to use zfs snapshots to ensure that I don’t use many system resources. Then I want to replicate those snapshots to a remote system for an offsite backup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Follow the instructions from: &lt;a href="https://github.com/jimsalterjrs/sanoid/blob/master/INSTALL.md" rel="noopener noreferrer"&gt;https://github.com/jimsalterjrs/sanoid/blob/master/INSTALL.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you’re done see if the &lt;code&gt;sanoid.timer&lt;/code&gt; works. This timer will execute a policy from &lt;code&gt;/etc/sanoid/sanoid.conf&lt;/code&gt; (empty by default).&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Find all the things that you want to snapshot by running:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ zfs list

NAME USED AVAIL REFER MOUNTPOINT
rpool 45.1G 412G 104K /rpool
rpool/ROOT 2.34G 412G 96K /rpool/ROOT
rpool/ROOT/pve-1 2.34G 412G 2.34G /
rpool/data 28.6G 412G 96K /rpool/data
rpool/data/vm-100-disk-0 128K 412G 64K -
rpool/data/vm-100-disk-1 6.08G 412G 5.96G -
rpool/data/vm-100-disk-2 19.7G 412G 18.7G -
rpool/data/vm-101-disk-0 2.73G 412G 2.70G -
rpool/var-lib-vz 14.1G 412G 14.1G /var/lib/vz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create file &lt;code&gt;/etc/sanoid/sanoid.conf&lt;/code&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[rpool/data]
        use_template = production
        recursive = yes
        process_children_only = yes

#############################
# templates below this line #
#############################

[template_production]
        frequently = 0
        hourly = 36
        daily = 30
        monthly = 3
        yearly = 0
        autosnap = yes
        autoprune = yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This template will backup all datasets in &lt;code&gt;rpool/data&lt;/code&gt; but NOT the &lt;code&gt;rpool/data&lt;/code&gt; itself. In this case I want to create snapshots of all the vm disks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remote replication
&lt;/h2&gt;

&lt;p&gt;Our setup will consist of two machines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;production machine&lt;/li&gt;
&lt;li&gt;remote machine, a repote machine that will store our snapshots&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Remote machine configuration
&lt;/h3&gt;

&lt;p&gt;Create dataset into which we’ll replicate the data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zfs create data/production-machine-xxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remote replication uses ssh as its transport layer and we don’t want to give the remote machine root access.&lt;/p&gt;

&lt;p&gt;We need to create a new user: &lt;code&gt;adduser remote-backup&lt;/code&gt;, and give him privileges to write to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zfs allow -u remote-backup compression,mountpoint,create,mount,receive,rollback,destroy data/production-machine-xxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Production machine configuration
&lt;/h3&gt;

&lt;h4&gt;
  
  
  SSH Config
&lt;/h4&gt;

&lt;p&gt;Edit &lt;code&gt;~/.shh/config&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host remote-machine:
  Hostname &amp;lt;ip addr&amp;gt;
  User remote-backup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy ssh key to remote machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-copy-id remote-machine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Timer
&lt;/h4&gt;

&lt;p&gt;Create &lt;code&gt;/etc/systemd/system/zfs-sync.timer&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=Run syncoid daily

[Timer]
OnBootSec=30min
OnCalendar=*-*-* 21:00:00 Europe/Warsaw
Persistent=true

[Install]
WantedBy=timers.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example values that can be used in OnCalendar (credit: &lt;a href="https://medium.com/@rockibul.islam20/configure-and-implement-of-systemd-timers-8c640cc6d667" rel="noopener noreferrer"&gt;Rockibul Islam&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Explaination Systemd timer
Every Minute *-*-* *:*:00
Every 5 minutes *-*-* *:*/5:00
Every 15 minutes *-*-* *:*/15:00
Every 30 minutes *-*-* *:*/30:00
Every 1 hour *-*-* *:00:00
Every other hour *-*-* */2:00:00
Every 12 hour *-*-* */12:00:00
Between certain hours *-*-* 9-17:00:00
Daily *-*-* 00:00:00
Every Night *-*-* 01:00:00
Every Night at 2am *-*-* 02:00:00
Every morning *-*-* 07:00:00
Every midnight *-*-* 00:00:00
Every sunday Sun *-*-* 00:00:00
Every friday at midnight Fri *-*-* 00:00:00
Every weekday Mon...Fri *-*-* 00:00:00
Every weekend Sat,Sun *-*-* 00:00:00
Every 7 days * *-*-* 00:00:00
monthly * *-*-01 00:00:00
Every quarter * *-01,04,07,10-01 00:00:00
Every 6 months * *-01,07-01 00:00:00
Every year * *-01-01 00:00:00

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Oneshot service
&lt;/h4&gt;

&lt;p&gt;Create file &lt;code&gt;/etc/systemd/system/zfs-sync.service&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=Send zfs snapshots to remote machine
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/syncoid --no-privilege-elevation -r --skip-parent rpool/data remote-machine:data/production-machine-xxx
[Install]
WantedBy=default.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable the timer and service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl daemon-reload; journalctl -f
systemctl enable zfs-sync.timer
systemctl enable zfs-sync.service

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start &lt;code&gt;zfs-sync.service&lt;/code&gt; manually to sync the first snapshot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl start zfs-sync.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can list snapshots on the remote machine by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zfs list -t snapshot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Setting obsidian-shellcommands plugin on flatpak</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sun, 30 Mar 2025 10:17:23 +0000</pubDate>
      <link>https://dev.to/finloop/setting-obsidian-shellcommands-plugin-on-flatpak-1hd8</link>
      <guid>https://dev.to/finloop/setting-obsidian-shellcommands-plugin-on-flatpak-1hd8</guid>
      <description>&lt;p&gt;Running Obsidian from flatpak comes with its own set of problems. One of them is that Obsidian is ran in sandbox environment - which makes sense when we consider security, but to be frank - it’s annoying when I have to do something non-standard.&lt;/p&gt;

&lt;p&gt;I wanted to run this command from obsidian (it updates my git repo):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx quartz sync --no-pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but after adding it to there:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9idqcn06p0k9q4g8kmx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9idqcn06p0k9q4g8kmx.png" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was welcomed with an error that it couldn’t find &lt;code&gt;npx&lt;/code&gt; command, which makes sense - I’m using &lt;a href="https://github.com/nvm-sh/nvm" rel="noopener noreferrer"&gt;NVM&lt;/a&gt; to manage node.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip&lt;/p&gt;

&lt;p&gt;To make it work I had to make sure that &lt;code&gt;npx&lt;/code&gt; was added to Obsidians &lt;code&gt;$PATH&lt;/code&gt; variable and obsidian has permissions to this directory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I used &lt;a href="https://flathub.org/apps/com.github.tchx84.Flatseal" rel="noopener noreferrer"&gt;Flatseal&lt;/a&gt; to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Give Obsidian permissions to &lt;code&gt;/home/$USER&lt;/code&gt; directory - that’s where &lt;code&gt;bin/&lt;/code&gt; of NVM resides&lt;/li&gt;
&lt;li&gt;Add NVM to &lt;code&gt;$PATH&lt;/code&gt;: &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdfxh236g81oawlokbx7x.png" width="636" height="446"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I also had to update the script to execute from the git root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd "$(git rev-parse --show-toplevel)" &amp;amp;&amp;amp; npx quartz sync --no-pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now running &lt;code&gt;Ctrl + P&lt;/code&gt; and typing &lt;code&gt;Update page&lt;/code&gt; updates the page directly from obsidian.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Fix file permissions in podman volumes</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sun, 30 Mar 2025 00:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/fix-file-permissions-in-podman-volumes-2igi</link>
      <guid>https://dev.to/finloop/fix-file-permissions-in-podman-volumes-2igi</guid>
      <description>&lt;p&gt;How to fix common permissions issues in podman volumes (both local and bind mounts)?&lt;/p&gt;

&lt;p&gt;The obvious way to fix them is to &lt;code&gt;chown&lt;/code&gt;, but as a user we cannot execute this command - users are not permitted to change ownership of files for security reasons. Buttt: podman has a command &lt;code&gt;podman unshare&lt;/code&gt; (I know, this name is not intuitive…) that lets us pretend to be root the same way as podman rootless containers do (root inside container is a current user, more on that in &lt;a href="https://www.tutorialworks.com/podman-rootless-volumes/" rel="noopener noreferrer"&gt;this article&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;We can execute &lt;code&gt;podman unshare chown -R 0:0 ./volume/path&lt;/code&gt; to change ownership of the volume to you user (that is &lt;code&gt;id -u&lt;/code&gt; on HOST).&lt;/p&gt;

&lt;p&gt;Or if you want to change it to the &lt;code&gt;user&lt;/code&gt; that was set:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;inside container, created by command eg. &lt;code&gt;podman run --user 1000&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;inside quadlet: &lt;code&gt;User=1000&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;podman unshare chown -R 1000:1000 ./volume/path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.tutorialworks.com/podman-rootless-volumes/" rel="noopener noreferrer"&gt;https://www.tutorialworks.com/podman-rootless-volumes/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.podman.io/en/latest/markdown/podman-unshare.1.html" rel="noopener noreferrer"&gt;https://docs.podman.io/en/latest/markdown/podman-unshare.1.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Thoughts on hosting my blog</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Tue, 31 Dec 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/thoughts-on-hosting-my-blog-12o9</link>
      <guid>https://dev.to/finloop/thoughts-on-hosting-my-blog-12o9</guid>
      <description>&lt;p&gt;My blog &lt;a href="https://garden.piotrk.it" rel="noopener noreferrer"&gt;https://garden.piotrk.it&lt;/a&gt; was built using &lt;a href="https://quartz.jzhao.xyz/" rel="noopener noreferrer"&gt;Quartz&lt;/a&gt; and so far I’m loving it. I’ve set it up such that it publishes automatically using &lt;a href="https://pages.cloudflare.com/" rel="noopener noreferrer"&gt;Cloudflare Pages&lt;/a&gt; because I wanted to get something running fast. One advantage of Cloudflare is that it gives me analytics for free. My end goal is to move out of Cloudflare and self-host.&lt;/p&gt;

&lt;p&gt;Updating this site is super easy,:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx quartz sync --no-pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the site is up!&lt;/p&gt;

&lt;p&gt;To make this process less painful (I’m lazy and don’t want to open a terminal) I’ve set up &lt;a href="https://github.com/Taitava/obsidian-shellcommands" rel="noopener noreferrer"&gt;Obsidian Shellcommands&lt;/a&gt; plugin. You can read abut this process here &lt;a href="https://garden.piotrk.it/%F0%9F%9F%AA-Meta/Setting-obsidian-shellcommands-plugin-on-flatpak" rel="noopener noreferrer"&gt;setting obsidian-shellcommands plugin on flatpak&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now running &lt;code&gt;Ctrl + P&lt;/code&gt; and typing &lt;code&gt;Update page&lt;/code&gt; updates the page directly from obsidian.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My debugging toolbox: strace</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sat, 03 Aug 2024 08:00:00 +0000</pubDate>
      <link>https://dev.to/finloop/my-debugging-toolbox-strace-22pi</link>
      <guid>https://dev.to/finloop/my-debugging-toolbox-strace-22pi</guid>
      <description>&lt;p&gt;From time to time, my usual debugging tools: good ol &lt;code&gt;printf&lt;/code&gt;, &lt;code&gt;logger.log&lt;/code&gt;, &lt;code&gt;console.log&lt;/code&gt;, &lt;code&gt;gdb&lt;/code&gt;, &lt;code&gt;pdb&lt;/code&gt; are not enough to solve the problem. This happens more than often when multiple processes/threads are involved or performance is an issue.&lt;/p&gt;

&lt;p&gt;One such tool that I found really useful is &lt;code&gt;strace&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94fzv853smrxvv3g0pkb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94fzv853smrxvv3g0pkb.png" alt="Linux Performance Observability Tools. Source: https://www.brendangregg.com/Perf/linux_observability_tools.png" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;
Linux Performance Observability Tools. Source: https://www.brendangregg.com/Perf/linux_observability_tools.png



&lt;p&gt;See &lt;code&gt;man strace&lt;/code&gt; (great read)!.&lt;/p&gt;

&lt;p&gt;TL;DR&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traces all syscalls (aka how your program interacts with os)&lt;/li&gt;
&lt;li&gt;It’s like &lt;code&gt;printf&lt;/code&gt; but it automatically prints &lt;em&gt;everything&lt;/em&gt; being read/written to any &lt;em&gt;file descriptor&lt;/em&gt; (file, socket etc.)&lt;/li&gt;
&lt;li&gt;Can show execution stack trace after each system call (flag &lt;code&gt;-k&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;and follow forks! (with &lt;code&gt;-f&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Automatically decodes pids / file descriptors (flags &lt;code&gt;--decode-pids=comm&lt;/code&gt; / &lt;code&gt;--decode-fds=all&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Each line follows: &lt;code&gt;callname(**args) = result&lt;/code&gt; &lt;sup id="fnref:1"&gt;1&lt;/sup&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slows down traced program&lt;/strong&gt; &lt;sup id="fnref:2"&gt;2&lt;/sup&gt;, sometimes ~ 100 times&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To showcase these features, I’ve created a toy program. I’m going to show you how to discover what’s it doing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Debugging missing config files
&lt;/h3&gt;

&lt;p&gt;Some programs are not very verbose. This one complains that it cannot open a file, but it doesn’t specify which one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./demo
Cannot open file.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running &lt;code&gt;strace ./demo&lt;/code&gt; will print all the relevant output. You can filter it by adding &lt;code&gt;-eread,write,open,openat,writev&lt;/code&gt; (common syscalls).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ strace -eread,write,open,openat,writev ./demo
openat(AT_FDCWD, "example.txt", O_RDONLY) = -1 ENOENT (No such file or directory)
write(1, "Cannot open file.\n", 18Cannot open file.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Program tries to open file &lt;code&gt;example.txt&lt;/code&gt; but it doesn’t exist!&lt;/p&gt;

&lt;h3&gt;
  
  
  Debugging running program
&lt;/h3&gt;

&lt;p&gt;Lets run the demo in background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./demo &amp;amp;
[1] 104794

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And connect to it with strace (&lt;code&gt;-p [PID]&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ strace -eread,write,open,openat,writev -p 104794
strace: Process 104794 attached
writev(3, [{iov_base="2137\n2137\n2137\n2137\n2137\n2137\n21"..., iov_len=8190}, {iov_base="2137\n", iov_len=5}], 2) = 8195

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So our program is writing &lt;code&gt;2137\n&lt;/code&gt; to file descriptor 3. What file is it? Use &lt;code&gt;--decode-fds=all&lt;/code&gt;! And bam it’s writing to file: &lt;code&gt;demo.txt&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ strace -eread,write,open,openat,writev --decode-fds=all -p 104794
strace: Process 104794 attached
writev(3&amp;lt;/home/pk/projects/strace/demo.txt&amp;gt;, [{iov_base="2137\n2137\n2137\n2137\n2137\n2137\n21"..., iov_len=8190}, {iov_base="2137\n", iov_len=5}], 2) = 8195

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If our binary has debug symbols you can event print preety stack traces with &lt;code&gt;-k&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strace -eread,write,open,openat,writev -p 104794 -k
strace: Process 104794 attached
writev(3, [{iov_base="2137\n2137\n2137\n2137\n2137\n2137\n21"..., iov_len=8190}, {iov_base="2137\n", iov_len=5}], 2) = 8195
 &amp;gt; /usr/lib/x86_64-linux-gnu/libc.so.6(writev+0x17) [0x11aa57]
...
 &amp;gt; /home/pk/projects/strace/demo(waitDemo()+0x85) [0x138e]
 &amp;gt; /home/pk/projects/strace/demo(main+0x12) [0x149e]
 &amp;gt; /usr/lib/x86_64-linux-gnu/libc.so.6(__libc_init_first+0x90) [0x29d90]
 &amp;gt; /usr/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x29e40]
 &amp;gt; /home/pk/projects/strace/demo(_start+0x25) [0x1245]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example traced program
&lt;/h3&gt;

&lt;p&gt;This program was used to showcase neat features of strace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
using namespace std;

void waitDemo() {
 ofstream file;
 file.open("./demo.txt");
 if (!file.is_open()) {
 exit(1);
 }
 while(true) {
 file &amp;lt;&amp;lt; "2137\n";
 usleep(1000);
 }
}

void openFileDemo() {
 ifstream file;
 file.open ("example.txt");
 if (!file.is_open()) {
 cout &amp;lt;&amp;lt; "Cannot open file.\n";
 exit(78);
 }
}

int main () {
 openFileDemo();
 waitDemo();
 return 0;
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compile with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;g++ main.cpp -g -o demo

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  More about strace
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://web.archive.org/web/20150312221019/http://chadfowler.com/blog/2014/01/26/the-magic-of-strace/" rel="noopener noreferrer"&gt;The magic of strace&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.brendangregg.com/blog/2014-05-11/strace-wow-much-syscall.html" rel="noopener noreferrer"&gt;strace Wow Much Syscall, Gregg Brendan&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://linux.die.net/man/1/strace" rel="noopener noreferrer"&gt;strace(1) - Linux man page&lt;/a&gt; ↩︎&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.brendangregg.com/blog/2014-05-11/strace-wow-much-syscall.html" rel="noopener noreferrer"&gt;strace Wow Much Syscall, Gregg Brendan&lt;/a&gt; ↩︎&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>cpp</category>
      <category>debugging</category>
      <category>linux</category>
    </item>
    <item>
      <title>Python Numpy Array Shared Between Processes</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Fri, 05 Jan 2024 09:03:05 +0000</pubDate>
      <link>https://dev.to/finloop/python-numpy-array-shared-between-processes-5136</link>
      <guid>https://dev.to/finloop/python-numpy-array-shared-between-processes-5136</guid>
      <description>&lt;p&gt;Python’s &lt;a href="https://docs.python.org/3/library/multiprocessing.shared_memory.html" rel="noopener noreferrer"&gt;multiprocessing.shared_memory&lt;/a&gt; module provides a way to share a block of memory between processes. It’s usefull in ml contexts, where an app will runs ML model in separate process and wants share the results with its parent process. Frigate NVR does exacly that, see: &lt;a href="https://github.com/blakeblackshear/frigate/blob/c5ccc0fb08cdcfd35d2dae534724103bfb7c82a8/frigate/object_detection.py#L186-L232" rel="noopener noreferrer"&gt;object_detection.py&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Define properties of shared memory
SHARED_MEMORY_NAME = "shm-1"
SHARED_MEMORY_SHAPE = (5, 5)
NP_DATA_TYPE = np.float64

# Calculate shared numpy array size
dsize = np.dtype(NP_DATA_TYPE).itemsize * np.prod(SHARED_MEMORY_SHAPE).astype(int)

# Create allocate shared memory with a given name
shm = shared_memory.SharedMemory(
 create=True,
 size=dsize,
 name=SHARED_MEMORY_NAME,
)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To access it from a different process, create &lt;code&gt;SharedMemory&lt;/code&gt; with &lt;code&gt;create=False&lt;/code&gt; and the same &lt;code&gt;name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ShmModifier(Process):
 def __init__ (self) -&amp;gt; None:
 # Required as per: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Process
 Process. __init__ (self)

 # Get shared memory
 self.out_shm = shared_memory.SharedMemory(name=SHARED_MEMORY_NAME, create=False)

 # Map it to numpy array
 self.out_np = np.ndarray(
 SHARED_MEMORY_SHAPE, dtype=np.float32, buffer=self.out_shm.buf
 )

 def run(self) -&amp;gt; None:
 # Overrides a numpy array (runs in a different process)
 self.out_np[0, 0] = 1
 self.out_shm.close()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Full working example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
from multiprocessing import Process
import multiprocessing.shared_memory as shared_memory

SHARED_MEMORY_NAME = "shm-1"
SHARED_MEMORY_SHAPE = (5, 5)
NP_DATA_TYPE = np.float64

class ShmModifier(Process):
 def __init__ (self) -&amp;gt; None:
 # Required as per: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Process
 Process. __init__ (self)

 # Get shared memory
 self.out_shm = shared_memory.SharedMemory(name=SHARED_MEMORY_NAME, create=False)

 # Map it to numpy array
 self.out_np = np.ndarray(
 SHARED_MEMORY_SHAPE, dtype=np.float32, buffer=self.out_shm.buf
 )

 def run(self) -&amp;gt; None:
 # Overrides a numpy array (runs in a different process)
 self.out_np[0, 0] = 1
 self.out_shm.close()

if __name__ == " __main__":
 # Calculate shared numpy array size
 dsize = np.dtype(NP_DATA_TYPE).itemsize * np.prod(SHARED_MEMORY_SHAPE).astype(int)

 # Create allocate shared memory with a given name
 shm = shared_memory.SharedMemory(
 create=True,
 size=dsize,
 name=SHARED_MEMORY_NAME,
 )
 out_np = np.ndarray(SHARED_MEMORY_SHAPE, dtype=np.float32, buffer=shm.buf)

 # Fill arr with zeros
 out_np[:] = np.zeros_like(out_np)

 print("Array before running the process:")
 print(out_np)
 dp = ShmModifier()
 dp.start()
 dp.join()

 print("Array after running the process:")
 print(out_np)
 shm.unlink()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this script will result in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array before running the process:
[[0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]]
Array after running the process:
[[1. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.python.org/3/library/multiprocessing.html" rel="noopener noreferrer"&gt;https://docs.python.org/3/library/multiprocessing.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.python.org/3/library/multiprocessing.shared_memory.html" rel="noopener noreferrer"&gt;https://docs.python.org/3/library/multiprocessing.shared_memory.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/blakeblackshear/frigate/blob/c5ccc0fb08cdcfd35d2dae534724103bfb7c82a8/frigate/object_detection.py#L186-L232" rel="noopener noreferrer"&gt;https://github.com/blakeblackshear/frigate/blob/c5ccc0fb08cdcfd35d2dae534724103bfb7c82a8/frigate/object_detection.py#L186-L232&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Django Vue (Axios) Cors headers + CSFR tokens</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Mon, 14 Aug 2023 13:44:05 +0000</pubDate>
      <link>https://dev.to/finloop/django-vue-cors-headers-4nia</link>
      <guid>https://dev.to/finloop/django-vue-cors-headers-4nia</guid>
      <description>&lt;p&gt;Basic CORS and CSFR settings for Django Rest Framework (DRF) + Axios:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Settings.py:
&lt;/span&gt;&lt;span class="bp"&gt;...&lt;/span&gt;

&lt;span class="n"&gt;CORS_ORIGIN_ALLOW_ALL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="n"&gt;CORS_ALLOWED_ORIGINS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:5173&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;CSRF_TRUSTED_ORIGINS&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:5173&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;CSRF_COOKIE_SECURE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;SESSION_COOKIE_SECURE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;CSRF_COOKIE_SAMESITE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;None&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;SESSION_COOKIE_SAMESITE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;None&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;CORS_ALLOW_CREDENTIALS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;CORS_ALLOW_HEADERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;accept&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content-type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user-agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x-csrftoken&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x-requested-with&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x-xsrf-token&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Vuejs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// axios config:&lt;/span&gt;
&lt;span class="nx"&gt;xsrfCookieName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;csrftoken&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;xsrfHeaderName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-CSRFToken&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;withCredentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read what these do before using them. I'm not responsible for any security issues that may arise from using these settings.&lt;/p&gt;

&lt;p&gt;Bugs I encountered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Reason: expected ‘true’ in CORS header ‘Access-Control-Allow-Credentials
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/63576338/django-check-cookiess-samesite-attribute" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/63576338/django-check-cookiess-samesite-attribute&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/django-cors-headers/" rel="noopener noreferrer"&gt;https://pypi.org/project/django-cors-headers/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>vue</category>
    </item>
    <item>
      <title>Poco F1 Restarts on Fastboot Amd</title>
      <dc:creator>Piotr</dc:creator>
      <pubDate>Sat, 08 Jul 2023 19:15:20 +0000</pubDate>
      <link>https://dev.to/finloop/poco-f1-restarts-on-fastboot-amd-3jj5</link>
      <guid>https://dev.to/finloop/poco-f1-restarts-on-fastboot-amd-3jj5</guid>
      <description>&lt;h2&gt;
  
  
  Poco F1 - Restarts on Fastboot (AMD)
&lt;/h2&gt;

&lt;p&gt;I tried to flash custom recoery for my Poco F1 (codename “beryllium”). I installed ADB drivers and drivers for my phone. Windows device manager said everything was ok so I procedded and entered fastboot mode (Volume down + Power). I entered command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fastboot devices

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the fastboot logo disappered and was replaced with text in top left corner: “Press any key to shutdown”. Then I remembered that the guide said this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Also, have a Xiaomi Account with Mobile Number of Sim1 ready for sign-in whenever required prior to Bootloader Unlocking and make sure you have a couple of Mobile Data MBs at least. And an INTEL PC/Laptop. For AMD you may need to do via WSL Ubuntu. If you encounter issues try to power off via the options available and boot straight to the fastboot or recovery depending in whichever stage you are.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Source: &lt;a href="https://forum.xda-developers.com/t/rom-13-official-pixelos-aosp-stable-16-02-2023.4401621/" rel="noopener noreferrer"&gt;[ROM][13][OFFICIAL] PixelOS [AOSP][STABLE][16/02/2023]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have AMD CPU so I had to do something else. I found a solution on XDA Developers forum.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Create a new *.bat file and execute it. It should contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@echo off
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "osvc" /t REG_BINARY /d "0000" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "SkipContainerIdQuery" /t REG_BINARY /d "01000000" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "SkipBOSDescriptorQuery" /t REG_BINARY /d "01000000" /f

pause

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will add some registry keys that will allow you to use fastboot on your phone on AMD CPU.&lt;/p&gt;

&lt;p&gt;Credit: &lt;a href="https://forum.xda-developers.com/t/fix-fastboot-not-working-on-ryzen-cpu.4182879/" rel="noopener noreferrer"&gt;[FIX] Fastboot not working on Ryzen CPU&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
    </item>
  </channel>
</rss>
