<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Filipe Braga</title>
    <description>The latest articles on DEV Community by Filipe Braga (@filbraga).</description>
    <link>https://dev.to/filbraga</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1019731%2F68134788-b9f0-494a-a29c-cf5467392b97.jpeg</url>
      <title>DEV Community: Filipe Braga</title>
      <link>https://dev.to/filbraga</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/filbraga"/>
    <language>en</language>
    <item>
      <title>Benefício Fiscal com o Fator R</title>
      <dc:creator>Filipe Braga</dc:creator>
      <pubDate>Thu, 17 Oct 2024 18:01:32 +0000</pubDate>
      <link>https://dev.to/filbraga/beneficio-fiscal-com-o-fator-r-1178</link>
      <guid>https://dev.to/filbraga/beneficio-fiscal-com-o-fator-r-1178</guid>
      <description>&lt;p&gt;O "fator R" é um indicador utilizado no regime tributário do Simples Nacional para determinar a forma de tributação de algumas atividades de prestação de serviços. Ele é calculado com base na relação entre a folha de salários (incluindo encargos) dos últimos 12 meses e o faturamento bruto da empresa no mesmo período.&lt;/p&gt;

&lt;p&gt;A fórmula para o cálculo do fator R é:&lt;/p&gt;

&lt;p&gt;Fator R = Folha de Salários dos Últimos 12 Meses \ Faturamento Bruto dos Últimos 12 Meses&lt;/p&gt;

&lt;p&gt;Se o fator R for igual ou superior a 28%, a empresa poderá ser tributada pelo Anexo III, que apresenta alíquotas de imposto mais baixas, começando em 6%. Caso o fator R seja inferior a 28%, a tributação ocorre pelo Anexo V, onde as alíquotas iniciais são mais altas, partindo de 15,5%.&lt;/p&gt;

&lt;p&gt;Portanto, para obter o benefício fiscal de pagar menos impostos, é necessário que a relação entre a folha de salários e o faturamento seja de, no mínimo, 28%. Isso incentiva as empresas a aumentarem a formalização e contratação de mão de obra.&lt;/p&gt;

</description>
      <category>contabilidade</category>
      <category>pessoajuridica</category>
      <category>pj</category>
    </item>
    <item>
      <title>NodeJS: what do JavaScript, a V8 engine, and a dinosaur have in common?</title>
      <dc:creator>Filipe Braga</dc:creator>
      <pubDate>Wed, 10 May 2023 23:47:22 +0000</pubDate>
      <link>https://dev.to/filbraga/nodejs-what-do-javascript-a-v8-engine-and-a-dinosaur-have-in-common-29o2</link>
      <guid>https://dev.to/filbraga/nodejs-what-do-javascript-a-v8-engine-and-a-dinosaur-have-in-common-29o2</guid>
      <description>&lt;p&gt;Let's imagine you are building a house. To build the house, you need building materials, tools, and a plan. JavaScript, Chrome V8 engine and the Libuv are the different tools and materials we will use to do it.&lt;/p&gt;

&lt;h1&gt;
  
  
  javascript:
&lt;/h1&gt;

&lt;p&gt;This is like the bricks blocks, cement and the blueprint we use to build the house. It is the main material or language that we use to create and control what our house will look like and how it will function.&lt;/p&gt;

&lt;h1&gt;
  
  
  v8 Engine:
&lt;/h1&gt;

&lt;p&gt;This is the constructor builder who reads the blueprint (JavaScript) and knows exactly how to turn it into a strong and finished house. The V8 engine is a powerful worker that understands our JavaScript code and makes it run quickly and efficiently on the computer.&lt;br&gt;
💡V8 is Google's open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js, among others. It implements ...&lt;/p&gt;

&lt;h1&gt;
  
  
  libuv:
&lt;/h1&gt;

