teleren/devto huggingface dataset:
Rails App Security
Tags: cybersecurity, api, rails
Published: 2022-03-14 03:48:35

Security is an important aspect to consider when building web applications. There are many layers to keep in mind when thinking about app security, such as the back-end storage, the web server, and the client-facing component.

Below are some things you can do to ensure that you build a more secure Rail app:

**1. Proper CORS configuration**
One important thing to do with CORS to prevent unwanted access is to define access within your APIs correctly. The example below uses the wildcard '*' allows access from any origin and gives access to any resources - typically, this is not advisable (it depends on the purpose of your API). Instead, you can define which origins are allowed to access your API.

This is an example of an unsecure CORS configuration: 

```
Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins '*'
    resource '*', headers: :any, methods: :any
  end
end
```

To define permitted origins and limit access, you can do something like this: 

```
Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins 'http://localhost:3000'
    resource '*', headers: :any, methods: [:get]
  end
end
```

**2. Authentication and Access Controls**
It is crucial to verify user identity to prevent unauthorized access. You can use the [Devise gem](https://rubygems.org/gems/devise) for user management. 

Another important thing to do is maintain control to CREATE, READ, UPDATE, DESTROY actions. It is important to reinforce ownership of records made by users so that users can modify only permitted records. [Pundit](https://github.com/varvet/pundit) is a great tool you can use to create user control policies. 

**3. Sessions Security**
You can avoid common hijacking situations by managing sessions. Implementing `reset_session` in your code prevents an attacker from using a fixed session to gain unauthorized access by issuing a new session identifier after a successful login.

Other things to keep in mind when using sessions: use HTTPS to prevent session theft, and do not store permanent data in sessions - store permanent data in the database. 

A great resource to use is Open Web Application Security Project (OSWAP).  [OWASP Top Ten](https://owasp.org/www-project-top-ten/) lists the ten most common security vulnerabilities and how to address them.
MAKING API CALLS without React Hooks
Tags: react, api, beginners, frontend
Published: 2022-03-14 03:34:25

## MAKING API CALLS
**Without React Hooks**

---

Something I wrote for my reference when not using react hooks.

// Making API calls
` const [user, setUser] = useState();
const [error, setError] = useState();
useEffect(() => {
  fetchUserData(userId)
    .then(res => setUser(res.data.user))
    .catch(err => setError(err.response.message));
}); ` 

// Manipulating the DOM
` const [count, setCount] = useState();
useEffect(() => {
  document.title = `Count is: ${count}`;
}); `

useEffect(() => {
` console.log("The component has mounted.");
}, []); `

---
IWD 2022 - Greenway Health
Tags: internationalwomensday, inclusion, awshero, infor
Published: 2022-03-14 03:20:07

Great to start International Women's Day 2022 week in a #greenway and had a great conversation with elite members of the panel.

Yes, Thanks for the invite, Panchsheela Basavan and Prasan S for their International Women's Day Celebration. It was wonderful to join hands for a remarkable event after a decade while the whole world is geared up on #internationalwomensday and be an #Infor representative.

As rightly said by Dr.Sam Jobin Manohar, the #CDCSoftware flag always flies high.

Happy Women's Day to all the lovely ladies. Always "Stand Up for Yourself"

I strongly believe that to break any bias, it's the women who have Stand Up for themselves. 
**To the women out there**
> There is no one else like you. 
> If you don’t express yourself…
> If you don’t explore who you are, 
> And most importantly if you don't Stand Up for Yourself,
> then the essence of you will be lost forever.

**To the men out there**
I would want to say a big thank you for breaking the bias and standing by all through the ups & downs in different roles - be it my father, brother, professors, friends, spouse, colleagues, classmates and most importantly my two little boys.

**Greenway Health Invitation and Event Announcement**
![Greenway - Poster](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9p6ujopsh9wxvkd4jj7.jpeg)

**Panel Discussion - Kat, Erin, Terri and Bhuvana**
![Greenway - Panel 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/agbbqjaaj4pk7sojiypy.jpeg)

**Panel Discussion - Kat, Erin, and Terri**
![Greenway - Panel 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mr0j734qh8sb3xbqzavw.jpeg)

**Carefully curated Memento**
![Memento](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9zdw6wc13y21fl4yb67q.jpg)
Create Custom HTML Components React
Tags: react, javascript, typescript, enetojara
Published: 2022-03-14 03:11:35

This generic component is useful if you are creating your own ui library and you want your components accept not only the props you want them to have, but also all the native props. for example you want your `Button` component to accept and auto complete the eventHandlers, aria-props and stuff w/out specifying'em.

---

```typescript
import React from "react";

const defaultProps = {
  tag: "section",
};

type Props = React.HTMLAttributes<HTMLElement> & typeof defaultProps & {
    tag: React.ElementType;
    className: string;
    cssModule?: CSSModule;
}

const Html: React.FC<Props> = (props) => {
    const { tag: Tag, ...attributes } = props;

    return <Tag {...attributes} className={classes} />;
};

Section.defaultProps = defaultProps;

export default Html;
```

---
now when you create your curstom button you'll see it will accept the props you set and also the "native props"
```typescript
<Html tag="button" onClick={e=>{e.preventDefault();}}/>
```
IWD 2022 - Girl Child Career Counselling by Infor
Tags: internationalwomensday, school, infor, inclusion
Published: 2022-03-14 03:09:35

The second event in the series for IWD 2022 was a great time with school kids. 

As  part of Infor’s Girl Child Career Counselling Program initiative, I chose to extend the Counselling Program to 13- to 14-year-old kids of the Little flower school at my home town,  Sathyamangalam, Tamil Nadu, India. My school days maths teacher Mr. Hari Narayanan, Director of Little Flower school was delighted to host me.

I had kicked off the first session with a visit to the school. I emphasized why is it important for the girls to focus on educate themselves, Stand Up for themselves, get back the focus and concentration on studies which was hit hard during COVID times aka online classes. At the end of the session, collected their interest on what would they look forward to from us to progress on their aspirations. The quiet girls became very interactive, extending one-hour session to two hours and still, the conversation was going on where the school director have to intervene to conclude. So emotional to leave since two girls were in literal tears expressing their interest to learn and move ahead. 

Infor WIN India Team will consolidate these data, design relevant content and schedule subsequent sessions. 

A wonderful initiative where Infor colleagues joined hands across India to make a wider impact in select rural schools. 

In the end, what the school director told was heartwarming,  
"Bhuvana, you saw the response right? 
The need is more on this side and time to change the profession to bring in change".
 
I assured him that continuing my career as a technophile and giving back to the grassroots where I came from would be a motivation to the younger generation.

![Littleflower Poster](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5cu17ocilicdttnlplbt.png)

**Little Flower school students eagerly awaiting!!** 
![Littleflower Students](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9zly1m4x42cxvrgn8zg.jpg)

**Introduction by Mr.Hari Narayanan, Director, Little Flower School**
![Littleflower Hari Sir](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvz02qb30mzpxqamqx3z.jpg)

**Interaction with students**
![Littleflower Students Interaction](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijncadzwv9j3z4iiuopw.jpg)

**Books as memento**
![Littleflower Memento](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5772fga5t11j6xujp3lp.jpg)

**#BreakTheBias with School kids**
![Littleflower BreakTheBias](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qh14pi2i1g9pp86yousc.jpg)
100 days of code
Tags: javascript, html, css, scss
Published: 2022-03-14 03:01:50

Hi there :) 
Here we are going to implement the 100 days of code challenge to master all the skills that i need as a dev for the web and mobile.
initially i started with HTML and Javascript in Day 1 and the HTML stands up to Day 1 - Day 10.


**

## JavaScript Learning curve
**
Roadmap to learn JavaScript 👇
I tweet below roadmap on twitter a few days back & people give thumbs up to this tweet, so I thought to put this roadmap in this post.

Alt Text

Hope you like this one 👍

Any code newbies can follow below roadmap to learn javascript 👇

Introduction to JavaScript
The JavaScript Glossary
JavaScript syntax
Lexical Structure
Expressions
Types
Variables
Math Operators
Functions
Immediately-Invoked Function Expressions IIFE
this
Arrow Functions
Loops
Loops and Scope
Arrays
Regular expressions
Template Literals
Semicolons
Strict Mode
JavaScript Dates
Math Object
Asynchronous programming and
Callbacks
JavaScript Timers
Promises
Async and Await
JavaScript Event Loop
Events
UI Events
Forms, controls
Document and resource loading
Advanced Topics 👇
Functional Programming in JS
Advanced Working With Functions
Closures
Regular Expressions
Unicode in JS
Storing data in the browser
I recommend these courses if you would like to checkout

MyLinkTree

Follow me on Twitter

Join us on WETESTERR Community

Subscribe to our YouTube for Tech podcast

If you like this article chances are you will like my other article as well 👇
🚀https://dev.to/tyaga001/generate-stub-test-data-using-jfairy-in-selenium-2c2m
🚀https://dev.to/tyaga001/chropath-is-no-more-a-xpath-finder-tool-it-has-evolved-a-lot-now-13fd
🚀https://dev.to/tyaga001/all-about-cypress-episode-1-0-12jl
Carbon Add Hours In Laravel Example
Tags: laravel, laravel8, carbon, php
Published: 2022-03-14 02:54:04

In this tutorial, we will see example of carbon add hours in laravel, here I will give you a simple example of laravel carbon add hours, carbon provides many function like addHour(), addHours() to add hour in laravel 8. Using the carbon addHour() or addHours() function you can change the hours in the date in laravel 8.

If we need to add hour or more then one hours in date and time then you can use carbon in laravel. carbon provides addHour() and addHours() method to add hours on carbon date object.

So, let's see an example of laravel 8 carbon add hours to date or add hours using carbon in laravel 8.

---

> **_[Read More : Carbon Add Hours In Laravel Example](https://techsolutionstuff.com/post/carbon-add-hours-in-laravel-example)_**
Create React Portals Typed Safe
Tags: react, typescript, javascript, portals
Published: 2022-03-14 02:53:43

today I will show you how to create a react portals with typescript the Propper way.

```typescript
import ReactDOM from "react-dom";
import * as React from "react";

const defaultProps = {
  tag: "section",
  create:false,
  className: "",
};

type Props = React.HTMLAttributes<HTMLElement> & typeof defaultProps &{
  /**
   * the html tag you would like to use as wrapper.
   * 
   * @default "section"
   */
    tag: keyof JSX.IntrinsicElements;
    id: string;
    /**
     * if true a new node/htmlTag will be created, else the html tag already exists.
     * @default false.
     */
    create: boolean;
}

const Portal: React.FC<Props> = props => {
  const { tag, create, id, className, children, ...rest } = props;
    const el = create ? document.createElement(tag) : document.getElementById(id);
    
    const wrapper = React.useRef<HTMLElement>(el);


        React.useEffect(() => {
        const current = wrapper.current as HTMLElement;
        if (!current) return;

            current.setAttribute("id", id);
            current.setAttribute("class", className);

            type K =  keyof typeof rest;

            Object.keys(rest).forEach(key => {
              const val = rest[key as K] as K
                current.setAttribute(key, val);
            });

            document.body.appendChild(current);
        

        return () => {
            if (create) {
                document.body.removeChild(current);
            }
        };
    }, [wrapper,id, create, className, rest]);

      if (!wrapper.current) {
        return <>{null}</>;
    }

    return ReactDOM.createPortal(children, wrapper.current);
};
 
export default Portal;
```
Ensuring Conversion of a Float to Nvarchar in T-SQL
Tags: sql, tutorial
Published: 2022-03-14 02:26:10

I ran into an interesting problem this week creating backfill data for an analytics process that involved a non-GUID ID value. The data is processed and stored in Microsoft SQL Server databases. These ID values are 8 numeric characters that ultimately are used as data type `nvarchar` in ETL processing.

My source data was an Excel spreadsheet I imported using the **Import** item from the standard **Tasks** option in SQL Server Management Studio. When I examined the data after import, the values appeared as I expected.  
![initial value of ID](https://kristenkinnearohlmann.dev/static/d362d6a06ed27f38a5a60ace1307a3e1/bc01b/img1-import-value.jpg)

I completed development on the needed transformations for the data. Since I planned to export the final table to each server where it was needed, I added an `INTO <schema.table>` statement to the final temp table to create the permanent table for the data. When I returned to QA the data, I noticed my ID values were now in scientific notation.  
![ID value as scientific notation](https://kristenkinnearohlmann.dev/static/d06ec339022c6d78581e72252ece6255/d141b/img2-scientific-notation.jpg)

Ultimately, these values are aggregated in a visualization tool for trends and predictions; these values would not accurately match those already in the table. When I checked the table that was created from my `INTO` statement, I found the ID column was translated as a float. I changed the data type to `nvarchar` and added a simple conversion to the `INSERT` statement to resolve.

```sql
SELECT CONVERT(nvarchar,@IDValue) As IdValue
```

This still resulted in a value that was in scientific notation!

By keying into the fact that SQL Server was identifying the ID value as a `float`, I located a solution for T-SQL that ensured the conversion of the value to `nvarchar` was complete and accurate.

```sql
SELECT CONVERT(nvarchar,CONVERT(bigint,@IDValue)) As IDValue
```

![convert the float value to bigint then to nvarchar](https://kristenkinnearohlmann.dev/static/a6b48606549b314f4d153bed8d2455d9/d7fe6/img3-convert-bigint-and-nvarchar.jpg)

By first converting the `float` value to `bigint`, the actual value is preserved. Further converting the resulting `bigint` value to `nvarchar` ensures a smooth insert into the table via an explicit data type. With this revised conversion, I was able to finish building the needed backfill table to complete my work.
Python Walrus Inside List Comprehension
Tags: python
Published: 2022-03-14 02:22:36

---
canonical_url: https://waylonwalker.com/til/walrus-comprehension/
cover_image: https://images.waylonwalker.com/til/walrus-comprehension.png
published: true
tags:
- python
title: Python Walrus Inside List Comprehension
---

Python 3.8 came out two and a half years ago and I have yet to really lean in on the walrus operator.  Partly because it always seemed like something kinda silly (my use cases) to require a python version bump for, and partly because I really didn't understand it the best.  Primarily I have wanted to use it in comprehensions, but I did not really understand how.

Now that Python 3.6 is end of life, and most folks are using at least `3.8` it seems time to learn and use it.

## What's a Walrus
_:=_

The assignment operator in python is more commonly referred to as the walrus operator due to how `:=` looks like a walrus.  It allows you to assign and use a variable in a single expression.

This example from the docs avoids a second call to the `len` function.

``` python
if (n := len(a)) > 10:
    print(f"List is too long ({n} elements, expected <= 10)")
```

## Let's get some data
_without a walrus_

In this example we are going to do a dict comp to generate a map of content from urls, only if their status code is 200.  When doing this in a dictionary comprehension we end up needing to hit the url twice for successful urls. Once for the filter and once for the data going into the dictionary.

``` python
{
    url: requests.get(url).content
    for url in ["https://waylonwalker.com/", "https://waylonwalker.com/broken"]
    if requests.get(url).status_code == 200
}
```

## Gimme some walrus
_using walrus in a dict comp_

Using the walrus operator `:=` list comp allows us to only put things into the dictionary that we want to keep, and not hit the url twice.

``` python
{
    url: r.content
    for url in ["https://waylonwalker.com/", "https://waylonwalker.com/broken"]
    if (r := requests.get(url)).status_code == 200
}
```

## FIN

The walrus is a nice to have option to save on extra function/network calls, and micro optimize your code without adding much extra.
C# Web Scraper
Published: 2022-03-14 02:15:15

---
canonical_url: https://ironsoftware.com/csharp/webscraper/examples/c-sharp-web-scraper/
---

Iron WebScraper provides a powerful framework to extract data and files from websites using C# code.


1. Install IronWebScraper to your Project using Nuget
2. Create a Class Extending `WebScraper`
3. Create an `Init` method that uses the `Request` method to parse at least one URL.
4. Create a `Parse` method to process the requests, and indeed `Request` more pages. Use response.Css to work with HTML elements using jQuery style CSS selectors
5. In your application please create and instance of your web scraping class and call the `Start();` method
6. Read our [C# webscraping tutorials](https://ironsoftware.com/csharp/webscraper/tutorials/webscraping-in-c-sharp/) to learn how to create advanced web crawlers using IronWebScraper

**C#:**
```cs
using IronWebScraper;
 
namespace WebScrapingProject
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var scraper = new BlogScraper();
            scraper.Start();
        }
    }
 
    class BlogScraper : WebScraper
    {
        public override void Init()
        {
            this.LoggingLevel = WebScraper.LogLevel.All;
            this.Request("https://blog.scrapinghub.com", Parse);
        }
 
        public override void Parse(Response response)
        {
            foreach (var title_link in response.Css("h2.entry-title a"))
            {
                string strTitle = title_link.TextContentClean;
                Scrape(new ScrapedData() { { "Title", strTitle } });
            }
 
            if (response.CssExists("div.prev-post > a[href]"))
            {
                var next_page = response.Css("div.prev-post > a[href]")[0].Attributes["href"];
                this.Request(next_page, Parse);
            }
        }
    }
}
```

**VB:**
```
Imports IronWebScraper
 
Namespace WebScrapingProject
	Friend Class MainClass
		Public Shared Sub Main(ByVal args() As String)
			Dim scraper = New BlogScraper()
			scraper.Start()
		End Sub
	End Class
 
	Friend Class BlogScraper
		Inherits WebScraper
 
		Public Overrides Sub Init()
			Me.LoggingLevel = WebScraper.LogLevel.All
			Me.Request("https://blog.scrapinghub.com", AddressOf Parse)
		End Sub
 
		Public Overrides Sub Parse(ByVal response As Response)
			For Each title_link In response.Css("h2.entry-title a")
				Dim strTitle As String = title_link.TextContentClean
				Scrape(New ScrapedData() From {
					{ "Title", strTitle }
				})
			Next title_link
 
			If response.CssExists("div.prev-post > a[href]") Then
				Dim next_page = response.Css("div.prev-post > a[href]")(0).Attributes("href")
				Me.Request(next_page, AddressOf Parse)
			End If
		End Sub
	End Class
End Namespace
```
Tamil OCR in C# and .NET
Published: 2022-03-14 02:08:54

---
canonical_url: https://ironsoftware.com/csharp/ocr/languages/tamil/
---

_Other versions of this document:_

- [தமிழில்](https://ironsoftware.com/csharp/ocr/languages/tamil-ta)
- [125 More OCR Languages](https://ironsoftware.com/csharp/ocr/languages/)

IronOCR is a C# software component allowing .NET coders to read text from images and PDF documents in 126 language, including Tamil.

It is an advanced fork of Tesseract, built exclusively for the .NET developers and regularly outperforms other Tesseract engines for both speed and accuracy.

## Contents of IronOcr.Languages.Tamil

This package contains 102 OCR languages for .NET:

- Tamil
- TamilBest
- TamilFast
- TamilAlphabet
- TamilAlphabetBest
- TamilAlphabetFast

## Download

Tamil Language Pack [தமிழ்]

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


## Installation

The first thing we have to do is install our **Tamil** OCR package to your .NET project.

`PM> Install-Package IronOCR.Languages.Tamil`

## Code Example

This C# code example reads Tamil text from an image or PDFv document.

**C#:**
```cs
//PM> Install-Package IronOcr.Languages.Tamil
using IronOcr;
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Tamil;
using (var Input = new OcrInput(@"images\Tamil.png"))
{
    var Result = Ocr.Read(Input);
    Var AllText =  Result.Text
}
```

**VB:**
```
'PM> Install-Package IronOcr.Languages.Tamil
Imports IronOcr
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Tamil
Using Input = New OcrInput("images\Tamil.png")
	Dim Result = Ocr.Read(Input)
	Dim AllText As Var = Result.Text
End Using
```
PERSONAL WEBSITE USING FLUTTER
Tags: beginners, flutter, design, portfolio
Published: 2022-03-14 02:08:28

[](url)[](url)[](url)## Introduction
   I build personalwebsite used by flutter  and hosted infirebase,.
Iknow this is not big website.but ecah person have easy to draw or learnthewebsite use flutter.firebaseis free space to host yourwebsite to internet.
[](url)
## Language
I  used dart  language to build the website ,why I use it because dart is to use compare to other languages

## Major Links of Website

**CODE**  - The source code is available in github and link given below-{% embed https://github.com/tintujoseph/website %}

**WEBSITE** - The link of my personal website is given below
[personal website](https://tintu-33120.web.app)


## Picture's of my Website

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/362g5pgai8m0t4z1gm5h.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1skdm1kckftzx7fyxmw.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ed4n7lu6p1ta0zcurnb.png)





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