teleren/devto huggingface dataset:
Compiling PostgreSQL extensions on Windows with MSVC
Tags: postgres, database, c
Published: 2023-07-30 22:25:05

## **Introduction**
PostgreSQL is an open-source relational database management system that is widely used in enterprise applications. PostgreSQL supports extensibility, which allows developers to extend its functionality by creating custom extensions. Developing PostgreSQL extensions on Windows with MSVC (Microsoft Visual C++) can be a challenging task for some developers.

**Step 1:** Download the PostgreSQL source code
First, we need to download the PostgreSQL source code. We can download the source code from the PostgreSQL website or use Git to clone the source code repository.

**Step 2:** Set up the PostgreSQL build environment
Once we have the PostgreSQL source code, we need to set up the build environment. To do this, we need to run the following command in the PostgreSQL source code directory:

`build\msvc\setenv.cmd`

This will open a new command prompt window with the environment variables set up for building PostgreSQL with MSVC.

**Step 3:** Build the PostgreSQL source code
To build the PostgreSQL source code, we need to run the following command in the PostgreSQL source code directory:
`nmake /f win32.mak`

This will start the build process, which may take several minutes to complete depending on the speed of your machine.

**Step 4:** Create a new Visual Studio project for the extension
Once the PostgreSQL source code is built, we can create a new Visual Studio project for our extension. To do this, we need to follow these steps:

1. Open Visual Studio and select "File" > "New" > "Project".
2. Select "Visual C++" > "Dynamic-link Library (DLL)" and enter a name for the project.
3. Select "DLL" for the "Application type" and "Empty Project" for the "Additional options".
4. Click "Create" to create the new project.

**Step 5:** Add the PostgreSQL include and library directories to the project
To use the PostgreSQL libraries in our extension, we need to add the PostgreSQL include and library directories to the project. To do this, we need to follow these steps:

1. Right-click on the project in the "Solution Explorer" and select "Properties".
2. Select "VC++ Directories" > "Include Directories" and add the path to the PostgreSQL include directory.
3. Select "Linker" > "General" > "Additional Library Directories" and add the path to the PostgreSQL lib directory.

**Step 6:** Add the extension source code to the project
Next, we need to add the extension source code to the project. To do this, we can either copy the source code to the project directory or add the source files to the project using the "Add Existing Item" option.

**Step 7:** Build the extension
Finally, we can build the extension by clicking on "Build" > "Build Solution" in Visual Studio. If everything is set up correctly, the extension should build without any errors.

## **Conclusion**
Compiling PostgreSQL extensions on Windows with MSVC can be a daunting task, but with the right tools and steps, it can be a straightforward process.
Moving to a new developer Twitter / X.com
Tags: webdev, javascript, twitter
Published: 2023-07-31 01:21:18

Hi there dev.to fam 👋

I'm just writing here to let any of my followers who followed my dev.to blog back in 2020-2021 that I'm moving to a new developer Twitter.

It took me about a year to go from 10 followers to 285 doing nothing but posting daily to dev.to. And to about 480 followers a year after that, which was phenomenal for a small-time tech blogger.


But after a while, my Twitter became a personal account. I got a full-time job as a software developer and politics and VC news took over my feed. I stopped posting. This was a mistake.

I'd like to start over with a new space dedicated entirely, once again, to development! You can find that here:

https://www.twitter.com/wallstwebdev

New York has been a gift to me, as far as advancing my development career. People here are supportive. In a city where finance, art, media, fashion, restaurants, and government have long been the major employers, tech isn't the oppressive force that it's seen as on the West Coast cities I grew up in.

To celebrate that and also to have a focus on uplifting NYC's small to medium sized businesses, I've re-branded with a new handle, Wall St Web Dev. My offices are a block away from Wall St in Lower Manhattan and I've found the area so charming that I wanted to celebrate it and its several hundred year history of small businesses flourishing in the neighborhood.

I look forward to getting back to posting in the days to come. Cheers! 🍻
WHAT is Apache Age?
Published: 2023-07-30 19:51:31

