teleren/devto huggingface dataset:
New simple way of creating custom Rate Limiters in Laravel 8
Tags: laravel, ratelimiting, throttling, routing
Published: 2020-10-04 19:21:32

In **Laravel** we use `throttle` middleware to restrict the amount of traffic for a given route or group of routes. The `throttle` middleware accepts two parameters that determine the maximum number of requests that can be made in a given number of minutes.
For example:
```
Route::middleware('throttle:60,1')->get('/user', function () {
        //
});
```
Here 60 is number of requests you can make in 1 minute.

Now in **Laravel 8** there is a new way to create custom Rate Limiters.
We can define our custom Rate Limiter in any Service Provider typically it should be in `RouteServiceProvider` like so.
>Rate limiters are defined using the RateLimiter facade's `for` method. The `for` method accepts a rate limiter name and a Closure that returns the limit configuration that should apply to routes that are assigned this rate limiter:
```
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\Facades\RateLimiter;

RateLimiter::for('testing', function (Request $request) {
    return Limit::perMinute(1000);
});
```
Now we can attach `testing` Rate Limiter using it's name with `throttle` middleware like `throttle:testing` instead of `throttle:60,1`:
```
Route::middleware('throttle:testing')->get('/user', function(){
    //
});
```
For further reading check out the [Laravel 8 Docs Rate Limiting](https://laravel.com/docs/8.x/routing#rate-limiting).
Need help in Populating HTML Table from a file
Tags: help, javascript, jquery
Published: 2020-10-04 19:06:04

Hi All,
Here am trying to retrieve data from text file and embed them to HTML table based on some condition.

Below is the code which is written in jQuery.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hieyt1xwr3o8j59nereg.PNG)

Issue is that the resulting array after filter shows no elements with length 0 

Below is the result for above code in console:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kgdvx84ix9bsb7u1fxuk.PNG)

Expected Result:
Resulting array after filter should have filtered array.

Troubleshooting done:
If the array lineByline is assigned with array values as in Line #61 which is commented then this works.

Kindly help me here please.
Flyweight Pattern
Tags: structural, pattern, designpattern, java
Published: 2020-10-04 19:01:07

Use sharing to support large numbers of fine-grained objects efficiently.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lx4f1gplevkqsflxpzwc.gif)

#Participants#

* Flyweight: declares an interface through which flyweights can receive and act on extrinsic state.
* ConcreteFlyweight: implements the Flyweight interface and adds storage for intrinsic state, if any. A ConcreteFlyweight object must be sharable. Any state it stores must be intrinsic, that is, it must be independent of the ConcreteFlyweight object's context.
* UnsharedConcreteFlyweight: not all Flyweight subclasses need to be shared. The Flyweight interface enables sharing, but it doesn't enforce it. It is common for UnsharedConcreteFlyweight objects to have ConcreteFlyweight objects as children at some level in the flyweight object structure (as the Row and Column classes have).
* FlyweightFactory: creates and manages flyweight objects.
Ensures that flyweight is shared properly. When a client requests a flyweight, the FlyweightFactory objects assets an existing instance or creates one, if none exists.
* Client: maintains a reference to flyweight(s). Computes or stores the extrinsic state of flyweight(s).

#Code#
```java
public class Main {

	public static void main(String[] args) {
		int extrinsicstate = 22;
		FlyweightFactory factory = new FlyweightFactory();
		Flyweight fx = factory.getFlyweight("X");
		fx.operation(--extrinsicstate);
		Flyweight fy = factory.getFlyweight("Y");
		fy.operation(--extrinsicstate);
		Flyweight fz = factory.getFlyweight("Z");
		fz.operation(--extrinsicstate);
		UnsharedConcreteFlyweight fu = new UnsharedConcreteFlyweight();
		fu.operation(--extrinsicstate);
	}
}

public class FlyweightFactory {
	private Hashtable<String, Flyweight> flyweights = new Hashtable<>();

	public FlyweightFactory() {
		flyweights.put("X", new ConcreteFlyweight());
		flyweights.put("Y", new ConcreteFlyweight());
		flyweights.put("Z", new ConcreteFlyweight());
	}

	public Flyweight getFlyweight(String key) {
		return ((Flyweight) flyweights.get(key));
	}
}

public interface Flyweight {
	void operation(int extrinsicstate);
}

public class ConcreteFlyweight implements Flyweight {

	@Override
	public void operation(int extrinsicstate) {
		System.out.println("ConcreteFlyweight: " + extrinsicstate);
	}
}

public class UnsharedConcreteFlyweight implements Flyweight {

	@Override
	public void operation(int extrinsicstate) {
		System.out.println("UnsharedConcreteFlyweight: " + extrinsicstate);
	}
}
```

