teleren/devto huggingface dataset:
How to get the DDL dump of a redshift database
Tags: aws, redshift, serverless, bash
Published: 2023-01-12 05:38:09


When I was googling "How to get the DDL dump of a redshift database" I found [this blog](https://awsbytes.com/how-to-get-the-ddl-of-a-table-in-redshift-database/) which proposed a way do it but the con of the approach proposed there is it requires us create new objects in redshift just to extract DDL which was not acceptable for me, so I tried and found a better way which is given below

## Approach

The approach below makes use of the following commands from redshift and wraps them in a bash script which makes use of the redshift data api
- [SHOW TABLE](https://docs.aws.amazon.com/redshift/latest/dg/r_SHOW_TABLE.html)
- [SHOW VIEW](https://docs.aws.amazon.com/redshift/latest/dg/r_SHOW_VIEW.html)
- [SHOW_EXTERNAL_TABLE](https://docs.aws.amazon.com/redshift/latest/dg/r_SHOW_EXTERNAL_TABLE.html)

## Steps

- Ensure [awscli](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) and [jq](https://stedolan.github.io/jq/tutorial/) command are installed.
- Create a script named `dumpddl.sh` with the following contents and give it executable permissions using command `chmod +x ./dumpddl.sh`
```bash
#!/usr/bin/env bash

CLUSTER_IDENTIFIER="<<your cluster identifier - required only for managed redshift>>"
WORKGROUP_NAME="<<workgroup name - required only for serverless>>"
DATABASE="<<your database>>"
DATABASE_USER="<<your database user>>"

function query_result() {
  query="$1"
  query_id=$(aws redshift-data execute-statement --with-event --db-user "${DATABASE_USER}" --cluster-identifier "${CLUSTER_IDENTIFIER}" --workgroup-name "${WORKGROUP_NAME}" --database "${DATABASE}" --sql "${query}" | jq -r ".Id")
  sleep 2
  aws redshift-data get-statement-result --id "${query_id}" | jq -r ".Records[][0].stringValue"
  echo ""
}

# Replace the below names of tables, views and external tables with the ones you want to take ddl dump on
query_result "SHOW TABLE person"
query_result "SHOW VIEW org_view"
query_result "SHOW EXTERNAL TABLE \"org_schema\".employee_details"
```
- Run following command to get the ddl dump
```bash
./dumpddl.sh > ddl_dump.sql
```

## Pros
- No need to install anything inside the redshift cluster.
- Works from the local machine even if redshift cluster is within a VPC(through redshift data API).
- Works for both managed redshift and serverless redshift.

## Cons
- Requires us to know the list of tables and views for which we want the ddl dump.
1519. Number of Nodes in the Sub-Tree With the Same Label
Tags: java, problemoftheday, leetcode, 100daysofcode
Published: 2023-01-12 05:36:22

**Problem Statement:**

You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

The edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.

Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.


**Example 1:**
**Input:** n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = "abaedcd"
**Output:** [2,1,1,1,1,1,1]
**Explanation:** Node 0 has label 'a' and its sub-tree has node 2 with label 'a' as well, thus the answer is 2. Notice that any node is part of its sub-tree.
Node 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5, as nodes 4 and 5 have different labels than node 1, the answer is just 1 (the node itself).


**Example 2:**
**Input:** n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb"
**Output:** [4,2,1,1]
**Explanation:** The sub-tree of node 2 contains only node 2, so the answer is 1.
The sub-tree of node 3 contains only node 3, so the answer is 1.
The sub-tree of node 1 contains nodes 1 and 2, both have label 'b', thus the answer is 2.
The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b', thus the answer is 4.


**Example 3:**
**Input:** n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab"
**Output:** [3,2,1,1,1]
 

**Constraints:**

- 1 <= n <= 105
- edges.length == n - 1
- edges[i].length == 2
- 0 <= ai, bi < n
- ai != bi
- labels.length == n
- labels is consisting of only of lowercase English letters.


**Solution:**
**Code:**
```
class Solution {
    private int[] ans;
    private List<List<Integer>> adjlist;
    private Set<Integer> visited;
    public int[] countSubTrees(int n, int[][] edges, String labels) {
        ans= new int[n];
        adjlist=new ArrayList<>(n);
        for(int i=0;i<n;i++){
            adjlist.add(new ArrayList<>());
        }
        for(int[] e: edges){
            adjlist.get(e[0]).add(e[1]);
            adjlist.get(e[1]).add(e[0]);
        }
        visited=new HashSet<Integer>(n);
        dfs(0,labels);
        return ans;
        
    }
    private int[] dfs(int node, String labels){
        visited.add(node);
        int[] count=new int[26];
        for(int adj:adjlist.get(node)){
            if(!visited.contains(adj)){
                int[] adjcount=dfs(adj,labels);
                for(int i=0;i<26;i++){
                    count[i]+=adjcount[i];
                }
            }
        }
        char ch=labels.charAt(node);
        count[ch-'a']++;
        ans[node]=count[ch-'a'];
        return count;

    }
}
```
How To Create Middleware For XSS Protection In Laravel 9
Tags: laravel, middleware, xss, php
Published: 2023-01-12 05:30:00

In this article, we will see how to create middleware for XSS protection in laravel 9. 

Cross-site scripting is a type of security vulnerability that can be found in some web applications. XSS attacks enable attackers to inject client-side scripts into web pages viewed by other users.

In laravel 9 we use middleware to prevent XSS attacks on website security. It's very necessary protection from XSS attacks or any other cyberattack on the website.

So, let's see laravel 9 create middleware for XSS protection, laravel 9 creates middleware and XSS protection in laravel 9.

The XSS filter through we can remove the HTML tag from our input value and also it's very important to remove the HTML tag for security. 

Input sanitization is a security protocol for checking, filtering, and cleaning data inputs from app users.

Types of XSS attacks?
There are three main types of XSS attacks:

- Reflected XSS, where the malicious script comes from the current HTTP request.
- Stored XSS, where the malicious script comes from the website's database.
- DOM-based XSS, where the vulnerability exists in client-side code rather than server-side code.
Amazon S3 now automatically encrypts all new objects!
Tags: aws, s3, cloud, storage
Published: 2023-01-12 05:20:54

**Introduction**

What a great news from amazon, now every object you upload to your S3 Bucket will be encrypted by default!! Adding another extra layer of security to your data which is the most important and expense thing in any Information System.

Amazon S3 now automatically applies S3 managed server-side encryption (SSE-S3) as a base level of encryption to all new objects added to S3, at no additional cost and with no impact on performance. SSE-S3 uses 256-bit Advanced Encryption Standard and has been configured for trillions of objects by customers. This new base level of encryption helps customers meet their encryption requirements, with no changes to applications. Alternatively, customers can still choose to update this default configuration using customer-provided encryption keys (SSE-C) or AWS Key Management Service keys (SSE-KMS).

Since 2017, customers have used the S3 Default Encryption feature to apply a base level of encryption for every object added to their buckets. S3 Default Encryption is an optional bucket-level setting that customers use to establish a default level of encryption. With this update, Amazon S3 will automatically apply SSE-S3 as the base level of Default Encryption setting for all new buckets and for existing buckets without any customer configured encryption setting. Existing buckets currently using S3 Default Encryption configuration will not change. Customers can continue to update the Default Encryption configuration but can no longer remove this setting from any S3 bucket to disable automatic encryption on new objects. As a result, all new data uploaded to S3 will be encrypted at rest.

The automatic encryption status for new object uploads and S3 Default Encryption configuration is available in AWS CloudTrail logs. Over the next few weeks, this status will begin to show in the S3 management console, S3 Inventory, S3 Storage Lens, and as an additional S3 API header in the AWS CLI and AWS SDK. We will update the S3 documentation once this additional information is available in all AWS Regions. This update is available in all AWS Regions, including the AWS GovCloud (US) Regions and AWS China Regions. For detailed information on the expected experience, see the AWS News Blog post for this new base level of encryption or visit the Amazon S3 encryption documentation.

**References**
[Amazon S3 now automatically encrypts all new objects](https://aws.amazon.com/about-aws/whats-new/2023/01/amazon-s3-automatically-encrypts-new-objects/)
React code create dynamic menu navigation
Tags: react, node, webdev, web3
Published: 2023-01-12 05:10:15

Here is an example of how you might use React to create a dynamic navigation menu:

First, you would need to create a component that represents the menu. You might call this component "NavMenu". Inside the component, you would define the structure and styling for the menu, as well as the logic for rendering the different menu items.

```
import React from 'react';

const NavMenu = ({ menuItems }) => {
  return (
    <nav>
      <ul>
        {menuItems.map((item) => (
          <li key={item.id}>
            <a href={item.link}>{item.label}</a>
          </li>
        ))}
      </ul>
    </nav>
  );
};

export default NavMenu;
```
In this example, the menuItems prop is passed to the component and it expects an array of menu items. Each item should have an "id" , "label" and "link" properties. These properties will be used to generate the structure of the menu.

Now you can use this component in other parts of your application and pass the menuItems prop with the desired data for rendering.

```
import NavMenu from './NavMenu';

const menuItems = [
  { id: 1, label: 'Home', link: '/' },
  { id: 2, label: 'About', link: '/about' },
  { id: 3, label: 'Contact', link: '/contact' },
];

const App = () => {
  return (
    <div>
      <NavMenu menuItems={menuItems} />
    </div>
  );
};
```

This is a basic example, in a real-world application, you might want to add more features such as active state handling, sub-menus, and more, but this example should give you a good starting point for building a dynamic navigation menu with React.
Lighting Services in Bondi-LED downlight installation in Woolahra
Tags: lightingservicesinbondi, switchboardrepairsinclovelly, lightingelectricianinrandwick
Published: 2023-01-12 05:08:12

https://goddardelectrical.com.au/

All forms of residential, commercial, and strata electrical work may be expertly completed by our team of NSW electricians that are completely trained, certified, and capable.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5z131gj44e83blvrqoac.jpg)
Contact Goddard Electrical if you need a trustworthy and experienced home, business, or strata electrician.Looking for Lighting Installation Experts in Bondi, New South Wales, at a reasonable price? Call us right away for further information at 0403 532 142.
Powerpoint Installation in Paddington-Switchboard Repairs in Clovelly
Tags: lightingservicesinbondi, switchboardrepairsinclovelly, lightingelectricianinrandwick, goddardelectrical
Published: 2023-01-12 05:03:10

https://goddardelectrical.com.au/

We Provide Dependable Downlight Installation Services At Affordable Costs. For a quote, call us. Visit our official website to learn more about our 24-hour emergency services, LED downlight installations, and other services.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3m514fz2kqu2hz6vtigc.jpg)
All forms of residential, commercial, and strata electrical work may be expertly completed by our team of NSW electricians that are completely trained, certified, and capable.
Decompile all the jar files in given directory
Tags: decompile, decompiler, java, jar
Published: 2023-01-12 04:57:52

---
title: Decompile all the jar files in given directory
published: true
description: 
tags: decompile, decompiler, java, jar
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-01-09 06:10 +0000
---
Procyon is a Java decompiler for reverse engineering compiled Java code. It can be used to decompile Java 5 and Java 7 bytecode and is open-source. Procyon's ability to decompile complex Java code and generate comprehensible output is one of its benefits. Decompiling JAR files is one of Procyon's common uses. The file format known as a JAR file, or Java Archive, is used to store multiple files, including Java classes and resources, in a single archive. Typically, these files are turned into Java bytecode, which can then be run on any Java Virtual Machine (JVM).

You must first download the [Procyon decompiler](https://github.com/mstrobel/procyon/wiki/Java-Decompiler) file from the official website and put it in a directory on your system before you can use Procyon to decompile a JAR file. After that, you can run the JAR file from the command line while specifying the JAR file you want to decompile as an argument. For instance, the "example.jar" JAR file can be decompiled using the following command:
```
java -jar procyon-decompiler.jar example.jar
```
By doing this, all of the class files in the JAR file will be extracted, and the decompiled source code will be written to separate files with the same name as the class file but a.java extension. The JAR file and the decompiled code will both be kept in the same directory.

You can use [Procyon decompiler](https://github.com/mstrobel/procyon/wiki/Java-Decompiler) and have a recursive look into folders with the following command.
```
find <jar_files_directory> -name "*.jar" -exec java -jar <procyon_decompiler_location> -jar {} -o <output_directory> \;
```

Example
```
find . -name "*.jar" -exec java -jar /Users/abc/Desktop/procyon-decompiler-0.6.0.jar -jar {} -o output/ \;
```

It's important to keep in mind that Java code decompiling is not always correct, and the resulting source code might not exactly match the original. Decompiling Java code may also be permitted in some circumstances, but it frequently violates copyright regulations, so it should be used with caution.

Procyon is a powerful resource for debugging Java code and has a wide range of applications. Procyon is a dependable decompiler that can assist you in achieving your objectives, whether you're looking to comprehend how a third-party library operates or recover lost source code.
Step-by-Step Guide to Migrating from Java 8 to Java 17 (or Later): Tips, Checklist and Best Practices
Tags: java, jdk, jdkupgrade, migration
Published: 2023-01-12 04:55:16

This blog post topic would be of interest to software developers, system administrators, and technical managers who work with Java-based applications and need to migrate to a later version of the language.

A detailed migration plan will depend on the specific circumstances of your application and the scale of the migration. However, here's a general outline of the steps that a detailed migration plan might include:

**Preparation**:

- Identify the current Java version and the target version.
- Review the changes and new features in the target version of Java.
- Assess the impact on the application and identify any potential issues.
- Identify any third-party libraries or frameworks used by the application and check for compatibility with the target Java version.

**Code changes**:

- Make any necessary code changes to ensure compatibility with the target Java version.
- Remove deprecated or removed features.
- Implement new features in the target version.
- Refactor or rewrite the code to improve performance and maintainability.

**Testing**:

- Create a test plan for the migration.
- Write automated tests for the application.
- Test the application thoroughly to ensure that it continues to function correctly after the migration.
- Run automated and manual tests to check for compatibility and functionality.
- Conduct load testing to ensure that the application can handle the expected workload.

**Deployment**:

- Update build and deployment scripts to use the target Java version.
- Update documentation to reflect the new Java version.
- Update any configuration files to reflect the new Java version.
- Create a backup of the application and its data before deploying the updated version.
- Deploy the updated application to a test environment and verify the behavior of the application.

**Production deployment**:

- Perform the migration in a production environment.
- Monitor the application for any issues and troubleshoot if necessary.
- Roll back to the previous version if there are any major issues in the migration.
- Test the application in production environment
- Test the application for performance and scalability

**Post Migration**:

- Retire any old version and related resources
- Re-evaluate the impact and adjust your plan accordingly
- Document all changes and new features
- Keep monitoring the system for few days/week

Note: This list is very high level thoughts, and additional steps may be required depending on the specific circumstances of the migration. It is a good practice to have a detailed plan, testing and back-up before migrating in production environment.

Additionally, Would be glad to hear from you can also, how your organization did the migration, what challenges faced and how it was solved.

Thanks for reading!
Aws operational analytics
Tags: aws, cloudwatch, cloudmonitoing
Published: 2023-01-12 04:46:29

When you operate cloud services with a devops culture, you depend on data from real world observations of the customer experience with your service. You actively seek to understand exactly when your customer experience changes for better or for worse so that you can deliver the best experience no matter what changes in your production environment. Many AWS customers use structured logs (e.g., JSON) for devops monitoring because it simplifies reporting on the data for operational investigations. But our most knowledgeable monitoring customers go a step further and use a capability in CloudWatch Logs called Embedded Metric format - EMF. Here’s a fun fact -- thirty percent of all AWS custom metrics are now generated via EMF. Why are so many customers using EMF for their service-specific operational metrics? It’s simple – EMF helps our customers get the most detailed monitoring and devops analytics with the least effort and cost.
#cloudwatch #amazon #cloudmonitoring #aws
Powerpoint Installation in Paddington-Switchboard Repairs in Clovelly
Tags: lightingelectricianinrandwick, goddardelectrical
Published: 2023-01-12 04:44:45

https://goddardelectrical.com.au/

Looking for Lighting Installation Experts in Bondi, New South Wales, at a reasonable price? Call us right away for further information at 0403 532 142.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x611twcgr9cpvn3spoz2.jpg)
All forms of residential, commercial, and strata electrical work may be expertly completed by our team of NSW electricians that are completely trained, certified, and capable.
Why Do We Use Lorem Ipsum ?
Tags: html, codenewbie
Published: 2023-01-12 04:24:43

1. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

2. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.

3. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy.
 
4. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

Source: https://www.lipsum.com/
Hey everyone first post so be kind lol
Tags: beginners, html, css, javascript
Published: 2023-01-12 04:21:47

Hey everyone, so it looks like I will be getting back into programming for afew reasons wich I wont get in to just yet. So basiclly To it I will have brush up on my HTML and CSS skills and finally get around to learning Javascript then obviously on to a JavaScript FrameWork. 
I do have a few questions about this whole thing:

Where is the best place to find project building guilds for beginners? 
Secondly What does the career of a Front end developer look like? Do most WFH? Or are they doing a hybrid WFH/workplace set up?
And Finally, do the mojority of Frontend developer stay in Frontend? Or will they most likly progress go to Back end then become a Web-developer?

Thank you
How setup Firebase on your Frontend project 🔥
Tags: firebase, javascript, webdev, tutorial
Published: 2023-01-12 04:07:39

Hey! :D

Here, I will help you to make the initial configuration of Firebase on your Frontend proyect. This also will be useful if you use vanilla Javascript or a framework like Vue or React.

### Configure the Firebase Account
First, we need to [create an account on Firebase](https://console.firebase.google.com) and add a New Project.

After that, you will have access to the Console of your project. On the Project Settings you can get your credentials for the SDK that we going to install.

![Get your credentials for Firebase SDK](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gua7rf84eukekbeha1yc.png)



### Let's write some code!
First, you need to install the SDK.

`npm i firebase` or `yarn add firebase`

After, I recommend to create a file called `firebase.ts` or something like that, where you can initialize Firebase and just imported when is needed, instead of using it globally.

Also, please avoid store your credentials directly on your code, there are packages like [dotenv](https://www.npmjs.com/package/dotenv) to this type of stuffs.

{% gist https://gist.github.com/nicolasmontielf/17cbadbd9c869c21233eea33b8caa9a1 %}

It's pretty simple, but let's explain some lines:
- **Line 5:** Here we create our configuration object. This is exactly the same that you saw on your Firebase Console.
- **Line 6:** If you never saw the `import.meta.env.KEY_NAME`, it's just the name convention that [Vite uses for the enviroment variables](https://vitejs.dev/guide/env-and-mode.html). So, if you don't use Vite, don't worry about this.
- **Line 17, 19:** Initialize and export your Firebase object.

Yeah, just like that. 

With this Firebase object, you can start using the different services that Firebase offers (Like databases, authentication, etc).
Here is an example in their own [documentation](https://firebase.google.com/docs/database/web/start#web-version-9). This Firebase Object always is a parameter when you want to initialize other service.

That's all, I hope it can be helpful for you 🥳