teleren/devto huggingface dataset:
Db emp
Published: 2023-03-14 02:05:58

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.Scanner;
import java.util.*;
import java.sql.Date;
import java.sql.PreparedStatement;

public class emp {
    public static void main(String args[]) throws ClassNotFoundException {
       
        try {
                Class.forName("com.mysql.jdbc.Driver");
            try (
                    Connection Con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/java","root","")) {
                Statement stmt =(Statement) Con.createStatement();
                Scanner sc= new Scanner(System.in);
                ResultSet r=stmt.executeQuery("select empname as query from employee where empname like'%d';");
                r.next();
                String query=r.getString("query");
                r.close();
                System.out.println(query);
                ResultSet rs=stmt.executeQuery("select * from employee where salary>=(select avg(salary) from employee );");
                 while (rs.next()){
                    System.out.println(rs.getInt(1)+" " + rs.getString(2) +" " + rs.getString(3)+" " + rs.getString(4)+" "  + rs.getDate(5)+" " + rs.getInt(6)+" " + rs.getInt(7) +" "+ rs.getInt(8));
               String sql2 ="create view emview as select * from employee where designation='xyz';" ;
                stmt.executeUpdate(sql2);
    
}
        } catch (Exception ex) {
            //Logger.GetLogger(java.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println(ex);
        }
    }
    }
}
Extract from db
Published: 2023-03-14 02:03:51

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;

/**
 *
 * @author A
 */
