teleren/devto huggingface dataset:
Easy hack to bypass MongoDB text search limit
Tags: mongodb, textsearch, multiple, database
Published: 2021-11-07 15:50:55

TLDR: Periodically run a script and set a helper field on each document, adding text from multiple fields and make that field searchable. 
 
Ok, it's not really a hack, just an easy method to circumvent the restriction MongoDB has that only lets you have a single field set to `$text` per collection.

Because MongoDB is a business that want to make money, they make some functionality available only via a paid premium license. This is totally fine, and most of the time you will manage great with all the wonderful, free utilities. 

However, for my hobby project I wanted to free text search multiple fields in a single document and this isn't allowed in the free license. Instead of implementing Elastic Search, I managed to make it work with only MongoDB

In my project, a user would have basic information on his profile and I wanted to make their email searchable with a free text search. The user also has additional contact information such as city, street address and country, which I also wanted to make searchable via free text search. And finally, they would have a membership which included `notes` that I also wanted to make searchable. 

My first approach, which I later abandoned was to make three collections: `profiles`, `memberships` and `contactInfo`. This allowed me to index one field per collection as a `$text`-field, making it searchable via a free text search. The problem with this approach is that my queries got very complex and super slow because I needed 3 queries each time I wanted a user's `profile`, `membership` and `contactInformation`. And I almost always want those together.

My second approach is a bit hacky, but works great! And it's totally within the bounds of what's allowed with a free license.

Firstly, I restructured my data model to a more NoSQL-ish pattern, where all the information needed together are in a single collection. I simply have a `users` collection with `profile`, `contactInfo` and `membership` information on it. With that, I get fast queries and a simple data model. The way I solved my need to free text search on multiple fields is quite easy; periodically run a script that calculates and writes a helper field called `keywords` which I build from other relevant fields on the document. I include notes, address, name, city, and any other fields I want and I have it indexed and set to `$text`. 

This allows me to effectively search multiple fields in a single collection using MongoDB.
Menulis Notasi Matematika Menggunakan MathJax
Tags: webdev, javascript, indonesia
Published: 2021-11-07 15:45:50

MathJax adalah mesin tampilan *open-source* berbasis javascript menggunakan notasi LaTeX, MathML, dan AsciiMath yang berfungsi di semua *browser* modern.

**"*Beautiful and accessible math in all browsers*"**

Sesuai dengan slogannya, kamu dapat menulis notasi matematika pada html atau markdown dengan mudah.

## Cara Menambahkan MathJax
Ada 2 cara menambahkan MathJax, yaitu:
- *Web Integration*
Cara ini merupakan cara yang paling mudah karena kamu cukup menambahkan *script* pada file html/markdown kalian.
```html
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
```
- *Server Integration*
MathJax tersedia sebagai *node package*, jadi kamu dapat menambahkannya dengan cara menginstall melalui npm.
```bash
npm i mathjax
```

## Cara menulis notasi matematika

Seperti yang sudah dijelaskan, kamu dapat menggunakan notasi LaTeX, MathML, atau AsciiMath. Kali ini saya hanya akan menjelaskan cara menulis menggunakan LaTeX saja.

Caranya cukup mudah yaitu, kamu cukup menulis notasi matematika menggunakan *syntax* LaTeX kemudian tambahkan masing-masing 1 tanda dolar (mode *inline*) atau dua tanda dolar (mode *display*) diantara notasi matematika tersebut `$...$` / `$$...$$`.

```html
<p>$$\lim_{x\to\infty}(\dfrac{1}{x})=0$$</p>
```
Hasilnya akan seperti berikut,

{% katex %}
\lim_{x\to\infty}(\dfrac{1}{x})=0
{% endkatex %}

### *Syntax* LaTeX

