teleren/devto huggingface dataset:
Better Looking Dates in Eleventy: Jan 01 2023 --> Jan 1st 2023
Tags: eleventy, tutorial
Published: 2023-01-06 17:43:11


By default, the default `readableDate` in Eleventy will output dates like: `Dec 03 2022`. Let's do better and set this up as the ordinal date. 

For most numbers, we end with th: 

```
    let ordinalSuffix = "th";
    if (day === 1 || day === 21 || day === 31) {
      ordinalSuffix = "st";
    } else if (day === 2 || day === 22) {
      ordinalSuffix = "nd";
    } else if (day === 3 || day === 23) {
      ordinalSuffix = "rd";
    }
```

Here's the full code for .eleventy.js or your date converter: 

```
  function convertDate(dateString) {
    const date = new Date(dateString);
    const day = date.getDate();
    const month = date.getMonth();
    const year = date.getFullYear();
    const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
    const monthName = monthNames[month];

    let ordinalSuffix = "th";
    if (day === 1 || day === 21 || day === 31) {
      ordinalSuffix = "st";
    } else if (day === 2 || day === 22) {
      ordinalSuffix = "nd";
    } else if (day === 3 || day === 23) {
      ordinalSuffix = "rd";
    }

    return `${monthName} ${day}${ordinalSuffix}, ${year}`;
  }

  eleventyConfig.addFilter("readableDate", dateObj => {
    // Convert the date object to a date string using the convertDate() function 
    // And make sure you have nd, st, rd, or th after the day
    var dateString = convertDate(dateObj);
    return dateString;
  });
```

