teleren/devto huggingface dataset:
Generalized Inverted Indexes And You
Published: 2024-06-18 04:00:54

---
title: Generalized Inverted Indexes And You
published: true
date: 2023-10-13 00:00:00 UTC
tags: 
canonical_url: https://kevinrocker.com/blog/2023-10-12-postgres-generalized-inverted-indexes/
---

I've been reading PostgreSQL documentation for fun lately, and I'd like to share what I've learned. Right now, that means advanced indexes and how to work with collection fields efficiently.

If you've ever worked prexisting array or JSON column and needed a complex `WHERE` clause for the latest feature, you might have worried about query performance. Or maybe you _didn't_ worry about it, only to find out later that it was glacially slow.Well good news! You can search these data structures efficiently with [Generalized Inverted Indexes](https://www.postgresql.org/docs/current/gin-intro.html), or GIN indexes.

I'm not entirely clear if the term is "GIN index" or just "GIN", but I'll stick to the former.

Just like B-Tree Indexes optimize basic lookups and sorting, GIN indexes improve performance for all types of operations involving collections. For example, finding all rows that contain an element in an array column.

For a concrete example, let's imagine a table like this:

```sql
CREATE TABLE farm_animals (
    id SERIAL PRIMARY KEY,
    name TEXT NOT NULL,
    tags TEXT[] NOT NULL
);
```

Loaded up with values

```sql
INSERT INTO farm_animals (name, tags) VALUES
    ('Chicken', ARRAY['bird', 'domestic']),
    ('Cow', ARRAY['mammal', 'domestic']),
    ('Rooster', ARRAY['bird', 'domestic']),
    ('Dog', ARRAY['mammal', 'domestic', 'pet']),
    ('Cat', ARRAY['mammal', 'domestic', 'pet']),
    ('Fish', ARRAY['aquatic']);
```

We try to find all the birds, but it's just too slow. This is going to be a very high-traffic query, and our data-set is huge.

A GIN index will unpack the array, and put each _unique value_ on its own row with a list of pointers to all the rows containing that value.

The resulting index looks like this:

```sql
farm_animals Table GIN Index on tags
------------------ ---------------------
id | name | tags key | row_pointers
---|---------|-------- ------- | -------------
 1 | Chicken | bird bird | 1, 3
 2 | Cow | mammal mammal | 2, 4, 5
 3 | Rooster | bird domestic| 1, 2, 3, 4, 5
 4 | Dog | mammal pet | 4, 5
 5 | Cat | mammal aquatic | 6
 6 | Fish | aquatic
```

Now we can safely ask questions like "how many farm animals are domestic mammals?" or "find all the birds" without parsing the array column at all, just from the index. Now all our farm animal searches will scale.

GIN indexes are versatile: they can be used to efficiently query array columns, JSON columns, and even to create an index for full-text search or text similarity checks—both topics that definitely deserve their own articles.

With this, you can use collection fields with comfort and the knowledge that you're not sacrificing searchability or speed. Now go forth and write that complex `WHERE` statement, filter on that JSON field, and aggregate your domesticated birds.

For more reading, check out the [official Postgres documentation](https://www.postgresql.org/docs/current/gin-intro.html).
Resize Disk VM Ubuntu 20.04 on Proxmox
Tags: ubuntu, proxmox, devops, vm
Published: 2023-10-13 01:23:32

Hallo world!
Saya menemukan sedikit masalah ketika ingin meresize kapasistas disk pada sebuah Virtual Machine. VM Ubuntu dengan kapasitas `500 GB` akan saya perbesara menjadi `1 TB`. Mudah saja hanya mematikan VM, tambahkan size melalui GUI Console Proxmox lalu booting ulang VM nya. Tapi masalahnya setelah saya cek dari sisi Ubuntu dengan perintah `df -h` ternyata tidak berubah.

Saya menemukan solusi pada Forum Rsemi Proxmox, berikut langkahnya.

- Menambah/mengubah ukuran disk dari konsol GUI

- Extend physical drive partition, Cek terlebih dahulu kapasitas free nya. Dari sini semua syntax saya asumsikan menggunakan user `root`. 

```
fdisk -l
```

- Extend physical drive partition, sesuaikan angka `3` dengan lokasi drive anda

```
growpart /dev/sda 3
```

Melihat phisical drive

```
pvdisplay
```

Instruksikan LVM bahwa ukuran disk telah berubah

```
pvresize /dev/sda3
```

Periksa phisical drive apakah sudah berubah

```
pvdisplay
```
Extend  Logical  volume 
Melihat LV awal yg sedang berjalan

```
lvdisplay
```

Catat nama LV nya, pada contoh `/dev/ubuntu-vg/ubuntu-lv`, lalu resize

```
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
```

Melihat apakah LV sudah berubah 

```
lvdisplay
```
  


- Resize Filesystem
Jalankan perintah berikut

```
resize2fs /dev/ubuntu-vg/ubuntu-lv
```

lalu cek untuk melihat hasil perubahan

```
fdisk -l 
```

Referensi
[https://forum.proxmox.com/threads/resize-ubuntu-vm-disk.117810/](https://forum.proxmox.com/threads/resize-ubuntu-vm-disk.117810/)
[TypeScript] How to create a union type consisting of string literals and string primitive
Tags: typescript
Published: 2023-10-13 01:06:00

Let's consider a way to specify specific strings like 'dog' or 'cat' as literal types while including other string types when creating types in TypeScript.

Let's start with a simple type:

```ts
type AnimalWithString = 'dog' | 'cat' | string
// type Animal = string
```

In this case, the type information for `Animal` becomes `type Animal = string`, which loses the information about 'dog' or 'cat'. This is not useful.

Let's remove the `string` type:

```ts
type Animal = 'dog' | 'cat'
// type Animal = "dog" | "cat"
const myAnimal:Animal = 'bird'
//Type '"bird"' is not assignable to type 'Animal'.(2322)
```

Now it becomes a simple union of literal types, and it won't accept other strings like 'bird'.

So let's use a technique.

Instead of `string`, we'll use `(string & {})`.

```ts
type AnimalSpecified = 'dog' | 'cat' | (string & {})
// type AnimalSpecified = "dog" | "cat" | (string & {})
const animalIncludingMightBe:AnimalSpecified = 'bird'
```

With this, we can maintain 'dog' and 'cat' while providing the information of the string type, creating a type that has both string literal types and string types.

Please try it out in the [TS Playground](https://www.typescriptlang.org/play?#code/C4TwDgpgBAggdgSwLYEMA2B1BwAWBlYAJwTgHMoBeKAcgBMB7U6qAHxoGMVhm2BnIkqQBQAehFRQkWIlSZs+AWUpR+xMkKGTo8ZOmV1GPDl2qiRW6brTKARA1I3WUG52A2h7enH5QkIHbIAXAF6VNQARgiEtKaa4Noy6HiQ7AgAZggQtPr2RtSuRgAUqoJQAGRQAN4AvgCUZhLxlrLJEKkZWbb2jmwuXD1QxYrkFTX1Hl4+KIlowTOt7ZnZYdRAA) to see its actual behavior.

In `(string & {})`, `{}` refers to a type that is **non-null** and **non-undefined**. By creating an intersection type with `string` using `&`, TypeScript can maintain the `string` type.

I learned about this method from [this StackOverflow question and answer](https://stackoverflow.com/questions/61047551/typescript-union-of-string-and-string-literals).

If you have any other better solutions, please let me know.

That's all.
gRPC 장단점 요약
Published: 2023-10-13 00:49:18

- 장점

1. json보다 5배 빠름. 여러 빅테크 기업에서 사용하고있음

2. protoBuf를 사용하여 속도가 매우빠름

3. 다양한언어 지원됨

4. msa 에서 외부 서비스간 호출시 유용
 
- 단점

1. 브라우저 지원안됨, 로우레벨 언어에서만 사용가능

2. 널리 쓰이지 못함
A 3D tetris game built with Three.js and React
Tags: tetris, games, threejs
Published: 2023-10-28 15:12:38

---
title: A 3D tetris game built with Three.js and React
published: true
date: 2023-10-13 00:44:00 UTC
tags: Tetris,Games,ThreeJS
canonical_url: https://reactjsexample.com/a-3d-tetris-game-built-with-three-js-and-react/
---

# threejs-tetris-react
 ![A 3D tetris game built with Three.js and React](https://reactjsexample.com/content/images/2023/10/Code_2023-10_11-38-03.jpg)

a 3D tetris game built with Three.js + React + TypeScript

[View Demo](https://project.threejs-tetris-react.rylan.cn/)[View Github](https://github.com/RylanBot/threejs-tetris-react?ref=reactjsexample.com)

## Get Started

```
npm install
npm run dev
```
A flexible task management library for JavaScript applications
Tags: task
Published: 2023-10-28 15:12:42

---
title: A flexible task management library for JavaScript applications
published: true
date: 2023-10-13 00:41:00 UTC
tags: Task
canonical_url: https://reactjsexample.com/a-flexible-task-management-library-for-javascript-applications/
---

 ![A flexible task management library for JavaScript applications](https://reactjsexample.com/content/images/2023/10/Code_2023-10_11-36-29.jpg)

![A flexible task management library for JavaScript applications](https://github.com/oktaysenkan/kronash/assets/42527467/7e237fb0-9566-4ca6-91d4-0b5dbabbf0aa)

# Kronash

### Manage timed tasks effortlessly

Kronash is a powerful, flexible and easy-to-use task management library for JavaScript applications.

## Motivation

Born out of the need to simplify and enhance the management of `setTimeout` and `setInterval`, Kronash provides a high-level API to handle scheduling tasks with a wide array of options and control mechanisms. It takes away the verbosity of dealing with JavaScript’s default timer functions, making your code cleaner and more intuitive.

Whether you need to create tasks that repeat at specified intervals, or simply delay certain operations, Kronash has got you covered. It even allows you to pause, resume, stop, and clear tasks whenever required, providing a level of control that’s often difficult to handle manually.

Kronash empowers you to write more understandable and maintainable code when dealing with async operations, timers or delays.

## Features

- 🌍 Framework Agnostic: Works seamlessly with any JavaScript framework or library, or in a plain JavaScript environment. It’s fully compatible with popular libraries like React, Vue, and Angular.
- 🚀 Easy Task Creation: Quickly set up tasks with desired settings.
- 🕹️ Full Task Control: Start, pause, resume, stop, or remove tasks as needed.
- 👀 Observer Pattern Support: Get updates on task state changes by subscribing to events.
- 🔗 Chainable API: Enables concise and logical code structure.
- 💅 TypeScript Support: Fully compatible with TypeScript for robust typing support.

## Resources

- **[Documentation](https://kronash-docs.vercel.app/)**
- **[React Demo](https://kronash-react-demo.vercel.app/)**

## GitHub

[View Github](https://github.com/oktaysenkan/kronash?ref=reactjsexample.com)
Do you know all these Typescript Utility Types?
Tags: typescript, tutorial, webdev, beginners
Published: 2023-10-13 00:08:21

Hey everyone,

I recently wrote [an article](https://bluesockets.com/typescript/typescript-utility-types/) exploring TypeScript's utility types. These are predefined type transformations that simplify working with types. These types are based on generics, enabling flexible and reusable type parameters. They allow developers to perform common type manipulations, making type definitions more efficient and readable. Here are some you should know:

1.**`Partial<Type>`**

Makes all properties of a given type optional.
   ```typescript
   type User = { id: number; name: string; email: string; };
   type PartialUser = Partial<User>;
   // Resulting type: { id?: number; name?: string; email?: string; }
   ```

2.**`Required<Type>`**

Enforces all properties of a given type to be required.
   ```typescript
   type PartialUser = { 
       id?: number; 
       name?: string; 
       email?: string; 
   };
   type RequiredUser = Required<PartialUser>;
   // Resulting type: { id: number; name: string; email: string; }
   ```

3.**`Readonly<Type>`**

Makes all properties of a given type readonly.
   ```typescript
   type MutableUser = { 
       id: number; 
       name: string; 
   };
   type ImmutableUser = Readonly<MutableUser>;
   // Resulting type: { readonly id: number; readonly name: string; }
   ```

4.**`Record<Keys, Type>`**

Constructs an object type with specified keys and a given value type.
   ```typescript
   type Weekdays = 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday';
   type Workload = Record<Weekdays, number>;
   // Resulting type: { Monday: number; Tuesday: number; Wednesday: number; Thursday: number; Friday: number; }
   ```

5.**`Pick<Type, Keys>`**

Selects a subset of properties from a given type.
   ```typescript
   type User = { 
       id: number; 
       name: string; 
       email: string; 
       age: number; 
   };
   type UserSummary = Pick<User, 'id' | 'name'>;
   // Resulting type: { id: number; name: string; }
   ```

6.**`Omit<Type, Keys>`**

Excludes specified properties from a given type.
   ```typescript
   type User = { 
       id: number; 
       name: string; 
       email: string; 
       age: number; 
   };
   type UserWithoutAge = Omit<User, 'age'>;
   // Resulting type: { id: number; name: string; email: string; }
   ```

7.**`Exclude<Type, ExcludedUnion>`**

Generates a new type by excluding types from the first type that are assignable to any type in the second type.
   ```typescript
   type AllColors = 'red' | 'blue' | 'green' | 'yellow';
   type PrimaryColors = 'red' | 'blue';
   type NonPrimaryColors = Exclude<AllColors, PrimaryColors>;
   // Resulting type: 'green' | 'yellow'
   ```

That's not all! [The article](https://bluesockets.com/typescript/typescript-utility-types/) also covers four more utility classes, custom utility types, and conditional types, providing examples for creating and leveraging them. These utility types enhance code readability, maintainability, and reusability.
What's A Book You'd Love to Read Again for the First Time?
Tags: discuss, codenewbie, beginner
Published: 2023-10-13 00:00:00

---
published_at : 2023-10-13 00:00 +0000
---
Tell us about a book that truly stuck with you and why you'd want to experience that initial read all over again.

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
What's the One Work Task You'd Cut?
Tags: discuss
Published: 2023-10-13 00:00:00

---
published_at : 2023-10-13 00:00 +0000
---
If you could free up time by cutting out one daily work activity, what would it be, and why? Don't all say "meetings!" at once.

Follow the DEVteam for more discussions and online camaraderie!

{% embed [https://dev.to/devteam](https://dev.to/devteam) %}
Modules Status Update
Tags: community, content
Published: 2023-10-20 18:22:50

---
title: Modules Status Update
published: true
date: 2023-10-13 00:00:00 UTC
tags: community, content
canonical_url: https://puppetlabs.github.io/content-and-tooling-team/blog/updates/2023-10-13-modules-status-update/
---

## Behind the screens

Trust you’ve had a rewarding week. As for the modules team, the majority of us were engaged in Puppet training sessions. It’s been an immersive experience delving into new techniques and best practices, fostering a stronger foundation for our ongoing projects. We’re excited to bring this newfound knowledge back to the team and continue delivering high-quality solutions. Looking forward to what the next week holds for us!

## Community Contributions

We’d like to thank the following people in the Puppet Community for their contributions over this past week:

- [`puppetlabs-apache#2481`](https://github.com/puppetlabs/puppetlabs-apache/pull/2481): “Drop EoL Ubuntu code”, thanks to [bastelfreak](https://github.com/bastelfreak)
- [`puppetlabs-apache#2480`](https://github.com/puppetlabs/puppetlabs-apache/pull/2480): “Remove outdated parameter documentation for ssl\_mutex”, thanks to [ekohl](https://github.com/ekohl)
- [`puppetlabs-apache#2479`](https://github.com/puppetlabs/puppetlabs-apache/pull/2479): “Drop EoL Debian 9 and older code”, thanks to [bastelfreak](https://github.com/bastelfreak)
- [`puppetlabs-postgresql#1514`](https://github.com/puppetlabs/puppetlabs-postgresql/pull/1514): “Drop code for Debian without systemd”, thanks to [bastelfreak](https://github.com/bastelfreak)

## New Module Releases

- [`puppetlabs-postgresql`](https://github.com/puppetlabs/puppetlabs-postgresql) (`10.0.0`)
Can You Ace a Coding Interview Without Solving the Problem(s)?
Tags: discuss, codenewbie, beginners
Published: 2023-10-13 00:00:00

Is it possible to excel in a coding interview even if you're unable to solve a particular problem?


Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
El Operador ternario en programación: Historia, ventajas y usos en diferentes lenguajes
Published: 2023-10-12 23:11:38

 En el mundo de la programación, los operadores son herramientas esenciales para tomar decisiones y simplificar el código. Uno de los operadores más interesantes es el llamado "operador ternario". Personalmente, descubrí su existencia en 2012 mientras trabajaba en Yarkan, gracias a mi amigo Angel Ybarbhuen, quien me enseñó cómo usarlo. Desde entonces, el operador ternario se ha convertido en una parte fundamental de mi arsenal de programación. En este artículo, exploraremos su historia, ventajas y cómo se utiliza en diferentes lenguajes de programación.

**Historia del Operador Ternario:**

    El operador ternario tiene una historia fascinante que se remonta a los primeros lenguajes de programación. Su origen se encuentra en el lenguaje de programación C, donde se introdujo por primera vez. A medida que los lenguajes evolucionaron, el operador ternario se incorporó a muchos de ellos debido a su eficacia en la escritura de código conciso y legible.

**¿Qué es el Operador Ternario?:**

Nota completa: [davdomin.blogspot.com/2023/10/el-operador-ternario-en-programacion.html](https://davdomin.blogspot.com/2023/10/el-operador-ternario-en-programacion.html)
Pvotal Technologies - End-to-end security software developer
Tags: cybersecurity
Published: 2023-10-12 22:34:56

Technology is pivotal in improving lives, sustaining the environment, and pushing society forward. Unfortunately, many go adrift while engineering solutions, lose track of their objectives, and decouple from their original vision before they run out the clock to pivot.

We engineered complex, automated processes aligned with best AIOps, BizDevOps, DevSecOps, CloudOps, and ITOps practices to reduce the technical debt involved in creating secure, scalable, and high-performing global scale apps. We built a comprehensive, low-code, event-driven, micro-service-based, Cloud Native platform to help businesses go to market faster by leveraging our highly agnostic processes.

[https://pvotal.tech](https://pvotal.tech)
Service Bus Data not pulling through webhooks
Published: 2023-10-12 22:33:55

We had an issue reported from App team where the messages was not going to service bus queue - this got fixed by enabling the private endpoint.

Later there was an issue where the webhook listening to the queue is not receiving messaging.
Changed the messaging type to AMQP and then NSG was modified to accept port 443 and 5671.

References:

https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-protocol-guide
Day 831 : Meeting of the Minds
Tags: hiphop, code, coding, lifelongdev
Published: 2023-10-12 22:14:32

_liner notes_:
- Professional : Today is the day I'm calling it for the updates I've been doing for the documentation. I tested them out in some application and spoke with the engineering team to get some clarification on things. Had a meeting of the minds. haha Also finalized the code snippets to be printed on flyers to be distributed at events. Had a couple of meetings. Followed up on some community questions. Pretty full day. Day flew by!

- Personal : Noticed that when I updated the Astro version of my side project, some stuff rendered weird on a page. Went back in and fixed it. Reviewed some tracks for the radio show. Took some code from an example tutorial and ported it over to CodePen so I can see it all in one place and play around with it.

![A road going through a forest of trees with orange, yellow, and green leaves in County Wicklow, Ireland](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dd5bu1dac3nkk8g45jyg.jpg)

I've been thinking about how I can technically do the things I want with my new side project. It involves streaming audio, but depending on the situation, it will come from different sources. I want to see if I can have one solution to make things easier. Going to pick up some projects on Bandcamp and get my social media posts ready to post tomorrow. I may start putting together tracks for the radio show so I have less to do on Friday.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube sQPrRtqyYcc %}
Tutorial de Instalação do Python e Configuração do Ambiente de Desenvolvimento com PyCharm
Tags: python, programming, tools, setup
Published: 2023-10-12 22:10:28

**Tutorial de Instalação do Python e Configuração do Ambiente de Desenvolvimento com PyCharm**

**1. Instalação do Python:**

- Acesse o site oficial do Python em [python.org](https://www.python.org/).

- Clique na opção "Downloads" no menu principal.

- Escolha a versão mais recente do Python e clique nela para baixar.

- Execute o arquivo de instalação baixado e siga as instruções, garantindo que a opção "Adicionar Python ao PATH" esteja marcada.

- Após a instalação, abra o PyCharm.

**2. Configuração do Ambiente no PyCharm:**

- Se você ainda não tiver o PyCharm instalado, acesse o site oficial do JetBrains em [jetbrains.com/pycharm](https://www.jetbrains.com/pycharm/) e faça o download da versão Community (gratuita) ou Professional (com recursos avançados).

- Após a instalação do PyCharm, abra o aplicativo.

- Para criar um novo projeto, clique em "File" (Arquivo) > "New Project" (Novo Projeto). Escolha a pasta onde deseja criar o projeto e selecione "Python" como a linguagem de programação.

- Configure o ambiente virtual Python para o projeto, que permite isolar as dependências do projeto. No PyCharm, vá para "File" (Arquivo) > "Settings" (Configurações) > "Python Interpreter" (Interpretador Python) e crie um ambiente virtual.

- Agora você pode criar e gerenciar projetos Python no PyCharm. A IDE oferece um ambiente de desenvolvimento completo, com ferramentas de depuração, controle de versão e muitos recursos avançados.

**3. Projetos em Diferentes Domínios:**

- **Console:** Use o PyCharm para criar projetos de console Python, onde você pode escrever scripts e interagir diretamente com o terminal.

- **Web:** Para desenvolvimento web, o PyCharm suporta estruturas Python populares, como Django e Flask. Você pode criar aplicativos da web, testá-los localmente e implantá-los em servidores web.

- **Aplicativo:** PyCharm é uma excelente escolha para o desenvolvimento de aplicativos Python, seja para desktop ou móveis. Você pode criar aplicativos usando bibliotecas como Tkinter para desktop ou Kivy para aplicativos móveis.

- **Desktop:** Para projetos de aplicativos desktop, você pode usar o PyCharm juntamente com bibliotecas como PyQt ou Tkinter para criar interfaces gráficas.

**4. Ferramentas de Depuração:**

- O PyCharm possui um depurador integrado que permite inspecionar variáveis, definir pontos de interrupção e depurar seus códigos passo a passo.

- Além disso, você pode integrar o PyCharm com ferramentas externas de depuração, como o PDB (Python Debugger) e aproveitar as funcionalidades avançadas de depuração.

Agora, você tem um ambiente de desenvolvimento Python completo no PyCharm, pronto para criar projetos em várias áreas e depurá-los com eficiência. Certifique-se de personalizar o PyCharm de acordo com suas preferências e necessidades específicas de projeto.