Apache Age is an open-source, distributed graph database that is built on top of PostgreSQL. It provides a native graph data store with support for graph queries, traversals, and analytics. Apache Age is designed to be easy to use, scalable, and performant.

The main advantage of Apache Age is its ability to seamlessly integrate with existing PostgreSQL-based applications. This means that organizations can easily extend their existing database infrastructure to support graph data, without having to introduce new technologies or learn new programming paradigms.

Apache Age uses a combination of table partitioning and indexing to achieve scalability and performance. The database is partitioned based on the graph topology, with each partition containing a subset of the graph data. This allows Apache Age to efficiently distribute queries and traversals across the cluster, while also minimizing the amount of data that needs to be scanned.

In addition to its scalability and performance benefits, Apache Age also provides a rich set of graph analytics features. These include support for centrality measures, community detection, and graph embeddings. These features enable organizations to gain deep insights into their graph data, and to use these insights to drive business decisions.

One of the key use cases for Apache Age is in social network analysis. Social networks are inherently graph-based, with nodes representing individuals and edges representing relationships between them.

In conclusion, Apache Age is a powerful and flexible graph database that offers scalability, performance, and a rich set of analytics features. Its seamless integration with PostgreSQL makes it easy to adopt and use, and its support for graph queries and traversals makes it ideal for a wide range of applications. If you are looking to work with graph data, Apache Age is definitely worth considering.
Cocaptain new Features
Tags: productivity, programming, vscode, javascript
Published: 2023-07-31 00:34:15

Are you tired from after writing comments after writing hundred lines of code, or you just started coding and you get stuck with no way to move on. I have the solution for you, Cocaptain is a vscode extension that aims to bring the potential of chatgpt to the visual studio code without any API-Key. The new features of Cocaptain include a pre-written patterns that make prompting more easy. We introduce two prompt for now : `comment the selection` and `Complete the code`. Those those two functionalites could be found in the context menu of vscode when selection a piece of code. We highly appreciate feature request and bug report (also a star in gitub motivate us) : https://github.com/Ayyoub-ESSADEQ/cocaptain/tree/main . Here is a simple presentation of those features : 

![Demo of the features](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64c10fek6wrinrmk3tvp.gif)
Clase 1|SOLIDITY| Hola mundo
Tags: solidity
Published: 2023-07-31 00:17:22

> 
#Hola a todos#

Voy a comenzar a estudiar solidity nuevamente y por lo tanto voy a utilizar dev.to para guardarlo como un blog para recordar mi codigo

Primero debemos de conectarnos a [Remix](https://remix.ethereum.org)


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




```
SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

contract HolaMundo {
string public miNombre = "Rodrigo";
}
```

##SPDX-License-Identifier: MIT##

1. Este comentario es un identificador de licencia que se utiliza para especificar qué tipo de licencia se aplica al código fuente. En este caso, indica que el código está licenciado bajo la Licencia MIT. La Licencia MIT es una licencia de código abierto muy permisiva que permite a cualquiera usar, modificar, distribuir y compartir el código bajo ciertas condiciones. El uso de este identificador facilita la comprensión de la licencia del código por parte de otras personas que quieran utilizarlo.


##pragma solidity 0.8.13;##

1. Esta declaración pragma indica la versión del compilador de Solidity que se debe utilizar para compilar el contrato. En este caso, se está utilizando la versión 0.8.13 de Solidity.



Este contrato se llama "HolaMundo" y contiene una sola variable llamada miNombre, que es de tipo string. La variable está declarada como pública, lo que significa que es accesible desde fuera del contrato.

La línea string public miNombre = "Rodrigo"; inicializa la variable miNombre con el valor "Rodrigo". Al ser pública, se genera automáticamente una función de lectura (getter) que permite a otros usuarios leer el valor de miNombre desde fuera del contrato.

En resumen, este contrato es bastante simple y su única funcionalidad es almacenar y permitir la lectura del nombre "Rodrigo" en la variable miNombre. Es común encontrar ejemplos de "Hola Mundo" cuando se presentan lenguajes de programación o contratos para mostrar la estructura básica y la sintaxis. Sin embargo, en aplicaciones descentralizadas más complejas, los contratos pueden tener funcionalidades mucho más avanzadas y útiles.


Despues de tener nuestro código listo debemos de compilarlo


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


Para poder compilarlo debemos dar clic en las opciones que se encuentran en el lado izquierdo


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


Despues de estar compilado debemos deployarlo


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

Despues de deployarlo podremos ver la variable que creamos dando clic en minombre


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

Y automaticamente nos debe de mostrar el nombre de nuestra variable
JETPACK COMPOSE
Tags: compose, jetpack, kotlin
Published: 2023-07-31 00:05:32

Oi, eu sou o Saulo e gostaria de compartilhar que iniciei meus estudos em Kotlin para desenvolvimento mobile.

Após algumas horas de estudos, esse foi o resultado.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wfxf7lr550uapvjc9wb5.png)
React Typescript Provider Boilerplate Snippet
Tags: react, typescript, provider, boilerplate
Published: 2023-07-31 00:00:13