&lt;p&gt;This is like the plumbing and electricity in our house, making sure that everything works smoothly and all the different parts of the house can communicate with each other. libuv helps with managing tasks and events in our Node.js house, so that it can handle many things at once, like turning on lights or using the faucet, without any problems.&lt;br&gt;
💡libuv is a C library originally written for Node.js to abstract non-blocking I/O operations. &lt;/p&gt;

&lt;p&gt;When we put all these elements together, we can build a strong, efficient, and functional house, which is our Node.js application. #nodejs is an open-source, cross-platform JavaScript runtime environment that allows developers to execute JavaScript code outside of a web browser.&lt;/p&gt;

</description>
      <category>node</category>
      <category>guide</category>
    </item>
    <item>
      <title>Troubleshooting Timezone Issues in PostgreSQL with DBeaver</title>
      <dc:creator>Filipe Braga</dc:creator>
      <pubDate>Fri, 24 Mar 2023 17:04:14 +0000</pubDate>
      <link>https://dev.to/filbraga/troubleshooting-timezone-issues-in-postgresql-with-dbeaver-2lc6</link>
      <guid>https://dev.to/filbraga/troubleshooting-timezone-issues-in-postgresql-with-dbeaver-2lc6</guid>
      <description>&lt;p&gt;When working with a PostgreSQL database and querying data using a tool like DBeaver, it's not uncommon to run into issues where the &lt;strong&gt;time displayed in DBeaver doesn't match the time stored in the database&lt;/strong&gt;. This can be confusing and frustrating, but fortunately, the most likely cause is easy to fix: &lt;strong&gt;the timezone settings in DBeaver&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;PostgreSQL stores dates and times in UTC format by default. This means that if you query a timestamp field in the database, you'll get back a value in UTC time. However, when that value is displayed in DBeaver, it will be adjusted to the timezone settings of your computer, which may not be the same as the server hosting the database.&lt;/p&gt;

&lt;p&gt;To fix this, you'll need to adjust the timezone settings in DBeaver to match the timezone of the server. You can do this by going to the "Window", and then selecting the "Preferences" tab. From there, you should see a setting for "User Interface". Set the timezone value to UTCZ, and then save your changes.&lt;/p&gt;

&lt;p&gt;Once you've made this adjustment, your queries should return results that match the actual timestamp values stored in the database. Keep in mind, though, that this adjustment only affects DBeaver. If you're using another tool to query the database, or if you're running queries programmatically, you may need to adjust the timezone settings in those tools as well.&lt;/p&gt;

&lt;p&gt;It's also worth noting that if you're working with a database that spans multiple timezones, you may need to take additional steps to ensure that your queries return accurate results. For example, you may need to convert timestamps to a consistent timezone before comparing them or aggregating data. However, for most cases, adjusting the timezone settings in DBeaver should be sufficient.&lt;/p&gt;

&lt;p&gt;In conclusion, if you're seeing a discrepancy between the time displayed in DBeaver and the time stored in your PostgreSQL database, don't panic. It's likely just a timezone issue, and can be easily fixed by adjusting the serverTimezone setting in DBeaver. With a little bit of configuration, you'll be able to query your database with confidence, knowing that you're working with accurate timestamp values.&lt;/p&gt;

&lt;h1&gt;
  
  
  PostgreSQL #DBeaver #timezone #database #timestamp #UTC #serverTimezone #querying #data #configuration #accuracy #datetime #computing #programming
&lt;/h1&gt;