#Output#
```
ConcreteFlyweight: 21
ConcreteFlyweight: 20
ConcreteFlyweight: 19
UnsharedConcreteFlyweight: 18
```
{% github https://github.com/eidherjulian61/design-patterns no-readme %}
{% link https://dev.to/eidher/principales-patrones-de-diseno-13ao
 %}
Stop lost your time with your web node deployment
Tags: serverless, node, easy, deploy
Published: 2020-10-04 18:56:54

Hi Webmasters !

Today I show you how to deploy your webapp on a **serverless service**.

After, many thank for your support in my last post !
https://dev.to/simerca/make-a-fast-auto-graphql-server-with-nodejs-and-postgres-in-5-minutes-146h

# Let's started !

## Did you know Vercel ?
 
**Vercel.app** is a service who sync your Github / Gitlab repo for easy deployment.
When you push on the master Vercel rebuild you'r project and deploy if passed the build step.

*create your account*
[Vercel.app](https://vercel.app)

The first step it's install Vercel CLI with this command:
```
npm i -g vercel
```

Next Create a Node project, like a VueJS project.
*exemple*
```
vue create my-awesome-app
```

inside your project set the repo:
*exemple*
```
git remote add origin https://gitlab.com/UserName/MyAwesomeProject
git add .
git commit -m "initial release"
git push -u origin master
```

now inside your app project
```
vercel
```

yes just this command without options can make the process of deployment easily

**Vercel** is awesome because you can set your domain for free ,but by default he give you a domain like xxxx.vercel.app for testing.

you can view log inside your dashboard 
https://vercel.com/dashboard

Enjoy the powerful of serverless
Anana's - Landing page
Tags: codepen, freecodecamp
Published: 2020-10-04 18:56:44

---
title: Anana's - Landing page
published: true
tags: codepen , freecodecamp
---

<p>This is a landing page (lang="es-AR") about pineapples!</p>

{% codepen https://codepen.io/leandroygz/pen/mdPNqNd %}
Cliff - The rust DBMS
Tags: database, sql, rust, hacktoberfest
Published: 2020-10-04 18:40:04

## What is Cliff?

Cliff is supposed to be a database management system like Microsoft Sql Server, MariaDB and PostgresDB. Even if additional features are planned this should be the basic structure. What distinguishes us from the others is that we use Rust. A memory-safe programming language without garbage collection or reference counting but which uses the ownership system.

## Contribute
Since Cliff is a relatively new project and there is no working prototype yet and a DBMS is not a small project either, we are urgently looking for support. 

Furthermore you have the advantage that a pull request will be counted to the Hacktoberfest this month. 

### What if I do not know Rust?
This is not a problem. We need people who maintain the documentation or design the website and addons like the webinterface with Svelte. 

## Links
* [GitHub Repository](https://github.com/cliff-db/cliff)
* [GitHub Repository of Webinterface Addon](https://github.com/cliff-db/webinterface)



Kind regards,
Robin Lindner
_The initiator of the cliff project_
My first CLI Project
Tags: ruby, api, cli
Published: 2020-10-04 18:26:20

It was the start of Project Week and I had a heaping scoop of “imposter syndrome” -- I felt as if I was tasked with something I could not accomplish nor comprehend, even though I have been preparing myself for this project for nearly 4 weeks. No one likes to feel fraudulent or fake. It’s like when you check out of the grocery store with a case of water bottles on the lower rack and they don’t check your receipt -- even though you truthfully bought it. You feel as if you may get caught despite your innocence. Similarly, I felt caught red-handed: this girl does not know how to code! What is she doing???? Despite these overwhelming feelings, I strode forward and dived into Project Week. 

As the week stumbled on, confusion made several star-lit appearances and I knew I had to dim its presence, quickly. It felt really great to ask for help on my project and receive it rightfully so. For me, asking for help can be a little alarming and anxiety-inducing because help usually coincides with being told to change your work or being told you did something wrong. However, the help I received was far from distressing and instead showed itself as an illuminated cobblestone path leading to the ocean: it just made sense. An obvious means to an end. I asked for help a lot and I am grateful that I did so.

As I finished my project, relief flooded forward but not as a turquoise wave but as a Northshore Long Island murky ebb. I knew I had still to make my claim as a “coder” with the assessment and proper articulation. I knew I had to stand by my code and be like “Yes, I wrote this and yes, I know what everything means.” But, it’s challenging being 1000% confident when a few weeks ago when someone said “Ruby” I thought “shiny.” Unpolluted confidence and pride definitely come in waves… so I must be patient.
 
I am looking forward to the next project week because it was overall an enlightening and learned experience. I have made great strides and will continue to do so because I have felt such gratification from coding so far. I can see a personal future with code which is nice to admit.
How to Import JSON Data into DynamoDB in Bulk
Tags: aws, json, database
Published: 2020-10-04 18:07:52

# Overview
I recently needed to import a lot of JSON data into DynamoDB for an API project I'm was working on. I couldn't find any pre baked solutions online, so I built my own. It's really very simple. It's a Node.js CLI script which accepts two command line arguments: the JSON file to load the data from (it expects this to contain a list of the items you want inserted) and the name of the DynamoDB table to insert it into. The only thing you'll need to change is to replace INSERT_REGION_NAME_HERE with your region, unless your items are very big - 25 is the max number of items that can be included in a batch request but there's also a separate size limit per request, so you might have to reduce that number.

For this sort of request, the individual keys in the items need to be wrapped in DynamoDB's type declaration syntax (e.g. { "S":"Blah"} to indicate that "Blah" is supposed to be a string"). Luckily, the npm module dynamodb-data-types does this all, but if you want to translate this code into another language, you'll probably need to do it yourself. 

# Prerequisites
* Node.js - Version doesn't matter much.
* AWS credentials setup on your local machine (see AWS's site)
* AWS SDK for Node.js (aws-sdk on npm)
* dynamodb-data-types npm module

# Code
```js
// Load the AWS SDK for Node.js
const AWS = require('aws-sdk');
const attr = require('dynamodb-data-types').AttributeValue;
// Set the region
AWS.config.update({ region: 'INSERT_REGION_NAME_HERE' });
let data = require(process.argv[2]);
// Create DynamoDB service object
var ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10'});
let items = [];
for (let index = 0; index < data.length; index++) {
    const element = data[index];
    // Format element in the correct format for DynamoDB's API 
    let item = {
        PutRequest: {
            Item: attr.wrap(element)
        }
    };
    items.push(item);
    
    if (items.length == 25 || index == data.length-1) {
        let params = {
            RequestItems: {
            }
        };
        params["RequestItems"][process.argv[3]] = items;
        // Async function call to write the items to the DB 
        ddb.batchWriteItem(params, function (err, data) {
            if (err) {
                console.log("Error", err);
            } else {
                console.log("Success", data);
            }
        });
        items = [];
    }
}
```
MY FIRST HACKTOBER-FEST
Tags: github, opensource, hacktoberfest2020, hacknight
Published: 2020-10-04 17:15:07

Before I share my experience on my first hacktober fest. Let me just give a brief detail about what is hacktoberfest ?

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y8mr3xbnj58695vh9ith.png)

###EVENT DETAILS :
Hacktoberfest is open to everyone in our global community. Whether you’re a developer, student learning to code, event host, or company of any size, you can help drive growth of open source and make positive contributions to an ever-growing community. All backgrounds and skill levels are encouraged to complete the challenge.

1. Hacktoberfest is a celebration open to everyone in our global community.
2. Pull requests can be made in any GitHub-hosted repositories/projects.
3. You can sign up anytime between October 1 and October 31.

###RULES :
To earn your Hacktoberfest tee or tree reward, you must register and make four valid pull requests (PRs) between October 1-31 (in any time zone). PRs can be made to any public repo on GitHub, not only the ones with issues labeled Hacktoberfest. If a maintainer reports your pull request as spam or behavior not in line with the project’s code of conduct, you will be ineligible to participate. This year, the first 70,000 participants who successfully complete the challenge will be eligible to receive a prize.

you can also grab one , Do sign in : https://hacktoberfest.digitalocean.com/

###MY EXPERIENCE :
Actually during my first year, I was not aware about this fest cause no one told me about this amazing fest. But during my second year, an open source community in our college had conducted a event hacknight-2020 that is where i got the brief idea about this amazing fest. 

I couldnt attend the hacknight because of personal reasons , So i was really sad about it .But i always wanted myself to be open source contributor cause contributing for major projects can make you gain alot of knowledge and experience. 

So i waited for another year, but due to covid reasons even this year we couldnt have the live interaction, but the event went through discord on Oct-3 to Oct-4 and there we had alot of fun . I named my team as XSpark and we pitched about our project idea for 1 min and we got amazing suggestion from the judges then we started working on our project and we successfully designed a website that is mainly useful for engineering students inorder to get H.W, notes ,project ideas, mentorship and we even added a discussion tab for students from different batches. We had completed the project but we couldnt upload it on devfolio cause our time was up !.Our team really felt bad ,but we didnt loose hope and we planned that we would come across more interesting project development for the upcoming year.

I completed my 4 PR successfully and i'm really happy about it.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7m5gbirdx4c1cnihdy0h.png)

I had an wonderful experience by learning the importance of open source. 
Thank you :)
New interview?
Tags: career, javascript
Published: 2020-10-04 17:05:36

This past week I have been working on a few code assignments. I heard back from HCL Technologies and they are not interested in continuing the hiring process. It is unfortunate to go as far as code challenge and not pass but I am remaining hopeful that opportunities may arise. Speaking of which, I got a new opportunity with Samsara. I found out about the company on a post on Linkedin about the top 50 up and coming tech companies to work at. I applied for an software development intern position and reached out to a recruiter on Linkedin soon afterwards. Within the hour, I got an email saying they are interested in moving forward with the process. I was given a code challenge with the option to practice via CodeSignal.com. I ended up trying the practice challenge and I barely finished 1 out of the 4 questions in the 70 minutes I was given. So i decided to reach out to hear to ask for extra time which she had offered. Its been 4 days and she has not gotten back to me about the time adjustment. I won't attempt it with 70 minutes because I know i wont be able to do my absolute best in that time frame. I also completed my JPMorgan and Co. assessment this week. It was done with this new technology called Hire Vue. You basically have 3 minutes to answer a few questions about yourself or your work. The questions are similar to actual interviews. Then you must complete 2 code challenges. After completing each question within 35 minutes, you must explain your thought process in 3 minutes in a video recording and how you could improve your solution had you been given more time.
This was a stressful week no doubt about it, but I kind of liked having all of these challenges and assesments to complete. I hope i get many more opportunities like this and can eventually get hired after doing one of these.
Resume Blog
Published: 2020-10-04 17:02:29

So, where do I begin... I have many different trade skills that I have acquired over the years. I know mechanics, carpentry, culinary arts, and even crafting. I have to say that my best projects so far have been a commercial, a short story that I'm writing and several drawings that I've made for family. I used to lead a team in SU diesel shop. I'd make sure everyone was practicing all the necessary steps for every single thing we had to fix or inspect. My dream job is and will always be a director/producer within the film industry.
Currying
Tags: javascript, beginners, codenewbie, 100daysofcode
Published: 2020-10-04 16:58:25


Currying is a technique in which you make a function that takes multiple arguments into a series of functions that each take only one argument. It is translating a function from callable as f(a, b, c, n) into callable as f(a)(b)(c)(n).

Let's start with an example of a function that takes two arguments.

```javascript
const multiply = (a, b) => {
    return a * b;
}

console.log(multiply(4, 3)); // 12
```

We will convert this into a series of functions where each one takes only one argument (currying):

```javascript
const multiply = (a) => {
    return (b) => {
        return a * b;
    }
}

console.log(multiply(4)(3)); // 12
```

Using shorthand:

```javascript
const multiply = a => b => a * b;
console.log(multiply(4)(3)); // 12
```

The outer function takes in `a` and returns a function that takes in `b` which eventually returns the multiplication of a and b.

Currying is commonly associated with partial application. The idea is to create a function with two or more arguments, and we only know the value(s) for some of those arguments. We can use partial application (currying) to supply the knows values and get a function in return that works with unknowns (at the moment). Once the remaining arguments are known, we can execute the returned function.

I, in all honesty, have not used currying that much in real-life applications. There are other ways to accomplish what we are trying to do with currying (classes, callback functions and higher-order functions). It is good to know.
Write a story with me!
Tags: hacktoberfest, experimental, writing, contributorswanted
Published: 2020-10-04 16:54:56

---
title: Write a story with me!
published: true
tags: hacktoberfest, experimental, writing, contributorswanted
--- 

So, here's my idea.

While signing up for Hacktoberfest this year, I thought "this is about writing code together." What else can we do together?

Write words. Create little worlds inside this one file.

Everything here goes into the public domain (CC0 license).

(Please follow the contributing guidelines — no less than 50 words, but no more than 250!)

**[VISIT GITHUB](https://github.com/mistermantas/nice-word-collection/blob/main/README.md)**
 
---

I also have a project called [cState](https://github.com/cstate/cstate/issues) — it's a hobby project of mine that sort of exploded (I mean, I think a thousand stars is a real explosion, OK?).

If these sound like your thing — HTML, CSS, JS, serverless, netlify, hugo, SSG themes — take a look:

- translations needed
- help with complex gohugo.io template logic PLS 
- a 'monitor' bot / html embed kind of thing
- not a super complex project 

---

You can always email me to ask for explanations/help: hi@mnts.lt
Scraping Yellow pages with Python and BeautifulSoup

Published: 2020-10-04 16:53:21

Today lets look at scraping Yellow pages data using Beautiful soup and the requests module in python.

Here is a simple script that does that. BeautifulSoup will help us extract information and we will retrieve crucial pieces of information.

To start with, this is the boilerplate code we need to get the Yellowpages.com search results page and set up BeautifulSoup to help us use CSS selectors to query the page for meaningful data.

We are also passing the user agent headers to simulate a browser call so we don't get blocked.

Now let's analyze the Yellow pages search results. This is how it looks.

And when we inspect the page we find that each of the items HTML is encapsulated in a tag with the class v-card.

We could just use this to break the HTML document into these cards which contain individual item information.

And when you run it.

You can tell that the code is isolating the v-cards HTML.

On further inspection, you can see that the name of the place always has the class business-name. So let's try and retrieve that.

That will get us the names.

Bingo!

Now let's get the other data pieces.

And when run.

Produces all the info we need including ratings, reviews, phone, address, etc.

In more advanced implementations you will need to even rotate the User-Agent string so Yellow pages cant tell its the same browser!

If we get a little bit more advanced, you will realize that Yellow pages can simply block your IP ignoring all your other tricks. This is a bummer and this is where most web crawling projects fail.

Overcoming IP Blocks

Investing in a private rotating proxy service like Proxies API can most of the time make the difference between a successful and headache-free web scraping project which gets the job done consistently and one that never really works.

Plus with the 1000 free API calls running an offer, you have almost nothing to lose by using our rotating proxy and comparing notes. It only takes one line of integration to its hardly disruptive.

Our rotating proxy server Proxies API provides a simple API that can solve all IP Blocking problems instantly.

With millions of high speed rotating proxies located all over the world,
With our automatic IP rotation
With our automatic User-Agent-String rotation (which simulates requests from different, valid web browsers and web browser versions)
With our automatic CAPTCHA solving technology,
Hundreds of our customers have successfully solved the headache of IP blocks with a simple API.

The whole thing can be accessed by a simple API like below in any programming language.

We have a running offer of 1000 API calls completely free.