teleren/devto huggingface dataset:
Arrays in Ruby
Tags: beginners, ruby, programming, backenddevelopment
Published: 2023-08-19 02:07:02

Today I learned about arrays and their methods in Ruby.

### Creating Arrays

Here are two basic arrays, created by an array literal:

```ruby
num_array = [1, 2, 3, 4, 5]
str_array = ["This", "is", "a", "small", "array"]
```

Created with the `Array.new` method. 2 optional arguments (initial size and default value):

```ruby
Array.new               #=> []
Array.new(2)            #=> [nil, nil]
Array.new(3, 4)         #=> [4, 4, 4]
Array.new(3, true)      #=> [true, true, true]
```
Array.new also supports block:

```ruby
Array.new(3) {|index| index * 2 } #=> [0, 2, 4]
```

Have to be used if default value is hash/array/object/etc. otherwise they'll share same reference:

```ruby
# no!
arr = Array.new(3, {})
arr.first[:a] = 5
arr #=> [{:a=>5}, {:a=>5}, {:a=>5}]

# yes!
arr = Array.new(3) { {} }
arr.first[:a] = 5
arr #=> [{:a=>5}, {}, {}]
```

### Accessing Elements

```ruby
str_array = ["This", "is", "a", "small", "array"]

str_array.first         #=> "This"
str_array.first(2)      #=> ["This", "is"]
str_array.last(2)       #=> ["small", "array"]

str_array[0]            #=> "This"
str_array[1]            #=> "is"
str_array[4]            #=> "array"
str_array[-1]           #=> "array"
str_array[-2]           #=> "small"

```

### Adding and Removing Elements

Adding: `#push` method or the shovel operator `<<`
Removing: `#pop` 

```ruby
num_array = [1, 2]

num_array.push(3, 4)      #=> [1, 2, 3, 4]
num_array << 5            #=> [1, 2, 3, 4, 5]
num_array.pop             #=> 5
num_array                 #=> [1, 2, 3, 4]
```

Adding in the beginning: `#unshift`
Removing in the beginning: `#shift`

```ruby
num_array = [2, 3, 4]

num_array.unshift(1)      #=> [1, 2, 3, 4]
num_array.shift           #=> 1
num_array                 #=> [2, 3, 4]
```

`#pop` and `#shift` can take integer arguments:

```ruby
num_array = [1, 2, 3, 11, 12, 13]

num_array.pop(3)          #=> [11, 12, 13]
num_array.shift(2)        #=> [1, 2]
num_array                 #=> [3]
```

### Adding and subtracting arrays

```ruby
a = [1, 2, 3]
b = [3, 4, 5]

a + b         #=> [1, 2, 3, 3, 4, 5]
a.concat(b)   #=> [1, 2, 3, 3, 4, 5]
```

To find differences between arrays:

```ruby
[1, 1, 1, 2, 2, 3, 4] - [1, 4]  #=> [2, 2, 3]
```

### Basic methods

```ruby
[].empty?               #=> true
[[]].empty?             #=> false
[5, 6].empty?           #=> false

[5, 6, 7].length        #=> 3

[5, 6, 7].reverse       #=> [7, 6, 5]

[5, 6, 7].include?(7)   #=> true
[5, 6, 7].include?("7") #=> false

[5, 6, 7].join          #=> "567"
[5, 6, 7].join("-")     #=> "5-6-7"
```
Day3/100- Exploring cpp and a mini project
Tags: beginners, cpp
Published: 2023-08-19 01:48:54

Hello everyone,

Day 3 of the coding journey has been quite the ride! 🚀

I began by diving deeper into CPP basics, cementing my understanding of the essentials. However, at a certain point, I found myself yearning for something more hands-on and exciting.

That's when I decided to embark on a mini project—hotel management. I started off by following a tutorial, but you know what? I wasn't satisfied with just stopping there. I kicked it up a notch and made the project more complex and challenging.

As I write this, I'm still at it—working hard to refine and expand my project. It's a reminder that coding isn't just about following a straight path; it's about exploring, experimenting, and pushing the boundaries of what we can create.

Remember, embracing those moments of curiosity can lead to some incredible discoveries. So, here's to stepping out of our comfort zones and turning boredom into innovation.

Stay curious,
Sivaraghavi
What is Machine Learning?
Tags: machinelearning, python, programming, beginners
Published: 2023-08-19 01:46:30

Machine learning has a different approach than traditional practice. In traditional programming, we write code to solve a problem and In Machine learning, we feed data to algorithms and algorithms learn from data and create an equation(algorithm) that can be used to predict unseen data.