Untuk menulis notasi matematika, saya sarankan untuk tidak menghafal *syntax*-nya tetapi menyiapkan referensi/*cheat sheet*. Jadi kamu cukup mencari apa yang kamu butuhkan saja.

## Referensi
1. [MathJax](https://www.mathjax.org/)
2. [MathJax *Documentation*](https://docs.mathjax.org/en/latest/index.html)
3. [MathJax *Basic Tutorial and Quick Reference*](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference)
npm i tradly - Headless API and JS Sdk to launch marketplace and omni-channel commerce apps
Published: 2021-11-07 15:12:54

Introducing Tradly JS SDK. We are super excited to bring this to you!
https://www.npmjs.com/package/tradly
- A headless API already saves a lot of time to launch #marketplace and #commerce apps. Adding a JS SDK means even faster development of front end apps.  Launch omnichannel commerce apps with your favourite #JAMstack now. 

To see the demo of the starter kit build with SDK > https://watchtracker.vercel.app/
Or start fresh 
1. Register for a free sandbox account and get the api key https://auth.sandbox.tradly.app/register
2. Fork the repository https://github.com/TRADLY-PLATFORM/Butterflies
3. Deploy on #vercel, #Clouflare or #Netlify for free to see the demo.


This mark an important milestone in our product releases. 
1. NEW: Tailwind CSS saving 40% of your front end developer time
2. NEW: Jamstack focused deployment tools make it easier than ever to launch apps. 
3. NEW: NextJS is a revolutionary framework to build static+dynamic together website. SEO benefits. Our design elements are componentized properly with deep thought process. So you can make changes easily. 
4. New SDK means saving your time to avoid API connection mistakes.

Our next goal:
1. Increase the performance of the starter kit and reaching GREEN on lighthouse performance benchmark. So your website loads faster.
2. Adding seller related features in the starter kit 
3.  Releasing few more layouts that suit to different business nature.

Let us know your feedbacks!
Executar javac desde PowerShell
Tags: java, powershell
Published: 2021-11-07 15:01:28

Para ejecutar **javac** en una ventana de PowerShell (en Windows) será fácil y sencillo si es que instalamos el JDK previamente.

Sin embargo, si necesitamos usar una versión de _Java_ distinta, este ejemplo muestra cómo seleccionar las librerías dependientes y compilar el proyecto entero.

La estructura de carpetas:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gv8qdftwcsojtdyv95xi.png)
  
El script para ejecutar:
{% gist https://gist.github.com/edgargs/3674dea09c8a7ed98420c1ba8d4f37b5 %}

El _tip_ es asignar temporalmente la ruta del JDK en el **Path**.
```
$Env:Path = "$JDK7\bin"
```

---
##Documentación
* https://stackoverflow.com/questions/24464295/compiling-and-running-java-application-using-powershell
* https://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx
Flexbox & Properties - Explained
Tags: webdev, beginners, css, html
Published: 2021-11-07 14:55:30

In the past, CSS layouts have been a huge pain point for web designers. In order to create a responsive layout, multiple divs have to be used throughout the HTML, and then the CSS needs to be modified to accommodate that. Flexbox is a way to create responsive layouts without this problem. Here's an intro on what flexbox is and how it works.

### display
- This states a flex container.
- It enables flex context of all it's children.
- It can be inline or block
```css
.div{
  display: flex;
}
```

### flex-direction
- It defines the direction of flex, items placed in a flex container.
- It is a single-direction layout concept.
```css
.container {
 flex-direction: row | row-reverse | column | column-reverse;
}
```
- row (default): left to right in ltr; right to left

- row-reverse: right to left in ltr; left to right

- column: same as row but top to bottom

- column-reverse: same as row-reverse but bottom to top

### flex-wrap
- By default, items will try to be fit in one line.
```css
.container {
  flex-wrap: nowrap | wrap | wrap-reverse;
}
```
- **nowrap** - all flex items will be on one line
- **wrap** - flex items will wrap onto multiple lines, from top to bottom.
- **wrap-reverse** - flex items will wrap onto multiple lines from bottom to top.

### flex-flow
- It is a shorthand for **flex-wrap** and **flex-direction** properties and they together defines the cross axes of the main container
```css
.container {
  flex-flow: column wrap;
}
```

### flex-shrink
- It defines the ability for flex item to shrink accordingly
```css
.item {
  flex-shrink: 3; /* default 1 */
}
```
Make sure *negative numbers are invalid*

### align-self
- It allows the default alignment needs to be overridden for a flex item

```css
.item {
  align-self: auto | flex-start | flex-end | center | baseline | stretch;
}
```

### align-content
- This aligns a flex container’s lines within when there is extra space in the cross-axis.

```css
.container {
  align-content: flex-start | flex-end | center | space-between | space-around | space-evenly | stretch | start | end | baseline | first baseline | last baseline + ... safe | unsafe;
}
```

### order

```css
.item {
  order: 5; /* default is 0 */
}
```
17th weekly post, Action matrix. Also, Lambda alias.
Tags: github, aws, intel
Published: 2021-11-07 14:53:51

## Items of the week

- **GitHub Action** - there can be up to 256 jobs per workflow run using a job matrix. One example use case is to run with multiple versions of Node.js, as pointed out by [the official GitHub Docs webpage](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix).

- **AWS Lambda** - we could create aliases for Lambda functions, an alias has its own ARN and points to specific version of a function. One use case is to set up production and staging aliases that points to different versions of a function, got this from chapter 6 of [Serverless Architectures on AWS](https://www.goodreads.com/en/book/show/29970427).

- **On the week 44 of 2021**, we saw the release of Intel's 12th generation Core processors known as Alder Lake, one of the highlights is that it's a hybrid architecture with both performance cores and efficiency cores. [AnandTech has a detailed review on this](https://www.anandtech.com/show/17047/the-intel-12th-gen-core-i912900k-review-hybrid-performance-brings-hybrid-complexity).

## A little note

Another small change in the post format, of the three weekly items, one will be from an online source, like an article or a Tweet, while another one will be from a book or a paper, and to mix things up a little, the third item will be a bit of a wild card, probably something new from that week. That's all for this week's post, thank you for reading and have a nice day!
How to Update Node.js to the latest version on Ubuntu
Tags: node, javascript, npm, linux
Published: 2021-11-07 14:51:14

![Nodejs Official Website](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ujxgme2xgt491sbe257i.png)
 
## Step - 1:
1st of all you need to download the latest version of Nodejs from the official [Nodejs website](https://nodejs.org/en/)
## Step - 2:
Go to the correct path using command line or GUI.
Using Command line
```
cd Downloads/node-v17.0.1-linux-x64.tar.xz/
tar -xf node-v17.0.1-linux-x64.tar.xz
```
Check Current Node version
```
node --version
v14.17.0
```
To upgrade 
```
sudo n latest
```
Check Updated Node version
```
node --version
v17.0.1
```
![Nodejs version Updated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ovxldoqmjmjihouse2l.png)
 
If you are using graphical interface then go to the destination path. Click right button and select extract here. Open the bin folder.
 ![Directories and files](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqk4xmcl4iwowbvx6uk8.png)
right click and select open in terminal
To upgrade 
```
sudo n latest
```
Check Updated Node version
```
node --version
v17.0.1
```
![Nodejs version Updated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ovxldoqmjmjihouse2l.png)
Thanks, if you like this article useful then smash the like button. Share it with your friends. Stay Tuned.
### If you want to learn more about Linux Command Line then you watch my [Playlist](https://youtube.com/playlist?list=PLldSzdV-qgykjEEzvw_fYK56F2w-5kfV5)
ทำไมผมถึงชอบ tmux
Tags: thai
Published: 2021-11-07 14:04:27

สวัสดีครับวันนี้จะมาเล่าถึงเครื่องมือที่ผมใช้มาประมาณเกือบ 3 ปีได้ซึ่งตัวนั้นก็คือ tmux

## tmux คืออะไร

จริงๆแล้วมันก็คือ terminal multiplexer หรือก็คือเครื่องมือที่จะจัดการหน้าต่างๆใน terminal ของเราตามรูปด้านล่าง

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xeqc8d640lfkjz6jus3f.png)

จากรูปข้างบนก็จะเห็นว่าเราสามารถแบ่งหน้าต่างๆออกได้มากมายตามที่เราต้องการเช่นเรารัน frontend และ backend ใน backend มีหลาย service

จริงๆแล้วมันมี tool ที่คล้ายๆแบบนี้เยอะ 1 ในนั้นก็คือที่ผมใช้มาก่อนหน้าก็คือ split pane เป็น feature หนึ่งในตัว [iterm2](https://iterm2.com/features.html) ครับ

เมื่อประมาณ 3 ปีที่แล้วตอนผมเริ่ม dev ใหม่ๆตอนนั้นผมใช้ macbook ส่วนตัวซึ่ง mac ตัวนั้นผมก็ลง iterm2 เอาไว้ ไอ้เจ้า iterm2 เนี่ยละครับมันมี split panes ถ้าใครอยากรู้ลองเข้าไปดูใน [doc](https://iterm2.com/features.html) ได้เลยครับ

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hz9ctgfk3s16dcrj1tso.png)

> สังเกตว่าจะคล้ายๆรูปข้างบนเลย

ทีนี้ก้ใช้เจ้า feature นี้มาเรื่อยๆจนกระทั่งผมเรียนจบแล้วเริ่มทำงานครับทีนี้ที่ทำงานให้ notebook ที่ลง linux(popos) เอาไว้ให้เป็นครั้งแรกที่ผมใช้ linux จริงๆจังๆไม่ได้แบบทำ lab ในมหาลัยที่เป็นพวก ubuntu จนกระทั่งใช้ไปใช้มาแล้วรู้สึกหงุดหงิดมากที่ไม่สามารถทำแบบ iterm2 ได้ผมก็เลยลองหาข้อมูลดูจนไปเจอ tmux แล้วผมก็ใช้มาเรื่อยๆจนถึงปัจุบัน(ถึงจะกลับมาใช้ mac แล้วแต่ก้ไม่ได้ใช้ feature ของ iterm อีกเลย)

ข้อดีของ tmux ที่ผมชอบ
- สามารถ config ได้อิสระ
- สามารถใช้ได้ทุก os (mac,linux,window wsl) -> ผมชอบสุดดดด ❤️
- มี ecosystem ของตัวมันเอง (theme, plugin)

ส่วนข้อเสียผมนึกไม่ออกแหะ

## สรุป

ทุกคนอาจจะชอบ tool ที่แตกต่างกันออกไปหรืออาจจะชอบแบบเปิดทีละ tab ก็ได้ ขึ้นอยู่กับแต่ละคนว่าชอบแบบไหนครับ

## Refs

- [tmux repo](tmux)
- [tmux plugin](https://github.com/tmux-plugins/tpm)
- [dracula theme](https://github.com/dracula/tmux)
- [my config](https://github.com/jungai/dotfiles/blob/master/tmux/.tmux.conf)
[ytdl-s3bucket]: Uploading Video Files to s3 Bucket with Python Using Youtube_dl
Tags: linux, cloud, python, aws
Published: 2021-11-07 13:12:14


<div>
[Source Code](https://gist.github.com/munazhe/ea34733ecae0983d9307f3e5cb1b60bd)
<script src="https://gist.github.com/munazhe/ea34733ecae0983d9307f3e5cb1b60bd.js"></script>
</div>
Using Azure Function bindings based on Identity
Published: 2021-11-07 13:02:21

<sub>Photo by <a href="https://unsplash.com/@nadineshaabana">Nadine Shaabana</a> on <a href="https://unsplash.com/s/photos/identity">Unsplash</a></sub>

[General availability for blob / queue / service bus / event hub](https://azure.microsoft.com/en-us/updates/general-availability-azure-functions-extensions-for-blobs-queues-event-hubs-service-bus-and-event-grid/) is now generally available.

Upgrading depends on your Azure Function version, [methods can vary](https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob#storage-extension-5x-and-higher).

[This tutorial](https://docs.microsoft.com/en-us/azure/azure-functions/functions-identity-based-connections-tutorial) shows how to configure Azure Function to use identity, and [this tutorial](https://docs.microsoft.com/en-us/azure/azure-functions/functions-identity-based-connections-tutorial-2) for an example on Service Bus connection.

Hope this helps !
Difference ReScript build system for each versions
Tags: rescript
Published: 2021-11-07 12:41:50


## Build system overview

|     |v6.0-8.2|v8.2-v9.0|v9.1|
|:----|:-------|:--------|:---|
|Lang manual link|[link](https://rescript-lang.org/docs/manual/v8.0.0/build-overview)|[link](https://rescript-lang.org/docs/manual/v9.0.0/build-overview)|[link](https://rescript-lang.org/docs/manual/latest/build-overview)|
|Build tool|bsb|bsb|rescript|
|Config|bsconfig.json|bsconfig.json|bsconfig.json|
|To build project|bsb -make-world|bsb -make-world|rescript build|
|Artifacts cleaning|bsb -clean-world|bsb -clean-world|rescript clean|
|Artifact cleaning2|bsb -clean|bsb -clean||

## Configuration

|     |v6.0-8.2|v8.2-v9.0|v9.1|
|:----|:-------|:--------|:---|
|Lang manual link|[link](https://rescript-lang.org/docs/manual/v8.0.0/build-configuration)|[link](https://rescript-lang.org/docs/manual/v9.0.0/build-configuration)|[link](https://rescript-lang.org/docs/manual/latest/build-configuration)|
|Name space(default)| false|false|false|
Finding factors of a number, Identify Prime and Composite number
Tags: javascript, math, prime, factors
Published: 2021-11-07 12:39:07

> Let’s define the terms first

### Prime number
A prime number is a number that has only two factors, 1 and the number itself

### Composite number
A composite number is a number which is not prime, e.g 72 have 12 factors `(1,2,3,4,6,8,9,12,18,24,36,72)`

```js
function findFactors(dividend) {
  var factors = [1, dividend];
  var quotient = Math.min();
  var divisor = 2;
  
  while(divisor < quotient) {
      quotient = dividend / divisor;
      if(Number.isInteger(quotient)) {
        factors.push(quotient, divisor);
      }
      divisor++;
  }

  return factors;
}


