<?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: Yuqing Ma</title>
    <description>The latest articles on DEV Community by Yuqing Ma (@yuqingma).</description>
    <link>https://dev.to/yuqingma</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%2F984739%2F69c1c1d7-8e48-4c05-83c3-8d03eec5ba56.png</url>
      <title>DEV Community: Yuqing Ma</title>
      <link>https://dev.to/yuqingma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yuqingma"/>
    <language>en</language>
    <item>
      <title>One year of using Ubuntu as daily Operating System from Microsoft Windows</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Tue, 01 Aug 2023 06:23:19 +0000</pubDate>
      <link>https://dev.to/yuqingma/one-year-of-using-ubuntu-as-daily-operating-system-from-microsoft-windows-2012</link>
      <guid>https://dev.to/yuqingma/one-year-of-using-ubuntu-as-daily-operating-system-from-microsoft-windows-2012</guid>
      <description>&lt;p&gt;Background Information&lt;br&gt;
Firstly, personal information about myself, I am a software developer and uses computer mainly for writing codes and internet surfacing. Sometimes, I cut video and edit photos. Secondly, computer hardware information,  CPU is Ryzen 5 2400G and GPU is Radeon RX 470. I built the computer from parts and forgot about the wireless internet, so I use a usb plugged WIFI internet card instead. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zKaBTgZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drvzwk1wblg5ozqso7pf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zKaBTgZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drvzwk1wblg5ozqso7pf.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
General Taste&lt;br&gt;
I don’t want to use Microsoft Windows 11 anymore, unless I have to do it.&lt;br&gt;
Pros of Ubuntu&lt;br&gt;
It is clean. The desktop is clean. The background app is clean. The menu is clean. In Windows 11 System, there is a weather widgets. For me, it is the most useless and annoying feature on the taskbar. When the mouse is over the weather section, a window jump out and cover a third of my screen, containing advertisement and outdated news from old media. There are also advertisement start menu of classic Windows. In Ubuntu there are zero &lt;br&gt;
advertisement and no such hover over window like weather widgets. In Windows 11, all the apps try to get a place at the desktop if not it will be tricky to find them. Then the desktop becomes crowded. Also many apps want to start when the operating system boost up. I know that I can set them not to do it, but sometime they start in the background. Then I find out my computer becomes mysteriously slow down. It need to be cleaned out and reset manually.&lt;br&gt;
Here it is my desktop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GrucGar1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgy4gq8o72oab308t2sz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GrucGar1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgy4gq8o72oab308t2sz.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;br&gt;
It does all the tasks I demanded. It is capable with all the code editing program and has basic apps such as browsers, LibreOffice, printer drivers, database management and social medias… We use more and more online editing also. For example, google drive is able to edit all documents. Canva is great for videos and photos and more. There are also free and more powerful with AI assistance.&lt;br&gt;
Due to its free and open-source Linux-based operating system, the system’s tools are more user friendly than Microsoft. Here is an example of screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e8H99EDS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1u0y6cmj9h49blevl0z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e8H99EDS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1u0y6cmj9h49blevl0z.png" alt="Image description" width="728" height="400"&gt;&lt;/a&gt;&lt;br&gt;
Cons of Ubuntu&lt;br&gt;
It takes time to adapt it. It requires users search information online to install apps and drivers. It could be pros if you want to learn how Operating System and software works  behind the sceens.&lt;br&gt;
It doesn’t have video games. Also, it could be pros if you want to be effective and get ride of addiction. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Webassembly Study Guide</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Mon, 01 May 2023 01:02:26 +0000</pubDate>
      <link>https://dev.to/yuqingma/webassembly-study-guide-acn</link>
      <guid>https://dev.to/yuqingma/webassembly-study-guide-acn</guid>
      <description>&lt;p&gt;Introduction&lt;br&gt;
