teleren/devto huggingface dataset:
Setup Pinia in Nuxt 3
Tags: nuxt3, javascript, pinia, node
Published: 2021-11-28 06:22:51

May be you are already learned about global state and the Vuex store in Vue and Nuxt projects. Is there any other store for Vue3. Yes, Pinia

 A minimal app is required to try Pinia store, let's create a nuxt3 app. 

## Setup Pinia store in a Nuxt3 app
 A minimal app is required to try Pinia store, let's create a nuxt3 app.

```
npx nuxi init nuxt3-app
```

To setup Pinia store add the Nuxt build module configuration, in nuxt-config, may be the yarn installation will already add it for you,lol.

```
yarn add pinia @pinia/nuxt
```
The nuxt config will look like this
```
// nuxt.config.js
export default {
  // ... other options
  buildModules: [
    '@pinia/nuxt',
  ],
}
```
## Create the store 
Go ahead and create store.ts in the src folder. Pinia uses same philosophy of Vuex, the official Vue  store. 

```
//store.ts
import { defineStore, acceptHMRUpdate} from 'pinia'

export const useStore = defineStore('storeId', {
  // arrow function recommended for full type inference
  state: () => {
    return {
      // all these properties will have their type inferred automatically
      counter: 10,
      name: 'Eduardo',
      isAdmin: true,
    }
  },
  actions:{
     hit(){
       this.counter++;
     }
  },

  getters:{
    getCount:(state)=>state.counter,
    getUser: (state)=> {
      state.name
    }
  }
})

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useStore, import.meta.hot))
}
```
### Accessing the state

 Accessing the state / getters / actions in a component by using the useStore. Sorry about mutation they are gone for ever.
```
//in some component
<script>
import { useStore } from '@/store'
export default {  
  data() {
    return {
      store: useStore()
    }
  },
}
</script>
```
In the template we can use the reactive store to access actions/ getter/ state.