</description>
      <category>postgres</category>
      <category>dbeaver</category>
      <category>timezone</category>
      <category>utc</category>
    </item>
    <item>
      <title>API with Typescript + Nest + TypeORM + Postgres + Docker</title>
      <dc:creator>Filipe Braga</dc:creator>
      <pubDate>Tue, 21 Mar 2023 17:17:42 +0000</pubDate>
      <link>https://dev.to/filbraga/api-with-typescript-nest-typeorm-postgres-docker-1m81</link>
      <guid>https://dev.to/filbraga/api-with-typescript-nest-typeorm-postgres-docker-1m81</guid>
      <description>&lt;p&gt;In this blog post, I'll show you how to set up a project using TypeScript, Nest, Postgres, Docker and how to seed your database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TypeScript&lt;/strong&gt; is a statically typed language that is a strict syntactical superset of JavaScript. It offers improved type safety and tooling support, making it a popular choice for larger-scale projects. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nest&lt;/strong&gt; is a framework for building efficient, scalable Node.js server-side applications. It provides a structure and a range of features that make it easier to develop and test applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Postgres&lt;/strong&gt; is a powerful open-source relational database management system that is well suited for complex data structures and large-scale data processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TypeORM&lt;/strong&gt; is an open-source Object Relational Mapping (ORM) tool that provides a way to interact with relational databases such as MySQL, PostgreSQL, and SQLite. It helps you to write database-related code using object-oriented programming in TypeScript or JavaScript, instead of writing raw SQL statements. TypeORM offers a lot of features such as transaction management, database migrations, connection pooling, etc. that makes it easy to work with databases in your applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt; is a containerization platform that makes it easier to deploy and run applications in different environments. We will launch a Postgres database and supporting service in docker.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Nest&lt;/strong&gt;:&lt;br&gt;
First, install nest-cli&lt;br&gt;
&lt;code&gt;npm i -g @nestjs/cli&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, create a new project using the nest cli&lt;br&gt;
&lt;code&gt;nest new project-name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Choose: npm for package manager,&lt;/p&gt;

&lt;p&gt;Next, enter in the project folder&lt;br&gt;
&lt;code&gt;cd project-name&lt;/code&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;PostgreSQL Database&lt;/strong&gt;&lt;br&gt;
Install pg&lt;br&gt;
&lt;code&gt;npm install pg --save&lt;/code&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;TypeORM&lt;/strong&gt;&lt;br&gt;
Install TypeOrm&lt;br&gt;
&lt;code&gt;npm install --save @nestjs/typeorm typeorm postgres&lt;/code&gt;&lt;/p&gt;



&lt;p&gt;Open your project with your IDE&lt;/p&gt;

&lt;p&gt;In the app.module.ts, add the connection to the databese with TypeOrmModule.forRoot():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: 'localhost',
      port: 5432,
      username: 'root',
      password: 'password',
      database: 'postgres',
      entities: [`${__dirname}/typeorm/entities/*{.js,.ts}`],
      synchronize: true, // do not use in prod
    }),
  ],
})
export class AppModule {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;BTW: you can delete app.service and app.controller&lt;/p&gt;




&lt;p&gt;Now, we should create our first module with nest cli:&lt;br&gt;
&lt;code&gt;nest g resource modules/users&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;choose REST API on terminal&lt;br&gt;
select 'yes' to generate CRUD entry points&lt;/p&gt;



&lt;p&gt;With the module created, we should now organize our project like this:&lt;/p&gt;

&lt;p&gt;1) create some folders called: typeorm &amp;gt; database / entities / seeds&lt;br&gt;
2) create data-source.ts, main.seed.ts and user.seed.ts&lt;br&gt;
3) move the user entity to the entity folders&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/src/typeorm
├── database
│   └── data-source.ts
├── seeds
│   └── main.seed.ts
└── entities
    └── user.entity.ts *(generated by the script)*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;insert the code bellow into the files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// users.entity.ts
