teleren/devto huggingface dataset:
FindFood program
Tags: python, beginners
Published: 2022-09-24 05:46:32

https://github.com/PiePirates/FindFood

This program I made allows you to search for restaurants based on the type of restaurants. 

I accomplished runtime of O(n/2) by using a maxheap and a heapsort function. I used the ord() function along with the string's of the types to sort the list of types in alphabetical order. I then used a search algorithm that iterates backwards through a list if its ord() value is greater than the ord() value at the middle index, and vice versa.

my user input function grabs the users input, and if the user misspells a type it'll give the user a list of types that are somewhat similar to what they originally inputted. 

lastly once you get the users input it returns a nicely formatted list of restaurants.

In closing, this program runs smoother thanks to the initial heapsort, and would save heaps of time thanks to the program only having to perform (n/2) computations for each search as compared to the standard (n) for a basic search algorithm. The program's runtime could be improved further if the data was structured in a tree where a greedy algorithm could be implemented.
Python Modules
Tags: python, programming, beginners, 100daysofcode
Published: 2022-09-24 05:37:01

A module is a collection on Python Declarations intended broadly to use as tools. Modules are also referred to as "packages" or "libraries"

To use a module in a file the syntax needs to be located at the top of that file like this:

```python
from module_name import object_name 
```
'datetime' is a library that comes as part of the Python Standard Library. 'datetime' helps you to be able to work with date and time in Python.
Let's try 'datetime' by importing the 'datetime' module.

```python
from datetime import datetime

time_now = datetime.now

print(time_now)
```

This outputs a combination of a date and time. 
Attributes year, month,day,hour,minute,second,microsecond.

Example:

```python

2022-09-25 01:34:55.601239
```
Lets try using a cooler module. Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. 

```python
import wikipedia

print(wikipedia.summary("python (programming language)"))
```

Output
```python
Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming. It is often described as a "batteries included" language due to its comprehensive standard library.Guido van Rossum began working on Python in the late 1980s as a successor to the ABC programming language and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000 and introduced new features such as list comprehensions, cycle-detecting garbage collection, reference counting, and Unicode support. Python 3.0, released in 2008, was a major revision that is not completely backward-compatible with earlier versions. Python 2 was discontinued with version 2.7.18 in 2020.Python consistently ranks as one of the most popular programming languages.
```
AWS Fargate Cheat Sheet
Published: 2022-09-24 05:35:11

Serverless compute for contai­ners.

AWS Fargate is a serverless, pay-as-you-go compute engine that lets you focus on **building applications without managing servers**.

Deploy and manage your applications, not infrastructure. Fargate removes the operational overhead of scaling, patching, securing, and managing servers.

Compatible with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS).

