teleren/devto huggingface dataset:
How to implement the APK packaging functionality in an Android application?
Published: 2023-06-28 17:56:50

Hello, I'm a mobile developer (Kotlin) with a little over 3 years of experience in programming in general. I have a project that has kept my ignorance thermometer super low because no matter how much documentation I read, it's hard to find something really useful or maybe something useful doesn't apply to me - who knows!

Getting to the point, the project would be similar to the 'SketchWare' application, which is an app through which users can create other Android applications using it! (The link below directs to a YouTube video where you can see this app in action). Creating some app features is not the challenge; however, the big problem lies in the logic behind the 'build apk' button that SketchWare has - which is its essence. To be more direct, where is the logic responsible for generating the APK file based on the code, resources, libraries, etc., that the user has inputted! (Note: I don't intend to know which logic specifically, but rather how it works, and clearly, I've been dancing around with Madame GPT until I'm exhausted!)

This is the functionality I would like to learn to implement (ironically or not, hahaha, this is one of the main characteristics that, as a mobile developer, I NEEDED to know), a functionality that allows users to generate APK packages! I've been studying this on my own for quite some time, and today I decided to reach out to other developers, hoping to receive some help!

Please watch the video; it will make it much clearer what I intend to do! Thank you in advance, and sending my regards![](https://youtu.be/Bx7FDkZjy9g)
Upgrade your open source dependencies
Tags: showdev, ruby, rails, opensource
Published: 2023-06-28 17:47:41

**TLDR:**
[Infield](https://www.infield.ai) automates away the toilsome parts of keeping Rails apps up to date. If you've ever run `bundle outdated` or `railsapp:upgrade` then you want to use Infield. You can try it out for free at (https://app.infield.ai/trial)

**Background**
I started as a consultant that did Rails upgrades only. As I did these projects I found myself running into the same problems over and over and feeling like software could help. Very little of the time spent upgrading packages is spent writing code. It’s spent prioritizing new releases, breaking complex upgrades down into small steps, researching changelogs, and assessing risk. That's why we're building Infield - we use AI to help automate upgrade research and use that research to automate project management.

**How it works**
We scan your dependencies and produce a dashboard that answers the question "Which packages should I upgrade, in what order?". We prioritize package upgrades that are high impact (e.g., security fixes, getting away from abandoned packages) relative to effort (are there breaking changes? is upgrading this package blocked on upgrading something else?). We have this data because we use GPT to read the changelog for every package you depend on.

When you have a larger upgrade that can't be tackled in a normal maintenance rotation you use our Upgrade Path feature to break it down. Our software takes a major upgrade (like Rails) and turns it into a series of small, individually backwards compatible steps that accumulate in the upgrade.

![upgrade path image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdtyuhmqmie0jb4fhgni.png)

Please check it out and write to us with any feedback at founders@infield.ai.
লিনিয়ার সার্চ (Linear Search) ইন জাভাস্ক্রিপ্ট
Tags: algorithms, javascript, linearsearch, programming
Published: 2023-06-28 17:37:01

সার্চিং অ্যালগরিদমের মধ্যে সব চেয়ে সহজ অ্যালগরিদম হচ্ছে লিনিয়ার সার্চ অ্যালগরিদম। লিনিয়ার সার্চ মানে কোনো কিছু সরল রৈখিকভাবে খোঁজা। 
ধরোন একটি শপিং মলে একটি ব্লকে প্রথম সারিতে ২০ টি দোকান আছে। আপনি ১৬ নাম্বার দোকান খুঁজে বের করতে চান। তাহলে আপনি যদি ১ নাম্বার দোকান থেকে ২০ নাম্বার দোকান পর্যন্ত সরল রৈখিকভাবে খুঁজতে থাকেন তাহলে নিশ্চয়ই একটা সময় পর আপনার টার্গেট ১৬ নাম্বার দোকান খুঁজে পাবেন।
এটাই হল linear search প্রক্রিয়া।

ধরি, আমাদের কাছে একটি অ্যারে আছে

**let numbers = [ 10, 12, 3, 52, 1, 25, 58, 65]**

এবং আমাদের 25 সংখ্যাটি খুঁজে বের করতে হবে অর্থ্যাৎ,
**target value = 25**

numbers অ্যারের মধ্যে target value আছে কি না তা আমাদের খুঁজে বের করতে হবে। target value লিস্টের কততম পজিশনে আছে তা জানা নেই। target value লিস্টের প্রথম পজিশনে থাকতে পারে, মধ্যখানেও থাকতে পারে আবার একেবারে শেষ পজিশনেও থাকতে পারে।

numbers অ্যারের মধ্যে একটি লুপ চালাতে হবে। প্রতিবার লুপ চালাকালিন সময়ে কন্ডিশন চেক করতে হবে অ্যারের ইনডেক্স অ্যার টার্গেট ভ্যালূ সমান কিনা। যদি সমান হয় তাহলে সেই ইনডেক্স সংখ্যাটি রিটার্ন করবে, আর সমান না হলে অ্যারের শেষ পর্যন্ত লুপ চালবে।
আসলে লিনিয়ার সার্চ হল, অ্যারের এর প্রথম ডাটা থেকে তুলনা করা হয়। যখনি অ্যারের ডাটা এর ভ্যালুর সাথে টার্গেট ভ্যালূ মিলে যাবে, তখন অ্যারের ইনডেক্স রিটার্ন করবে।

কাজের ধাপ:

১। প্রথমে একটি ফর লুপ তৈরি করতে হবে এবং লুপটি **Array.length** পর্যন্ত চলবে।
২। লুপ চলাকালীন অ্যারের প্রতিটি ইনডেক্স এর ভ্যালূর সাথে টার্গেট ভ্যালূ সমান হয় কিনা যাচাই করতে হবে। যদি সমান হয়, তাহলে লুপ সেখানেই শেষ হবে, আর যদি সমান না হয়, তাহলে পরবর্তী ইনডেক্সে যাবে। যদি টার্গেট ভ্যালূ অ্যারের শেষ ইনডেক্সে থাকে তাহলে শেষ ইনডেক্স পর্যন্তই লুপ চলবে।


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

যদি টার্গেট ভ্যালূ অ্যারের মধ্যে একাধিকবার থাকে তাহলে যতগুলো ইন্ডেস্কে টার্গেট ভ্যালূ পাওয়া যাবে সবগুলো ইন্ডেস্ক বের করতে হবে। একে গ্লোবাল লিনিয়ার সার্চ বলা হয়। সেক্ষেত্রে আমাদের একটি এম্পটি অ্যারে নিতে হবে,

**let  newArray = [];**

প্রতিবার ইন্ডেস্ক চেক করার সময় যদি টার্গেট ভ্যালূ পাওয়া যায় তাহলে সেই ইন্ডেস্ক (i) কে নতুন অ্যারের ভিতর পুশ করতে হবে এবং newArray কে রিটার্ন করতে হবে।


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7oz39uu69fxh87fjjkfi.png)
Debug and CFlags of Postgres
Published: 2023-06-28 17:32:46

Modern software development relies heavily on databases to store and manage enormous volumes of data. A strong, feature-rich, and highly adaptable open-source relational database management system (RDBMS), PostgreSQL stands out among the many solutions available. This blog post will provide you a thorough introduction to PostgreSQL, whether you're an experienced developer trying to advance your knowledge or a newcomer exploring the world of databases.

Open-source object-relational database management system PostgreSQL, also known as "Postgres," places a strong emphasis on extensibility and standards compliance. It was first created at the University of California, Berkeley in the 1980s, and since then, it has become more well-known because of its cutting-edge features, dependability, and active open-source community.


## Install postgres 14.7 version

### System Details

```bash
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy
```

### Install dependencies 

```bash
sudo apt install build-essential libreadline-dev zlib1g-dev libssl-dev libxml2-dev libxslt-dev
```

### Download postgres 14.7

```bash
curl -OL https://ftp.postgresql.org/pub/source/v14.7/postgresql-14.7.tar.gz
```

###  Extract the file

```bash
tar xvf postgresql-14.7.tar.gz
cd postgresql-14.7
```



### Configure the build

```bash
./configure --prefix=$(pwd) --enable-cassert --enable-debug CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer"
```

### Run make

```bash
make
sudo make install
```
Dicas PostgreSQL
Tags: postgres, dba
Published: 2023-06-28 17:30:49

Para verificar o tamanho das tabelas do banco de dados no PostgreSQL podemos utilizar o comando abaixo:

`SELECT esquema, tabela,
       pg_size_pretty(pg_relation_size(esq_tab)) AS tamanho,
       pg_size_pretty(pg_total_relation_size(esq_tab)) AS tamanho_total
  FROM (SELECT tablename AS tabela,
               schemaname AS esquema,
               schemaname||'.'||tablename AS esq_tab
          FROM pg_catalog.pg_tables
         WHERE schemaname NOT
            IN ('pg_catalog', 'information_schema', 'pg_toast') ) AS x
 ORDER BY pg_total_relation_size(esq_tab) DESC;`

Para cancelar instruções SQL podemos utilizar o comando abaixo:

`SELECT
pg_terminate_backend(procpid)
FROM
pg_stat_activity
WHERE
current_query = '<IDLE>'`

Para verificar índices que estão faltando podemos utilizar a consulta abaixo:

`SELECT 
 relname AS TableName
 ,seq_scan-idx_scan AS TotalSeqScan
 ,CASE WHEN seq_scan-idx_scan > 0 
 THEN 'Missing Index Found' 
 ELSE 'Missing Index Not Found' 
 END AS MissingIndex
 ,pg_size_pretty(pg_relation_size(relname::regclass)) AS TableSize
 ,idx_scan AS TotalIndexScan
FROM pg_stat_all_tables
WHERE schemaname='public'
 AND pg_relation_size(relname::regclass)>100000 
ORDER BY 2 DESC;`

Para visualizar as queries que estão rodando a mais de 1 minuto podemos usar a consulta abaixo:

`SELECT
CURRENT_TIMESTAMP - query_start AS runtime,
datname,
usename,
query
FROM
pg_stat_activity
WHERE
state = 'active'
AND CURRENT_TIMESTAMP - query_start > '1 min'
ORDER BY
1 DESC;`
HOW TO? - link FontAwesome to HTML
Tags: webdev, css, html, frontend
Published: 2023-06-28 17:27:08

Hi there,

I am doing my “Portfolio Project” and I am trying to add some Font Awesome icons (Facebook, Twitter, GitHub, Mail, Phone )

I can’t figure out why it’s not working for two days :exploding_head:

I have even downloaded those icons from Font Awesome and have it in my VS Code as #all.css and #brands.css linked to the HTML file

I have also linked the same link they use in the freeCodeCamp example of the project.

I have tried many variations of typing fa like fab, fa-brands, etc.

I have even just copied the Font Awesome link from my previous project and then copied the code for the icon and it doesn’t work as well in my current project (in my previous project it all works)

None of these works.

Here is the link to my CodePen code with this project - https://codepen.io/01JohnnyJohn/pen/jOQyYyj

Just in case CodePen is not working:

This is all links I have tried - all.css and brands.css are downloaded files from Font Awesome and other links are links I’ve tried to use.

By the way, If i comment out the last TWO links the “mail”

`<link rel="stylesheet" href="styles.css">
    <link rel="stylesheet" href="all.css">
    <link rel="stylesheet" href="brands.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">`

I have nothing related to icons in my CSS.

I need help with those icons, because I can’t finish the project without them(

Best regards!
#react #javascript
Published: 2023-06-28 17:26:36

Hello, Everyone I am new in this platform. And also I am currently learning react . I got a problem. can you guy's please solve this problem?
the problem is...  In the above screen, I am trying to import the company logo dynamically but it's not working it's only working manually.. Can you guys tell me what is the problem there?
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/reaaaizsxp40nxd2swrr.png)
Excluindo Valores no PostgreSQL: Utilizando Expressões Regulares para Filtrar Dados
Tags: postgres, regex
Published: 2023-06-28 17:23:42

No PostgreSQL, o operador !~ é usado para verificar se uma string não corresponde a uma expressão regular. Ele retorna verdadeiro se a string não corresponder à expressão regular especificada.

Em termos mais simples, o operador !~ é usado para negar a correspondência de uma expressão regular. Se a expressão regular encontrar uma correspondência na string, o operador !~ retornará falso. Por outro lado, se a expressão regular não encontrar uma correspondência na string, o operador !~ retornará verdadeiro.

`SELECT *
FROM tabela
WHERE coluna !~ '^(sup|age)'`

No contexto da consulta SQL que forneci anteriormente, a cláusula WHERE coluna !~ '^(sup|age)' está excluindo os valores em que a coluna não corresponde ao padrão definido pela expressão regular '^(sup|age)', ou seja, valores que não começam com "sup" ou "age".



Essa é uma forma diferente de escrever em relação a forma tradicional abaixo:

`SELECT *
FROM tabela
WHERE coluna !ILIKE 'sup%' AND coluna !ILIKE 'age%'`
Como somar valores de um objeto que pode ter algumas propriedades indefinidas?
Published: 2023-06-28 17:22:28


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

const products = [
  {name: 'Laptop', price: 1000},
  {name: 'Mobile', price: 500},
  {name: 'TV', price: 2000},
  {name: 'Camera', price: undefined}
]

function sumPriceProducts() {
  return products.reduce((acc, product) => {
      return acc + (product.price || 0);
  }, 0);
}

let soma = sumPriceProducts()
console.log(soma);
cplusplus code example won't compile
Tags: beginners, programming, discuss, codenewbie
Published: 2023-06-28 17:01:11

`#include <iostream>
class base_class {
	public:
		virtual void vf1() = 0; //pure virtual
		virtual void vf2();
		virtual void vf3();
};
class derived_class : public base_class {
	public:
		void vf1(); // OK if it is virtual also
//		virtual void vf1();
//		virtual void vf2(int);
		virtual void vf3();
};
int main(int argc, char** argv) {
//1	derived_class d;
//2	base_class *bp = &d;
//3	bp->vf1();
//4	bp->vf2();
//5	d.vf2();
}
ERROR MSG: undefined reference to `vtable for derived_class'

This code example, from cplusplus.com, does not compile when any of lines 1-5 are put in! It does when they are commented out, so the classes are OK. The error, line 1 in, points to the makefile line where the .exe file is created from the .o file! The .o file is in the project directory so that is not the problem.  Creating the .exe file is. The above error msg is what I get when I compile with line 1 installed! Help!
syd / wt1v
`
The Internals of PostgreSQL: Chapter 4: Foreign Data Wrappers and Parallel Query
Tags: bitnine, postgressql, summary, database
Published: 2023-06-28 16:39:28

Abbreviations to be used in the post:
FDW = Foreign Data Wrappers
MED = Management of External Data

FDW allows access to remotely stored data with the help of SQL/MED. In order to use FDW, appropriate extensions have to be installed, and necessary commands such as 'CREATE FOREIGN TABLE", "CREATE SERVER" have to be set-up. Once the set-up is complete, foreign tables can be accessed on the remote servers through SELECT queries. Moreover, FDW also allows join operations between foreign tables. 

The process of how FDW works is:
1. The analyzer generates the query tree from the SQL input.
2. The executor connects to the remote server through the use of specific libraries based on foreign data wrapper being used. 
3. The cost of each plan path is estimated using the EXPLAIN command, given that the use_remote_estimate option is enabled.
4. Deparsing: creation of plain text SQL statement from a plan tree.
5. This plain text SQL statement is sent to the remote server. The result is processed by the executor. This processing includes join operations, and necessary operations made on the tables. The results may also be converted into a PostgreSQL readable format.

FDW extensions use the EXPLAIN command to get statistics, and estimate the plan tree for a query (As discussed in chapter 3). These results are best reflected by postgres_fdw extension of FDW. Others may not provide enough information.

In order to execute SELECT queries, a sequence of SQL statements are followed:
1. Start a remote transaction.
2. Declare a cursor.
3. Fetch the result.
4. Close the cursor.
5. Commit the transaction.

For multi-table queries, each foreign table is fetched individually through single table SELECT statement, and then a join operation is performed on the local server. This was done in earlier versions even if the foreign tables were on the same remote server - In later versions, postgres_fdw can execute remote join operation on the remote servers if the tables are on the same server (the use_remote_estimate option should be enabled). Although, it is important to keep in mind that distributed deadlock detection is not supported by FDW - hence, if multiple transactions involve updates on both local and foreign tables simultaneously, deadlocks can occur. This is one disadvantage, or a short coming of Postgre's FDW.

Overall, FDW supports access to remote data, and allows managing it just like local data - resulting in seamless integration of data.
attaching to a post
Tags: cpp, beginners, help
Published: 2023-06-28 16:22:00

I was going to make a post about problems with virtual functions and needed to attach some code snippets so anyone can see what I am talking about. It would be useless to talk about code without making an attached file of the code. I've done this same thing on several other forums, but I have yet to figure out how to do so with this forum.  If I can't make a post with an attached file then this forum is useless!  Please tell me I am missing something here!
syd / wt1v
All Source Code Is Only An Urgency, Not Important
Published: 2023-06-28 16:03:59

If you read the timeless classic, [The Seven Habits of Highly Effective People](https://amzn.to/3pvQbj1), by Stephen R. Covey you will discover one of the main tenets:



## Where Your Focus Should Be
Focus on what's important, not just the urgent.

When I first heard about that I thought isn't everything important actually urgent?  It's not though.
Here are two examples:
1. The phone rings - it is an urgency to answer it because it will stop ringing.  But answering the phone in the long run (to chat with someone) when you are working on something important is actually a distraction.
2. You need to pee.  That is a real urgency but over your lifetime you will never want to say, "I spent my life peeing." 😂 It's just an urgency.

The author displays a diagram that helps you to break up your activities into the urgent versus the important.  It looks something like this one:

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

**Image from **: https://www.peoplehum.com/blog/the-divide-between-urgent-and-important-tasks

## If Always Focus On Code
If you always focus on the technical details of code it is probable you'll become an amazing software developer.

However, unless you create solutions that solve problems for users, you'll never accomplish much.

For example think about applications you use and how they actually solve your problems:

1. **web browsers **- allow you to find and read information that is available online
2. **mail clients **- allow you to easily read your correspondence from others and send messages and replies
3. **word processors** - allow you to write up your ideas and format them so others can get the information easily and can recognize your great ideas.

## Apps Get Noticed, Code Does Not
The point here is that apps get noticed and are important to people, but for the most part code is not.

## I'm a `<Insert Tech Here>` Dev
This is why the discussions about which front-end (Angular, React, Vue, ad infinitum...) are not useful.  Those are just tools.  

## Think Of It Like A Hammer
Imagine someone saying, "Hey, I am really able to use a hammer great.  I am an expert hammer user.  The stuff I can do with a hammer is amazing."

No one cares.
But, what they do care about is what you build with that hammer.
If you built the Eiffel Tower using that hammer, people are going to care. 

## But What About The Skills?
Yeah, I know.  I've been writing code for over 30 years and I've used C/C++, C#, JavaScript, ReactJS, ElectronJS, PERL, Swift, Kotlin and more.

I've written apps on every platform (Windows, Mac, Linux) but none of that matters. 

## Only Apps Matter
The only thing that matters is if I've built an app you know about.

## This Kind of Mindset Will Help You Grow
Think about this and start thinking about your skills a bit differently and it'll help you be more valuable to every company that you work for and hopefully eventually help you build your own app and company.
Understanding the useRef Hook in React A Comprehensive Guide
Published: 2023-06-28 16:01:20

Hello again friends! In this article, I'm going to be explaining all you need to know about the useRef hooks. But before I go on, let me give a brief insight of what react hooks are. 

React Hooks are simple JavaScript functions that we can use to isolate the reusable part from a functional component. Hooks can be stateful and can manage side-effects. React provides a bunch of standard in-built hooks: useState : To manage states. Returns a stateful value and an updater function to update it.

Alright now let's dive into the main topic, the useRef(initialValue) is a built-in React hook that accepts one argument as the starting value and returns a reference (aka ref). A reference is an object having a special property current .

```
import { useRef } from 'react';

function MyComponent() {
  const startingValue = 0;
  const reference = useRef(startingValue);

  const someHandler = () => {
    // Access reference value:
    const value = reference.current;

    // Update reference value:
    reference.current = newValue;
  };

  // ...
}
```

reference.current accesses the reference value, and reference.current = newValue updates the reference value. Pretty easy right?

The two things to remember about references:

1.The value of the reference is persisted (remains unchanged) between component re-renderings;

2.Updating a reference doesn't trigger a component re-rendering.
Now, let's see how to use useRef() in practice.

```
import { useRef } from 'react';

function LogButtonClicks() {
  const countRef = useRef(0);
  
  const handle = () => {
    countRef.current++;
    console.log(`Clicked ${countRef.current} times`);
  };

  console.log('I rendered!');

  return(
<>
<input type="text" ref = {countRef}/>
<button onClick={handle}>Click me</button>
</>
 
);
}
```

Using const countRef = useRef(0), a reference with the initial value of 0 is created.

At the point when the button is clicked, handle callback is summoned and the reference esteem is augmented: countRef.current++. After that, the console is logged with the reference value.

Refreshing the reference esteem countRef.current++ doesn't set off part re-delivering. "I rendered!" shows that this is the case. is logged to the console only once during initial rendering, and when the reference is updated, there is no re-rendering.

I hope this short explanation helps, thank you for reading