![screenshot of code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/49zloktso75uyo5g07dl.png)

Hi friends. In my last projects I use providers a lot:

* Auth (login, logout, user)
* AppState (which part of the app is loaded and which is not, user settings) 
* NavigationProvider (page neighbors, go next, go back)
* ModalsProvider (open in modal form a component with some props)

So I came up with a provider snippet, which is easy to copy, past, expand and use from everywhere.

## Boilerplate  

`Provider.tsx`

```ts
import React, { createContext, useState } from 'react'

// rename Context and Provider to something meaningful, they will be imported from other components

interface Props {
	children: JSX.Element | JSX.Element[]
}

interface State {}

interface Methods {}

interface ContextType {
	state: State
	methods: Methods
}

const defaultContextValue = {} as ContextType

export const Context = createContext<ContextType>(defaultContextValue)

const defaultState = {}

const Provider: React.FC<Props> = ({ children }) => {
	const [state, setState] = useState<State>(defaultState)

	// here write some functions that change state, then put them to the mothods object 

	const methods = {}

	const contextValue = { state, methods }

	return <Context.Provider value={contextValue}>{children}</Context.Provider>
}

export default Provider
```
## Usage example 

### Provider 

`App.tsx`

```tsx
import Provider1 from './Provider1'
import Provider2 from './Provider2'

const App = () => {
	return (
		<Provider1>
			<Provider2>
				
			</Provider2>
		</Provider1>
	)
}

```

### Context 

When every provider has the same structure, you can use any of them easily/intuitively from anywhere. 

`Component.ts`

```ts

import { useContext } from 'react'
import { Context1 } from './Provider1'
import { Context2 } from './Provider2'

const Component = () => {
	const { state: provider1State, methods: provider1Methods } =
		useContext(Context1)
	const { state: provider2State, methods: provider2Methods } =
		useContext(Context2)

	return (
		<div className='someComponent'>
			<div>{provider1State.someField}</div>
			<div>{provider2State.someField}</div>
			<button>provider1Methods.someMethod</button>
			<button>provider2Methods.someMethod</button>
		</div>
	)
}
```
In a real project you'll have meaningful names for every provider (not Provider1, Provider2 as in the example above) so it'll be easy to read and write code even when many providers meats together in one component. E.g. `authState.userName`, `authMethods.login`, `appState.contentLoaded`. 

If you don't like such an approach, look at [useReducer](https://react.dev/reference/react/useReducer) hook.
Exploring Some features of Apache-age
Published: 2023-07-30 19:56:24

Apache Age is an open-source extension of PostgreSQL that provides a graph database functionality. Some of the key features of Apache Age include:

1. Graph database functionality:
Apache Age allows users to store and manipulate graph data, which is useful for a wide range of applications, including social networks, recommendation engines, and knowledge graphs.