- [Documentation](https://aws.amazon.com/fargate/)
- [User Guide](https://docs.aws.amazon.com/fargate/?id=docs_gateway)


![AWS Fargate Flow](https://d1.awsstatic.com/re19/FargateonEKS/Product-Page-Diagram_Fargate%402x.a20fb2b15c2aebeda3a44dbbb0b10b82fb89aa6a.png)

## Alternatives

- Google Kubernetes Engine (GKE)
- Red Hat OpenShift Container Platform
- Azure Kubernetes Service (AKS)
- Rancher
- Azure Container Instances
- Cloud Foundry
- Oracle Cloud Infrastructure Container Engine for Kubernetes

## Q

How AWS Fargate different from AWS ECS?

In AWS ECS, you manage the infrastructure - you need to provision and configure the EC2 instances.
While in AWS Fargate, you don't provision or manage the infrastructure, you simply focus on launching Docker containers. You can think of it as the serverless version of AWS ECS.

> - [Practice notes](https://romankurnovskii.com/en/docs/aws-certified-developer-associate/ec2/)
> - [Questions](https://dev.to/romankurnovskii/aws-ec2-top-
questions-certified-developer-exam-27oo)
Software Engineering Projects
Tags: javascript, software, beginners, programming
Published: 2022-09-24 05:16:45

[Software engineering projects](https://takeoffprojects.com/software-engineering-projects) are an integral part of the UG and PG of any student. Only attaining the knowledge and expertise of software engineering is of little use if you do not experiment with it. It helps for well-paying jobs as a software engineer, it is paramount to have significant experience with software engineering projects.

All the firms hiring a software engineer demand some hands-on experience working on [software engineering projects.](https://www.youtube.com/watch?v=wPq7i_e32KI) It is why most students seek to work on these projects in their conventional education.

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

Therefore, doing software engineering projects can help you get knowledge in college days & kick-start your professional career. Implementing your theoretical knowledge in building systems and software will help you clarify the theoretical concepts and dig in deeper.

To help you get started, here is a list of some exciting software project ideas that you can start implementing on your own.

**Few title for the software engineering projects:**
- [Software Development Process Ambidexterity And Project Performance: A Coordination Cost-effectiveness View](https://takeoffprojects.com/project-details/software-development-process-ambidexterity-and-project-performance-a-coordination-cost-effectiveness-view--1475)
- [Studying Task Processes For Improving Programmer Productivity](https://takeoffprojects.com/project-details/studying-task-processes-for-improving-programmer-productivity--1470)
- [The Impact Of Correlated Metrics On The Interpretation Of Defect Models](https://takeoffprojects.com/project-details/the-impact-of-correlated-metrics-on-the-interpretation-of-defect-models--1466)
- [An Empirical Study Of Obsolete Answers On Stack Overflow](https://takeoffprojects.com/project-details/an-empirical-study-of-obsolete-answers-on-stack-overflow--1438)
- [Automatically Assessing Code Understandability
](https://takeoffprojects.com/project-details/automatically-assessing-code-understandability--1432)
113. Leetcode solution in Java
Tags: beginners, java
Published: 2022-09-24 04:17:09

```
class Solution {
  public List<List<Integer>> pathSum(TreeNode root, int sum) {
    List<List<Integer>> ans = new ArrayList<>();
    dfs(root, sum, new ArrayList<>(), ans);
    return ans;
  }

  private void dfs(TreeNode root, int sum, List<Integer> path, List<List<Integer>> ans) {
    if (root == null)
      return;
    if (root.val == sum && root.left == null && root.right == null) {
      path.add(root.val);
      ans.add(new ArrayList<>(path));
      path.remove(path.size() - 1);
      return;
    }

    path.add(root.val);
    dfs(root.left, sum - root.val, path, ans);
    dfs(root.right, sum - root.val, path, ans);
    path.remove(path.size() - 1);
  }
}

```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/path-sum-ii/
How To Read a local JSON File Using Fetch API
Tags: javascript, webdev, beginners, tutorial
Published: 2022-09-24 04:16:10

**How To Read a local JSON File Using Fetch API**

**Can I use Fetch on a local JSON file?**

- The standard method that can be used to read

- JSON files (either locally or uploaded to a server) is the Fetch API.

- Use the same syntax for both. The only difference is the URL

First Create A .JSON file With name test.json

```
{
"countries":[
{
   "name": "Indonesia",
   "capital": "Jakarata"
},
{
   "name": "Philippines",
   "capital": "Manila"
  }
 ]
}
```

Then create JavaScript file give name fetch.js

```
fetch("test.json")
.then(response => response.json())
.then(data => showInfo(data));

function showInfo(data) {
console.table(data.countries);
}
```
Marketing Digital en Guadalajara
Published: 2022-09-24 03:35:09

Hoy en día el [marketing digital](https://segundopiso.mx/) a tomado mas fuerza gracias a la pandemia que nos toco vivir, ya que muchos negocios  y empresas tenían que buscar la solución de llegar a sus clientes para tener ventas, una solución a este problema fue vender en linea, aquí  es donde entra el marketing digital a través del diseño de paginas web, campañas en Google Ads, publicidad en redes sociales, entre otros.
Backwards to go forward
Published: 2022-09-24 03:31:06

I was feeling overwhelmed the last few days with my dev journey- like I was kind of drowning in information and lost. So I decided to start from the beginning again, the basics and fundamentals of JS to get me back on track.

I already feel much better, tackling early concepts like array, basic functions and callbacks, and other beginner stuff. I will succeed at this and need to take on each step like this- one bite at a time with solid knowledge to back it all up.
Day 627 : Real New York
Tags: hiphop, code, coding, lifelongdev
Published: 2022-09-24 03:08:34

_liner notes_:
- Professional : Had pretty much all day free to focus on work. I was able to create a proof of concept for a Web Component that will hopefully replace some React only components. Took a lot of trial and error, but I got it working and put it into a demo application. Also started getting ready for my trip on Sunday.

- Personal : Last night, I got caught up with "Atlanta" and then saw that "Kevin Can F.. Himself" season 2 started and watched some episodes till I fell asleep. Also was thought about my next side project and went through some tracks for the radio show.

![A sculpture of a giant hand coming up out of the ground in a desert of Atacama, Chile with some mountains in the distance.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sp2tozz2vyityxtlbfyr.png)

I am so tired. I've been taking naps. haha Also did some laundry for my upcoming trip. Going to finish working on the radio show prep. Maybe watch some "Kevin Can F.. Himself" and catch up. Since I'll be out again next week, probably won't be posting blogs, but will be updating https://Dwane.in with pics and videos of my trip as usual. Here's to seeing the real New York.

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube hpwdA8gBEK0 %}
Bootcamp vs self-taught
Tags: codenewbie, opinion
Published: 2022-09-24 02:51:03

Learning to code take discipline, and a lot of reading. I first started learning how to code during a college course that wasn't even focused on code, but was still taught to understand the main idea of programming logic with a language.

Python was the language in question and after taking this course I went on my own to learn more about the language and how to use a programming language. This was hard for me since I was left alone not knowing which way to go or how to pick up  techniques to use.

## Bootcamp Learning

This was about the time that I decided that I needed to have a structure learning path to get me ready for what a job may need from a developer.

While most concepts taught in coding bootcamps involve a programming language or two, the major takeaway during a coding bootcamp is learning how to learning.

This is the most powerful tool any developer can have as the language or framework they work with is just the tool. Tools have instruction manuals, and programming languages have documentation.

Documentation is extensive for any language or framework and is where most programming starts when learning a new technology.

As most programming languages can be used the same way, just with different syntax, learning why different technologies exists becomes the real question.

Whether it a web application, embedded system software, mobile development or systems software, a different technology exists for the proficiency that they excel at.

This is the main point of any bootcamp for someone just starting out learning how to code.

## Self-taught coder

Being a self-taught coder myself, many struggles are felt early on with not knowing which way to go or how to even start a project. 

Not having the knowledge of how to use any programming language is only the first barrier. After that, its knowing what language to use and why.

Many programs exist to help self-taught learning and built knowledge enough to do something with, but fall flat when it comes time to choose a project and how to progress or even where to start. 

Without being guided through simple exercises like implementing CRUD functions for a web app, or centering a `<div>` it may be difficult at first where the best place to start is.

Through extra learning and reading up on code projects in active and open development can help build up enough knowledge. This can help implement simple tasks which build into scalable projects later on through trial and error.

## Conclusion

Being a self-taught programming can have tough, but learning from a fast pace code bootcamp can fly by so quickly that it may be hard to pick up the concept of building a project.

Learning where to start a project and how to use a particular technology will be the largest hurdle to overcome in the beginning and will eventually be a constant learning experience.

In the end, no matter how a developer started as a self-taught, bootcamper, or even a university student, all paths while learning how to be a programmer eventually become a self-taught route.
jamstack static website forms
Tags: webdev, html, forms, ssg
Published: 2022-09-24 02:36:04

## jamstack forms

I am going to show you a quick solution on how to quickly add [static website forms](https://fabform.io) to any static website.

As you may know, a static website does not have a backend -- so there are no server-side languages to handle any forms. 

A static site only consists of just (HTML,CSS and Javascript). Static website are also known as jamstack websites.

That begs the question. How can you add a static website form to your website?

![static website forms](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qpaxflv3fszjybbyxjmu.jpg)

Turns out, its quite simple. We will be using a forms back-end service called [fabform.io](https://fabform.io) to add a contact form to our static site.

Simply navigate to fabform.io to create a free account and click on "Create Endpoint". Cut and paste your new endpoint id into the action property of your HTML contact form.

Here is an example HTML contact form for your jamstack ~ static website.

```
<form action="https://fabform.io/f/{form-id}" method="post">
 <label for="email">Your Email</label>
 <input name="email" type="email">
 <button type="submit">Submit</button> 
</form>
```
Feel free to modify your contact form and add any fields you which to collect forms data from.

Just remember to name each html forms field with the name you want to store each field for.

That's all there is to it. You can now publish your jamstack ~ static website as you normally do.

Congratulations! You have a fully working a static website form on up and running on your site.

**Bonus**

If you are creating a new website with the hugo static website generator.

I would recommend you check out these awesome [free hugo themes](https://hugo-templates.netlify.app) that have [static website forms](https://fabform.io) already built into the themes.
Majority Sum - II
Tags: javascript, leetcode
Published: 2022-09-24 02:16:09

```js
/**
 * @param {number[]} nums
 * @return {number[]}
 */

var majorityElement = function (nums) {
  let map = {};
  let comparedTo = Math.floor(nums.length / 3);
  let newArray = [];

  for (let i = 0; i < nums.length; i++) {
    if (map[nums[i]]) {
      map[nums[i]] = map[nums[i]] + 1;
    } else {
      map[nums[i]] = 1;
    }
  }

  for (const key in map) {
    let value = map[key];
    if (value > comparedTo) {
      newArray.push(key);
    }
  }
  return newArray;
};


```
User avatars for your next project in 1 API call
Tags: serverless, cloud, go, aws
Published: 2022-09-24 02:15:18

## Serverless Userpics

Open-source code: [Github](https://github.com/arthtyagi/serverless-userpics)
Try live: [userpics.devclad.com](https://userpics.devclad.com)

## Background?

I had been using Dicebear avatars locally for my app ([DevClad](https://devclad.com)) but then I came across a better set of avatars by Craftworks.design (a free set) and thought I should use them for all my projects.

## Gist of it

So, long story short, I created a Cloudflare R2 bucket, uploaded 100 avatars, created a serverless Go function using Vercel serverless functions and voila!

Run `curl -XGET 'https://userpics.devclad.com/api/getpic'` and instantly get a random user avatar URL.

## Why a URL?

So- why a URL? Why not streamed bytes directly in response?

It works for everyone this way.

✅ **Case 1**: Someone might be simply embedding the image. A permlink of the image is objectively better.
✅ **Case 2**: Save it to your own S3 bucket.

## How does it work

✅ **Case 1**: `curl -XGET 'https://userpics.devclad.com/api/getpic'`
✅ **Case 2**: An example in Python (specifically tailored for Django) that works with [userpics.devclad.com](https://userpics.devclad.com)

``` python
def random_avatar():
    name = str(uuid.uuid4())[:8]
    with open(f"media/avatars/{name}.png", "wb+") as f:
        url = requests.get("https://userpics.devclad.com/api/getpic")
        response = requests.get(url.text, stream=True)
        if not response.ok:
            raise Exception("Could not get avatar")
        for block in response.iter_content(1024):
            if not block:
                break
            f.write(block)
    return f"avatars/{name}.png"
```

That's it. Feel free to open feature requests or whatever.
The repo is here - [github.com/arthtyagi/serverless-userpics](https://github.com/arthtyagi/serverless-userpics)
Global scope and Script scope
Tags: learning, note, javascript
Published: 2022-09-24 02:09:06

## Global scope and Script scope

```
let a = 0; // script scope
var b = 0; // global scope
function c() {} // global scope
```

---

**Global scope**
var and function are contained by the window object. It means global scope.
That's why no need to write like below. Global object(window) can omit to write.

```
console.log(window.b);
window.c();

// We can omit "window"
console.log(b);
c()
```

---

**Script scope**
When we declare variables with let or const.
Those are gonna be script scope.
Generally, script scope is also called global scope, because script scope is similar to ease of use with global scope.
But to be exact it's different.

```
let a = 0;
const b = 0;
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j432mrrj4k8c1dyxqedg.png)
Majority Element -I
Tags: javascript, leetcode
Published: 2022-09-24 02:04:48

```js
const majorityElement_1 = (arr) => {
  let map = new Map();
  let maxOcuuredElement = -1;
  let comparedTo = Math.floor(arr.length / 2);

  for (let i = 0; i < arr.length; i++) {
    if (!map.has(arr[i])) {
      map.set(arr[i], 1);
    } else {
      map.set(arr[i], map.get(arr[i]) + 1);
    }
  }

  for (let [key, value] of map) {
    console.log(key + " = " + value);
    if (value > comparedTo) {
      maxOcuuredElement = key;
    }
  }
  return maxOcuuredElement;
};

// console.log(removeExactlyOneDuplicate([2, 3, 9, 2, 2]));
// console.log(removeExactlyOneDuplicate([8, 5, 1, 9]));
console.log(removeExactlyOneDuplicate([2, 2, 3, 3]));

var majorityElement = function (nums) {
  let map = {};

  for (let i = 0; i < nums.length; i++) {
    if (map[nums[i]]) {
      map[nums[i]] = map[nums[i]] + 1;
    } else {
      map[nums[i]] = 1;
    }
  }

  let max = 0;
  let maxKey = 0;
  for (const key in map) {
    let value = map[key];
    if (max < value) {
      max = value;
      maxKey = key;
    }
  }
  return maxKey;
};


```
Number of Island - I
Tags: javascript, leetcode
Published: 2022-09-24 02:02:43

```js
/**
 * @param {character[][]} grid
 * @return {number}
 */
var numIslands = function (grid) {
  let rows = grid.length;
  let cols = grid[0].length;
  let numberOfIsland = 0;

  if (rows.length === 0) {
    return 0;
  }

  for (let i = 0; i < rows; i++) {
    for (let j = 0; j < cols; j++) {
      if (grid[i][j] === "1") {
        markIsland(i, j, grid, rows, cols);
        numberOfIsland++;
      }
    }
  }
  return numberOfIsland;
};

const markIsland = (i, j, grid, rows, cols) => {
  if (i < 0 || j < 0 || i >= rows || j >= cols || grid[i][j] !== "1") {
    return;
  }
  grid[i][j] = 2;
  markIsland(i + 1, j, grid, rows, cols);
  markIsland(i - 1, j, grid, rows, cols);
  markIsland(i, j + 1, grid, rows, cols);
  markIsland(i, j - 1, grid, rows, cols);
};

console.log(
  numIslands([
    ["1", "1", "1", "1", "0"],
    ["1", "1", "0", "1", "0"],
    ["1", "1", "0", "0", "0"],
    ["0", "0", "0", "0", "0"],
  ])
);

```
Rails: Using Lots of ActionText Inputs on the Same Page
Tags: rails, trix
Published: 2022-09-24 01:49:46

Here's a quick one!

I used ActionText and Trix for a Facebook clone project, but I ran into a problem using multiple Trix input areas for different posts and comments on the same page.

When a user had more than one post you could comment on, commenting on one post would cause some issues if you left that comment before saving it to comment or post elsewhere.

The problem is how Trix handles input using a hidden field that contains the real data you'll be saving to your database. It turns out all the different Trix inputs were all writing to the same hidden input field!

The fix was easy once I was able to figure out the issue: each `rich_text_area` needed to also have its own unique ID, so that Trix could match each unique input with the corresponding hidden field.

Hope that helps someone working with multiple ActionText inputs on the same page!
DSP909- Topics-in-open-source - LAB2
Tags: opensource
Published: 2022-09-24 00:29:39

## Overview
In this lab we were asked to create the fork and clone somebody else project from the [release 0.1](https://github.com/Seneca-CDOT/topics-in-open-source-2022/wiki/release-0.1) list.
After forking we need to create the new branches on the repo which i have created [here](https://github.com/anshul137/ap21-ssg) to work on and add more functionality to it.
We need to convert the SSG project in such so that it can now take both `.txt` files and `.md` files type and parses the data out of md file and convert it into html page.

## Issue
- I have created this [issue 6](https://github.com/a-parris21/ap21-ssg/issues/6#issue-1383140837) on the [Arryell Parris](https://github.com/a-parris21/ap21-ssg) project.

## Description of my Work
To run the code and test it out for the markdown feature you need to use this command `node main.js -i "./files/lab2.md"`.
In his code i have created the new function in the helper.js file which can read the `.md` file type extension and push the data in the array. Additionally I have used conditional statement in his code to check if the file type is `.txt` or `.md`

Arryell Parris release 0.1 was not working as expected. I have created some extra changes in his function to make it work.
After completing all my work in the issue-6 branch I have created the [Pull Request](https://github.com/a-parris21/ap21-ssg/pull/8) from my branch to his main branch.