<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amiya Behera on Medium]]></title>
        <description><![CDATA[Stories by Amiya Behera on Medium]]></description>
        <link>https://medium.com/@amiya_rbehera?source=rss-a8d67654adeb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3HLJV1MBs_CxSlb3.jpg</url>
            <title>Stories by Amiya Behera on Medium</title>
            <link>https://medium.com/@amiya_rbehera?source=rss-a8d67654adeb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:49:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amiya_rbehera/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to call javascript in rust using boa-engine and ?]]></title>
            <link>https://medium.com/@amiya_rbehera/how-to-call-javascript-in-rust-using-boa-engine-and-c4ed55e2df03?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4ed55e2df03</guid>
            <category><![CDATA[js-rust]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[boa]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 16:00:33 GMT</pubDate>
            <atom:updated>2025-10-08T16:13:17.094Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to call javascript in rust using boa-engine and esbuild?</h3><blockquote><a href="https://iambrainstorming.github.io/coding_blog/js-in-rust/js-in-rust.html">https://iambrainstorming.github.io/coding_blog/js-in-rust/js-in-rust.html</a></blockquote><blockquote><strong>Example</strong><br> <a href="https://github.com/boa-dev/boa/blob/main/examples/src/bin/modules.rs">https://github.com/boa-dev/boa/blob/main/examples/src/bin/modules.rs</a></blockquote><p>Imports</p><p>```rust<br> use std::env;<br> use std::path::PathBuf;<br> use std::{error::Error, path::Path, rc::Rc};</p><p>use boa_engine::{<br> builtins::promise::PromiseState, js_string, module::SimpleModuleLoader, Context, JsError,<br> JsNativeError, JsValue, Module, NativeFunction,<br> };<br> use boa_parser::Source;<br> ```</p><p>## Folder</p><p>Folder for esbuild</p><p>tests/modules/package.js</p><p>## Esbuild</p><p>esbuild_tests.js</p><p>```js<br> import { build } from “esbuild”;<br> import { polyfillNode } from “esbuild-plugin-polyfill-node”;</p><p>build({<br> entryPoints: [“package.js”],<br> bundle: true,<br> outfile: “tests/modules/package.js”,<br> format: “esm”,<br> // sourcemap: ‘inline’,<br> minify: true,<br> plugins: [polyfillNode()],<br> }).catch(() =&gt; process.exit(1));</p><p>```</p><p>## Node packages</p><p>```bash<br> yarn add esbuild<br> yarn add esbuild-plugin-polyfill-node<br> ```</p><p>### package.json</p><p>```json<br> “scripts”: {<br> “esbuild-test”: “node esbuild_tests.js”<br> }<br> ```</p><p>### Folders for js</p><p>js-api/hello.js</p><p>```js<br> export function helloWorld(): String {<br> return “Hello, world!”;<br> }<br>```</p><p>package.js</p><p>```js<br>import { helloWorld } from “./js-api/hello”;</p><p>export { helloWorld };<br>```</p><p>```rust<br> let root = env::current_dir().unwrap();<br> println!(“Project root: {:?}”, root);</p><p>// Build path to package.js<br> let js_file_path: PathBuf = root.parent().unwrap().join(“tests/modules/package.js”);<br> println!(“JS file path: {:?}”, js_file_path);</p><p>let path: &amp;Path = js_file_path.as_path();</p><p>println!(“{:?}”, path);</p><p>let source = Source::from_filepath(path).unwrap();</p><p>let module_pathbuf = root.parent().unwrap().join(“tests/modules”);</p><p>let module_path: &amp;Path = module_pathbuf.as_path();</p><p>println!(“{:?}”, module_path);</p><p>// // println!(“source: {:?}”, source);<br> let loader = Rc::new(SimpleModuleLoader::new(module_path).unwrap());<br> // // Instantiate the execution context<br> let context = &amp;mut Context::builder()<br> .module_loader(loader.clone())<br> .build()<br> .unwrap(); // // Add the runtime intrisics<br> let module = Module::parse(source, None, context).unwrap();</p><p>loader.insert(<br> Path::new(module_path)<br> .canonicalize()<br> .unwrap()<br> .join(“main.mjs”),<br> module.clone(),<br> );<br> let promise_result = module<br> // Initial load that recursively loads the module’s dependencies.<br> // This returns a `JsPromise` that will be resolved when loading finishes,<br> // which allows async loads and async fetches.<br> .load(context)<br> .then(<br> Some(<br> NativeFunction::from_copy_closure_with_captures(<br> |_, _, module, context| {<br> // After loading, link all modules by resolving the imports<br> // and exports on the full module graph, initializing module<br> // environments. This returns a plain `Err` since all modules<br> // must link at the same time.<br> module.link(context)?;<br> Ok(JsValue::undefined())<br> },<br> module.clone(),<br> )<br> .to_js_function(context.realm()),<br> ),<br> None,<br> context,<br> )<br> .then(<br> Some(<br> NativeFunction::from_copy_closure_with_captures(<br> // Finally, evaluate the root module.<br> // This returns a `JsPromise` since a module could have<br> // top-level await statements, which defers module execution to the<br> // job queue.<br> |_, _, module, context| Ok(module.evaluate(context).into()),<br> module.clone(),<br> )<br> .to_js_function(context.realm()),<br> ),<br> None,<br> context,<br> );</p><p>// Very important to push forward the job queue after queueing promises.<br> context.run_jobs();</p><p>match promise_result.state() {<br> PromiseState::Pending =&gt; {<br> println!(“Module can’t load”);<br> }<br> PromiseState::Fulfilled(v) =&gt; {<br> assert_eq!(v, JsValue::undefined());<br> }<br> PromiseState::Rejected(err) =&gt; {<br> println!(<br> “{:?}”,<br> JsError::from_opaque(err).try_native(context).unwrap()<br> );<br> }<br> }</p><p>// We can access the full namespace of the module with all its exports.<br> let namespace = module.namespace(context);</p><p>let hello_world_namespace = namespace.get(js_string!(“helloWorld”), context).unwrap();<br> let hello_world = hello_world_namespace<br> .as_callable()<br> .ok_or_else(|| JsNativeError::typ().with_message(“mix export wasn’t a function!”))<br> .unwrap();<br> let result = hello_world<br> .call(&amp;JsValue::undefined(), &amp;[], context)<br> .unwrap();</p><p>println!(“result = {}”, result.display());</p><p>```</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4ed55e2df03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pagination with leptos]]></title>
            <link>https://medium.com/@amiya_rbehera/pagination-with-leptos-5cb6cec27637?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cb6cec27637</guid>
            <category><![CDATA[lepto]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Thu, 09 Jan 2025 05:13:24 GMT</pubDate>
            <atom:updated>2025-01-09T05:15:09.212Z</atom:updated>
            <content:encoded><![CDATA[<p>Using leptos 0.7</p><pre>use leptos::prelude::*;<br>use leptos::ev::SubmitEvent;<br>use serde::{Deserialize, Serialize};<br>use leptos::task::spawn_local;<br>use leptos::html;<br><br><br>#[derive(Serialize, Deserialize, Clone)]<br>struct PaginatedPosts {<br>    posts: Vec&lt;u64&gt;,<br>    current_page: u64,<br>    total_pages: u64,<br>}<br><br>#[component]<br>pub fn Pagination() -&gt; impl IntoView {<br>    let (page, set_page) = signal(1);<br>    let (page_size, set_page_size) = signal(10);<br>    let (posts, set_posts) = signal::&lt;Option&lt;Vec&lt;u64&gt;&gt;&gt;(None);<br>    let (total_posts_length, set_total_posts_length) = signal(0);<br>    let (total_pages, set_total_pages) = signal(0);<br>    let input_element_page: NodeRef&lt;html::Input&gt; = NodeRef::new();<br><br>    let input_element_page_size : NodeRef&lt;html::Input&gt; = NodeRef::new();<br><br>    // Fetch paginated posts when `page` or `page_size` changes<br>    Effect::new(move |_| {<br>        let user = &quot;example_account_id&quot;.to_string(); // Replace with actual user ID<br>        let page = page();<br>        let page_size = page_size();<br><br>        spawn_local(async move {<br>            let result = paginate_posts_by_address(user, page, page_size).await;<br>            match result {<br>                Ok((Some(posts), total_length)) =&gt; {<br>                    set_posts.set(Some(posts.clone()));<br>                    set_total_posts_length.set(total_length);<br>                    set_total_pages.set((total_length + page_size - 1) / page_size);<br>                }<br>                _ =&gt; {<br>                    set_posts.set(None);<br>                    set_total_posts_length.set(0);<br>                    set_total_pages.set(0);<br>                }<br>            }<br>        });<br>    });<br><br>    // Handle page navigation<br>    let go_to_page = move |new_page: u64| {<br>        if new_page &gt; 0 &amp;&amp; new_page &lt;= total_pages() {<br>            set_page.set(new_page);<br>        }<br>    };<br><br>    // Handle page size change<br>    let update_page = move |ev: SubmitEvent| {<br>        ev.prevent_default();<br>        let input = input_element_page.get().expect(&quot;&lt;input&gt; should be mounted&quot;).value();<br>        gloo::console::log!(input.clone());<br>        let new_page = input.parse::&lt;u64&gt;().unwrap_or(1);<br>        set_page.set(new_page); // Reset to the first page<br>    };<br><br>        // Handle page size change<br>        let update_page_size = move |ev: SubmitEvent| {<br>            ev.prevent_default();<br>            let input = input_element_page_size.get().expect(&quot;&lt;input&gt; should be mounted&quot;).value();<br>            let new_size = input.parse::&lt;u64&gt;().unwrap_or(10);<br>            set_page_size.set(new_size);<br>            set_page.set(1); // Reset to the first page<br>        };<br><br>    view! {<br>        &lt;div class=&quot;p-4 space-y-4&quot;&gt;<br>            &lt;h1 class=&quot;text-2xl font-bold&quot;&gt;Paginated Posts&lt;/h1&gt;<br><br>            // Display posts<br>            &lt;div class=&quot;space-y-2&quot;&gt;<br>                {move || match posts() {<br>                    Some(posts) =&gt; {<br>                        posts<br>                            .into_iter()<br>                            .map(|post| {<br>                                view! { &lt;div class=&quot;p-2 border rounded&quot;&gt;{post}&lt;/div&gt; }<br>                            })<br>                            .collect_view()<br>                            .into_any()<br>                    }<br>                    None =&gt; view! { &lt;div&gt;No posts found.&lt;/div&gt; }.into_any(),<br>                }}<br><br>            &lt;/div&gt;<br><br>            // Pagination controls<br>            &lt;div class=&quot;flex items-center justify-between&quot;&gt;<br>                &lt;button<br>                    class=&quot;px-4 py-2 bg-blue-500 text-white rounded disabled:opacity-50&quot;<br>                    on:click=move |_| go_to_page(page() - 1)<br>                    disabled=move || page() &lt;= 1<br>                &gt;<br>                    &quot;Previous&quot;<br>                &lt;/button&gt;<br>                &lt;span class=&quot;text-gray-700&quot;&gt;<br>                    &quot;Page &quot;{page}&quot; of &quot;{total_pages}&quot; (Total Posts: &quot;{total_posts_length}&quot;)&quot;<br>                &lt;/span&gt;<br>                &lt;button<br>                    class=&quot;px-4 py-2 bg-blue-500 text-white rounded disabled:opacity-50&quot;<br>                    on:click=move |_| { go_to_page(page() + 1) }<br>                    disabled=move || { page() &gt;= total_pages() }<br>                &gt;<br>                    &quot;Next&quot;<br>                &lt;/button&gt;<br>            &lt;/div&gt;<br><br>           // Page selector<br>            &lt;form on:submit=update_page class=&quot;flex items-center space-x-2&quot;&gt;<br>                &lt;label class=&quot;text-gray-700&quot;&gt;Page Number:&lt;/label&gt;<br>                &lt;input<br>                    type=&quot;number&quot;<br>                    class=&quot;p-2 border rounded&quot;<br>                    node_ref=input_element_page<br>                    value=move || { page().to_string() }<br>                /&gt;<br>                &lt;button type=&quot;submit&quot; class=&quot;px-4 py-2 bg-green-500 text-white rounded&quot;&gt;<br>                    &quot;Update&quot;<br>                &lt;/button&gt;<br>            &lt;/form&gt;<br>            &lt;br/&gt;<br><br>               // Page size selector<br>            &lt;form on:submit=update_page_size class=&quot;flex items-center space-x-2&quot;&gt;<br>                &lt;label class=&quot;text-gray-700&quot;&gt;Page Size:&lt;/label&gt;<br>                &lt;input<br>                    type=&quot;number&quot;<br>                    class=&quot;p-2 border rounded&quot;<br>                    node_ref=input_element_page_size<br>                    value=move || {page_size().to_string()}<br>                /&gt;<br>                &lt;button type=&quot;submit&quot; class=&quot;px-4 py-2 bg-green-500 text-white rounded&quot;&gt;<br>                    Update<br>                &lt;/button&gt;<br>            &lt;/form&gt;<br>        &lt;/div&gt;<br>    }<br>}<br><br>// Mock API function (replace with your actual API call)<br>async fn paginate_posts_by_address(<br>    user: String,<br>    page: u64,<br>    page_size: u64,<br>) -&gt; Result&lt;(Option&lt;Vec&lt;u64&gt;&gt;, u64), String&gt; {<br>    // Simulate an API call<br>    let all_posts = (1..=100).collect::&lt;Vec&lt;u64&gt;&gt;();<br>    let start = (page - 1) * page_size;<br>    let end = start + page_size;<br>    let posts = all_posts.get(start as usize..end as usize).map(|s| s.to_vec());<br>    let all_posts_length = all_posts.len() as u64;<br>    Ok((posts, all_posts_length))<br>}<br><br></pre><p><a href="https://iambrainstorming.github.io/coding_blog/leptos/pagination.html">https://iambrainstorming.github.io/coding_blog/leptos/pagination.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cb6cec27637" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Switching your text editor]]></title>
            <link>https://medium.com/@amiya_rbehera/switching-your-text-editor-9cbdc327597a?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cbdc327597a</guid>
            <category><![CDATA[helix]]></category>
            <category><![CDATA[text-editor]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Sun, 05 May 2024 08:01:36 GMT</pubDate>
            <atom:updated>2024-05-05T08:02:11.143Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://iambrainstorming.github.io/coding_blog/rust/text-editor.html">https://iambrainstorming.github.io/coding_blog/rust/text-editor.html</a></p><p>## [Helix editor](<a href="https://helix-editor.com/">https://helix-editor.com/</a>)</p><p>&lt;<a href="https://helix-editor.com/">https://helix-editor.com/</a>&gt;</p><p>Modal editor</p><p>A post-modern text editor.</p><p>### Lightweight and Speed:<br>Helix is ightweight nature and fast performance. It runs in the terminal, making it efficient and responsive even on remote servers or low-resource environments.</p><p>### Keyboard-Centric Interface:<br>Helix has a unique modal interface that allows users to navigate and edit text using keyboard commands. This can be very efficient for those who prefer to keep their hands on the keyboard without reaching for the mouse.<br>You use keyboard shortcuts to select, multi-select, delete, copy, and switch modes, making it fast and efficient to write your document or code once you have become familiar with them.</p><p>### Extensive Customization:<br>Helix is highly customizable, allowing users to tailor it to their specific needs. Users can create custom key mappings, and configure settings to create a personalized editing environment.</p><p>To have word wrap:</p><p>.helix/config.toml</p><p>```toml<br>[editor.soft-wrap]<br>enable = true<br>max-wrap = 25 # increase value to reduce forced mid-word wrapping<br>max-indent-retain = 0<br>wrap-indicator = “” # set wrap-indicator to “” to hide it<br>```</p><p>### Learning Curve and Efficiency:<br>While Helix has a learning curve initially, some users argue that once mastered, it can be extremely efficient for text editing and manipulation. In command mode, activated by pressing the colon key (:), you can explore the tutorial (:tutor) to gain experience with Helix commands within a few days or a week.</p><p>### Use yazi for terminal file manager: <br> <br>[Yazi](<a href="https://github.com/sxyazi/yazi">https://github.com/sxyazi/yazi</a>)</p><p>yz-fp</p><p>```bash<br>#!/bin/bash</p><p>selected_file=”$1&quot;</p><p># KEY ASSUMPTIONS<br># — editor pane was the most recently active pane<br># — yazi fp is only open floating pane</p><p># go back to editor<br>zellij action toggle-floating-panes</p><p># open selected file in editor<br>zellij action write 27 # send escape key<br>zellij action write-chars “:open $selected_file”<br>zellij action write 13 # send enter key</p><p># go back to floating yazi pane and close it<br>zellij action toggle-floating-panes<br>zellij action close-pane<br>```</p><p>yy</p><p>```bash<br>#!/bin/bash</p><p>zellij run -c -f — yazi “$PWD” <br>```</p><p>copy yz-fp and yy to /bin folder and make it executable</p><p>```bash<br>sudo cp yz-fp /bin<br>sudo cp yy /bin<br>sudo chmod +x yz-fp<br>sudo chmod +x yy<br>```</p><p>You can configure it for helix in yazi.toml file</p><p>.config/yazi/</p><p>[yazi.toml](<a href="https://yazi-rs.github.io/docs/configuration/overview">https://yazi-rs.github.io/docs/configuration/overview</a>)<br>```toml<br>[opener]<br>helix = [<br> { run = ‘yz-fp “$0”’, desc = “Use yazi as file picker within helix” },<br>]</p><p>[open]<br>rules = [<br> { name = “**/*”, use = “helix” },<br>]<br>```</p><p>~/.config/helix</p><p>config.toml</p><p>```toml<br>[keys.normal]<br>C-y = “:sh yy” # launch filepicker</p><p>[editor.lsp]<br>display-inlay-hints = true</p><p>[keys.normal.space]<br>“H” = “:toggle lsp.display-inlay-hints”<br> <br>```</p><p>It will open file picker on Ctrl+y in zellij</p><p>Space + Capital H for toggle inlay hints</p><p>### Use Zellij terminal workspace</p><p>&lt;<a href="https://zellij.dev/">https://zellij.dev/</a>&gt;</p><p>Zellij Tutorial</p><p>&lt;<a href="https://zellij.dev/tutorials/basic-functionality/">https://zellij.dev/tutorials/basic-functionality/</a>&gt;</p><p>### Rust based terminal</p><p>&lt;<a href="https://github.com/alacritty/alacritty">https://github.com/alacritty/alacritty</a>&gt;</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cbdc327597a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Error handling in leptos]]></title>
            <link>https://medium.com/@amiya_rbehera/error-handling-in-leptos-0aaca4f167bd?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/0aaca4f167bd</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[lepto]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 08:38:30 GMT</pubDate>
            <atom:updated>2024-03-11T08:43:32.511Z</atom:updated>
            <content:encoded><![CDATA[<p>Check input is number and is less than 20</p><p>Using thiserror crate for error handling</p><pre><br>use leptos::*;<br>use serde::{Deserialize, Serialize};<br>use thiserror::Error;<br><br>#[derive(Error, Debug, Clone, Deserialize, Serialize)]<br>pub enum NumberError {<br>    #[error(&quot;Number getter than 20&quot;)]<br>    NumberGreater20,<br>    #[error(&quot;Error parsing to number: `{0}`&quot;)]<br>    ParseIntError(String),<br>}<br><br>#[component]<br>pub fn NumericInput() -&gt; impl IntoView {<br>    let (value, set_value) = create_signal(Ok(0));<br><br>    let on_input = move |ev| {<br>        let result_value = event_target_value(&amp;ev).parse::&lt;i32&gt;();<br>        let result = match result_value {<br>            Ok(parsed_value) =&gt; {<br>                if parsed_value &gt; 20 {<br>                    Err(NumberError::NumberGreater20)<br>                } else {<br>                    Ok(parsed_value)<br>                }<br>            }<br>            Err(value) =&gt; Err(NumberError::ParseIntError(value.to_string())),<br>        };<br>        set_value(result)<br>    };<br><br>    view! {<br>        &lt;h1&gt;&quot;Error Handling&quot;&lt;/h1&gt;<br>        &lt;label&gt;<br>            &quot;Type a number less than than 20 (or something that&#39;s not a number!)&quot;<br>            &lt;input type=&quot;number&quot; on:input=on_input/&gt;<br>            &lt;ErrorBoundary<br>                // the fallback receives a signal containing current errors<br>                fallback=|errors| view! {<br>                    &lt;div class=&quot;error&quot;&gt;<br>                        &lt;p&gt;&quot; Errors: &quot;&lt;/p&gt;<br>                        // we can render a list of errors as strings, if we&#39;d like<br>                        &lt;ul&gt;<br>                            {move || errors.get()<br>                                .into_iter()<br>                                .map(|(_, e)| view! { &lt;li&gt;{e.to_string()}&lt;/li&gt;})<br>                                .collect_view()<br>                            }<br>                        &lt;/ul&gt;<br>                    &lt;/div&gt;<br>                }<br>            &gt;<br>                &lt;p&gt;&quot;You entered &quot; &lt;strong&gt;{value}&lt;/strong&gt;&lt;/p&gt;<br>                 // If you don&#39;t want to display the value:<br>                 // {move || value.get().map(|_| ())}<br>            &lt;/ErrorBoundary&gt;<br>        &lt;/label&gt;<br>    }<br>}<br></pre><p><a href="https://iambrainstorming.github.io/coding_blog/leptos/leptos_error_handling.html">https://iambrainstorming.github.io/coding_blog/leptos/leptos_error_handling.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0aaca4f167bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parsing with Xpath in rust]]></title>
            <link>https://medium.com/@amiya_rbehera/parsing-with-xpath-in-rust-197b10f1e638?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/197b10f1e638</guid>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Thu, 05 Oct 2023 10:54:32 GMT</pubDate>
            <atom:updated>2023-10-05T10:54:32.672Z</atom:updated>
            <content:encoded><![CDATA[<p>Parsing with Xpath in rust</p><p>You can use package: sxd-xpath</p><pre>cargo new xml_parse</pre><p>In Cargo.toml</p><pre>[dependencies]<br>sxd-xpath=&quot;0.4.2&quot;<br>sxd-document=&quot;0.3.2&quot;</pre><pre>use std::fs;<br>use sxd_document::parser;<br>use sxd_xpath::{evaluate_xpath, Context, Factory, Value};<br>fn remove_first_two_lines(input: &amp;str) -&gt; String {<br>    let mut lines = input.lines();<br>    let mut result = String::new();<br><br>    // Skip the first two lines<br>    lines.nth(0);<br>    lines.nth(0);<br><br>    for line in lines {<br>        result.push_str(line);<br>        result.push(&#39;\n&#39;);<br>    }<br><br>    result<br>}<br><br><br>fn get_list() {<br>    let file = fs::read_to_string(&quot;src/ids.xml&quot;).unwrap();<br>    let data = remove_first_two_lines(&amp;file);<br>    let package = parser::parse(&amp;data).expect(&quot;failed to parse XML&quot;);<br>    let document = package.as_document();<br><br>    let value = evaluate_xpath(&amp;document, &quot;//Id&quot;);<br><br>    match value {<br>        Ok(Value::Nodeset(nodeset)) =&gt; {<br>            for node in nodeset.iter() {<br>                println!(&quot;{}&quot;, node.string_value());<br>            }<br>        }<br>        _ =&gt; {<br>            println!(&quot;XPath expression didn&#39;t return a nodeset&quot;);<br>        }<br>    }<br>}<br><br>fn main() {<br>    get_list();<br>}</pre><p>ids.xml</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;<br>&lt;!DOCTYPE eSearchResult PUBLIC &quot;-//NLM//DTD esearch 20060628//EN&quot; &quot;https://eutils.ncbi.nlm.nih.gov/eutils/dtd/20060628/esearch.dtd&quot;&gt;<br>&lt;div&gt;<br>&lt;Id&gt;37793170&lt;/Id&gt;<br>&lt;Id&gt;37793014&lt;/Id&gt;<br>&lt;Id&gt;37792757&lt;/Id&gt;<br>&lt;Id&gt;37792561&lt;/Id&gt;<br>&lt;Id&gt;37792179&lt;/Id&gt;<br>&lt;Id&gt;37790950&lt;/Id&gt;<br>&lt;Id&gt;37790689&lt;/Id&gt;<br>&lt;Id&gt;37790685&lt;/Id&gt;<br>&lt;Id&gt;37790681&lt;/Id&gt;<br>&lt;Id&gt;37790651&lt;/Id&gt;<br>&lt;Id&gt;37789937&lt;/Id&gt;<br>&lt;Id&gt;37789815&lt;/Id&gt;<br>&lt;Id&gt;37789674&lt;/Id&gt;<br>&lt;Id&gt;37789431&lt;/Id&gt;<br>&lt;Id&gt;37788598&lt;/Id&gt;<br>&lt;Id&gt;37788081&lt;/Id&gt;<br>&lt;Id&gt;37787682&lt;/Id&gt;<br>&lt;Id&gt;37787533&lt;/Id&gt;<br>&lt;Id&gt;37787338&lt;/Id&gt;<br>&lt;Id&gt;37787330&lt;/Id&gt;<br>&lt;Id&gt;37787327&lt;/Id&gt;<br>&lt;Id&gt;37787268&lt;/Id&gt;<br>&lt;Id&gt;37783146&lt;/Id&gt;<br>&lt;Id&gt;37781996&lt;/Id&gt;<br>&lt;Id&gt;37781611&lt;/Id&gt;<br>&lt;Id&gt;37779775&lt;/Id&gt;<br>&lt;Id&gt;37779596&lt;/Id&gt;<br>&lt;Id&gt;37779203&lt;/Id&gt;<br>&lt;Id&gt;37777423&lt;/Id&gt;<br>&lt;Id&gt;37776597&lt;/Id&gt;<br>&lt;Id&gt;37776007&lt;/Id&gt;<br>&lt;Id&gt;37774586&lt;/Id&gt;<br>&lt;Id&gt;37774576&lt;/Id&gt;<br>&lt;Id&gt;37773778&lt;/Id&gt;<br>&lt;Id&gt;37773541&lt;/Id&gt;<br>&lt;Id&gt;37772835&lt;/Id&gt;<br>&lt;Id&gt;37772621&lt;/Id&gt;<br>&lt;Id&gt;37771545&lt;/Id&gt;<br>&lt;Id&gt;37771101&lt;/Id&gt;<br>&lt;Id&gt;37770849&lt;/Id&gt;<br>&lt;Id&gt;37770282&lt;/Id&gt;<br>&lt;Id&gt;37768948&lt;/Id&gt;<br>&lt;Id&gt;37768533&lt;/Id&gt;<br>&lt;Id&gt;37768482&lt;/Id&gt;<br>&lt;Id&gt;37768298&lt;/Id&gt;<br>&lt;Id&gt;37766883&lt;/Id&gt;<br>&lt;Id&gt;37766376&lt;/Id&gt;<br>&lt;Id&gt;37766316&lt;/Id&gt;<br>&lt;Id&gt;37766298&lt;/Id&gt;<br>&lt;Id&gt;37765198&lt;/Id&gt;<br>&lt;/div&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=197b10f1e638" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What if crypto token prices are discovered through consensus rather than demand and supply?]]></title>
            <link>https://medium.com/@amiya_rbehera/what-if-crypto-token-prices-are-discovered-through-consensus-rather-than-demand-and-supply-b6a96e6c566b?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6a96e6c566b</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Mon, 19 Dec 2022 07:11:53 GMT</pubDate>
            <atom:updated>2024-03-11T08:40:29.492Z</atom:updated>
            <content:encoded><![CDATA[<p>Scams involving cryptocurrency are extremely prevalent.<br>The majority of coins on the cryptocurrency market are worthless meme coins, but they nevertheless manage to dupe individuals into parting by enticing them to grow their money and making them rich in no time.<br>Crypto scams are currently not limited to big cities now they have even begun targeting underdeveloped villages in nations like India.</p><p>The issue is caused by the price being determined by the supply and demand of tokens on exchanges without considering their utility. The prices of tokens depend on how many people you manage to fool, and the scammer’s ability to make a sudden spike through pump and dump.</p><p>Crypto scams, also negatively impact useful coins, and all currency prices move in sync, both good coins, and bad coins get dumped in a beer market.</p><p>Can we discover prices through consensus and using human rationality rather than speculation? There may be some way out.</p><p>The score schelling game can assist in determining cryptocurrency prices in decentralized exchanges by consensus and human reason.</p><p>The algorithm is provided in the following link:</p><p><a href="https://github.com/amiyatulu/shivarthu/blob/main/docs/Shivarthu.md#price-discovery-of-projects-through-score-schelling-game">https://github.com/amiyatulu/shivarthu/blob/main/docs/Shivarthu.md#price-discovery-of-projects-through-score-schelling-game</a></p><p>But setting an exchange using score schelling game is not without challenges. One of the problem is arbitrage. If the AMM price is lower than the market price, then people will drain all the liquidity and sell it at a higher price in the market. The solution can be the ability to withdraw after a month or have a KYC so that you can’t withdraw tokens after certain limits.<br>Similarly, if the demand and utility of the token are more and the price is set lower, it can create a shortage, and more people will not be benefited, so, prices need to be increased through consensus.</p><p>Blog:</p><p><a href="https://iambrainstorming.github.io/coding_blog/shivarthu/consensus_price_discovery.html">https://iambrainstorming.github.io/coding_blog/shivarthu/consensus_price_discovery.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6a96e6c566b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Love for USD pegged stable coin by the crypto community must end]]></title>
            <link>https://medium.com/@amiya_rbehera/love-for-usd-pegged-stable-coin-by-the-crypto-community-must-end-4255efa2c8a8?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4255efa2c8a8</guid>
            <category><![CDATA[stablecoin-cryptocurrency]]></category>
            <category><![CDATA[crytpocurrencies]]></category>
            <category><![CDATA[crytocurrency]]></category>
            <category><![CDATA[stable-coin]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 11:13:20 GMT</pubDate>
            <atom:updated>2022-06-01T11:13:20.895Z</atom:updated>
            <content:encoded><![CDATA[<p>Terra 2.0 crashed with a collapse of $40 billion. Many speculate the bear market of crypto is because of collapse of Terra. Though reason for collapse is bad algorithmic design, but similar collapse of USD can have precarious impact on whole crypto, and create havoc not just in US but across the globe if crypto is adopted everywhere.</p><p>USD is issued by US govt. Though they maintain about only 10–15% inflation per year, but its never predictable because it&#39;s under centralized control. There are many instances of bank crisis in the history, that lead to sudden devalue of USD, and history will repeat itself.</p><p>Using USD as mainstream crypto doesn’t even meet the ethos of cryptocurrency, as it has to be decentralized. We should limit using USD backed stable coins, and don’t allow it to have a huge market cap.<br>What we need is gold backed or gold price pegged stable coins in mainstream use, so that it doesn’t destabilizes during crisis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*kWBmwSXSEXdel0wOkx94zg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4255efa2c8a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What packages do I need to ditch javascript for the frontend?]]></title>
            <link>https://medium.com/@amiya_rbehera/what-packages-do-i-need-to-ditch-javascript-for-the-frontend-872577a86c1b?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/872577a86c1b</guid>
            <category><![CDATA[yew]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Tue, 12 Apr 2022 17:15:42 GMT</pubDate>
            <atom:updated>2022-04-12T17:44:29.115Z</atom:updated>
            <content:encoded><![CDATA[<p>The more I use rust, the more I like the language. Just two years back I discovered yew framework, that is similar to react. I learned to make a demo app on yew but I can’t move to yew for production till alternatives of the following packages are built for Yew.</p><p>1) Formik and Yup for form checking (<a href="https://github.com/jfbilodeau/yew_form">https://github.com/jfbilodeau/yew_form</a>)</p><p>2) Bootstrap or Material UI for styling (<a href="https://github.com/dancespiele/yew_styles">https://github.com/dancespiele/yew_styles</a>)</p><p>3) Dropzone for file upload (<a href="https://gist.github.com/GlooriousWalrus/b38543ae0e9a9a6a0d1a87d5b4297061">https://gist.github.com/GlooriousWalrus/b38543ae0e9a9a6a0d1a87d5b4297061</a>)</p><p>4) Text editor like Quill</p><p>5) IPFS client (Seems it is available: <a href="https://crates.io/crates/ipfs-embed">https://crates.io/crates/ipfs-embed</a>)</p><p>6) Polkadot Client (<a href="https://github.com/paritytech/subxt">https://github.com/paritytech/subxt</a>) and @polkadot/extension-dapp</p><p>7) Apollo client for graphql (<a href="https://github.com/obmarg/cynic">https://github.com/obmarg/cynic</a>)</p><p>Maybe in one or two years, yew will be production-ready and I can quit javascript. 😀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=872577a86c1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time command to paste in documents]]></title>
            <link>https://medium.com/@amiya_rbehera/time-command-to-paste-in-documents-ccca913813ed?source=rss-a8d67654adeb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccca913813ed</guid>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Amiya Behera]]></dc:creator>
            <pubDate>Fri, 15 May 2020 10:19:48 GMT</pubDate>
            <atom:updated>2020-05-15T10:27:56.442Z</atom:updated>
            <content:encoded><![CDATA[<p>Time management is an essential skill to increase productivity. But typing the current time or date can be tedious for tracking your tasks.</p><p>Here is a Linux way of creating short cuts for date and time:</p><p>Install xclip</p><pre>sudo apt install xclip</pre><p>In bin folder (/bin) create a file mydate</p><pre><strong>sudo</strong> nano mydate</pre><p>In the mydate file:</p><pre>#!/bin/sh<br><strong>echo</strong> &quot;$(date +&quot;%d-%m-%Y %r&quot;)&quot; <strong>|</strong> xclip -sel clip</pre><p>Make the file executable:</p><pre>sudo chmod +x mydate</pre><p>Put the command ``mydate`` in as keyboard shortcut key</p><p>Add short cut key like: Shift+Ctrl+D</p><p>Similarly for time only:</p><p>mytime</p><pre>#!/bin/sh<br>echo &quot;$(date +&quot;%r&quot;)&quot; | xclip -sel clip</pre><p>Create keyboard short cut key by adding command ``mytime``</p><p>You can use Short cut key: Shift + Ctrl + T</p><p>Use your command to copy date or time to clipboard and then Ctrl + V to paste.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccca913813ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>