public class jdbccon extends HttpServlet {

      
   
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException { 
        
       
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            
            
            try{
                Class.forName("com.mysql.jdbc.Driver");
                //Execute sql query
                try ( //open connection
                        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/javapoint","root",""); //Execute sql query
                        Statement stmt = conn.createStatement()) {
                    
                    ResultSet rs = stmt.executeQuery("select * from emp");
                    
                    //Extract data from result set
                    while(rs.next()){
                        int id=rs.getInt("id");
                        int age=rs.getInt("age");
                        String name=rs.getString("name");
                        
                        
                       
                        out.println("ID:"+id+"<br>");
                        out.println(",Age:"+age+"<br>");
                        out.println(",Name:"+name+"<br>");
                    }
                   
                    rs.close();
                    stmt.close();
                    conn.close();
                } catch (SQLException ex) {
                    Logger.getLogger(jdbccon.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (ClassNotFoundException ex) { 
            Logger.getLogger(jdbccon.class.getName()).log(Level.SEVERE, null, ex);
        } 
          }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
  
    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
  
}
Print no.
Published: 2023-03-14 01:58:58

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author A
 */
public class printnumber extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet printnumber</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet printnumber at " + request.getContextPath() + "</h1>");
            for(int i = 1; i <= 10; i++)
        {
            out.println(i);
        }
            out.println("</body>");
            out.println("</html>");
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
Db registration
Published: 2023-03-14 01:57:10

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author A
 */
public class reg extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

    response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
	
        String name = request.getParameter("name");
        String email = request.getParameter("email");
        String pass = request.getParameter("pass");
        
        try {
        
            // loading drivers for mysql
            Class.forName("com.mysql.jdbc.Driver");
            
            //creating connection with the database 
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","");

            PreparedStatement ps = con.prepareStatement
                        ("insert into email values(?,?,?)");

            ps.setString(1, name);
            ps.setString(2, email);
            ps.setString(3, pass);
            int i = ps.executeUpdate();
            
            if(i > 0) {
                out.println("You are sucessfully registered");
            }
        
        }
        catch(ClassNotFoundException | SQLException se) {
        }
	
    }
}
Db insert query login
Published: 2023-03-14 01:56:06

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author A
 */
public class table {
     public static void main(String args[]) throws ClassNotFoundException {
       
        try {
            Class.forName("com.mysql.jdbc.Driver");
           Connection Con = DriverManager.getConnection("jdbc:mysql://localhost:3306/practice","root","");
           Statement stmt = Con.createStatement();   
           Scanner sc= new Scanner(System.in); 
           
           String name= sc.next();
           stmt = Con.createStatement();
           stmt.executeUpdate("INSERT INTO login ('report_number', 'accd_date','location') VALUES (104,12-11-2004,'bhdc');");
           System.out.println(name + " is added successfully");
           stmt.executeQuery(name);
                ResultSet rs = stmt.executeQuery("select * from practice");
                while(rs.next()){
                    System.out.println(rs.getInt(1)+" "+rs.getInt(2)+" "+rs.getString(3));
                }
            } catch (SQLException ex) {
            
         }
        } 
    
        }
Codes for daily life
Tags: javascript, webdev, beginners
Published: 2023-03-14 01:23:30

This post is in construction, i wanna increase more codes that i use in my day by day.

**Remove Duplicate Elements**

Recently, i needed to group by identical products and sum your prices that received in list. First, i remove duplicate product id and then i group by id.

To remove duplicates values, do this:

`const removeDuplicates = (arr) => [...new Set(arr)];

const productsId = ["17", "27", "17", "40"];

removeDuplicates(productsId); // ['17', '27', '40']
`

**Uppercase first letter**

Who has never needed put first letter in uppercase to show in page, do this:

const capitalize = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;

......

Updates will be coming soon
Test Driven Learning
Tags: c, testing
Published: 2023-03-14 00:58:37

Idea: learn a new code base by writing tests. Read all of the public API. Come up with questions and try to answer them by writing tests.

I tried this idea with the [libbson](http://mongoc.org/libbson/current/index.html). I help maintain libbson. I was curious to see what (if anything) I would learn by surveying and testing the public API.

This is a summary of the results.

## Discover API

I learned about the existence of the following:

- `BCON_EXTRACT` to extract values from a `bson_t`.
- `bson_unichar_t` and related API to represent a Unicode codepoint in a `uint32_t`.
- `bson_writer_t` to write a sequence of BSON documents to a buffer.

## Find Surprising Behavior

`bson_copy_to (<stack allocated>, <heap allocated>)` results in a leak. For example:
```c
static void test_bson_copy_to(void) {
    bson_t *dst = bson_new(); // dst is heap allocated.
    bson_t src = BSON_INITIALIZER; // src is stack allocated.
    BCON_APPEND(&src, "a", BCON_INT32(1));
    bson_copy_to(&src, dst); // struct for `bson_t` is leaked!
    ASSERT_BSON_EQUAL(&src, dst);
    bson_destroy(&src);
    bson_destroy(dst);
}
```

`bson_validate` double validates UTF-8 values. `bson_iter_visit_all` validates UTF-8, as does the visitor functions.

Found that `BSON_CHECK_VERSION` is incorrectly documented. "is greater than" should be "is greater than or equal to". Fixed with (https://github.com/mongodb/mongo-c-driver/pull/1219).

## Answer Open Questions

As I read through API, I wrote down many open questions and answered them with tests:

- Q: Does `bson_append_array` reject documents with non integer string keys?
    - A: No. But `bson_append_array` warns if the first key is not "0".

- Q: Does `bson_append_utf8` error if given invalid UTF-8? A: No.

- Q: If the default `bson_context_t` is used, is a child process likely to produce the same `bson_oid_t`?
    - A: No. The default `bson_context_t` disables the PID cache.

- Q: Does the max len option of `bson_json_opts_new` produce invalid UTF-8 characters if on multi-byte character boundary? A: Yes.

- Q: Does `bson_concat` support self-concatenation? A: Yes

- Q: Can `bson_iter_find_descendant` and `bson_iter_recurse` use the same iterator for input and output? A: Yes

- Q: Will parsing an integer value in JSON promote to int64 if it does not fit in int32? A: Yes.

- Q: How does `bson_string_t` grow allocations? A: By power of 2.

## Learn more C

Learned about `static` keyword applied to array sizes: https://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html

Learned that `aligned_alloc` requires alignment to be a power of `2 >= sizeof(void*)`, and memory requested be a multiple of alignment.

## Conclusion

I think this was a valuable time investment.

For further reading, I recommend David Golden's [A better way to learn a new codebase](https://xdg.me/learn-a-new-codebase/). That article inspired this idea.
ChatGPT...good for code reviews?
Tags: codereviewvillains, codereview, programming, productivity
Published: 2023-03-14 00:53:25

It seems like how the world is treating ChatGPT and other LLMs is the same as how the World Wide Web was treated back at the start.

The question I have is, can it be put to use for code reviews in a way that CISOs are happy?
Learning Flexbox: My Journey of Replicating Instagram's Layout
Tags: beginners, css
Published: 2023-03-14 00:29:38

As a beginner in web development, I wanted to learn how to create flexible and responsive layouts using CSS. I discovered Flexbox and decided to replicate the mobile version of Instagram's layout to test my new knowledge.

To begin the task:
1- I looked at Instagram's page source code and based my HTML on it.
2-To ensure the layout was accurate, I carefully checked the sizing, padding, border, and margin values of the page's elements.
3- I used Flexbox properties such as justify-content, align-items, and flex-wrap to precisely position and align elements on the page. 

In resume what I discovered with it:
- display:flex; defines an element as a flex container;

- flex-direction: defines the main direction of elements within the flex container;

- justify-content: defines how elements are distributed along the main axis of the flex container;

- align-items: defines how elements are aligned along the cross axis of the flex container;

- flex-wrap: defines whether elements within the flex container should be arranged in one or multiple lines;

- flex-basis: defines the base size of a flex item, based if the display is in collumn or in row


Although it was challenging, taking me three days to complete, the experience taught me valuable skills and improved my understanding of Flexbox. I now have a better grasp of how to create modern, visually appealing layouts that are both flexible and responsive.

Take a look :D

{% embed https://srhiulli.github.io/InstagramPage/ %}
Construindo Arquiteruras Orientadas a Eventos
Tags: braziliandevs, cloud, aws, serverless
Published: 2023-03-14 00:11:57

🇧🇷 Tradução completa do [Building Event Driven
Architectures](https://serverlessland.com/event-driven-architecture/intro) do [Serverless Land](https://serverlessland.com/).

**Nota:** Essa é uma tradução livre, não oficial, realizada no meu tempo livre - Eduardo Rabelo.

# Construindo Arquiteruras Orientadas a Eventos

[As arquiteturas orientadas a eventos](https://serverlessland.com/event-driven-architecture) são um estilo de arquitetura que pode ajudá-lo a aumentar a agilidade de criar aplicativos confiáveis ​​e escaláveis. Serviços serverless como EventBridge, Step Functions, SQS, SNS e Lambda têm uma afinidade natural com arquiteturas orientadas a eventos - elas são invocadas por eventos, emitem eventos e possuem recursos nativos para construir com eventos.

[Saiba mais](./src/01-01-introducao-a-arquitetura-orientada-a-eventos.md) sobre arquiteturas orientadas a eventos, incluindo conceitos-chave, práticas recomendadas, serviços da AWS e recursos de introdução.

![Imagem mostrando comunicação do cliente (produtor de eventos) com o agente de eventos (event broker) e os consumidores de eventos](https://serverlessland.com/assets/images/eda/event-producer-broker-consumer.png)

Este guia irá te apresentar a arquiteturas orientadas a eventos. Você vai compreender os padrões das arquiteturas orientadas a eventos e os serviços da AWS usados para implementá-los. Aprenda as práticas recomendadas para criar arquiteturas orientadas a eventos, desde a criação de esquemas de eventos até o tratamento de conceitos como a idempotência. Ao concluir esse guia, você encontrará recursos extras para expandir seu conhecimento em como criar arquiteturas orientadas a eventos na AWS.

# A tradução completa no GitHub

{% embed https://github.com/oieduardorabelo/construindo-arquiteruras-orientadas-a-eventos-serverless-land %}
Debugging Firefox on Android
Tags: webdev, devtools
Published: 2023-03-14 00:08:38

---
title: Debugging Firefox on Android
published: true
date: 2023-03-14 00:05:24 UTC
tags: webdev, devtools
canonical_url: https://chenhuijing.com/blog/debugging-firefox-on-android/
cover_image: https://chenhuijing.com/assets/images/posts/firefox-android/debugging-1280.jpg
---

I just figured out how to get my Android phone recognised by [Android Debug Bridge (`adb`)](https://developer.android.com/studio/command-line/adb.html) on my MacBook, which finally allowed me to remote debug websites on Firefox Android. Just so I don’t forget what I did, this is a short documentation of the steps needed to get everything to work. Hopefully it will stay relevant for a good while.

Firefox official documentation is actually very clear: [about:debugging](https://firefox-source-docs.mozilla.org/devtools-user/about_colon_debugging/index.html), however, the first time I tried it, I could not for the life of myself get it to work. ¯\\\_(ツ)\_/¯

1. Enable Developer menu on your Android device.
2. Enable USB Debugging in the Android Developer Menu.
3. Enable USB Debugging in Firefox on the Android device.
4. Connect the Android device to your computer.

> First make sure you have installed Android Debug Bridge from Android Tools on your computer in order for it to be able to connect to your device. You do not need to install the full Android Studio SDK. Only adb is needed.

To install `adb`, download the SDK Platform Tools from [https://developer.android.com/studio/releases/platform-tools.html](https://developer.android.com/studio/releases/platform-tools.html), there are versions for every OS but I’m using Mac specifically.

After that, unzip the files into an easily accessible folder on your computer. From the command line, navigate to folder and run `./adb devices` to see list of devices connected.

If no devices show up, then the issue might be on the Android device side of things. Following the advice from [this Stack Overflow post](https://stackoverflow.com/questions/21170392/my-android-device-does-not-appear-in-the-list-of-adb-devices), what worked for both my Android 11 and Android 12 devices was to switch the USB configuration to `PTP (Picture Transfer Protocol)`.

After that running `./adb devices` actually did list something.

 ![adb list showing device connected](https://chenhuijing.com/assets/images/posts/firefox-android/adb-list.png)

Go back to `about:debugging` and refresh the page. If the devices are listed on the command line, they will show up in the left sidebar (at least they did for me).

 ![Setup for remote debugging](https://chenhuijing.com/assets/images/posts/firefox-android/setup-1280.png)

Happy debugging! 🪲
What are the best ways to get a tech job in 2023?
Tags: beginners, career, discuss, webdev
Published: 2023-03-14 00:00:48

Hello Dev community👋🏾!
I'm in a limbo here and need some help...

I am currently in the market looking for an entry level job as a web developer or front end developer. Don't really see much junior positions available.Everything is pretty much mid or senior level. If there **IS** a junior position, the stack tech list has technologies that I haven't even learned about or heard of. My current skills include but not limited to:

- React 

- Next.js

- Tailwind CSS

- JavaScript

- HTML/CSS

- Git/Vercel/Netlify

Do I need to increase my tech stack? Should I also learn backend to increase my chances of finding a job? Right now I am currently learning about algorithms and giving myself 2 months to job prep. But in the mean time, what resources (other than LinkedIn) are good for looking for work? I created my [portfolio](https://cp-portfolio-iota.vercel.app/) and thought I would get noticed. But nope, nothing. So any feedback would be great, and also any job boards or (legitimate) tech recruiting agencies!