### State
A single state can be accessed as follows
```
<template>   
   <div>
    {{store.name}}
......
````
### Getters
Getters are functions which return the read only state for stores, which can be also accessed with store object and insert in template with my favorite double mustache.

```
<template>  
{{store.getCount}}
......
```
### Actions
Actions are for making something happen, like increasing a count, or validating a user etc.

```<v-btn @click="store.hit()">Hit me</v-btn>```

Read more [Nuxt3 guides](https://devguides.vercel.app)
OverSimplified: Programming Languages
Tags: beginners, computerscience, programming, concepts
Published: 2021-11-28 06:20:44

> *Welcome! In this series, I try to oversimplify CS concepts in an attempt to help us all better understand them. Thanks for your time, enjoy!*

---

##What is a Programming Language?
- Programming Languages are tools that provide us with a set of rules and keywords which we can use to communicate with computers.

####Okay so... how does this help us communicate?
- Computers only understand _**Binary (1's and 0's)**_ or _**Machine Code**_.
- Programming Languages allow us to write code that is legible to us, but can also be _**compiled**_ into machine code.

![Alt Text](https://media.giphy.com/media/7FrOU9tPbgAZtxV5mb/giphy.gif)

(If you want to take a deep dive into how computers read and execute code I recommend watching [this video](https://www.youtube.com/watch?v=QXjU9qTsYCc).)

---

##Low-Level vs High-Level Languages
- _**Lower Level Languages (Assembly, Machine Code, etc...)**_:
  - Require management of hardware processes
  - Harder to read/write
  - Quicker to compile/execute
- _**Higher Level Languages (Python, JS, etc...)**_:
  - Hide hardware processes from us / abstract them away
  - Easier to read/write
  - Slower to compile/execute
- _**Abstraction**_ is a buzzword that refers to the level of control a language requires us to have over hardware processes.

---

## Statically Typed vs Dynamically Typed Languages
- Types refer to how a language treats [_**variables**_](https://dev.to/sinaprograms/oversimplified-variables-1b5f).
- _**Statically typed languages**_:
  - Define the data types of variables
  - Variables can not have a value with a different data type

```
int numTen = 10
str greeting = "Hello World"
```
- _**Dynamically typed languages**_:
  - Data type of variable = data type of the value
  - Allow us to assign and reassign any value to any variable
```
numTen = 10
numTen = "Hello World"
```
---
##Best Programming Languages to get you employed in 2023
- _**Entry level**_:
  - JavaScript (*Web Development*)
  - Python (*Data Science & A.I.*)
  - Swift (*Mobile*)
- _**Robotics and Gaming**_:
  - C++
- _**Blockchain**_:
  1. Solidity
  2. Rust
  3. Go
- _**Enterprise**_:
  - Python
  - C++
  - Java
Using NEW, instead of MAKE, to create slice
Tags: go
Published: 2021-11-28 05:43:43

---
title: Using NEW, instead of MAKE, to create slice
published: true
description: 
tags: go
//cover_image: https://direct_url_to_image.jpg
---

As we know, slices in golang are reference types, and hence, need `make` to initialize them.

```go
func main() {
	a := make([]int32, 0)
	a = append(a, 10, 20, 30)
	fmt.Println(len(a), cap(a), reflect.ValueOf(a).Kind())
}
>>> 3 4 slice
```

But, can we use `new` to make slices? It's meant to be used for value types only. So how can it work here?🤯

Let's see

```go
func main() {
	a := new([]int32)
}
```
Does this↑ work? Yes. It does. So what is the difference?

The difference is that this gives you a pointer, as is the case anytime you use `new`. Thus to actually use it, you have to dereference it everytime. 

Example:

```go
func main() {
	a := new([]int32)
	*a = append(*a, 10, 20, 30)
	fmt.Println(len(*a), cap(*a), reflect.ValueOf(*a).Kind())
}
>>> 3 4 slice
```

Another simple change you can do is to dereference it immediately after creation. This will save you the effort of dereferencing it every other time.

```go
func main() {
	a := *new([]int32)
	a = append(a, 10, 20, 30)
	fmt.Println(len(a), cap(a), reflect.ValueOf(a).Kind())
}
>>> 3 4 slice
```

There's another important concept:
> Every time you append to a slice, it gives you a new slice with a different address (though it points to same underlying array)

Let's see this with same example:

```go
func main() {
	a := make([]int32, 0)
	fmt.Printf("%p\n", a)
	
	a = append(a, 10, 20, 30)
	fmt.Printf("%p\n", a)
	
	a = append(a, 10, 20, 30)
	fmt.Printf("%p\n", a)
	
	fmt.Println(len(a), cap(a), reflect.ValueOf(a).Kind())
}
>>> 0x116bea0
>>> 0xc0000220e0
>>> 0xc00001c100
>>> 6 8 slice
```
You see, all 3 addresses are different.

But, can we keep the addresses same even after append? Well yes!! It's here your `NEW` approach comes into place. See this:

```go
func main() {
	a := new([]int32)
	fmt.Printf("%p\n", a)

	*a = append(*a, 10, 20, 30)
	fmt.Printf("%p\n", a)

	*a = append(*a, 10, 20, 30)
	fmt.Printf("%p\n", a)

	fmt.Println(len(*a), cap(*a), reflect.ValueOf(*a).Kind())
}
>>> 0xc00011c030
>>> 0xc00011c030
>>> 0xc00011c030
>>> 6 8 slice
```

You see? All 3 addresses remain same!!!

That's all folks for now🤩
Back Propagation in Neural Networks
Tags: python, ai, programming, beginners
Published: 2021-11-28 05:41:05

Hello all,

It is very important to know how the Back Propagation works in Neural Networks in order to find the optimal weights. So, to know more about this concept let us quickly dive into following slides:-

Download the whole document as a pdf document from the following link:-
https://www.kaggle.com/ruthvikrajamv/back-propagation
Why I choose NextJS over CRA for new projects
Tags: nextjs, react, webdev, javascript
Published: 2021-11-28 05:34:04

I used to use [Create React App (CRA)](https://reactjs.org/docs/create-a-new-react-app.html) for building new applications (i.e. [app.example.com]()). For landing pages, however, I would use [NextJS](https://nextjs.org/) for better SEO (i.e. [www.example.com]()). Nowadays I will exclusively use NextJS over CRA when starting new applications for the following three reasons.

## Reason 1: Monolith

When starting a new application, the main goal is to find product market fit. This means reducing distractions. With Create React App, we might need to build three different applications to test out our idea (Client App, Landing Page, API). With NextJS, we only need to build one app to test out our idea.

NextJS allows us to build our landing page, application, and API server all in a monolith. We can write [backend routes](https://nextjs.org/docs/api-routes/introduction) that interact with a database inside of the `api/` directory, server side render pages that is important to SEO, and also render things in the client side if necessary.

I want to build a monolith when kickstarting an app without compromising SEO. NextJS is the only tool that allows me to do that so that I can focus on solving problems for customers.

## Reason 2: Performance

Google ranks websites with better performance higher in search results. Therefore some say only use NextJS when SEO matters...but it's hard for me to think of a reason why we would not want better performance and SEO regardless of the application. Why sacrifice on SEO when we don't have to? NextJS gives us the best of both worlds; we can decide when to server side render and when to client side render. 

## Reason 3: Ecosystem

By using NextJS, we expose ourselves to not only the React ecosystem but also the Vercel ecosystem. Vercel provides us with an easy way to deploy our NextJS application and take advantage of serverless. I am very excited to see Vercel build upon their [edge functions](https://vercel.com/features/edge-functions) to provide an end to end development platform for JavaScript engineers.

## Conclusion

I reach for NextJS when starting any new application because it allows me to build a monolith using a mature framework to validate business ideas without sacrificing on performance.
Simplest example to understand types, aliases and comparisons between them
Tags: go
Published: 2021-11-28 05:23:31

---
title: Simplest example to understand types, aliases and comparisons between them
published: true
description: 
tags: go
//cover_image: https://direct_url_to_image.jpg
---

#### Have a look at this example:

```go
func main() {
	type _a int32
	type _b _a
	type _c = _a

	var a _a = 10
	var b _b = 10
	var c _c = 10

	fmt.Println(a == _a(b))
	fmt.Println(a == c)
}
```

What you see here is first `fmt` statement requiring a `cast`, whereas second one doesn't.

#### The reason for this is 2 simple rules:
1. Types created from another type, even containing same exact same fields, are `not` directly comparable
2. Aliases created from types `are` directly comparable.

> For both: comparison after typecasting works perfectly well.

Sweet and simple..😊
Cara mendapatkan uang dari menjadi freelancer online
Tags: freelance, nugasin, proyek, jasa
Published: 2021-11-28 05:21:22

Kali ini saya ingin memberikan informasi bagi pembaca sekalian, ada website freelance online Indonesia yang bisa menjadi tempat rekomendasi untuk mendapatkan cuan tambahan yaitu, nugasin.com

Website ini beru berdiri awal tahun 2021 hingga saat ini November 2021 telah terpublis lebih dari 100 proyek dan 68ribu freelancer tergabung di nugasin.com

Fitur-fitur yang ditawarkan pun cukup oke, mulai dari 
1. BUAT PROYEK untuk mencari bantuan freelancer yang ada di website nugasin.com
2. BUAT JASA untuk menawarkan jasa atau keahlian kita kepada orang lain, nantinya mereka bakal memesan jasa kita apabila tertarik
3. Tersedia transaksi rekber, sangat berguna bagi teman-teman yang ingin transaksi person 2 person dengan orang lain yang pembayarannya bisa dari seluruh bank di Indonesia serta bisa juga melalui E-Wallet mulai dari Gopay, DANA, LinkAja dan Shopeepay.

Fitur unggulan di nugasin.com ini adanya metode pembayaran cicilan lhooo, buat teman-teman yang punya proyek dengan nominal yang cukup besar, tidak usah khawatir, bisa bayar dengan cicilan kok, hehehe. 

Ayoo tunggu apalagi, jangan lupa gabung ke website tersebut, dan nikmati beragam fitur-fitur yang tidak akan kalian temukan di website freelance lainnya

Terima kasih sudah membaca artikel saya ini...
Update Manager Doesn’t Offer an Upgrade to the New Release in Ubuntu?
Tags: ubuntu
Published: 2021-12-14 05:05:14

---
title: Update Manager Doesn’t Offer an Upgrade to the New Release in Ubuntu?
published: true
date: 2021-11-28 05:14:38 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/update-manager-doesnt-offer-an-upgrade-to-the-new-release-in-ubuntu/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">mirrors</span><span style="font-size: 1.2em; color: initial;">release-management</span><span style="font-size: 1.2em; color: initial;">upgrade</span></p>
</header>

So I have Ubuntu installed on my pc, and I want to upgrade to the new Ubuntu which was just released. When I check for any new updates it doesn’t show any upgrades to the new release. How can I fix this? Thanks!

#### Accepted Answer

If you’re not getting an option to upgrade then your local mirror might be out of date, you can either wait a bit for that to resolve itself, or manually switch to another mirror. You should also make sure your software properties [settings are correct](https://askubuntu.com/a/125646/235).

- [How can I get apt to use a mirror close to me, or choose a faster mirror?](https://askubuntu.com/questions/37753/how-can-i-get-apt-to-use-a-mirror-close-to-me-or-choose-a-faster-mirror)

After that follow the upgrade instructions:

- [How do I upgrade to a newer version of Ubuntu?](https://askubuntu.com/questions/110477/how-do-i-upgrade-to-a-newer-version-of-ubuntu)

The post [Update Manager Doesn’t Offer an Upgrade to the New Release in Ubuntu?](https://stackallflow.com/ubuntu/update-manager-doesnt-offer-an-upgrade-to-the-new-release-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).
How to Add a DNS Server via resolv.conf in Ubuntu?
Tags: ubuntu
Published: 2021-12-14 05:05:05

---
title: How to Add a DNS Server via resolv.conf in Ubuntu?
published: true
date: 2021-11-28 05:13:50 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/how-to-add-a-dns-server-via-resolv-conf-in-ubuntu/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">resolv.conf</span></p>
</header>

Is `/etc/resolv.conf` useless in [Ubuntu 12.04 LTS](http://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_12.04_LTS_.28Precise_Pangolin.29) (Precise Pangolin)?

I see that the DNS server information is stored in [NetworkManager](http://en.wikipedia.org/wiki/NetworkManager) now. The `nmcli` command line tool can list that for you.

If I want to add one more [DNS](http://en.wikipedia.org/wiki/Domain_Name_System) server, will adding it to `/etc/resolv.conf` by using the `resolvconf` package help?

#### Accepted Answer

If `/etc/resolv.conf` contains `nameserver 127.0.0.1` then adding entries to `/etc/resolvconf/resolv.conf.d/tail` won’t really do anything useful.

If you are using NetworkManager then you should instead statically add nameserver addresses via _network indicator_: _Edit Connections… | Edit… | IPv4 Settings | Additional DNS servers_.

If you _really_ want to add more entries to `/etc/resolv.conf`, create a `/etc/resolvconf/resolv.conf.d/tail` and add them there.

As with every Ubuntu release, it’s recommended to read the Ubuntu Release Notes, available here:

- [https://wiki.ubuntu.com/PrecisePangolin/ReleaseNotes/UbuntuDesktop](https://wiki.ubuntu.com/PrecisePangolin/ReleaseNotes/UbuntuDesktop)

The Desktop and Common Infrastructure sections contain a link to

- [http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/](http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/) covering the changes to the DNS infrastructure in 12.04.

The post [How to Add a DNS Server via resolv.conf in Ubuntu?](https://stackallflow.com/ubuntu/how-to-add-a-dns-server-via-resolv-conf-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).
Add Fake Display When No Monitor Is Plugged in in Ubuntu?
Tags: ubuntu
Published: 2021-12-14 05:03:15

---
title: Add Fake Display When No Monitor Is Plugged in in Ubuntu?
published: true
date: 2021-11-28 05:08:12 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/add-fake-display-when-no-monitor-is-plugged-in-in-ubuntu/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">14.04</span><span style="font-size: 1.2em; color: initial;">display-resolution</span><span style="font-size: 1.2em; color: initial;">headless</span><span style="font-size: 1.2em; color: initial;">nx</span><span style="font-size: 1.2em; color: initial;">remote desktop</span></p>
</header>

I have an Ubuntu 14.04 server that has no external monitor connected. I use NoMachine to remote control the machine. When I do so, the Unity/Gnome interface doesn’t see any monitors connected, so I can only use 800×600 when connecting with NoMachine. If I plug in a monitor, I can set the resolution to whatever size the NoMachine window is on the remote computer.

Is there a way to create a “fake” monitor device on Ubuntu so I can set a desktop resolution in Unity/Gnome?

#### Accepted Answer

Found a way to do it without requiring a dummy plug: [Ubuntu Headless VNC VESA 800×600 Resolution Fix ~ Andy Hawkins @ June 12, 2011](https://web.archive.org/web/20150912064745/http://blog.mediafederation.com:80/andy-hawkins/ubuntu-headless-vnc-vesa-800x600-fix/)

Basically install a dummy driver:

```
sudo apt-get install xserver-xorg-video-dummy

