teleren/devto huggingface dataset:
10 steps to secure your Laravel Application
Tags: laravel, security, tips
Published: 2023-07-03 21:27:44

---
title: 10 steps to secure your Laravel Application
published: true
description: ten steps to secure your laravel website
tags: laravel, security, tips
# published_at: 2023-07-03 19:43 +0000
---
When we prepare to upload Laravel Project, we assume to make sure that your application is entirely secure,

We can ensure securing our application by following these steps:

1- **Disable Debug Mode:** 
 Inside the `.env` file you should make sure that you make 

```html
    APP_DEBUG=false
```

Also,  Secure the `.env` file, by writing this code in the .htaccess file Because this file holds sensitive data, we should care about securing it

```html
<Files .env>
    Order allow,deny
    Deny from all
</Files>
```

2- **Authentication & Authorization**
Keep in your mind that you should secure important routes with Authentication, Also Authorize any action and make sure that user holds that permission to perform it.
The best ways to handle Authorization in Laravel are Gate and Policy.

3- **Activate SSL Certificate**
to protect the connection between the User and the website, for example, if your website is e-commerce it will be important to build trust between the user and your website.

4- **Rate Limiting**
Rate limiting is a technique used to limit the number of requests that a user or client can make to an application or API during a specific period of time, for more information visit this [link](https://laravel.com/docs/10.x/rate-limiting)

5- **Show Clear Success, Errors Messages to users**
You should display a clear message to users even if success or failure, and save it to the Log if it's a failure.

6- **Don't use outdated packages**
When you're using packages in your application you should use updated packages,

7- **Validation is very important**
You Must make sure to validate any inputs and attachments to prevent uploading any suspicious files.

8- **Choose suitable Webhosting**
It's important to care about choosing your web hosting and make sure they take recurring Backups.

9- **Backup your data**
It Mainly depends on No#8, but if you're in shared hosting you will need to take Backups manually.

10- **Keep up-to-date**
You must follow updates continuously, especially Laravel growing each day.
Use ChatGPT to Explore Your Database Schema
Tags: database, chatgpt, openai, ai
Published: 2023-07-03 21:26:11

---
title: Use ChatGPT to Explore Your Database Schema
published: true
description: 
tags: database, chatgpt, openai, ai
---

SchemaCrawler is a relational database exploration tool. It obtains database schema metadata such as tables, stored procedures, foreign keys, triggers and so on, and makes them available for search. The traditional way to use SchemaCrawler has been the command-line or an interactive shell. 

SchemaCrawler is now integrated with ChatGPT to provide an interactive way to interrogate your database schema metadata. When you start SchemaCrawler with the “chatgpt” command, you will have an interactive chat shell with ChatGPT, enhanced with information about your database metadata. No database information will be sent to OpenAI servers.

You can try prompts such as the following ones:

- "List all tables"
- "Describe the Track table"
- "What are the indexes on the Track table?"
- "What are the Track columns?"
- "What is the Track primary key?"
- "Show me the triggers on Track"
- "Find the parents of Track"
- "What are the dependents of Album?"

To quit the console, you can type something like:

- "I think I have everything I need"
or simply, "done", "exit" or "quit".

To start using this integration, you will need to create your own [OpenAI API key](https://www.howtogeek.com/885918/how-to-get-an-openai-api-key/). Then download a SQLite database called ["chinook-database-2.0.1.sqlite"](https://github.com/schemacrawler/chinook-database/releases/download/v16.11.7/chinook-database-2.0.1.sqlite) into your current directory.

Run this command:

```sh
docker run \
--mount type=bind,source="${PWD}",target=/home/schcrwlr \
--rm -it \
schemacrawler/schemacrawler \
/opt/schemacrawler/bin/schemacrawler.sh \
--server=sqlite \
--database=chinook-database-2.0.1.sqlite \
--info-level=standard \
--command=chatgpt \
--api-key YOUR_OPENAI_API_KEY
```

(If you are using PowerShell on Windows, replace the trailing backslash on each line with a back-tick, and map the current directory differently.)

At the prompt, enter some of the commands above.

After you have got this working, use the SchemaCrawler command-line to connect to your own database, and explore it using a natural language interface courtesy of ChatGPT.
The "Can We Not" Principle
Tags: productivity, devops
Published: 2023-07-03 21:08:41

One of the most important pillars I use to guide my decisions is the "Can we not?" principle. It's a simple idea: if I can avoid doing something, I should.

Sure, you do have to do *some* things to, say, build and sell a product or manage a household. But things you've done are also the source of future problems. Code we write has to be maintained. Features we build have to be supported.

The more we do, the more we have to do. And this just keeps adding up -- what is an organization or household but an ever-growing collection of things that have to be maintained?

Conversely, any time you *don't* do something you now have one fewer thing to deal with tomorrow. That is, if that thing you didn't do today is also something you don't *have* to do tomorrow.

Some things can't be avoided. But far more things can be avoided than we typically think. It's always worth asking the question: "Can we not?"
AJAX in Elanat framework
Tags: javascript, html, webdev, tutorial
Published: 2023-07-03 20:47:36

Sending and receiving data in [Elanat](https://elanat.net) is done through a JavaScript function called el_AjaxPostBack. The el_AjaxPostBack function has extensive features and you don't need to be involved in the complexities of receiving and transferring data with Ajax.

You can add el_AjaxPostBack function in your add-ons.
This function exist in global.js file in:
/client/script/global.js

This function consists of 4 arguments as follows :

```javascript
el_AjaxPostBack(obj, FetchScript, PostbackSectionId, Retrieved)
```

**obj** should be the value of **this**.
**FetchScript** is a boolean variable that, if its value is true, calls the scripts read by AJAX.
**PostbackSectionId** is a string that, if the name of an ID is written in the tags on the page, the returned value will be added as AJAX at the beginning of the tag.
**Retrieved** is a boolean variable that, if its value is true, replaces the tags inside the PostbackSectionId tag with the AJAX return value; If **PostbackSectionId** is not used, it will include the tag named **div_PageLoad**, and if this tag is missing, it will include the **body** tag of the HTML page.
Note:

If the value **use_retrieved=true** exists in the querystring, the Retrieved variable will be activated.

The HTML code below is an example of using this function in a button and sending it as AJAX.

```html
<form method="post" action="/">

	Name:
	<input name="txt_Name" type="text">

	Email:
	<input name="txt_Email" type="text">

	Phone number:
	<input name="txt_Phonenumber" type="text">

	<input name="btn_Send" type="submit" value="send" onclick="el_AjaxPostBack(this)">

</form>
```
Fundamentos de diseño de interfaces ✍
Published: 2023-07-03 20:17:50

Apuntes para poder realizar diseño en el ámbito de desarrollo web

## _Recordar_ 👀
- Conocer el tamaño de la pantalla
 - relación de aspecto (16:9 - 1:1)
 - resolución
 - densidad de pixeles

- Saber en que se circunstancias se usará nuestro aplicativo

## _Color_
- RGB (255, 255, 255)
- El color tiene una variación por el tipo de pantalla

## _Software _
- Figma

## _Que cosas tiene buen diseño_
- Es innovador
- Hace un producto usable
- Es estético
- Hace un producto entendible
- Es discreto
- Es honesto
- Es duradero
- Cuida hasta el ultimo detalle
- Respeta el medio ambiente
- Menos es mas

## Principios Heurísticos
Los principios heurísticos surge de estrategias derivadas de experiencias previas con problemas similares

## 1.1 Percepción y comportamiento
- **Efecto estético - usabilidad**
se percibe algo agradable cuando es facil de utilizar

- **La ley de hick**
se basa en la toma de decisiones, a mas opciones mas tiempo en decidir

- **Equilibrio entre flexibilidad y usabilidad**
a medida aumenta la flexibilidad, disminuye la usabilidad

- Cargo de trabajo
consta en convertir una tarea en minitareas

- **La ley de miller**
la cantidad de retener elementos en la mente de una persona suele ser de 5 a 9 items.

## 1.2 Relación y jerarquía
## 1.3 Forma
## 1.4 Interacción
Join the error revolution now!
Tags: programming, webdev, devops, productivity
Published: 2023-07-03 19:47:02

## Attention all programmers

We are taking a stand - no more software errors without also giving us the solutions.  But how to make this happen?

We have introduced a new tool to help you quickly resolve errors.  All kinds of errors.  Errors developing, operating, and supporting software.  Find out more with our short [intro video](https://rumble.com/v2f0a34-the-new-codaea-microsoft-visual-studio-extension.html) - and give us some feedback at <a href="mailto:marketing@codaea.io">marketing@codaea.io</a>.  How can we help make it easier to resolve coding errors?  How can we help you make your software easier to use and support?

Get up to speed on Integrated Centralized Error Management.
One config file to rule them all
Tags: javascript, webdev, react
Published: 2023-07-03 19:41:30

Modern web development involves working with multiple JS build tools and frameworks, each requiring their own configuration files. Managing these configuration files, such as `.eslintrc`, `next.config.js`, and `tailwind.config.js`, can become cumbersome and time-consuming. In this blog post, I'll explore the idea of combining these configuration files into a single file called `global.config.js`, centralizing project configuration and reducing distractions.

## Config files everywhere

As I'm writing this blog post, my project root contains an `.eslintrc.json`, `next.config.js`, `postcss.config.js`, `tailwind.config.js`, and `tsconfig.json`. Although my configuration is pretty out-of-the-box and each file is less than 30 lines, those files take up valuable space in my VSCode sidebar and distract from what's important: my source code.

My case is far from exceptional. Some other projects use far more configuration files. Imagine how cluttered a project can get when you add a `.babelrc`, `prettier.config.js`, `jest.config.js`, `cypress.json`, etc.

## The solution: `global.config.js`

I'd like to propose a simple solution: consolidating configuration files in a file called `global.config.js`. The configuration for each tool would be stored in the exported object, under a key with the name of the npm package.

Projects should still allow usage of individual configuration files for cases when configuration is large and complex (e.g. `tsconfig.json`), but should first scan to see if a `global.config.js` exists and configuration for their tool is present.

Here's what a simple `global.config.js` might look like:

```js
module.exports = {
  eslint: {
    extends: ["next/core-web-vitals"]
  },
  postcss: {
    plugins: {
      tailwindcss: {},
      autoprefixer: {}
    }
  },
  tailwindcss: {
    content: ["./src/pages/**/*.{js,ts,jsx,tsx,mdx}"],
    theme: {
      extend: {
        backgroundImage: {
          "gradient-radial": "radial-gradient(var(--tw-gradient-stops))"
        }
      }
    },
    plugins: [require("@tailwindcss/typography")]
  }
}
```

## But what about types?

Type completion can be easily enabled for `global.config.js` by adding type definitions in comments, like Tailwind and NextJS already do in their config files.

```js
module.exports = {
  // ...

  /** @type {import('tailwindcss').Config} */
  tailwindcss: {
    content: ["./src/pages/**/*.{js,ts,jsx,tsx,mdx}"],
    theme: {
      extend: {
        backgroundImage: {
          "gradient-radial": "radial-gradient(var(--tw-gradient-stops))"
        }
      }
    },
    plugins: [require("@tailwindcss/typography")]
  }
}
```

## Next steps

If you like this idea, submit a PR to your favorite build tool! If you don't, let me know why on Twitter. Or don't and just keep going about your life.

_If you liked the article, don't forget to share it and follow me at [@nebrelbug](https://twitter.com/nebrelbug) on Twitter._
A new CSS-in-JS package for SolidJS
Tags: solidjs, css, showdev
Published: 2023-07-03 18:42:11

It can be advantageous to write some components with some local CSS rules. This package leverages the [native CSS nesting](https://developer.chrome.com/articles/css-nesting/) and produces a fast CSS-in-JS/Component solution: there is no parsing, just directly adding a `style` element to the `<head>` tag of the DOM.

We have produced a less than 700B package to write CSS-in-JS for SolidJS: <https://github.com/ndrean/solid-css/>.

This package uses `document` so is not suited for SSR.

It exports the function `css`, `styled`, `createGlobalStyles` and `keyframes`.

You write a template CSS string and pass it to the `css` function to produce a `class`:

```js
const bluediv = css`
  background-color: bisque;
  color: midnightblue;
`;
```

and use it:

```js
<div class={bluediv}>I am blue</div>;
```

You can design animated components. An example with a `styled` component:

```js
const rescale = keyframes`
  0% {transform: scale(0.5)}
  100% {transform: scale(1)}
`;

const AnimSurf = (props) => styled("span", props)`
  font-size: ${props.size}em;
  animation: ${rescale} 2s ease infinite;
`;
```

and use it:

```js
<AnimSurf size={3}>🏄</AnimSurf>;
```

## Conditional classes

You have two ways to use it. Define a function or object that returns CSS strings:

```jsx
const styles = (props) => {
  base: `
    cursor: pointer;
    font-size: ${props.size ?? 1}em;
    border-radius: 0.3em;
    padding: 0.3em;
  `,
  danger: `
    color: red;
    animation: ${rescale} 1s ease infinite;
  `,
  disabled: `
    pointer-events: none;
    opacity: ${props.opacity};
  `;
}
```

You can write:

```jsx
const Btn = (props)=> styled('button', props)`
  ${styles(props).base +
  props.danger ? styles(props).danger : ""}
`

<Btn>Base button</Btn>
<Btn danger={true} onClick={()=> alert('danger')}>Danger button</Btn>
```

To make life easier, the primitive `styled` can read the props and sets the class when the styles are defined as above:

```jsx
const Button = (props) => styled("button", props)`
  ${styles(props).base}
  ${styles(props)}
`;
```

We can use it:

```jsx
<Button size={3}>Base button</Button>

<Button
  disabled
  className={css`
    box-shadow: 6px -6px teal;
  `}
  >
  Disabled with shadow
</Button>
```


You can use reactive styles with the `style` prop, overwrite classes for styled components, create conditional CSS depending on the props, and define global styles. Check the Readme and the example.
What's the difference between a library and a framework?
Tags: discuss, help, explainlikeimfive, beginners
Published: 2023-07-03 19:19:25

Just like the title says, I'd like help understanding the difference between a library and a framework.

I'm a non-techie, so simple explanations and analogies are most definitely welcome. [#explainlikeimfive](https://dev.to/t/explainlikeimfive) 🙌

Bonus points if you can provide examples of each!
GSoC Week 4 Update
Tags: gsoc
Published: 2023-07-03 19:17:26

# Brief
This week I successfully finished implementing the fast algorithm. Now my `LombScargleCrossspectrum` and `LombScarglePowerspectrum` are that much closer to completion. Only things left to sort out/implement are time lags and phase lag functions and checking the phase of the output.

# Details
Testing on the following synthetic data has been conducted to compare the outputs with the existing cross spectrum and power spectrum for evenly spaced data first then checking the outputs of the lomb scargle variants on unevenly sampled data

```
rand = np.random.default_rng(42)
n = 1000
t = np.linspace(0, 10, n)
y = np.sin(2 * np.pi * 3.0 * t) + 0.1 * rand.standard_normal(n)
y2 = np.sin(2 * np.pi * 3.0 * t) + 0.1 * rand.standard_normal(n)
y -= np.min(y)
y2 -= np.min(y2)
```

## The Cross spectra for evenly sampled data

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

## The time lags for evenly sampled data

As it is evident the time lags need work.

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

## The power spectra for evenly sampled data
One quirk is that the power spectrum class is returning the power spectrum with a negative sign. This is a known bug. The values otherwise are within margin of error.

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

## The Lomb Scargle cross spectrum and power spectrum when data is unevenly sampled

`t = np.sort(rand.random(n))*10`

### The cross spectrum

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

### The power spectrum

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

### The time lags

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

They are off here too. Which will be fixed in the coming week.

For exhaustive testing code refer
{% embed https://gist.github.com/pupperemeritus/5edfe636312947d6e292713760059283.js %}
Connect ChatGPT to your SQL Database
Tags: chatgpt, sql, database, machinelearning
Published: 2023-07-03 19:06:43

With our [latest real time information release](https://ainiro.io/blog/chatgpt-with-real-time-information), we're now able to connect ChatGPT to any SQL database you have, and transmit the result of your SQL to ChatGPT, for then to have it analyse your data, answer your question, and return an answer accordingly.

However, before I start explaining the process, let's first enjoy a screenshot 😁

![Connect ChatGPT with your SQL database](https://ainiro.io/assets/images/connect-chatgpt-to-your-sql-database.jpeg)

## What you're looking at

The above ChatGPT answer was created by executing the following SQL

```sql
select f.title as Film, count(fa.actor_id) as Actors
	from film as f
  	join film_actor as fa on f.film_id = fa.film_id
	group by f.title
    order by Actors desc
    limit 10
```

The above SQL of course is a part of a Hyperlambda snippet, that looks as follows;

```
data.connect:[generic|sakila]
   data.select:@"select f.title as Film, count(fa.actor_id) as Actors
	from film as f
  	join film_actor as fa on f.film_id = fa.film_id
	group by f.title
    order by Actors desc
    limit 10;"
   .result:
   for-each:x:@data.select/*
      set-value:x:@.result
         strings.concat
            get-value:x:@.result
            .:"Film "
            get-value:x:@.dp/#/*/Film
            .:" "
            .:"Actor count "
            get-value:x:@.dp/#/*/Actors
            .:"\r\n"
   return:x:@.result
```

The above Hyperlambda snippet again is using the Hyperlambda **[strings.mixin]** slot, which combines natural language text with the result of executing Hyperlambda code. Below is a screenshot of the complete training snippet if you're interested.

![Executin SQL to create ChatGPT context data](https://ainiro.io/assets/images/extracting-sql-data-for-chatgpt.jpeg)

Once the context is semantically matched towards the query, being e.g.

> How many actors played in the movie MUMMY CREATURES?

The SQL extracts the following data;

```
Film MUMMY CREATURES Actor count 11
Film BOONDOCK BALLROOM Actor count 11
Film LAMBS CINCINATTI Actor count 10
Film HELLFIGHTERS SIERRA Actor count 10
Film ARABIA DOGMA Actor count 10
Film WIZARD COLDBLOODED Actor count 9
Film SUBMARINE BED Actor count 9
Film RANDOM GO Actor count 9
Film LESSON CLEOPATRA Actor count 9
Film IMAGE PRINCESS Actor count 9
```

Then our OpenAI machine learning functions submits the above data to OpenAI's APIs, which then uses the above as its _"real time data foundation for answering the question"_, the end result being something such as follows;

> There was 11 actora playing in the movie MUMMY CREATURES

In the video below I am walking you through the entire process

{% embed https://www.youtube.com/watch?v=f3_l5NAQS1U %}

Pretty kick ass if you ask me 😁
http requests are always served at port 80. PROOF!
Tags: webdev, javascript, programming, networking
Published: 2023-07-03 18:57:14

We know that http requests are by default goes to port 80. 
In this article I will prove that this fact is true. 

For this demonstration, I am going to create a tiny Nodejs server.

```javascript
const express = require('express')
const app = express() 
app.get('/',(req,res)=>{
    res.send('hi')
})

const port = 5000
app.listen(port,()=>console.log(`listening on port ${port}`))
```
Start the server by typing `node app.js` in the terminal.

Now go to the browser and write the url `http://localhost:5000`.
The output will be:
<kbd>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fkbyv5b11hhhjga43exi.png)
</kbd>

Now, rewrite the url again but omit the port number this time. ie 
search `http://localhost`.
Now you will get error this time:
<kbd>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/295jyr2mxz32y08rpe0n.png)
</kbd>

You get this error because you made a http request and http requests are resolved on port 80, but your Nodejs server is listening on port 5000 and there is no service running on port 80. 

**Now the magic is going to happen.**
If you want to `http://localhost` doesn't throw error on the browser, you have to make some changes in the Nodejs file.

```javascript

const express = require('express')
const app = express() 
app.get('/',(req,res)=>{
    res.send('hi')
})

const port = 80
app.listen(port,()=>console.log(`listening on port ${port}`))

```

Restart the server and search `http://localhost` in the browser.
The output is:
<kbd>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c20nblgfdachflxo6pb5.png)
</kbd>

**HOLLA**! There is no error! And we did wrote the port number in the url.

Thus it is proved that http request are resolved on port 80.