function isPrime(number) {
  return findFactors(number).length === 2
}

var num = 5;
var factors = findFactors(num);

console.log(factors.length + " factors found (" + factors.sort((a, b) => a-b) + ")");
console.log(isPrime(num) ? "It's a prime number" : "It's a composite number");

var num = 72;
var factors = findFactors(num);

console.log(factors.length + " factors found (" + factors.sort((a, b) => a-b) + ")");
console.log(isPrime(num) ? "It's a prime number" : "It's a composite number");

```
How to use API using Axios : Basic
Tags: beginners, webdev, programming, javascript
Published: 2021-11-07 12:24:18

# How to fetch API using Axios 

## What is Axios?
Axios is a simple promise based HTTP client for the browser and node.js. Axios provides a simple to use library in a small package with a very extensible interface.

To install Axios, you must be have [Node JS](https://nodejs.org/en/) installed on your device.

### Let's begin the journey 🔥

- Let's install Axios, paste the following command in your terminal
```powershell
npm i axios
```
- Now, the main part arrives,

To get the API data,
```js
app.get('/', (req, res) => {
    // get random user api using axios and show it on the page in json
    axios.get('https://tiny-news-api.herokuapp.com/api/news') // API url which is getting data
        .then((response) => {
            res.send(response.data);
        })
        .catch((error) => {
            console.log(error);
        });
})
```
Check out the whole [Code](https://github.com/snowbit-coderboi/axios-tutorial), and try forking the repository to save it, so you can refer to it any time you want.
![How to fork](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jzkyheqavfxaprpmxe3l.png)
WhatsApp, Instagram, Messenger, Facebook mulai menampilkan branding 'Meta' baru
Tags: whatsapp
Published: 2021-11-07 11:50:07

 

 

WhatsApp, Instagram, Messenger, dan aplikasi Facebook lainnya telah mulai menampilkan merek 'Meta' baru perusahaan di perangkat Android dan iOS. Pembaruan datang seminggu setelah Facebook mengumumkan bahwa mereka mengubah nama perusahaannya menjadi Meta.

Rebranding pertama kali terlihat oleh pengguna WhatsApp beta, dan sekarang perubahan tersebut telah mulai diluncurkan untuk semua pengguna.


Pada tahun 2019, Meta yang disebut Facebook sudah mulai menampilkan branding aslinya di aplikasi WhatsApp dan Instagram. Hal ini dilakukan untuk menyoroti kepemilikan perusahaan atas dua platform tersebut. Perusahaan telah mengumumkan bahwa mereka ingin membangun pengalaman mendalam yang disebut 'metaverse' dan nama barunya adalah cerminan dari hal yang sama.

Dalam berita lain, Facebook memutuskan untuk menggunakan nama baru beberapa bulan setelah bekerja mengembangkan pengalaman augmented reality (AR) dan virtual reality (VR).

CEO Facebook Mark Zuckerberg mengatakan dalam sebuah surat publik bahwa Meta akan tentang metaverse di mana orang akan dapat berinteraksi satu sama lain secara virtual melalui Internet dengan cara yang mendalam. Namun, dia tidak menjelaskan apa yang sebenarnya bisa kami harapkan dari perusahaan di masa mendatang.
Announcing climate-friendly-cop26.org
Tags: climate, webdev, sustainability
Published: 2021-11-07 11:38:09

After my frustrating discovery last week of the large greenhouse gas emissions from the [official COP26 summit website](https://ukcop26.org/), I decided to try and recreate it in a more performant and environmentally-friendly form.

The first version of [https://climate-friendly-cop26.org/](https://climate-friendly-cop26.org/) has just gone live. It is a little rough around the edges, being the product of a single developer over the course of a day, but it already provides a lower emission alternative to reading the content on the main site. Hopefully, it should also demonstrate that building fast and planet friendly websites is no more difficult than building their slow and high-emissions brethren.

The [source code](https://github.com/BezPowell/climate-friendly-cop26) is available on github if anyone wants yo contribute by adding-in some of the missing content, or fixing some of the visual bugs. Hopefully next week I'll find time to produce a more in-depth write-up.
5 Steps to Grow your traffic
Published: 2021-11-07 11:35:34

Building a successful website is about much more than just publishing content and hoping for the best. To do so, you need to be strategic and plan ahead. That being said, there are a few key things that you can do to increase your traffic and create a strong foundation for your site. In this article, we're going to take a look at five key ways that you can grow your traffic.

Step 1: Create Quality Content
Step 2: Optimize Your Site For Search Engines
Step 3: Share Your Website On Social Media Platforms
Step 4: Build Relationships With Relevant Influencers     Step 5: Get Strategic With Partnerships


5 Ways to Grow Your Traffic (And Succeed!) https://medium.com/@RyanACearns/5-Steps-to-Grow-your-Traffic-and-Succeed-496f82fe1944#.3bndpwjxj

"What is the easiest thing for my business to do?"  A:  Create quality content.
This is a simple answer with an even more complex process. Many people have a hard time coming up with ideas, and it's nearly impossible to create content on a consistent basis if you're not relying on a process or a checklist, or both. Your content can't just be written haphazardly.
Source: https://www.tommypetrussia.com/
Laravel: Is it okay to change the config in runtime?!
Tags: laravel
Published: 2021-11-07 10:43:19

I was working on implementing settings for emails, taxes, SMS providers so the client can change the credentials by themselves and switch between some providers. 

That credentials and active providers are stored in the database, and I get 'em in the AppServiceProvider and overrider the config with 'em

But I had an issue with Queue Jobs

> Since queue workers are long-lived processes, they will not notice changes to your code without being restarted

So I was in front of 2 solutions 
- Restart the worker after updating DB 
- Change how some integrated services like "Mail" get the config and replace 'em from database

I choose the 2nd solution since it's challenging 🙂

## But it okay to do so "Change the config in runtime"? I just dunno, maybe I'll have some issue like this in the future.