```

Then write it in the `/usr/share/X11/xorg.conf.d/xorg.conf` (or possibly `/etc/X11/xorg.conf`) file (create one, if it does not exist):

```
Section "Device"
    Identifier "Configured Video Device"
    Driver "dummy"
EndSection

Section "Monitor"
    Identifier "Configured Monitor"
    HorizSync 31.5-48.5
    VertRefresh 50-70
EndSection

Section "Screen"
    Identifier "Default Screen"
    Monitor "Configured Monitor"
    Device "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    Modes "1024x800"
    EndSubSection
EndSection

```

Then restart the computer.

The post [Add Fake Display When No Monitor Is Plugged in in Ubuntu?](https://stackallflow.com/ubuntu/add-fake-display-when-no-monitor-is-plugged-in-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).
How to Fix My Sound Enhancers/Equalizer in Ubuntu?
Tags: ubuntu
Published: 2021-12-14 05:04:56

---
title: How to Fix My Sound Enhancers/Equalizer in Ubuntu?
published: true
date: 2021-11-28 05:09:28 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/how-to-fix-my-sound-enhancers-equalizer-in-ubuntu/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">alsa</span><span style="font-size: 1.2em; color: initial;">pulseaudio</span></p>
</header>

What I am looking for is to have **system wide** implementation of sound enhancements like bass boosts, echoes, Fidelity, Stereo enhancement and so on.

Audio Video players have their own equalizer but they enhance only the audio / video files they are playing.

So to enhance sounds playing such as: YouTube, Spotify, System Sound, etc. I need a enhancer software. Back in Windows, I used to use SRS HD audio lab to do the same.

P.S. I have a horrible Speaker set.

#### Accepted Answer

PulseAudio Equalizer is the way to go.

Here’s a blog post about it: [http://www.webupd8.org/2013/10/system-wide-pulseaudio-equalizer.html](http://www.webupd8.org/2013/10/system-wide-pulseaudio-equalizer.html)

Since pulseaudio-equalizer [is part of Ubuntu 17.04](http://packages.ubuntu.com/zesty/pulseaudio-equalizer), you can simply [enable the universe repository](https://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository) and then issue the installation command:

```
sudo apt-get install pulseaudio-equalizer