This function takes advantage of the fact that most dates are ordinaled (if that's a word) with 'th'. We just have to add st to 1, 21, and 31... and then nd to 2 and 22, and we can't forget rd tacked onto 3 and 23.
How to monitor a Java remote app with VisualVM
Published: 2023-01-06 17:37:09

Add the following JVM arguments to the remote app:
`-Djava.rmi.server.hostname=[enter_hostname_here]
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=[enter_port_here]  
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.local.only=false`

Open VisualVM locally and setup a new JMX connection with SSL disabled.

Note: make sure the server is not open to the public internet!
Day 5: Building a local audio transcription engine running on your web browser with JavaScript
Tags: 100daysofcode, challenge, javascript, webdev
Published: 2023-01-06 17:31:00

On-device speech recognition for the web? Even for transcription? Yes and Yes!

[Leopard](https://picovoice.ai/platform/cat/) Speech-to-Text processes voice data on your browser, without sending voice data to a 3rd party cloud.

**1. Setup & Installation**
Create a project and install the SDK:
```
npm install @picovoice/leopard-web
```
Get your AccessKey from the [Picovoice Console](https://console.picovoice.ai/) - It's free

**2. Serving the Model**
Leopard is an on-device speech-to-text solution. So we need to transfer the [model](https://github.com/Picovoice/leopard/blob/master/lib/common/leopard_params.pv) (deep neural network) to the client to enable voice processing within the browser. 

2 options:

2.1 Serve the model on the Public Directory and pass the URL to SDK. 
Pro: Reduces the page size 
Con: Requires upfront work. 
2.2. Ship the model with the page content by transforming it into a text form using Base64 Encoding. 
Pro: Very straightforward. There is even a utility in the Leopard package to convert the model into base64 format:
```
npx pvbase64 -i ${MODEL_PATH} -o ${BASE64_PATH}
```
Con: Yes, the page size!

**3. Implement Speech Recognition in JavaScript**
Create an instance of Leopard:
```
const handle = await Leopard.create(
  accessKey,
  leopardModel
);
```
Paste your AccessKey from Picovoice Console (i.e. replace accessKey above). leopardModel is an object containing information about the whereabouts of the model. If you are using the public directory method, use this:
```
const leopardModel = {
  publicPath: publicRelativePath,
}
```
If you are using the base64 method, use this:
```
const leopardModel = {
  base64: base64String,
}
```
Transcribe audio:
```
function getAudioData(): Int16Array {
  ... // function to get audio data
}
const result = await handle.process(getAudioData());
console.log(result.transcript);
console.log(result.words);
```
Implement getAudioData based on your application. It can read from a microphone via Web Audio API or possibly a file.

This post was originally published on [Picovoice blog](https://picovoice.ai/blog/speech-to-text-using-javascript/)!
JavaScript in Nutshell: The Core
Published: 2023-10-18 08:14:11

---
title: JavaScript in Nutshell: The Core
published: true
date: 2023-01-06 17:30:00 UTC
tags: 
canonical_url: 
---

# 

## Spread Operator

JavaScript မှာ လူသုံးများတဲ့ Operator ပါ။ တော်တော်လေးလည်းမိုက်တယ်။ သူက Iterable Interface ထုတ်ပေးထားတဲ့ကောင်တွေကို Spread ချင်တဲ့အခါမျိုးမှာသုံးလို့ရတယ်။ လူသိများတာက Array လို Object လိုကောင်တွေပေါ့။

```
const user = {
    name: "Mg Mg",
    age: 18,
}

```

User ကို Job ထပ်ထည့်ချင်တယ်။ ဒါပေမဲ့ Indexer နဲ့မသွားချင်ဘူး၊ မူရင်း State ကို Mutate မလုပ်ချင်ရင်ဒီလိုသုံးလို့ရတယ်။

```
const profile = {
    job: "Full Stack Developer",
    ...user
}

```

ဒါဆိုရင် profile ကို job Append လုပ်ပြီးသားဖြစ်သလို Original object ကို Mutate တာကနေလည်းရှောင်လို့ရတယ်။ Side Effect တွေကိုပြောတာ။ State ကို Update ချင်ရင်လည်းသုံးလို့ရတယ်။

```
const updatedProfile = {
    ...profile,
    age: 19
}

```

ဒါဆိုရင် updatedProfile မှာရှိတဲ့ age က 19 ဖြစ်သွားမှာပါ။ List of Argument အနေနဲ့ပေးချင်တဲ့အခါကြရင်လည်း Spread Operator ကိုသူံးလို့ရတယ်။

```
const numbers = [1, 2, 3, 4, 5]
const max = Math.max(...numbers) // 5

```

Reference Type တွေက Side effect တွေကိုဖြစ်တတ်တယ်။ State တွေ Mutate သွားတာမျိုးဖြစ်တယ်။ Array တစ်ခုကို Descending Order နဲ့ဆီချင်တဲ့အခါမျိုး။

```
const numbers = [1, 2, 3, 4, 5]
numbers.sort((a, b) => b - a)
console.log(numbers) // [5, 4, 3, 2, 1]

```

Array က Reference Type တာမို့လို့ မူရင်း State ကို Mutate သွားလိမ့်မယ်။ ဒါကိုရှောင်ချင်ရင် Spread အကူအညီနဲ့ဒီလိုမျိုးသွားလို့ရတယ်။

```
const descendingNumbers = [...numbers].sort((a, b) => b - a)

```

ဒါဆိုရင် Array အသစ်ကို Sort တာဖြစ်လို့ မူရင်း Array ကို Effect မဖြစ်တော့ဘူးပေါ့။

## Destructing

Array ဒါမှမဟုတ် Object ရဲ့ Property Value တွေကိုဆွဲထုတ်ပြီးယူချင်ရင် Destructing ကိုသုံးလို့ရတယ်။

```
const [a, b] = [1, 2] // 1 1

```

Object တွေမှာဆိုရင် Original Object ရဲ့ Key နဲ့ Name တူမှ Destruct လို့ရမယ်။

```
const {name, age} = {
    name: "Mg Mg",
    age: 18
}
console.log(`${name} is ${age} years old`)

```

Object တွေမှာ Destructing လုပ်ရင်းနဲ့ Rename လို့ရတယ်။

```
const {data: user} = fetch("https://...")

```

API ကပြန်လာမဲ့ Object မှာ data Field ပါလာတယ်ဆိုပါစို့။ ဒီကောင်ကို user အနေနဲ့ Rename လုပ်ပြီးသုံးလို့ရတယ်။ Removing Unwanted Object Fields user Object ကနေ age Field ကိုဖယ်ချင်ရင်ဒီလိုသုံးလို့ရတယ်။

```
const user = {
    name: "Mg Mg",
    age: 18
}
const removeAgeField = (obj) => {
    const {age, ...rest} = obj
    return rest
}
const userWithoutAge = removeAgeField(user)
console.log(userWithoutAge) // {name: "Mg Mg"}

```
Article Assignment
Published: 2023-01-06 17:23:54

1.
My name is Shotaro.  I am 23 years old.  He is from Tokyo, Japan.  At university, I majored in sports culture and studied the spread and development of sports in developing countries.  I came to Vancouver after graduating college, so I don't have full-time work experience, but I worked part-time at a gas stop.
In fact, after graduating from university, I wanted to join JICA, an organization that supports developing countries.  However, it became difficult to go abroad due to the influence of covid-19, so when I thought about other options, I chose to study in Canada.  Also, when I thought about what kind of skills I would need in the future, I thought that computer science would be the one for me, so I decided to take this course.Also, I love watching sports and playing Ultimate Frisbee.  The Japanese team at the World Cup the other day excited and moved us.  I was very surprised and happy because I didn't think Japan would beat Germany or Spain.  Also, I've been playing Ultimate Frisbee since University.  Ultimate is a competition using Frisbee, and if you connect the pass to your goal zone, you will score, and We will do it at 7 to 7.  Last summer I participated in an all-Canada competition.  It's been four years since I've continued, but I still want to continue, so I want to do my best in this year's tournament as well.
2.
What I expect from this course is to acquire the basics of computer science and the skills necessary for programming and web development.  I have no experience studying computer science and everything is new information, so there are many things I do not understand, but I would like to clear them one by one.
3.
I'm a little confused because I don't know anything until I see it in class, but I'm trying to do my own research and understand it.  I think there will be a lot of difficult things, but if I'm in trouble, I want to ask for help and do my best.
4.
After taking this course, I would like to get a job and be able to work in Vancouver.  Because there are no signs of improvement in the working environment in Japan, I would like to work here as a developer and eventually get permanent residency.  It's a difficult challenge for me, but I want to do my best without giving up.I also have a slightly different vision, and if I can become a developer, I think it will be a working holiday in another country.  Vancouver is also a very nice place, but I am also interested in other countries.  I am also interested in JICA, and would like to volunteer in developing countries if given the chance.
Leetcode 1833 : Maximum Ice Cream Bars
Tags: programming, tutorial, computerscience
Published: 2023-01-06 17:19:07

## Intuition
The question is to find the maximum number of chocolates the boy can have within the limit coins. So to have maximum chocolates, it is always optimal to buy the chocolate bars at a small cost. So we can sort the costs array and just keep on checking whether it's okay to buy the current chocolate with the money in hand.

## Approach
1. Sort the array.
2. Traverse through the array keeping a running sum.
3. Increment the running sum with the cost and check whether the running sum is less than or equal to the cost limit. If yes, then we can buy that chocolate bar, or else we will stop.
4. Once gets out of the array, return the count of chocolate bars.

## Complexity
- Time complexity:
We are sorting the array and also traversing through the array once.
So time complexity will be O(nlogn) + O(n) where n = length of the array.

- Space complexity:
The sorting can take up some amount of space. But other than that, we are not making use of any extra space. So space complexity will be O(1).

## Code
```java
class Solution {
    public int maxIceCream(int[] costs, int coins) {
        int length = costs.length;
        // eventhough the constraint starts from 1, 
        // just adding as part of practice
        if (length == 0 || costs == null) {
            return 0;
        }
        if (coins <= 0) {
            return 0;
        }
        Arrays.sort(costs);
        int runningSum = 0;
        int chocolateBar = 0;
        for (int num : costs) {
            runningSum += num;
            if (runningSum <= coins) {
                chocolateBar++;
            }
            else {
                break;
            }
        }
        return chocolateBar;
    }
}
```

Please feel free to suggest a better approach or a different approach for the same problem. Also, correct me if I have any mistakes.
Thanks.
Reducing time complexity using a map
Tags: webdev, javascript, programming, typescript
Published: 2023-01-06 17:17:13

Reducing time
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t66atuz2z8n5mczs0w0q.jpeg) complexity using a Map.

Map in JavaScript
In this article, we would be discussing Map object provided by ES6. Map is a collection of elements where each element is stored as a Key, value pair. Map object can hold both objects and primitive values as either key or value. When we iterate over the map object it returns the key, value pair in the same order as inserted.

Map (using Binary Search Tree)		

1. O(log(n))
**** Implemented using Binary Search Tree****
For more reference 
[](https://adrianmejia.com/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/)

I sometimes see this kind situation:
We are looping through an array, and for each element of this array, we are looking into another array to find some data related to this element (or sometimes several other arrays to find more data).
Example
Let’s say we have an array of animals, and an array of cat.
Each animals has a favourite cat. For each animals , we know his favourite cat because each animals has an attribute which is the id of his favourite cat.
Let’s say we want to print in the console, for each animals , his name and the name of his favourite cat.
The common implementation
Usually, common implementations for this problem looks something like that.
Using the method find on the cats array, or an alternative, in order to loop for each animals through the cat array to find the cat we are looking for.
It’s clear, simple, and it works. So that’s nice.
But if we check at the time complexity, it’s not that nice:
we loop through the N animals
and for each animals we loop through the M cats to find his favourite cat
So the time complexity is O(N*M).
And the space complexity is O(N+M) because we have N+M elements to store in memory.
We can do better
By using a Map instead of an array to store the cats, we are going to reduce the time complexity to O(N), without increasing the space complexity. Why ? Because accessing a value with the get method of a Map (in practice) is constant in time (O(1)).
First, we create a Map from the cats array, by setting the id as key and the cat as value.
Then, we replace the find on the cats array by a get on catsMap, and we are good to go.
Conclusion 
Using javascript in built function is always a better choice since it is a higher order function. Instead of using for loop for iteration.
Main or Master: Where Do You Git-llegiances lie?
Tags: discuss, github, git
Published: 2023-01-06 17:16:17

If you've been using github long enough, you'll recall a time where your primary branch was named **master** by default. **Master** was all we knew as the primary.

Then, I don't exactly recall when, a decision was made to now make the primary branch **main**. I say decision because although that's what most people switched to, not everyone was on board...

In a number of instances, these type of changes are thrust upon us and we end up accepting them. Even in cases when we're not 100% with them.

That got me curious about peoples preferences....

What do you prefer for your primary branch name; **main** or **master**? Also, why?

---
###  Thank you for reading, let's connect!
Thank you for visiting this little corner of mine. Let's connect on [Twitter](https://twitter.com/Psypher1), [Polywork](https://www.polywork.com/psypher1) and [LinkedIn](https://www.linkedin.com/in/jamesmidzi/)
383. Ransom Note
Tags: java, strings, leetcode, 100daysofcode
Published: 2023-01-06 17:09:55

**Problem Statement:**
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.

Each letter in magazine can only be used once in ransomNote.

**Example 1:**
**Input:** ransomNote = "a", magazine = "b"
**Output:** false

**Example 2:**
**Input:** ransomNote = "aa", magazine = "ab"
**Output:** false

**Example 3:**
**Input:** ransomNote = "aa", magazine = "aab"
**Output:** true
 

**Constraints:**

- 1 <= ransomNote.length, magazine.length <= 105
- ransomNote and magazine consist of lowercase English letters.

**Solution:**
**Algorithm:**
1. Create an array of size 26 to store the frequency of each character in magazine.
2. Traverse through the magazine string and increment the frequency of each character in the array.
3. Traverse through the ransomNote string and decrement the frequency of each character in the array.
4. If the frequency of any character in the array becomes negative, return false.
5. Return true.

**Code:**
```
public class Solution {

    public boolean canConstruct(String ransomNote, String magazine) {
        int[] arr = new int[26];
        for (int i = 0; i < magazine.length(); i++) {
            arr[magazine.charAt(i) - 'a']++;
        }
        for (int i = 0; i < ransomNote.length(); i++) {
            if (--arr[ransomNote.charAt(i) - 'a'] < 0) {
                return false;
            }
        }
        return true;
    }

```
**Time Complexity:**
O(n+m) where n is the length of ransomNote and m is the length of magazine.

**Space Complexity:**
O(1) since size of array is constant.
#Rust – Install Rust and Hello World 🌐 in #RaspberryPi
Tags: englishpost, helloworld, installationprocess
Published: 2023-01-09 17:28:55

---
title: #Rust – Install Rust and Hello World 🌐 in #RaspberryPi
published: true
date: 2023-01-06 16:57:02 UTC
tags: EnglishPost,EnglishPost,HelloWorld,Installationprocess
canonical_url: 
---

Hi !

Quick post today on how to install rust in a Raspberry Pi, and later create a hello world test app.

## Install Rust

I’m starting this with the latest updates for Raspberry Pi OS installed.

![current raspberry pi os installed](https://brunocapuano.files.wordpress.com/2023/01/image-14.png?w=859)

The command to install rust is this one:

```

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

```

Check the [Rust Lang documentation](https://www.rust-lang.org/tools/install) for more details.

Let’s choose the default installation, this may take a couple of minutes.

And now, we can check the rust and cargo versions with the following commands

```

rustc --version
cargo --version

```

![checking rust and cargo versions with command line](https://brunocapuano.files.wordpress.com/2023/01/image-15.png?w=348)

## Hello World project

Now let’s use cargo to create a new project. I’ll name it “DemoBlogPost”. In the following image, we can check the default contents of the project

- cargo.toml
- src/main.rs

![createing a new project with cargo and check the generated files](https://brunocapuano.files.wordpress.com/2023/01/image-16.png?w=727)

Time to edit the main.rs file. I’m not a VIM user, so it’s nano time.

![editing the main rs file with nano](https://brunocapuano.files.wordpress.com/2023/01/image-17.png?w=1024)

And now, time to run the project !

![](https://brunocapuano.files.wordpress.com/2023/01/image-18.png?w=904)

Super fun and literally a great way to use a device like a raspberry pi to learn Rust !

Happy coding!

Greetings

El Bruno

More posts in my blog [ElBruno.com](https://www.elbruno.com).

* * *
Discover the Excitement and Intrigue of The Eminence of Shadow: The Best Anime of 2022!
Tags: anime, discuss, review
Published: 2023-01-06 16:54:18

Get ready to have your socks knocked off by the wild ride that is The Eminence of Shadow, the must-see anime of 2022! This epic series is already 14 episodes deep, and let me tell you, it's a doozy.

The Eminence of Shadow follows the story of a young boy who is on a mission to become the ultimate puppet master and pull all the strings from the shadows. But things don't always go as planned, and one day he gets hit by a truck and dies. Bummer, right? Wrong! Because in the world of The Eminence of Shadow, death is just a minor inconvenience. The young boy gets reborn as Cid Kagenou, and he's ready to continue his quest for shadow domination.

Cid may look like a total nobody, but he's secretly a total bada**. He meets an elven girl named Alpha who is infected by some mysterious disease, and Cid uses his mad skills to cure her. Alpha is so impressed that she decides to join Cid's secret organization, Shadow Garden, which is dedicated to fighting the evil Cult of Diablos. Sounds like a pretty sweet gig, right?

Well, here's the thing: Cid made all of this up. He thinks the whole Cult of Diablos thing is just a delusion, and he has no idea that he's actually caught up in a crazy power struggle. But no matter – Cid, aka Shadow, is ready to kick some butt and save the day, declaring "I am atomic" as he fights for justice. Just hearing that iconic line gives me chills!

The Eminence of Shadow is a total blast, with epic fight scenes, gorgeous animation, and a cast of characters that will steal your heart. Don't miss out on the wildest anime adventure of 2022 – watch The Eminence of Shadow now!
Hello, World(s)!
Tags: webdev, beginners, programming, career
Published: 2023-01-06 16:43:01

**Indeed**, hello, _multiple_ worlds! (As I mentioned in one of my posts on the Welcome thread, I have now moved past "Hello, World!" in several programming languages.)

At age 78, soon to turn 79, I don't consider myself much of a software "developer." I'm more of a software hobbyist. Anyway, who's hiring developers born during World War II?

**I retired** from software technical writing 14 years ago after working for several large telecommunications companies. I used to write hardware and software manuals and training courses and even tested some hardware and software. But that was long ago, in a younger universe...far, far away behind me.

Over the past few years, however, I have been using software "development"--at the hobbyist level--as a way to help keep my aging brain alert, alive, and open to learning. In my own mind, at least, that daily tinkering seems to be working.

**I'm now** in the process of learning how to get better at working with several software languages and frameworks. I also occasionally write online reviews of beginner-level software books. One other part of my learning process is to find relatively easy software projects, try them out, and attempt to make minor modifications that work (or blow up). I jump from one thing to another as my interests change, so skill-wise I tend to remain just a few steps above "Hello, World!" while I keep collecting more languages and packages to play with. Yes, I know. Definitely NOT the best way to develop any depth in my abilities.

I'm trying to change some of that now, if only to pare down the number of "how to" binders and books currently stacked on my shelves. In short, I'm narrowing my focus a bit. For the near future, I intend to just center my attention on...Java, JavaScript, Rust, Python, C#, .Net, Angular, PostgreSQL, Go, Spring Boot, Haskell, and one or two others I can't seem to remember at the moment.

**Anyway**, as Buzz Lightyear _never_ said: "To infinite loops...and beyond!"  

(_Cover photo by Si Dunn_)
Introducing Rubberduck, the chat assistant that makes coding easier!
Published: 2023-01-06 16:41:25

Get help with code explanations, error diagnosis, and more, all within your IDE.

Here are some examples of what it can do:

### Diagnose an error and new write code to fix it
The error was part of the development process, after I changed the interface in a different file.
![Rubberduck error diagnosis](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zu9lcdg9edcahe3o29c4.png)

### Explain code and refactor it afterwards
![Rubberduck code explanation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/975c87989ypigtpphcld.jpg)

Sign up for the alpha waitlist to try it out: https://rubberduck.tech