2. Compatibility with PostgreSQL:
Apache Age is built on top of PostgreSQL, which is a well-established and widely used relational database management system. This means that users can leverage the scalability, reliability, and security features of PostgreSQL while also taking advantage of Apache Age's graph database functionality.

3. Support for property graphs:
Apache Age supports property graphs, which are a common graph data model that allows users to associate arbitrary key-value pairs with nodes and edges.

4. Cypher query language:
Apache Age supports the Cypher query language, which is a powerful and intuitive language for querying graph data.

5. Integration with other tools:
Apache Age can be integrated with a wide range of other tools and technologies, including Apache Spark, Apache Kafka, and Apache Hadoop, which makes it a versatile and flexible option for a wide range of applications.

6. Open source and community-driven:
Apache Age is an open-source project, which means that anyone can contribute to its development and improvement. This also means that users can benefit from a vibrant and active community of developers and users who can provide support and guidance.
Control rc car using raspberry pi (Part 2 : The web server)
Tags: beginners, raspberrypi, python, unity3d
Published: 2023-07-30 23:11:53

## Building the web server
In this part, we will start building the web server that will run on raspberry pi and will receive commands to control the rc car.
### The framework used
We will use [Bottle](https://bottlepy.org/docs/dev/) a lightweight web framework for python.
This is the first time I use python to build a web server and it was a very positif experience.
With Bottle.py, all you need is:

- Create a file, I named it `server.py`.

- Create a route.

- And run the server.
The minimal code needed to run a server is:
```
from bottle import route, run

@route('/')
def index():
    return "Hello world"

run(host='localhost', port=8080)
```

To let other devices on the same network connect to the server, we will change the last line to `run(host='0.0.0.0', port=8080)`

Thats it, the server is running and can be accessed from other devices in the same network.

### Create the routes
The routes could be implemented differently, but for simplicity we will use six routes :

- Tree routes to control the front wheels: `/right`, `/left` and `center`.

- Tree routes to control the rear wheels: `/forward/<speed>`, `backward/<speed>` and `/stop`. We use, in the tow first routes, a wildcard `<speed>`, to make the routes dynamic and change the speed of the car. The speed is an int that can change from 0 to 100, I will explain how to use it in the next parts.
The code of the server.py is :
```
from bottle import post, route, run

@route("/")
def index():
    return "RC Car Server"


@route("/right")
def right():
    return "Car turning right"


@route("/left")
def left():
    return "Car turning left"


@route("/center")
def center():
    return "Car turning center"


@route("/forward/<speed>")
def forward(speed):
    return "Car running froward at speed : " + speed


@route("/backward/<speed>")
def backward(speed):
        return "Car running backward at speed : " + speed


@route("/stop")
def stop():
        return "Car stopped, the speed is : 0"

run(host="0.0.0.0", port=8080)
```

Thats it for the server, we will improve it in next parts
Setup a Local Database
Tags: database, mysql, beginners, learning
Published: 2023-07-30 23:11:25

---
canonical_url: https://seankegel.com/set-up-a-local-database
---

There are plenty of ways to setup a database for local development. You can use Docker containers, install locally using Homebrew or other tools, and various other GUI tools.

My option of choice is [DBngin](https://dbngin.com/). It is a simple tool which lets you add databases quickly for whatever you need including MySQL, Postgres, and even Redis.


![DBngin Services](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ie9ra9bis4vh1zhzdgz0.png)

I am going to create a MySQL database.

![Create a MySQL database in DBngin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22vwzq8b2c0aj9ep05ks.png)

...and it is just that simple! Now just start the new database and DBngin will take care of the rest!


![Running service from DBngin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jd3xg117t8loncnphudp.png)

DBngin also happens to be made by the company behind my favorite database GUI tool, [TablePlus](https://tableplus.com/). If you use TablePlus, you can click on the arrow next to the "Start/Stop" button and open the database right in TablePlus.


![TablePlus](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v37wba52f9j06aof3vz.png)

From there, it is easy to create databases, tables, and setup users.


![Creating tables and databases in TablePlus](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0ec3nwiwx0iout8v5lw.png)

A future post can go into more MySQL or TablePlus usage, but if you want to dive in deeper to MySQL, I cannot recommend the [MySQL for Developers](https://planetscale.com/learn/courses/mysql-for-developers/introduction/course-introduction) course on Planetscale by Aaron Francis enough. It is a fantastic resource and even if you have been using MySQL for awhile, I am sure there will still be something to learn!

I know this was a simple post, but hopefully others getting started in there careers can find it helpful.
Go: Build binary for Android
Tags: go, android, tutorial, programming
Published: 2023-07-30 22:12:12

Go `1.20.6` and Ubuntu `20.04.6` was used in this post.

## Android NDK

Download [Android NDK](https://developer.android.com/ndk/downloads) and unzip. By the time I write this post I use `android-ndk-r25c-linux.zip`.

## Command

Change `CC` and `CXX` to `android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin` and you can choose `clang` base on your target architecture and android API, and also add `CGO_ENABLED=1`. Example target `aarch64` and `android28`:

```bash
CC="/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang" CXX="/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++" GOOS=android GOARCH=arm64 CGO_ENABLED=1 go build
```

### Result

Here the result, now we can run using app like [Termux](https://github.com/termux/termux-app):

![result go build for android](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bgm2clv0lzcwwbuf6g1.png)
Postgresql c functions
Tags: postgres, database
Published: 2023-07-30 22:11:15

## **Introduction**

PostgreSQL is an open-source relational database management system that provides a powerful set of features and tools for handling large and complex data sets. One of the key strengths of PostgreSQL is its ability to be extended using C functions.

C functions in PostgreSQL refer to functions that are implemented in C and can be called from SQL statements. These functions can be used to perform a wide range of tasks, such as data manipulation, complex calculations, and advanced data analysis.

**1. Aggregate Functions:** These functions take a set of input values and return a single output value. Examples of aggregate functions include SUM, AVG, and COUNT.

**2. Window Functions:** These functions perform calculations across a set of rows that are related to the current row. Examples of window functions include ROW_NUMBER, RANK, and LAG.

**3. Scalar Functions:** These functions take a single input value and return a single output value. Examples of scalar functions include UPPER, LOWER, and LENGTH.

**4. Table Functions:** These functions return a table as their output, which can be used in subsequent SQL statements. Examples of table functions include UNNEST and GENERATE_SERIES.

Creating C functions in PostgreSQL requires knowledge of the C programming language and an understanding of the PostgreSQL API. The PostgreSQL API provides a set of functions and data structures that can be used to interact with the database.

To create a C function in PostgreSQL, you need to define the function signature, which includes the name of the function, the input parameters, the return type, and any other relevant information. You also need to implement the function body, which performs the desired operations.

Once the C function is defined and implemented, it can be registered with the database using the CREATE FUNCTION statement. This makes the function available to be called from SQL statements.

## **Conclusion**
C functions in PostgreSQL provide a powerful way to extend the functionality of the database and perform complex operations on data. However, creating and using C functions requires knowledge of the C programming language and the PostgreSQL API.
React Native force to bundle javascript in Debug build
Tags: reactnative
Published: 2023-07-30 21:30:35

You can use a special env. variable on iOS

```shell
FORCE_BUNDLING=1 yarn ios
```

Source: https://github.com/facebook/react-native/blob/667d85bddada31a51bcf6e05b3b042efb93ddb78/packages/react-native/scripts/react-native-xcode.sh#L39

---

For android edit your app's `android/app/build.gradle` file:

```gradle
// React Native <= 0.70.x
project.ext.react = [
  // ...
  bundleInDebug: System.getenv("FORCE_BUNDLING") != null,
]

// React Native >= 0.71.x
react {
    debuggableVariants = System.getenv("FORCE_BUNDLING") ? [] : ["debug"]
}
```

then you can use: 

```shell
FORCE_BUNDLING=1 yarn android
```