import { Column, CreateDateColumn, DeleteDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';

@Entity('users')
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  email: string;

  @Column()
  active: boolean;

  @Column()
  birthday: Date;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @DeleteDateColumn()
  deletedAt: Date;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// users.service.ts
import { Injectable } from '@nestjs/common';
import { User } from 'src/typeorm/entities/user.entity';
import { DataSource } from 'typeorm';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';

@Injectable()
export class UsersService {
  constructor(private dataSource: DataSource) {}
  private userRepository = this.dataSource.getRepository(User);

  async create(createUserDto: CreateUserDto) {
    return this.userRepository.save(createUserDto);
  }

  async findAll(): Promise&amp;lt;User[]&amp;gt; {
    return this.userRepository.find();
  }

  async findOne(id: number) {
    return this.userRepository.findOneBy({ id });
  }

  async update(id: number, updateUserDto: UpdateUserDto) {
    let user = await this.findOne(id);
    user = { ...user, ...updateUserDto };
    return await this.userRepository.save(user);
  }

  async remove(id: number) {
    const user = await this.findOne(id);
    return await this.userRepository.softRemove(user);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// data-source.ts
import { DataSource, DataSourceOptions } from 'typeorm';

export const dataSourceOptions: DataSourceOptions = {
  type: 'postgres',
  host: 'localhost',
  port: 5432,
  username: 'root',
  password: 'password',
  database: 'postgres',
  entities: ['src/**/*.entity{.js,.ts}'],
};

export default new DataSource(dataSourceOptions);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// main.seed.ts
import { DataSource } from 'typeorm';
import { dataSourceOptions } from '../database/data-source';
import { User } from '../entities/user.entity';

const dataSource = new DataSource(dataSourceOptions);
const userRepository = dataSource.getRepository(User);

async function connect() {
  try {
    if (dataSource.isInitialized) {
      await dataSource.destroy();
    }
    await dataSource.initialize();
    console.log('Data Source has been initialized!');
  } catch (err) {
    console.error('Error during Data Source connect', err);
  }
}

async function disconnect() {
  try {
    await dataSource.destroy();

    console.log('Data Source disconnected!');
  } catch (err) {
    console.error('Error during Data Source disconnect', err);
  }
}

async function seed() {
  const UserSeed = () =&amp;gt; [
    {
      name: 'John Doe',
      email: 'john@doe.com',
      active: true,
      birthday: '1990-01-01',
    },
    {
      name: 'Jane Doe',
      email: 'jane@doe.com',
      active: false,
      birthday: '1990-01-31',
    },
    {
      name: 'Josh Doe',
      email: 'josh@doe.com',
      active: true,
      birthday: '2020-12-31',
    },
  ];

  await userRepository.save(UserSeed());
  console.log('created seeds');
}

async function runSeed() {
  await connect();
  console.log('connected');
  await seed();
  console.log('seed done');
  await disconnect();
  console.log('disconnected');
}

runSeed();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Now, we should create our 'docker-compose.yml' file in the root folder, and then run &lt;code&gt;sudo docker-compose up&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;! Make sure the Docker is running in your system !&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3.1'

services:
  db:
    image: postgres:14.2-alpine
    restart: always
    environment:
      POSTGRES_USER: "root"
      POSTGRES_PASSWORD: "password"
      POSTGRES_DB: "postgres"
    ports:
      - "5432:5432"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some useful docker commands:&lt;br&gt;
&lt;code&gt;sudo docker ps&lt;/code&gt; to list all containers&lt;br&gt;
&lt;code&gt;sudo docker stop my_container_name&lt;/code&gt; to stop a specific container&lt;/p&gt;



&lt;p&gt;Now, add a script to package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// package.json
"seed":"npx ts-node src/typeorm/seeds/main.seed.ts",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in a new terminal on the IDE run the code &lt;code&gt;npm start&lt;/code&gt; to synchronize the database&lt;/p&gt;

&lt;p&gt;kill the application, and then run the script &lt;code&gt;npm run seed&lt;/code&gt; to populate the database&lt;/p&gt;




&lt;p&gt;Its Done! now if you run &lt;code&gt;npm start&lt;/code&gt; and send a &lt;code&gt;GET&lt;/code&gt; request on &lt;code&gt;localhost:3000/users&lt;/code&gt;, you shold get all the users from the seed.&lt;/p&gt;

</description>
      <category>crypto</category>
      <category>cryptocurrency</category>
      <category>blockchain</category>
      <category>airdrop</category>
    </item>
  </channel>
</rss>