```

For older releases, add the PPA first:

```
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update

```

- [Are PPAs safe to add to my system and what are some “red flags” to watch out for?](https://askubuntu.com/questions/35629/are-ppas-safe-to-add-to-my-system-and-what-are-some-red-flags-to-watch-out)

After PulseAudio Equalizer is installed, you can launch its GUI with the applications `qpaeq` or `pulseaudio-equalizer-gtk`.

![PulseAudio Multiband EQ window](https://i.stack.imgur.com/n8quV.png)

The post [How to Fix My Sound Enhancers/Equalizer in Ubuntu?](https://stackallflow.com/ubuntu/how-to-fix-my-sound-enhancers-equalizer-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).
Brightness Is Reset to Maximum on Every Restart in Ubuntu?
Tags: ubuntu
Published: 2021-12-14 05:04:51

---
title: Brightness Is Reset to Maximum on Every Restart in Ubuntu?
published: true
date: 2021-11-28 05:08:57 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/brightness-is-reset-to-maximum-on-every-restart-in-ubuntu/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">brightness</span></p>
</header>

The brightness of my laptop is reset to max on every restart. I tried the solution provided at [this website](http://ubuntuguide.net/how-to-save-screen-brightness-settings-in-ubuntu-12-04-laptop/) but had no luck.

This command

```
cat /sys/class/backlight/acpi_video0/max_brightness