In this post, we will discuss machine learning, types of machine learning, the use of machine learning, and the limitations of machine learning in simple words.

## Types of Machine Learning Algorithms

There are three types of machine learning algorithms based on the type of training types.

1. _Supervised Learning_
2. _Unsupervised Learning_
3. _Reinforcement Learning_

### Supervised Learning

In supervised learning, we have input and output data, and we train our model to extract features from input data and output data, It’s similar to how we learn in school, we have questions and answers, and we learn on the basis of questions and answers and we can predict answers in the exams based on our learning.

Supervised learning is widely used in classification and regression problems.

Predicting something in categories is called classification and predicting something in numbers is called regression. we will discuss classification and regression in detail in upcoming posts. keep reading.## Use of Machine Learning

Nowadays machine learning is used in almost every field, from defence to agriculture. The aim is to make things easy, faster, accurate and efficient.

### Machine Learning in Agriculture

Machine learning is used in agriculture to predict weather forecasting, soil analysis, crop yield prediction, disease detection, etc.

### Machine Learning in Defense

In defence, machine learning is used in many ways such as face recognition, object detection, speech recognition, threat detection, etc.

### Machine Learning in Healthcare

In healthcare machine learning is used in many ways such as disease detection, drug discovery, medical imaging, etc.

### Machine Learning in Finance

In finance, machine learning is used in many ways such as fraud detection, stock market prediction, loan approval, etc.

## Limitations of Machine Learning

Like every other technology machine learning also has some limitations. Machine learning depends on data, There are many factors which can affect the performance of machine learning models such as data quality, data availability, bias in data, overfitting, underfitting, etc.

There is a saying in machine learning “Garbage in Garbage out”. If we feed garbage data to the machine learning model, it will give garbage output.

## Conclusion

It’s the 21st century and machine learning is everywhere and it’s evolving day by day. It’s very important to understand machine learning and the logic behind it. we will discuss the logic behind machine learning in upcoming posts.

Thanks for reading this post. I hope you like this post. If you have any questions, then feel free to comment below.
XcodeProjectBump: The Ultimate Tool for Automated Version Updates in Info.plist
Tags: opensource, ios, productivity
Published: 2023-08-19 00:45:18

Hello, fellow developers!

Managing the version of an iOS app can often feel repetitive and mundane. Specifically, manually updating version information in the Info.plist isn't just prone to errors but can also be a dent in our productivity. Recognizing this pain point, I introduce XcodeProjectBump.

**🌟 Key Features of XcodeProjectBump:**

🔍 Auto-detects the Info.plist file within your Xcode project.
📈 Seamlessly bump major, minor, hotfix, or build versions.
🍏 Crafted with Swift, leveraging the power of XcodeProj for proficient project manipulations.

**How to Use:**
XcodeProjectBump is designed for simplicity and can be used right from your terminal. For detailed usage instructions and installation, please refer to the GitHub repository.

![screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnp3wzyzxag0k85v7050.png)

If you're keen on contributing or have any feedback, feel free to raise issues or submit pull requests!

🔗 Check out XcodeProjectBump on GitHub
https://github.com/techinpark/XcodeProjectBump
A React library to create 9-slice image surfaces
Tags: images
Published: 2023-08-19 04:09:02

---
title: A React library to create 9-slice image surfaces
published: true
date: 2023-08-19 00:39:00 UTC
tags: Images
canonical_url: https://reactjsexample.com/a-react-library-to-create-9-slice-image-surfaces/
---