This article is only focusing on the future and advantages of Webassembly, but telling you the condition of&lt;br&gt;
implementation for Webassembly in nowadays development.&lt;br&gt;
Webassembly is a low-level language, unlike Python or JavaScript, so it is difficult to learn. It is newly&lt;br&gt;
developed and lack of implementation such as, Exceptions or Closures, so the developer has problems to&lt;br&gt;
translate some code from C or JavaScript directly to Webassembly. Therefore, if you want to use it in&lt;br&gt;
industrial world, for client side, it is better to use AssemblyScript, which is built on WebAssembly , and its&lt;br&gt;
packages. Also it is recommended to combination of languages and platforms for large applications. For&lt;br&gt;
backend server, Webassembly is only a binary program and does not include an operating system&lt;br&gt;
environment. We cannot replace Docker with it. At the same time, it is still suggested to use certain functions&lt;br&gt;
or AI (TensorFlow) due to its properties.&lt;br&gt;
AssemblyScript&lt;br&gt;
It is easy to learn AssemblyScript as long as you learned TypeScript and JavaScript. Keep in mind that they&lt;br&gt;
are only syntax similar and the basic logic is different. AssemblyScript provides standard low-level functions&lt;br&gt;
that map directly to WebAssembly. Without AssemblyScript, developers need to use C, GO or Rust to achieve&lt;br&gt;
the Emscripten function. With help of JavaScript framework, such as Vue, React, Angular, you can install the&lt;br&gt;
AssemblyScript written package Lume, a 3D WebGL library. (&lt;a href="https://github.com/lume/glas"&gt;https://github.com/lume/glas&lt;/a&gt;) Since the&lt;br&gt;
WebAssembly takes less time and memory for animation and&lt;br&gt;
video process, the website can be more efficient.&lt;br&gt;
Compiling to WebAssembly&lt;br&gt;
From the official website &lt;a href="https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm"&gt;https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm&lt;/a&gt;, you can learn&lt;br&gt;
how to setup environment and compile C to wasm file, which is binary file can be imported directly to JS file.&lt;br&gt;
The tutorial on Youtube from Michael Grieco (&lt;a href="https://www.youtube.com/watch"&gt;https://www.youtube.com/watch&lt;/a&gt;?&lt;br&gt;
v=RSLHrmDL4kU&amp;amp;list=PLysLvOneEETPM_YbEyZcJ35_3pSdrj33O&amp;amp;index=2&amp;amp;ab_channel=MichaelGrieco)&lt;br&gt;
is great for beginner to learn the concept and use of C to wasm.&lt;br&gt;
Conclusion&lt;br&gt;
If you need a fast development for simple website and deal with small amount of user, you can scape&lt;br&gt;
WebAssembly and keep using Docker. However, with the implementation of VR devices, the future website&lt;br&gt;
requires lots of animation and 3D video process. WebAssembly will be the lead technology in this field.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to use v-model in render function vue 3 composition API?</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Thu, 16 Feb 2023 18:52:30 +0000</pubDate>
      <link>https://dev.to/yuqingma/how-to-use-v-model-in-render-function-vue-3-composition-api-3479</link>
      <guid>https://dev.to/yuqingma/how-to-use-v-model-in-render-function-vue-3-composition-api-3479</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
This article focus on v-model in render function with two kinds of components, custom components and pre-built components. From the official document on VueJs, v-model directive is expanded to modelValue and onUpdate:modelValue props during template compilation—we will have to provide these props ourselves:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export default {&lt;br&gt;
  props: ['modelValue'],&lt;br&gt;
  emits: ['update:modelValue'],&lt;br&gt;
  render() {&lt;br&gt;
    return h(SomeComponent, {&lt;br&gt;
      modelValue: this.modelValue,&lt;br&gt;
      'onUpdate:modelValue': (value) =&amp;gt; this.$emit('update:modelValue', value)&lt;br&gt;
    })&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Soon, you will be confused about where to use the emits and props. In most cases, emits and props are defined in child components and render functions are used in parent components.&lt;br&gt;
Render function applications in custom components:&lt;br&gt;
Let’s define the child component first.&lt;br&gt;
Child Component&lt;br&gt;
`&lt;/p&gt;


&lt;ul&gt;

    &lt;li&gt;

      {{ tag }}
    &lt;/li&gt;

  &lt;/ul&gt;

&lt;p&gt;&lt;br&gt;
&amp;lt;br&amp;gt;
const props = defineProps({&amp;lt;br&amp;gt;
    title: String&amp;lt;br&amp;gt;
})&amp;lt;br&amp;gt;
&lt;code&gt;&lt;br&gt;
We need a props from parent components to pass data to child components. So, title is the props in the child component. The we need to pass data to title in render function from parent component.&lt;br&gt;
&lt;/code&gt;&amp;lt;br&amp;gt;
render(){&amp;lt;br&amp;gt;
    return h(&amp;lt;br&amp;gt;
         Childcustomcom,&amp;lt;br&amp;gt;
    {&amp;lt;br&amp;gt;
        ‘title’:[‘hello’,’this’,’is’,’array’],&amp;lt;br&amp;gt;
    }&amp;lt;br&amp;gt;
)&amp;lt;br&amp;gt;
}&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;script lang="ts"&amp;gt;&amp;lt;br&amp;gt;
import Childcustomcom  from &amp;amp;#39;./childcustomcom.vue&amp;amp;#39;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;export default{&amp;lt;br&amp;gt;
  name: &amp;amp;#39;customcom&amp;amp;#39;,&amp;lt;br&amp;gt;
  components: {&amp;lt;br&amp;gt;
    Childcustomcom&amp;lt;br&amp;gt;
  }&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
`&lt;/p&gt;

&lt;p&gt;Now we are done with props. Then we need to pass data from the child component to parent component. We need an emits. &lt;br&gt;
child Component&lt;br&gt;
`&lt;/p&gt;


&lt;ul&gt;

    &lt;li&gt;

      {{ tag }}
    &lt;/li&gt;

  &lt;/ul&gt;

&lt;p&gt;&lt;br&gt;
&amp;lt;br&amp;gt;
const props = defineProps({&amp;lt;br&amp;gt;
    title: String&amp;lt;br&amp;gt;
})&amp;lt;br&amp;gt;
const newTag = ref(&amp;amp;#39;&amp;amp;#39;)&amp;lt;br&amp;gt;
const emit = defineEmits([&amp;amp;#39;addTag&amp;amp;#39;])&amp;lt;br&amp;gt;
function handleinput(){&amp;lt;br&amp;gt;
    emit(‘addTag, newTag.value)&amp;lt;br&amp;gt;
}&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&lt;code&gt;&lt;br&gt;
In side render function we need v-on to trigger the event. V-on in render function is on the capitalized &lt;br&gt;
&lt;/code&gt;render(){&lt;br&gt;
    return h(&lt;br&gt;
         Childcustomcom,&lt;br&gt;
    {&lt;br&gt;
        ‘title’:[‘hello’,’this’,’is’,’array’],&lt;br&gt;
        ‘onAddTag’ : (value) ={&lt;br&gt;
            console.log(value)&lt;br&gt;
                    },&lt;br&gt;
    },&lt;br&gt;
)&lt;br&gt;
}`&lt;br&gt;
Render function applications in pre-built components:&lt;br&gt;
We use the example from the Naive UI components. &lt;a href="https://www.naiveui.com/en-US/os-theme/components/dynamic-input" rel="noopener noreferrer"&gt;https://www.naiveui.com/en-US/os-theme/components/dynamic-input&lt;/a&gt;&lt;br&gt;
Ninput has dynamic props including v-model value (Value in controlled mode)&lt;br&gt;
but we cannot the value props directly, it will cause error.&lt;br&gt;
Inside render function:&lt;/p&gt;

&lt;p&gt;`render(){&lt;br&gt;
        return h(&lt;br&gt;
        NInput,&lt;br&gt;
        {&lt;br&gt;&lt;br&gt;
            'default-value': customvalue,&lt;br&gt;
            'on-change': (v:string)=&amp;gt;{&lt;br&gt;
                customvalue=v&lt;br&gt;
            },&lt;br&gt;
            type:"text", &lt;br&gt;
        })}&lt;br&gt;
    },&lt;/p&gt;

&lt;p&gt;const customvalue = ref(‘’)&lt;/p&gt;

&lt;p&gt;`Here we need on-change call back function to update the value from input to customvalue, the default-value props to give the initial value to ninput.&lt;/p&gt;

</description>
      <category>vibecoding</category>
    </item>
    <item>
      <title>MarkMap Correction</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Mon, 23 Jan 2023 14:34:40 +0000</pubDate>
      <link>https://dev.to/yuqingma/markmap-correction-175k</link>
      <guid>https://dev.to/yuqingma/markmap-correction-175k</guid>
      <description>&lt;p&gt;The code in the demo of markmap library from &lt;a href="https://markmap.js.org/" rel="noopener noreferrer"&gt;https://markmap.js.org/&lt;/a&gt; does not follows the grammar of Typescript. We need to correct some errors for it.&lt;/p&gt;

&lt;p&gt;Code in markmap-hooks.tsx:&lt;br&gt;
` import React, { useState, useRef, useEffect } from 'react';&lt;br&gt;
import { Transformer } from 'markmap-lib';&lt;br&gt;
import { Markmap } from 'markmap-view';&lt;/p&gt;

&lt;p&gt;const transformer = new Transformer();&lt;br&gt;
const initValue = `# markmap&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;beautiful&lt;/li&gt;
&lt;li&gt;useful&lt;/li&gt;
&lt;li&gt;easy&lt;/li&gt;
&lt;li&gt;interactive
`;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;export default function MarkmapHooks() {&lt;br&gt;
const [value, setValue] = useState(initValue);&lt;br&gt;
// Ref for SVG element&lt;br&gt;
const refSvg = useRef(null);&lt;br&gt;
// Ref for markmap object&lt;br&gt;
const refMm = useRef(null);&lt;/p&gt;

&lt;p&gt;useEffect(() =&amp;gt; {&lt;br&gt;
// Create markmap and save to refMm&lt;br&gt;
if (refMm.current) return;&lt;br&gt;
refMm.current = Markmap.create(refSvg.current);&lt;br&gt;
}, [refSvg.current]);&lt;/p&gt;

&lt;p&gt;useEffect(() =&amp;gt; {&lt;br&gt;
// Update data for markmap once value is changed&lt;br&gt;
const mm = refMm.current;&lt;br&gt;
if (!mm) return;&lt;br&gt;
const { root } = transformer.transform(value);&lt;br&gt;
mm.setData(root);&lt;br&gt;
mm.fit();&lt;br&gt;
}, [refMm.current, value]);&lt;/p&gt;

&lt;p&gt;const handleChange = (e:any) =&amp;gt; {&lt;br&gt;
setValue(e.target.value);&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
&lt;br&gt;
);&lt;br&gt;
}&lt;br&gt;
&lt;code&gt;&lt;br&gt;
I didn’t fix the error in markmap-class.tsx and used it as component so the code from index.tsx is different:&lt;br&gt;
&lt;/code&gt;import React, { useState } from 'react';&lt;br&gt;
import { render } from 'react-dom';&lt;br&gt;
import MarkmapHooks from './markmap-hooks';&lt;br&gt;
import './style.css';&lt;/p&gt;

&lt;p&gt;function TryApp() {&lt;br&gt;
  const [type, setType] = useState('hooks');&lt;/p&gt;

&lt;p&gt;const Component =  MarkmapHooks ;&lt;br&gt;
  return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
      &lt;br&gt;
    &lt;br&gt;
  );&lt;br&gt;
}

&lt;p&gt;export default TryApp;&lt;br&gt;
`&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>productivity</category>
      <category>tooling</category>
    </item>
    <item>
      <title>How to understand example from React Redux from TypeScript?</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Fri, 13 Jan 2023 22:14:37 +0000</pubDate>
      <link>https://dev.to/yuqingma/how-to-understand-example-from-react-redux-from-typescript-g5b</link>
      <guid>https://dev.to/yuqingma/how-to-understand-example-from-react-redux-from-typescript-g5b</guid>
      <description>&lt;p&gt;How to understand example from React Redux from TypeScript?&lt;br&gt;
&lt;strong&gt;Introduction&lt;/strong&gt;:&lt;br&gt;
Redux is essential for data processing in React development and TypeScript is getting popular. The document also recommends using TypeScript.  For beginner of  those concepts, the original document is a little bit challenging. Here, I make some extra notes for the Typescript example.&lt;br&gt;
Sample from &lt;a href="https://redux-toolkit.js.org/tutorials/typescript" rel="noopener noreferrer"&gt;https://redux-toolkit.js.org/tutorials/typescript&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Main&lt;/strong&gt;:&lt;br&gt;
A Store is a place where the entire state of your application lists. It manages the status of the application and has a dispatch(action) function. It is like a brain responsible for all moving parts in Redux. So you can think that store centrally holds the data in memory.&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%2Fgwsb8idfw3ks9ed8s80t.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%2Fgwsb8idfw3ks9ed8s80t.png" alt="Image description" width="500" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Component is fundamental for React, so many concepts can be explained from concept of  components. 
This code comes from index.tsx.&lt;/em&gt;
&lt;code&gt;&amp;lt;Provider store={store}&amp;gt;
&amp;lt;App /&amp;gt;
&amp;lt;/Provider&amp;gt;&lt;/code&gt;
You can consider store is passed to root component as props. That is the reason that all the other child components can use store directly.
Then we start looks at the store.ts in src/app folder.
`import { configureStore, ThunkAction, Action } from '@reduxjs/toolkit';
import counterReducer from '../features/counter/counterSlice';&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;export const store = configureStore({&lt;br&gt;
  reducer: {&lt;br&gt;
    counter: counterReducer,&lt;br&gt;
  },&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;export type AppDispatch = typeof store.dispatch;&lt;br&gt;
export type RootState = ReturnType;&lt;br&gt;
export type AppThunk = ThunkAction&amp;lt;&lt;br&gt;
  ReturnType,&lt;br&gt;
  RootState,&lt;br&gt;
  unknown,&lt;br&gt;
  Action&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;;&lt;code&gt;&lt;br&gt;
_From Object Oriented Programming, we can consider store is an object from configureStore class. We will talk about counterSlice later. Then we look at the type of AppDispatch and RootState.typeof store.dispatch returns a type of store.dispatch and ReturnType&amp;lt;typeof store.getState&amp;gt; also return the type of getState. _&lt;br&gt;
Here it is an example of ReturnType&amp;lt;typeof &amp;gt; with concept of generics&lt;br&gt;
&lt;/code&gt;function sendData(a: number, b: number) {&lt;br&gt;
return {&lt;br&gt;
a: &lt;code&gt;${a}&lt;/code&gt;,&lt;br&gt;
b: &lt;code&gt;${b}&lt;/code&gt;&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
type Data = ReturnType&lt;br&gt;
// The same as writing:&lt;br&gt;
// type Data = {&lt;br&gt;
// a: string,&lt;br&gt;
// b: string&lt;br&gt;
// }`&lt;br&gt;
We should understand an idea Type Assertion in typescript. &lt;br&gt;
Angle Brackets &amp;lt;&amp;gt; is called Type Assertion or casting.&lt;br&gt;
Example:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;`let code: any = 123; &lt;br&gt;
let employeeCode =  code; &lt;br&gt;
console.log(typeof(employeeCode)); //Output: number&lt;/p&gt;

&lt;p&gt;let employee = { };&lt;br&gt;
employee.name = "John"; //Compiler Error: Property 'name' does not exist on type '{}'&lt;br&gt;
employee.code = 123; //Compiler Error: Property 'code' does not exist on type '{}'&lt;/p&gt;

&lt;p&gt;interface Employee { &lt;br&gt;
    name: string; &lt;br&gt;
    code: number; &lt;br&gt;
} &lt;/p&gt;

&lt;p&gt;let employee =  { }; &lt;br&gt;
employee.name = "John"; // OK&lt;br&gt;
employee.code = 123; // OK&lt;code&gt;&lt;br&gt;
Here it is the explaination for ThunkAction&lt;br&gt;
We can consider it as utility types in Typescript.&lt;br&gt;
&lt;/code&gt;export type AppThunk = ThunkAction&amp;lt;&lt;br&gt;
ReturnType,&lt;br&gt;
RootState,&lt;br&gt;
unknown,&lt;br&gt;
Action&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;;`&lt;br&gt;
Then here is the blog to explain ThunkAction&lt;br&gt;
&lt;a href="https://bloggie.io/@_ChristineOo/understanding-typings-of-redux-thunk-action" rel="noopener noreferrer"&gt;https://bloggie.io/@_ChristineOo/understanding-typings-of-redux-thunk-action&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;`import { AnyAction } from 'redux'&lt;br&gt;
import { sendMessage } from './store/chat/actions'&lt;br&gt;
import { RootState } from './store'&lt;br&gt;
import { ThunkAction } from 'redux-thunk'&lt;/p&gt;

&lt;p&gt;export const thunkSendMessage =&lt;br&gt;
  (message: string): ThunkAction =&amp;gt;&lt;br&gt;
  async dispatch =&amp;gt; {&lt;br&gt;
    const asyncResp = await exampleAPI()&lt;br&gt;
    dispatch(&lt;br&gt;
      sendMessage({&lt;br&gt;
        message,&lt;br&gt;
        user: asyncResp,&lt;br&gt;
        timestamp: new Date().getTime()&lt;br&gt;
      })&lt;br&gt;
    )&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;export type ThunkAction&amp;lt;&lt;br&gt;
  R, // Return type of the thunk function&lt;br&gt;
  S, // state type used by getState&lt;br&gt;
  E, // any "extra argument" injected into the thunk&lt;br&gt;
  A extends Action // known types of actions that can be dispatched&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;= (dispatch: ThunkDispatch, getState: () =&amp;gt; S, extraArgument: E) =&amp;gt; R&lt;code&gt;&lt;br&gt;
Redux Thunk is the standard middleware for writing sync and async logic that interacts with the Redux store. A thunk function receives dispatch and getState as its parameters. Redux Thunk has a built in ThunkAction type which we can use to define types for those arguments:&lt;br&gt;
&lt;/code&gt;function exampleAPI() {&lt;br&gt;
  return Promise.resolve('Async Chat Bot')&lt;br&gt;
}&lt;br&gt;
Example of using ThunkAction directly&lt;br&gt;
import { AnyAction } from 'redux'&lt;br&gt;
import { sendMessage } from './store/chat/actions'&lt;br&gt;
import { RootState } from './store'&lt;br&gt;
import { ThunkAction } from 'redux-thunk'&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;export const thunkSendMessage =&lt;br&gt;
  (message: string): ThunkAction =&amp;gt;&lt;br&gt;
  async dispatch =&amp;gt; {&lt;br&gt;
    const asyncResp = await exampleAPI()&lt;br&gt;
    dispatch(&lt;br&gt;
      sendMessage({&lt;br&gt;
        message,&lt;br&gt;
        user: asyncResp,&lt;br&gt;
        timestamp: new Date().getTime()&lt;br&gt;
      })&lt;br&gt;
    )&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;function exampleAPI() {&lt;br&gt;
  return Promise.resolve('Async Chat Bot')&lt;br&gt;
}&lt;br&gt;
`&lt;br&gt;
To reduce repetition, you might want to define a reusable AppThunk type once, in your store file, and then use that type whenever you write a thunk:&lt;br&gt;
export type AppThunk = ThunkAction&amp;lt;&lt;br&gt;
  ReturnType,&lt;br&gt;
  RootState,&lt;br&gt;
  unknown,&lt;br&gt;
  AnyAction&lt;/p&gt;

&lt;blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;In src/features/counter/counterSlice.ts file &lt;br&gt;
Define the state of Counter and pass it to initialState.&lt;br&gt;
`export interface CounterState {&lt;br&gt;
value: number;&lt;br&gt;
status: 'idle' | 'loading' | 'failed';&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const initialState: CounterState = {&lt;br&gt;
value: 0,&lt;br&gt;
status: 'idle',&lt;br&gt;
};&lt;code&gt;&lt;br&gt;
Inside counterSlice object, name:’counter’ gives a name for your actions. If the name is ‘counter’ then the updateCounter action will have {type: ‘counter/updateCounter’} . If it is ‘abc’ then your action will have {type:’abc/updateCounter’}. The name should be distinguished from other reducers’ names.&lt;br&gt;
In the const selectCount = (state: RootState) =&amp;gt; state.counter.value; the counter is not the name counter in counterSlice object. This selector function assumes that the reducer from the slice will be on the counter property of your root reducer. So in store.ts file this code :&lt;br&gt;
&lt;/code&gt;export const store = configureStore({&lt;br&gt;
  reducer: {&lt;br&gt;
    counter: counterReducer,&lt;br&gt;
  },&lt;br&gt;
}); `&lt;br&gt;
It defines the counter in selectCount. The location of the reducer relative to the root state is determined by the property key when you combine your reducers with configureStore or combineReducers.&lt;/p&gt;

&lt;p&gt;In redux, the reducers are the pure functions that contain the logic and calculation that needed to be  performed on the state.&lt;/p&gt;

&lt;p&gt;We need to discuss what extraReducers is. The &lt;code&gt;extraReducers&lt;/code&gt; field lets the slice handle actions defined elsewhere, including actions generated by createAsyncThunk or in other slices.&lt;br&gt;
Builder in action reduer is a type-safe boundary around unsafe code. &lt;br&gt;
addCase will run the reducer if the dispatched action's action.type field exactly matches the string that you provide&lt;br&gt;
&lt;code&gt;const reducer = createReducer(0, {&lt;br&gt;
  "increment": (state) =&amp;gt; state + 1,&lt;br&gt;
  "set": (state, action: PayloadAction&amp;lt;number&amp;gt;) =&amp;gt; action.payload&lt;br&gt;
});&lt;br&gt;
It does the same result as follow:&lt;br&gt;
const reducer = createReducer(0, (builder =&amp;gt; builder&lt;br&gt;
  .addCase(incrementAction, (state) =&amp;gt; state + 1)&lt;br&gt;
  .addCase(setAction, (state, action) =&amp;gt; action.payload)&lt;br&gt;
));&lt;/code&gt;&lt;br&gt;
incrementAsync is an object of createAsyncThunk class so it has type parameters:&lt;br&gt;
A string that will be used to generate additional Redux action type constants, representing the lifecycle of an async request:&lt;br&gt;
For example, a type argument of 'users/requestStatus' will generate these action types:&lt;br&gt;
pending: 'users/requestStatus/pending'&lt;br&gt;
fulfilled: 'users/requestStatus/fulfilled'&lt;br&gt;
rejected: 'users/requestStatus/rejected'&lt;br&gt;
createSlice will return an object that looks like:&lt;br&gt;
{&lt;br&gt;
    name : string,&lt;br&gt;
    reducer : ReducerFunction,&lt;br&gt;
    actions : Record,&lt;br&gt;
    caseReducers: Record.&lt;br&gt;
    getInitialState: () =&amp;gt; State&lt;br&gt;
}&lt;br&gt;
Each function defined in the reducers argument will have a corresponding action creator generated using createAction and included in the result's actions field using the same function name.&lt;br&gt;
That is why we have export const { increment, decrement, incrementByAmount } = counterSlice.actions;&lt;br&gt;
export const incrementIfOdd =&lt;br&gt;
  (amount: number): AppThunk =&amp;gt;&lt;br&gt;
  (dispatch, getState) =&amp;gt; {&lt;br&gt;
    const currentValue = selectCount(getState());&lt;br&gt;
    if (currentValue % 2 === 1) {&lt;br&gt;
      dispatch(incrementByAmount(amount));&lt;br&gt;
    }&lt;br&gt;
  };&lt;br&gt;
The : is also used in typescript to define an objects type. &lt;br&gt;
It is different from function types expression in Typescript&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>How to use Typescript Package in Javascript React?</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Sun, 08 Jan 2023 20:53:12 +0000</pubDate>
      <link>https://dev.to/yuqingma/how-to-use-typescript-package-in-javascript-react-3igk</link>
      <guid>https://dev.to/yuqingma/how-to-use-typescript-package-in-javascript-react-3igk</guid>
      <description>&lt;p&gt;Introduction:&lt;br&gt;
With the popularity of typescript, more newly developed npm package uses Typescript and the existed project mainly uses Javascript as the development language.  It is important to add typescript for an existing React App project.&lt;br&gt;
Setup:&lt;br&gt;
Install typescript:&lt;br&gt;
 npm install --save typescript @types/node @types/react @types/react-dom @types/jest&lt;br&gt;
Created a file with js extension. &lt;br&gt;
Warning: It will cause error if you directly use ts extension.&lt;br&gt;&lt;br&gt;
Here is a demo code from re_point/react-page-slides&lt;br&gt;
`&lt;br&gt;
import React from 'react';&lt;br&gt;
import {ISlideConfig, PageSlides, SlideParallaxType} from '@re_point/react-page-slides';&lt;/p&gt;


&lt;p&gt;export const MainPage = () =&amp;gt; {&lt;br&gt;&lt;br&gt;
    const slides: ISlideConfig[] = [&lt;br&gt;&lt;br&gt;
        {&lt;br&gt;&lt;br&gt;
            content: &lt;/p&gt;first page content,&lt;br&gt;&lt;br&gt;
            style: {&lt;br&gt;&lt;br&gt;
                backgroundImage: 'url("public/photo/photo_1.jpg")'&lt;br&gt;&lt;br&gt;
            }&lt;br&gt;&lt;br&gt;
        },&lt;br&gt;&lt;br&gt;
        {&lt;br&gt;&lt;br&gt;
            content: second page content,&lt;br&gt;&lt;br&gt;
            style: {&lt;br&gt;&lt;br&gt;
                backgroundImage: 'url("public/photo/photo_2.jpg")'&lt;br&gt;&lt;br&gt;
            }&lt;br&gt;&lt;br&gt;
        },&lt;br&gt;&lt;br&gt;
        {&lt;br&gt;&lt;br&gt;
            content: third page content,&lt;br&gt;&lt;br&gt;
            style: {&lt;br&gt;&lt;br&gt;
                backgroundImage: 'url("public/photo/photo_2.jpg")'&lt;br&gt;&lt;br&gt;
            }&lt;br&gt;&lt;br&gt;
        },&lt;br&gt;&lt;br&gt;
    ];&lt;br&gt;&lt;br&gt;
    return (&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        enableAutoScroll={true}&amp;lt;br&amp;gt;
        transitionSpeed={1000}&amp;lt;br&amp;gt;
        slides={slides}&amp;lt;br&amp;gt;
        parallax={{&amp;lt;br&amp;gt;
            offset: 0.6,&amp;lt;br&amp;gt;
            type: SlideParallaxType.reveal&amp;lt;br&amp;gt;
        }}&amp;lt;br&amp;gt;
    /&amp;amp;gt;&amp;lt;br&amp;gt;
)&amp;lt;br&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;};&lt;br&gt;&lt;br&gt;
`Change export const MainPage = () to const MainPage =()&lt;br&gt;&lt;br&gt;
add export default MainPage at the end&lt;/p&gt;

</description>
      <category>cryptocurrency</category>
      <category>blockchain</category>
      <category>bitcoin</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>Supplementary Notes for Vue-Advanced-Cropper</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Fri, 16 Dec 2022 20:47:00 +0000</pubDate>
      <link>https://dev.to/yuqingma/supplementary-notes-for-vue-advanced-cropper-2247</link>
      <guid>https://dev.to/yuqingma/supplementary-notes-for-vue-advanced-cropper-2247</guid>
      <description>&lt;p&gt;Introduction:&lt;br&gt;
There are many images cropper packages on NPM platform. I have tried some of them for my projects and found out the most suitable and compatible image processing tool for Vue Cli 3.  It offers the website (&lt;a href="https://advanced-cropper.github.io/vue-advanced-cropper/"&gt;https://advanced-cropper.github.io/vue-advanced-cropper/&lt;/a&gt; )  for demonstrations and documentations. &lt;br&gt;
At the same time, there are some details to take care about. Also this article is beginer friendly for a simple setup. &lt;br&gt;
Setup&lt;br&gt;
Instead of using  npm install -S vue-advanced-cropper. It requires following command for Vue 3.&lt;br&gt;
&lt;em&gt;npm install -S vue-advanced-cropper@next&lt;/em&gt;&lt;br&gt;
Principal Concepts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h_28LB5Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mwusg7cez6vy4kdzfuvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h_28LB5Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mwusg7cez6vy4kdzfuvq.png" alt="Image description" width="388" height="395"&gt;&lt;/a&gt;&lt;br&gt;
It is composed of three main parts: boundaries, visibleArea and coordinates. &lt;/p&gt;

&lt;p&gt;Boundaries is the image area inside the cropper section. By default, it is equal to an image fitted to a cropper.&lt;/p&gt;

&lt;p&gt;The visibleArea is the part of the image that a user see.  It has same aspect ratio as boundaries. &lt;/p&gt;

&lt;p&gt;Coordinates is the cropped coordinates of an image( left,top,width,height) inside the the visibleArea which is defined by coordinates.&lt;br&gt;
*&lt;em&gt;Minimal Working Example&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
It is necessary to implement and start with the minimal working example.&lt;br&gt;
`&lt;br&gt;
    
        :src="img"&lt;br&gt;
        @change="change"&lt;br&gt;
    /&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&amp;lt;br&amp;gt;
import { Cropper } from &amp;amp;#39;vue-advanced-cropper&amp;amp;#39;;&amp;lt;br&amp;gt;
import &amp;amp;#39;vue-advanced-cropper/dist/style.css&amp;amp;#39;;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;export default {&amp;lt;br&amp;gt;
    components: {&amp;lt;br&amp;gt;
        Cropper,&amp;lt;br&amp;gt;
    },&amp;lt;br&amp;gt;
    data() {&amp;lt;br&amp;gt;
        return {&amp;lt;br&amp;gt;
            img: &amp;amp;#39;&amp;lt;a href="https://images.pexels.com/photos/4323307/pexels-photo-4323307.jpeg"&amp;gt;https://images.pexels.com/photos/4323307/pexels-photo-4323307.jpeg&amp;lt;/a&amp;gt;&amp;amp;#39;,&amp;lt;br&amp;gt;
        };&amp;lt;br&amp;gt;
    },&amp;lt;br&amp;gt;
    methods: {&amp;lt;br&amp;gt;
        change({ coordinates, canvas }) {&amp;lt;br&amp;gt;
            console.log(coordinates, canvas);&amp;lt;br&amp;gt;
        },&amp;lt;br&amp;gt;
    },&amp;lt;br&amp;gt;
};&amp;lt;br&amp;gt;
&lt;code&gt;&lt;br&gt;
To achieve the result of static cropper, you only need to alternate the &amp;lt;cropper /&amp;gt; section in the minimal working example with the following code.&lt;br&gt;
&lt;/code&gt;
    :src="img"&lt;br&gt;
    :stencil-props="{&lt;br&gt;
        handlers: {},&lt;br&gt;
        movable: false,&lt;br&gt;
        scalable: false,&lt;br&gt;
        aspectRatio: 1,&lt;br&gt;
    }"&lt;br&gt;
    :resize-image="{&lt;br&gt;
        adjustStencil: false&lt;br&gt;
    }"&lt;br&gt;
    image-restriction="stencil"&lt;br&gt;
/&amp;gt;&lt;code&gt;&lt;br&gt;
For the fixed stencil size, change the &amp;lt;cropper/&amp;gt; with  &lt;br&gt;
&lt;/code&gt;
    :src="img"&lt;br&gt;
    :stencil-props="{&lt;br&gt;
        handlers: {},&lt;br&gt;
        movable: false,&lt;br&gt;
        scalable: false,&lt;br&gt;
    }"&lt;br&gt;
    :stencil-size="{&lt;br&gt;
        width: 280,&lt;br&gt;
        height: 280&lt;br&gt;
    }"&lt;br&gt;
    image-restriction="stencil"&lt;br&gt;
/&amp;gt;&lt;code&gt;&lt;br&gt;
If you need to move and resize its stencil, classic hybrid method is recommended.&lt;br&gt;
&lt;/code&gt;
    :src="img"&lt;br&gt;
    :auto-zoom="true"&lt;br&gt;
 /&amp;gt;&lt;code&gt;&lt;br&gt;
There are only two default stencil, RectangleStencil, which shows above, and  CircleStencil. I created a simple circleStencil example based from the instruction. &lt;br&gt;
&lt;/code&gt;&lt;br&gt;

src="https://images.pexels.com/photos/1254140/pexels-photo-1254140.jpeg?auto=compress&amp;amp;cs=tinysrgb&amp;amp;dpr=2&amp;amp;h=650&amp;amp;w=940"&lt;br&gt;
:stencil-component="$options.components.CircleStencil"&lt;br&gt;
/&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&amp;lt;br&amp;gt;
import { CircleStencil, Cropper } from &amp;amp;#39;vue-advanced-cropper&amp;amp;#39;;&amp;lt;br&amp;gt;
import &amp;amp;#39;vue-advanced-cropper/dist/style.css&amp;amp;#39;;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;export default {&amp;lt;br&amp;gt;
components: {&amp;lt;br&amp;gt;
Cropper,CircleStencil&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
data() {&amp;lt;br&amp;gt;
return {&amp;lt;br&amp;gt;
img: &amp;amp;#39;&amp;lt;a href="https://images.pexels.com/photos/4323307/pexels-photo-4323307.jpeg"&amp;gt;https://images.pexels.com/photos/4323307/pexels-photo-4323307.jpeg&amp;lt;/a&amp;gt;&amp;amp;#39;,&amp;lt;br&amp;gt;
};&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
methods: {&amp;lt;br&amp;gt;
change({ coordinates, canvas }) {&amp;lt;br&amp;gt;
console.log(coordinates, canvas);&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
};&amp;lt;br&amp;gt;
&lt;code&gt;&lt;br&gt;
Here is the example with circle edition of cropper with upload ability. &lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Load image&lt;/p&gt;





&lt;p&gt;&amp;lt;br&amp;gt;
import { CircleStencil, Cropper } from &amp;amp;#39;vue-advanced-cropper&amp;amp;#39;;&amp;lt;br&amp;gt;
import &amp;amp;#39;vue-advanced-cropper/dist/style.css&amp;amp;#39;;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// This function is used to detect the actual image type, &amp;lt;br&amp;gt;
function getMimeType(file, fallback = null) {&amp;lt;br&amp;gt;
const byteArray = (new Uint8Array(file)).subarray(0, 4);&amp;lt;br&amp;gt;
let header = &amp;amp;#39;&amp;amp;#39;;&amp;lt;br&amp;gt;
for (let i = 0; i &amp;amp;lt; byteArray.length; i++) {&amp;lt;br&amp;gt;
header += byteArray[i].toString(16);&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
switch (header) {&amp;lt;br&amp;gt;
case &amp;amp;quot;89504e47&amp;amp;quot;:&amp;lt;br&amp;gt;
return &amp;amp;quot;image/png&amp;amp;quot;;&amp;lt;br&amp;gt;
case &amp;amp;quot;47494638&amp;amp;quot;:&amp;lt;br&amp;gt;
return &amp;amp;quot;image/gif&amp;amp;quot;;&amp;lt;br&amp;gt;
case &amp;amp;quot;ffd8ffe0&amp;amp;quot;:&amp;lt;br&amp;gt;
case &amp;amp;quot;ffd8ffe1&amp;amp;quot;:&amp;lt;br&amp;gt;
case &amp;amp;quot;ffd8ffe2&amp;amp;quot;:&amp;lt;br&amp;gt;
case &amp;amp;quot;ffd8ffe3&amp;amp;quot;:&amp;lt;br&amp;gt;
case &amp;amp;quot;ffd8ffe8&amp;amp;quot;:&amp;lt;br&amp;gt;
return &amp;amp;quot;image/jpeg&amp;amp;quot;;&amp;lt;br&amp;gt;
default:&amp;lt;br&amp;gt;
return fallback;&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
}&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;export default {&amp;lt;br&amp;gt;
components: {&amp;lt;br&amp;gt;
Cropper,&amp;lt;br&amp;gt;
CircleStencil&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
data() {&amp;lt;br&amp;gt;
return {&amp;lt;br&amp;gt;
image: {&amp;lt;br&amp;gt;
src: null,&amp;lt;br&amp;gt;
type: null&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
};&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
methods: {&amp;lt;br&amp;gt;
crop() {&amp;lt;br&amp;gt;
const { canvas } = this.$refs.cropper.getResult();&amp;lt;br&amp;gt;
canvas.toBlob((blob) =&amp;amp;gt; {&amp;lt;br&amp;gt;
// Do something with blob: upload to a server, download and etc.&amp;lt;br&amp;gt;
}, this.image.type);&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
reset() {&amp;lt;br&amp;gt;
this.image = {&amp;lt;br&amp;gt;
src: null,&amp;lt;br&amp;gt;
type: null&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
loadImage(event) {&amp;lt;br&amp;gt;
// Reference to the DOM input element&amp;lt;br&amp;gt;
const { files } = event.target;&amp;lt;br&amp;gt;
// Ensure that you have a file before attempting to read it&amp;lt;br&amp;gt;
if (files &amp;amp;amp;&amp;amp;amp; files[0]) {&amp;lt;br&amp;gt;
// 1. Revoke the object URL, to allow the garbage collector to destroy the uploaded before file&amp;lt;br&amp;gt;
if (this.image.src) {&amp;lt;br&amp;gt;
URL.revokeObjectURL(this.image.src)&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
// 2. Create the blob link to the file to optimize performance:&amp;lt;br&amp;gt;
const blob = URL.createObjectURL(files[0]);&amp;lt;br&amp;gt;
// 3. The steps below are designated to determine a file mime type to use it during the &amp;lt;br&amp;gt;
// getting of a cropped image from the canvas. You can replace it them by the following string, &amp;lt;br&amp;gt;
// but the type will be derived from the extension and it can lead to an incorrect result:&amp;lt;br&amp;gt;
//&amp;lt;br&amp;gt;
// this.image = {&amp;lt;br&amp;gt;
// src: blob;&amp;lt;br&amp;gt;
// type: files[0].type&amp;lt;br&amp;gt;
// }&amp;lt;br&amp;gt;
// Create a new FileReader to read this image binary data&amp;lt;br&amp;gt;
const reader = new FileReader();&amp;lt;br&amp;gt;
// Define a callback function to run, when FileReader finishes its job&amp;lt;br&amp;gt;
reader.onload = (e) =&amp;amp;gt; {&amp;lt;br&amp;gt;
// Note: arrow function used here, so that &amp;amp;quot;this.image&amp;amp;quot; refers to the image of Vue component&amp;lt;br&amp;gt;
this.image = {&amp;lt;br&amp;gt;
// Set the image source (it will look like blob:&amp;lt;a href="http://example.com/2c5270a5-18b5-406e-a4fb-07427f5e7b94"&amp;gt;http://example.com/2c5270a5-18b5-406e-a4fb-07427f5e7b94&amp;lt;/a&amp;gt;)&amp;lt;br&amp;gt;
src: blob,&amp;lt;br&amp;gt;
// Determine the image type to preserve it during the extracting the image from canvas:&amp;lt;br&amp;gt;
type: getMimeType(e.target.result, files[0].type),&amp;lt;br&amp;gt;
};&amp;lt;br&amp;gt;
};&amp;lt;br&amp;gt;
// Start the reader job - read file as a data url (base64 format)&amp;lt;br&amp;gt;
reader.readAsArrayBuffer(files[0]);&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
},&amp;lt;br&amp;gt;
destroyed() {&amp;lt;br&amp;gt;
// Revoke the object URL, to allow the garbage collector to destroy the uploaded before file&amp;lt;br&amp;gt;
if (this.image.src) {&amp;lt;br&amp;gt;
URL.revokeObjectURL(this.image.src)&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
};&amp;lt;br&amp;gt;
`&lt;br&gt;
Remaind: toBlob is very important because that toBlob() will only do the first bullet synchronously, but will do the conversion to image format in a non blocking manner&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Compare Composition API and Options API in VueJS CLI Life-cycle</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Tue, 06 Dec 2022 17:07:55 +0000</pubDate>
      <link>https://dev.to/yuqingma/compare-composition-api-and-options-api-in-vuejs-cli-life-cycle-55h5</link>
      <guid>https://dev.to/yuqingma/compare-composition-api-and-options-api-in-vuejs-cli-life-cycle-55h5</guid>
      <description>&lt;p&gt;Introduction:&lt;br&gt;
In Vue 3 composition api alone with Typescript is available and gaining popularity in web and application development industry. In this lecture, we will talk about the usage and adventages of  options API and composition API in term of Life-cycle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NsK6RC-C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9agvj2pt3pg3t3ezbiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NsK6RC-C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9agvj2pt3pg3t3ezbiv.png" alt="Image description" width="880" height="1392"&gt;&lt;/a&gt;&lt;br&gt;
Why Life-Cycle?&lt;br&gt;
Because JavaScript is a single-threaded, non-blocking, asynchronous, concurrent programming language, which allows you to open parts of web pages at the same time and single crush doesn’t cause the shut down of the entire website, and Vue Cli is mainly built with JavaScript. Therefore we need to define a procedure for data fetching and operational logic. Otherwise if the logical function run before the data is ready, it will cause error. If you choose to use options API, you always need to remember or try which part of your events are and where your data are coming from. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9QLBryJ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rheelz014m6dwvuualv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9QLBryJ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rheelz014m6dwvuualv6.png" alt="Image description" width="132" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here it is the grammar of the options API. Async is required when await even it defined inside.&lt;br&gt;
Note that setup() is called before data() and components, so inside setup there is no access to data(), such as this.name in async mounted(). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a9wBA-z3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kxusn160oq58eoruq781.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a9wBA-z3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kxusn160oq58eoruq781.png" alt="Image description" width="392" height="522"&gt;&lt;/a&gt;&lt;br&gt;
How to get and post data in setup()?&lt;br&gt;
Suppose the data provided from other component, you need an inject package from ‘vue’ then therefore async setup can have access to the inject(‘id’). To post a data from setup, we need return it, for example trylist, audioList here. In async beforeUpdate(), we can directly use audioList.&lt;/p&gt;

&lt;p&gt;Console.Log Problems&lt;br&gt;
In JavaScript synchronous function, console.log can't execute until the method it called is done. In async function console.log executes independently and doesn’t wait till the response. It may cause error sometimes, so a better way to check data validation is to use it in  or Html to show data on pages.&lt;br&gt;
Composition API&lt;br&gt;
Instead of thinking about the sequence of life-cycle in options API. In composition API with TypeScript, everything can be defined inside setup function. The syntax followed:&lt;/p&gt;

&lt;p&gt;import { inject } from 'vue'&lt;br&gt;
import { defineComponent } from 'vue'&lt;br&gt;
import {useStore} from ‘vuex’&lt;br&gt;
const store = useStore()&lt;br&gt;
const onsubmitresult = () =&amp;gt;{&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W1HEaP73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nkz7rmxi89wbhd7zxr42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W1HEaP73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nkz7rmxi89wbhd7zxr42.png" alt="Image description" width="612" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can consider composition API is in options setup function without return. With TypeScript, which is object-oriented programming language, you can use it like Java or  C++.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TwTUBog1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6k7o3c5pb0xui8e0j8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TwTUBog1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6k7o3c5pb0xui8e0j8c.png" alt="Image description" width="589" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Therefore with the concept of object- oriented programming, we don’t need to check the life-cycle of API and step procedure, such as await then ... ,and we only need to think about how logic of function,data types, etc.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>compositionapi</category>
      <category>optionsapi</category>
    </item>
    <item>
      <title>Fix vetur can't find package.json Error</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Tue, 06 Dec 2022 15:55:39 +0000</pubDate>
      <link>https://dev.to/yuqingma/fix-vetur-cant-find-packagejson-error-24jj</link>
      <guid>https://dev.to/yuqingma/fix-vetur-cant-find-packagejson-error-24jj</guid>
      <description>&lt;p&gt;Working with vs code and vue project, we may encounter error from vs code “vetur can't find&lt;br&gt;
package.json” .&lt;br&gt;
The problem,sometimes, causes by vetur, because it looks for the package.json in root directory of&lt;br&gt;
opening folder. We need to add a vetur.config.js file in the root folder of the project.&lt;br&gt;
The content follows:&lt;br&gt;
// vetur.config.js&lt;br&gt;
/** @type {import('vls').VeturConfig} &lt;em&gt;/&lt;br&gt;
module.exports = {&lt;br&gt;
// **optional&lt;/em&gt;* default: &lt;code&gt;{}&lt;/code&gt;&lt;br&gt;
// override vscode settings&lt;br&gt;
// Notice: It only affects the settings used by Vetur.&lt;br&gt;
settings: {&lt;br&gt;
"vetur.useWorkspaceDependencies": true,&lt;br&gt;
"vetur.experimental.templateInterpolationService": true&lt;br&gt;
},&lt;br&gt;
// &lt;strong&gt;optional&lt;/strong&gt; default: &lt;code&gt;[{ root: './' }]&lt;/code&gt;&lt;br&gt;
// support monorepos&lt;br&gt;
projects: [&lt;br&gt;
'./packages/repo2', // shorthand for only root.&lt;br&gt;
{&lt;br&gt;
// &lt;strong&gt;required&lt;/strong&gt;&lt;br&gt;
// Where is your project?&lt;br&gt;
// It is relative to &lt;code&gt;vetur.config.js&lt;/code&gt;.&lt;br&gt;
root: './packages/repo1',&lt;br&gt;
// &lt;strong&gt;optional&lt;/strong&gt; default: &lt;code&gt;'package.json'&lt;/code&gt;&lt;br&gt;
// Where is &lt;code&gt;package.json&lt;/code&gt; in the project?&lt;br&gt;
// We use it to determine the version of vue.&lt;br&gt;
// It is relative to root property.&lt;br&gt;
package: './package.json',&lt;br&gt;
// &lt;strong&gt;optional&lt;/strong&gt;&lt;br&gt;
// Where is TypeScript config file in the project?&lt;br&gt;
// It is relative to root property.&lt;br&gt;
tsconfig: './tsconfig.json',&lt;br&gt;
// &lt;strong&gt;optional&lt;/strong&gt; default: &lt;code&gt;'./.vscode/vetur/snippets'&lt;/code&gt;&lt;br&gt;
// Where is vetur custom snippets folders?&lt;br&gt;
snippetFolder: './.vscode/vetur/snippets',&lt;br&gt;
// &lt;strong&gt;optional&lt;/strong&gt; default: &lt;code&gt;[]&lt;/code&gt;&lt;br&gt;
// Register globally Vue component glob.&lt;br&gt;
// If you set it, you can get completion by that components.&lt;br&gt;
// It is relative to root property.&lt;br&gt;
// Notice: It won't actually do it. You need to use &lt;code&gt;require.context&lt;/code&gt; or &lt;code&gt;Vue.component&lt;/code&gt;&lt;br&gt;
globalComponents: [&lt;br&gt;
'./src/components/*&lt;em&gt;/&lt;/em&gt;.vue'&lt;br&gt;
]&lt;br&gt;
}&lt;br&gt;
]&lt;br&gt;
}&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Four Ways to Create Docker Image for Java SpringBoot Project</title>
      <dc:creator>Yuqing Ma</dc:creator>
      <pubDate>Mon, 05 Dec 2022 16:14:35 +0000</pubDate>
      <link>https://dev.to/yuqingma/four-ways-to-create-docker-image-for-java-springboot-project-17cj</link>
      <guid>https://dev.to/yuqingma/four-ways-to-create-docker-image-for-java-springboot-project-17cj</guid>
      <description>&lt;p&gt;In this lecture, we will discuss how to build up Docker Image for the SpringBoot project in 4 different ways.&lt;br&gt;
(1) use spring-boot-maven-plugin built-in Build-Image (without Dockerfile)&lt;br&gt;
(2) use Jib-Maven-Plugin (without Dockerfile)&lt;br&gt;
(3) use dockerfle-maven-plugin (with Dockerfile)&lt;br&gt;
(4) standard docerfile&lt;br&gt;
Prepare:&lt;br&gt;
Code:&lt;br&gt;
&lt;a href="https://github.com/davelms/medium-articles/tree/master/spring-maven-docker"&gt;https://github.com/davelms/medium-articles/tree/master/spring-maven-docker&lt;/a&gt;&lt;br&gt;
make sure the following command can run spring boot Project&lt;br&gt;
First, use spring-boot-maven-plugin built-in Build-Image&lt;br&gt;
SpringBoot preinstalls the plugin for building the Docker image. We don’t need to do any modifications, we need to make sure that it is in the poxm.xml file (spring-boot-starter-parent)&lt;br&gt;
All the setup is default setup and you don’t need to do any modification also.&lt;br&gt;
Run the following command in the Spring Boot Root directory.&lt;br&gt;
&lt;em&gt;mvn spring-boot:build-image&lt;/em&gt;&lt;br&gt;
Once you see Successfully built image, you can type:&lt;br&gt;
_docker images&lt;br&gt;
_For verifying if the image works with the name of the jar file&lt;br&gt;
_docker run -p 9000:8080 -t name:version&lt;br&gt;
_Then goes to localhost:9000 to test the run&lt;/p&gt;

&lt;p&gt;Second, Jib-Maven-Plugin&lt;br&gt;
You only need to run the following command&lt;br&gt;
mvn compile com.google.cloud.tools:jib-maven-plugin:2.3.0:dockerBuild&lt;br&gt;
~mvn compile&lt;br&gt;
com.google.cloud.tools:jib-maven-plugin:2.3.0&lt;br&gt;
use Jib plugin&lt;br&gt;
once success you can see&lt;br&gt;
Built image to Docker daemon as …&lt;/p&gt;

&lt;p&gt;Third&lt;br&gt;
We need a Dockerfile in the root directory.&lt;br&gt;
FROM adoptopenjdk/openjdk11:alpine&lt;br&gt;
RUN addgroup -S spring &amp;amp;&amp;amp; adduser -S spring -G spring&lt;br&gt;
USER spring:spring&lt;br&gt;
VOLUME /tmp&lt;br&gt;
ARG JAR_FILE&lt;br&gt;
ADD ${JAR_FILE} /app/app.jar&lt;br&gt;
EXPOSE 8080&lt;br&gt;
ENTRYPOINT [“java”,”-Djava.security.egd=file:/dev/./urandom”,”-jar”,”/app/app.jar”]&lt;br&gt;
In pom.xml file, you need to add tags and some configurations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w9gBX9Eg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1x11l246xg0a5ysfb8rv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w9gBX9Eg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1x11l246xg0a5ysfb8rv.png" alt="Image description" width="880" height="1300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run command MVN PACKAGE&lt;/p&gt;

&lt;p&gt;Fourth,with docker build command for docker images&lt;br&gt;
With installed java 11 and maven, the following command can run&lt;br&gt;
mvn spring-boot:run&lt;br&gt;
Spring Boot framework&lt;br&gt;
The docker file as follow :&lt;br&gt;
&lt;em&gt;FROM adoptopenjdk/openjdk11:alpine-jre&lt;br&gt;
FROM maven:3.6.3 AS maven&lt;br&gt;
LABEL MAINTAINER=”&lt;a href="mailto:anyname@gmail.com"&gt;anyname@gmail.com&lt;/a&gt;”&lt;br&gt;
WORKDIR /usr/src/app&lt;br&gt;
COPY . /usr/src/app&lt;br&gt;
RUN mvn package&lt;br&gt;
CMD [“mvn”,”spring-boot:run”]&lt;/em&gt;&lt;br&gt;
Build the container image&lt;br&gt;
docker build -t nametheimage .&lt;br&gt;
You can check the image in docker Images.&lt;br&gt;
Done&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>docker</category>
      <category>java</category>
    </item>
  </channel>
</rss>