```

Returns

```
cat: /sys/class/backlight/acpi_video0/max_brightness: No such file or directory

```

Then I found that I don’t have a folder named `acpi_video0`, but a folder called `intel_backlight`:

[![screenshot of /sys/class/backlight/intel_backlight in Nautilus](https://i.stack.imgur.com/H4V5L.png)](https://i.stack.imgur.com/H4V5L.png)

Every time I increase or decrease the brightness using the brightness control keys, the values in `brightness` and `actual_brightness` get updated.

Is there any method I could follow to set the brightness to a fixed value on every boot and vary it as and when I need it using the brightness control keys?

#### Accepted Answer

You could try adding a line to /etc/rc.local that will set the desired brightness level. To edit the file, run

```
sudo -H gedit /etc/rc.local

```

and add the following

```
echo X > /sys/class/backlight/intel_backlight/brightness

```

so that the end result looks like this

```
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo X > /sys/class/backlight/intel_backlight/brightness

exit 0

```

Substitute `X` by the desired brightness level.

In case /etc/rc.local doesn’t exist, as is the case with new Ubuntu releases, you’ll need to create it, and make eecutable with the following commands:

```
printf '%sn' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local

```

PS: Alternatively, there may be `/sys/class/backlight/acpi_video0/brightness` instead of the above. Brightness levels vary wildly, and may range from 0 to 10 or to 1000. To find the maximum value, try

```
cat /sys/class/backlight/acpi_video0/max_brightness
or
cat /sys/class/backlight/intel_backlight/max_brightness

```

The post [Brightness Is Reset to Maximum on Every Restart in Ubuntu?](https://stackallflow.com/ubuntu/brightness-is-reset-to-maximum-on-every-restart-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).