# REACT-9-SLICE
 ![A React library to create 9-slice image surfaces](https://reactjsexample.com/content/images/2023/08/Code_2023-08_09-34-40.jpg)

![A React library to create 9-slice image surfaces](https://github.com/dnbard/react-9-slice/raw/master/images/logo.png?raw=true)

React library to create [9-slice image](http://rwillustrator.blogspot.com/2007/04/understanding-9-slice-scaling.html) surfaces. Check [the demo](https://dnbard.github.io/react-9-slice/)!

## Install

```
npm install react-9-slice --save
```

## Usage example

```
import React, { Component } from 'react';
import React9Slice from 'react-9-slice';

class MyComponent extends Component(){
    render(){
        return <React9Slice width={ 256 }
                            height={ 256 }
                            border={ 85 }
                            image="/images/myImage.png"
                            imageSize={{ x: 1024, y: 512 }}>
            HELLO WORLD!
        </React9Slice>
    }
}
```

## API

- `width`, `height` – size of the surface
- `border` – size of the non-scalable parts
- `image` – path to the image (you should provide it yourself)
- `imageSize` – initial size of the image
- `style` – styles for the `children`
- `children` – this element are going to be placed in the center of the surface

## GitHub

[View Github](https://github.com/kanazaya74Raccon/react-9-slice?ref=reactjsexample.com)
Confident Corn: A 24/7 AI-Powered News Aggregator and Publisher
Tags: ai, news, web, automation
Published: 2023-08-19 00:38:48

Hello Dev.to community! 👋

I'm Ilya Gazman, an Android Developer with a fascination for AI and automation. Today, I'm excited to unveil [Confident Corn](https://confident-corn.com), a fully AI-powered news aggregator and publisher that operates 24/7.

**What Makes Confident Corn Unique?**
Confident Corn is not just another news aggregator. It's an end-to-end AI-driven platform that:

- **Crawls the Web**: Using Google search, it fetches top news from various sources, aggregating them into comprehensive insights.
- **Crafts Masterpieces**: Through advanced AI algorithms, it synthesizes the aggregated news into well-crafted articles.
- **Creates AI-Made Images**: Even the images on the site are AI-generated, with prompts crafted by AI for a cohesive visual experience.
- **Publishes Across Platforms**: Confident Corn shares the news on Facebook, Twitter, Reddit, and maybe one day on Dev.to as well :), all autonomously.

**100% AI-Made News, 24/7**
Confident Corn represents a new frontier in news consumption. By leveraging AI, it ensures continuous, unbiased, and personalized news delivery. Whether it's crafting articles or generating images, every aspect is handled by AI, providing a seamless and innovative news experience.

**Join the Future of News**
I invite you to explore [Confident Corn](https://confident-corn.com) and witness the power of AI in revolutionizing news aggregation and publishing. Your feedback and thoughts are essential as we continue to evolve and redefine the news landscape.

Check out [Confident Corn](https://confident-corn.com) and share your thoughts in the comments below. Together, we can embrace the future of news, one AI-crafted article at a time.

Happy exploring! 🌽📰
Sukrutrahane portfolio website created using React
Tags: portfoliopage
Published: 2023-08-19 04:09:08

---
title: Sukrutrahane portfolio website created using React
published: true
date: 2023-08-19 00:33:00 UTC
tags: PortfolioPage
canonical_url: https://reactjsexample.com/sukrutrahane-portfolio-website-created-using-react/
---

## Portfolio Website [sukrutrahane](https://sukrutrahane.netlify.app/)

[![Sukrutrahane portfolio website created using React](https://github.com/sukrutrahane/Sukrut-Portfolio/raw/main/Images/interface.png)](https://github.com/sukrutrahane/Sukrut-Portfolio/blob/main/Images/interface.png)

[View Demo](https://sukrutrahane.netlify.app/)[View Github](https://github.com/sukrutrahane/Sukrut-Portfolio?ref=reactjsexample.com)

## Built With
 ![Sukrutrahane portfolio website created using React](https://reactjsexample.com/content/images/2023/08/Code_2023-08_09-27-42.jpg)

This project was built using these technologies.

- React.js
- Node.js
- Express.js
- CSS3
- VsCode

## Features

**📖 Multi-Page Layout**

**🎨 Styled with React-Bootstrap and Css with easy to customize colors**

**📱 Fully Responsive**

## Getting Started

Clone down this repository. You will need `node.js` and `git` installed globally on your machine.

## 🛠 Installation and Setup Instructions

1. Installation: `npm install`

2. In the project directory, you can run: `npm start`

Runs the app in the development mode. Open [http://localhost:3000](http://localhost:3000) to view it in the browser. The page will reload if you make edits.
Mejora tu productividad con estas extensiones de AWS para Visual Studio Code
Tags: aws, productivity, extensions, vscode
Published: 2023-08-19 00:26:00

Uno de los objetivos como desarrolladores es ser productivos a la hora de codificar, no solo utilizando buenas prácticas en cuanto a código sino también con las herramientas que utilizamos al desarrollar, es por eso que hoy compartiremos algunos de los plugins recomendados que debes tener instalados en tu Visual Studio Code si estás desarrollando algún proyecto con tecnología de AWS.

**AWS Toolkit:** la extensión oficial de AWS para Visual Studio Code, contiene múltiples funcionalidades como:
- Exploración y administración de los recursos de AWS, incluidos objetos de S3, tablas de DynamoDB e instancias de EC2.
- Permite desarrollar, probar y publicar aplicaciones con Elastic Beanstalk.
- Creación, registro e implementación de aplicaciones para Elastic Container Service.
- Brinda plantillas de proyecto para CloudFormation, funciones Lambda y otros servicios de AWS.

![AWS Toolkit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/re5fvi2i9q82z3i6y4qd.gif)

**Serverless Console:** funciona como una interfaz alternativa a CloudWatch enfocada a servicios Serverless, pero no se limita a ellos.
- Los logs se agrupan por proyecto y corresponden a un único servicio.
- Cada stage tiene su propia pestaña.
- El tiempo mostrado (hace 5 minutos, hace dos días, etc…) se muestra en función del timestamp.
- Los logs se pueden agrupar por solicitud.
- Se puede buscar dentro de Log Stream.
- Conexión con DynamoDB para realizar consultas a las tablas por medio de Scan y Query


**Serverless IDE:** agiliza la escritura de plantillas por medio de su autocompletado inteligente.

- Provee soporte para SAM, CloudFormation y Serverless Framework.
- Permite navegar entre definiciones y referencias de los recursos.
- Puede validar plantillas y referencias al igual que propiedades y salidas.
- Brinda un rápido acceso a la documentación de AWS para revisar las propiedades de los recursos dentro de una plantilla.

Y tú, ¿qué otras extensiones conoces? ¡Compártelo!
Using J2V8 on Android: How should I get the function handle of JS?
Tags: java, android, j2v8
Published: 2023-08-19 00:07:26

JavaScript is a powerful language that allows developers to add dynamic and interactive features to their websites and applications. With the rise of mobile development, it has become essential to find ways to integrate JavaScript into native mobile platforms like Android. One popular solution for this is using J2V8, a library that allows you to run JavaScript code on Android using the V8 engine.

When working with J2V8 on Android, one common question that arises is how to get the function handle of JavaScript code. In other words, how can you call a JavaScript function from your Android code? This article will explore different approaches to obtaining the function handle and provide some tips and tricks along the way.

1\. Loading JavaScript code
---------------------------

Before we can get the function handle, we need to load the JavaScript code into our Android application. J2V8 provides a simple way to do this using the `V8.createIsolate()` and `V8.createContext()` methods. These methods create an isolated environment where you can execute JavaScript code.

2\. Evaluating JavaScript code
------------------------------

Once the JavaScript code is loaded, we can evaluate it using the `V8Object.executeJSFunction()` method. This method takes the name of the JavaScript function as a parameter and returns a `V8Function` object, which represents the function handle.

    V8Object v8Object = v8Context.executeJSFunction("myFunction");
    V8Function functionHandle = (V8Function) v8Object;
    

 

Now that we have the function handle, we can call the JavaScript function from our Android code using the `call()` method of the `V8Function` object.

    functionHandle.call(null, null);
    

 

3\. Passing arguments to JavaScript functions
---------------------------------------------

Passing arguments to JavaScript functions is straightforward. You can use the `call()` method with additional parameters to pass arguments to the JavaScript function.

    functionHandle.call(null, "Hello", "World");
    

 

In this example, we are passing two arguments, "Hello" and "World", to the JavaScript function.

Conclusion
----------

Getting the function handle of JavaScript code when using J2V8 on Android is a relatively simple process. By loading the JavaScript code, evaluating it, and obtaining the function handle, you can seamlessly integrate JavaScript into your Android applications. Remember to have fun while experimenting with J2V8 and explore the possibilities of combining JavaScript and Android development!

References
----------

*   [J2V8 GitHub Repository](https://github.com/eclipsesource/J2V8)
*   [V8 JavaScript Engine](https://v8.dev/)
Juggling JavaScript: A Dive Into Variables.
Tags: javascript, beginners, webdev, variables
Published: 2023-08-18 23:31:38


In the world of programming variables serve as the foundational building blocks for storing your data and manipulating it. Below I share what I have learned about this concept.

Exhibit A: **<u>Declaring Variables</u>**
Variables are like boxes, ready to hold all sorts of goodies. JavaScript allows us to declare variables using the **let**, **const**, or even **var** keyword. The difference? let allows reassignment, while const grants us the power to keep constants constant (unchangeable).

```
let firstName = "Tshegofatso"; // Declared variable called firstName and assigned Tshegofatso as value.
const pi = "3.14159"; // This will never change I'm afraid lol
```


Exhibit B: **<u>Variable Naming</u>**
In JavaScript, naming variables is important. Variables should be named in a way that allows us to easily understand what’s inside them. Variable names can include letters, digits, underscores, and a dollar signs. But they can't start with a digit and **cannotContainSpaces**. When a name you have for a variable contains multiple words, we use camelCase (words go one after the other with no space, each word except the first one starts with a Capital letter) this helps you to have readable and neat variable names. 

```
let myFavoriteNumber  = 14 ;
const myHomeCity = "Johannesburg";

```
Exhibit C: **<u>Assigning Values to Variables</u>**
After creating the variable we can give it a value. The equal sign **=** is used to assign a value to our variable. Variables can hold any type of data: numbers, strings, booleans, objects, arrays, and more. Text values are always enclosed in quotes.

```
let name = "Tshego"; 
let height = 163;
const greeting = "Hello, World";
```

Exhibit D: **<u>Constants in Detail</u>**
There will be times when you need to tell the program that the variable can't change it's value throughout the program, this is where constants _**const**_ comes in. Constants must have a value when declared and they cannot change their value.

```
const colour = 'purple';
console.log(colour); // Output to color will always be purple throughout the program
```
 
... And I think that wraps up my summary about variables.
Kesowa - The real truth by drone data
Tags: drones, gis, aerial
Published: 2023-08-18 23:13:41

Kesowa is a leading drone service provider offering aerial mapping, drone survey inspection, route optimization, and more.

Our team comprises a group of boundary-less thinkers, collaborators, and creators who want to look ahead and create impactful futuristic services and solutions.

ARU, our flagship Drone Data management platform, allows you to easily upload, share, and view drone data from any device, anywhere, and anytime.

[https://www.kesowa.com](https://www.kesowa.com)
Day 808 : Working Weekend
Tags: hiphop, code, coding, lifelongdev
Published: 2023-08-18 22:18:57

_liner notes_:
- Professional : I did it! I was able to get the demo application "working". I just need to clean it up and send some data to the front-end. It was enough to allow me to create a blog post to walk through the application showing the new feature. I was able to submit a rough draft for review within time to still take advantage of the half day. Just glad I was able to get the demo functional. In the end, it wasn't too bad. I just had no real experience with websockets and using a new third party SDK.

- Personal : Last night, I pretty much banged my head against the demo application for work for a few hours to get it in a good state. Also bought some tracks from Bandcamp to post up on my social media. Went to bed pretty late.

![A tree with few leaves grown on the edge of a cliff with the mesas in Grand Canyon, AZ, USA in the background.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q408znluy5iy5ops750u.jpg)

So tired. I finally went to a doctor to get a checkup and took blood to do tests to make sure everything is good. Since I was doing blood tests, I had to fast for like 8 hours which mean I had to get up even earlier to make sure I ate enough to last me for the day. Just got back and I'm tired. Going to eat, work on the radio show and probably pass out. We're supposed to have guests on the radio show (https://kNOwBETTERHIPHOP.com) tomorrow and have some stuff I want to work on Sunday (https://untilit.works). Going to be a working weekend. 

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube bdDHEHt9CA8 %}
How to make a Web App and a Chrome Extension communicate using Manifest V3
Published: 2023-08-18 22:06:50

Chrome's Manifest V3 has introduced a refined approach to communication between web apps and Chrome extensions. This update brings forward the use of `chrome.runtime.sendMessage`, replacing the traditional `postMessage`. Notably, Manifest V2 is no longer available. In this guide, we'll explore the straightforward process of adapting to this change and facilitating seamless communication between your web app and Chrome extension.


## Quick Setup Steps

1. **TypeScript Support:**
   If you're using TypeScript, install `@types/chrome` for proper type support of Chrome APIs. This ensures smooth development and fewer errors.

2. **Manifest Configuration:**
   In your extension's manifest file, include your web app's URL in the `externally_connectable` field. This establishes a secure channel for communication.

## Sending Messages from Web App to Extension

```javascript
// In your web app's script

const extensionId = 'your_extension_id'; // Replace with actual extension ID

const message = {
  data: 'Hello from the web app!'
};

chrome.runtime.sendMessage(extensionId, message, callback});
```

## Listening to Messages in Your Extension

```javascript
// In your extension's background script

chrome.runtime.onMessageExternal.addListener(
  (message, sender, sendResponse) => {
    console.log('Received message:', message.data);
  }
);
```

## Embrace Efficient Communication

By adopting `chrome.runtime.sendMessage` and following these simple steps, you ensure effective communication between your web app and Chrome extension. Say goodbye to the old ways and welcome the new era of streamlined messaging. Happy coding! 🚀