teleren/devto huggingface dataset:
[PWN.02] Open Read Write
Tags: pwnable, security
Published: 2022-10-23 08:07:35

### Open Read Write
We **Open** _files_ and **Read** data from _files_, **Write** data into _files_.

In this section, We learn ORW to exploit and get shell command shell. 

Following is ORW Syscall: 

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

Firs, How to open file?:
_file_ is /tmp/file
We have to Push the file path into Stack. 
/tmp/file = 0x6c69662f706d742f65
The above hexadecimal value is written in little-endian basis.
```c
push 0x65
mov rax, 0x6c69662f706d742f
push rax
mov rdi, rsp ; rdi is File name in this code.
xor rsi, rsi ; XOR for setting rsi to 0 means O_RDONLY
xor rdx, rdx ; There is no mode in Open file.
mov rax, 0x05 ; Open file is 0x02.
syscall ; open("/tmp/file", RD_ONLY, NULL)
```

Second How to read file?:
We can write how to read file with code similar to the above.
```c
mov rdi, rax ; We will get fd(file descriptor)[] rax stored in .
mov rsi, rsp ; a variable for read is set.
sub rsi, 0x30 ; Set bufsize to 0x30.
mov rdx, 0x30 ; Data Length is 0x30
mov rax, 0x3 ; Read file is 0x00
syscall ; read(fd, buf, 0x30)
```

Finally, We already know how to write file:
```c
mov rdi, 1 ; fd is set to STDOUT or File name.
mov rax, 0x4 ; Write file is 0x01.
syscall ; write(fd, buf, 0x30)
```

We use **_syscall_** to call kernel functions.
We can't use kernel functions in user mode in general. but we can call kernel function by System call.

There are many **_syscall_** to use so we can find it out more!
[https://faculty.nps.edu/cseagle/assembly/sys_call.html](https://faculty.nps.edu/cseagle/assembly/sys_call.html)
Como enlazar vistas en Pug con ExpressJS
Tags: javascript, webdev, pug, spanish
Published: 2022-12-07 15:21:47

Para poder implementar vistas en ExpressJS, te recomiendo pasar por [este artículo](https://dev.to/maxwellnewage/como-crear-vistas-en-expressjs-2ppe) primero antes de continuar.

## Ya domino el armado de vistas, dame algo mas difícil!
Cuando llamamos a las vistas a través del ruteo de ExpressJS usando pug, nos limitamos a hacerlo sobre una única página. Es lógico pensar que para crear mas vistas, debemos establecer rutas nuevas y llamarlas mediante la url. Pero armando un sitio web, necesitamos que esas urls se puedan llamar directamente desde enlaces en las vistas.

Empecemos armando las vistas!

## Home y Contacto
Crearemos dos vistas pug. Una vista home (views/home.pug):

```
doctype html
html
  head
    title Home
  body
    a(href='#') Enlace a contacto
```

Y una vista Contacto (views/contact.pug):

```
doctype html
html
  head
    title Contacto
  body
    a(href='#') Enlace a home
```

Luego crearemos una ruta para cada vista:

```javascript
app.get('/home', function (req, res) {
  res.render('home');
});
 
app.get('/contact', function (req, res) {
  res.render('contact');
});
```

La vista home debe enlazar a contacto mediante un link y viceversa. Y como estamos dentro del contexto de nuestro servidor, las url que generamos son:

- http://localhost:3000/home
- http://localhost:3000/contact

Entonces para poder usar dicha ruta en nuestras vistas, es tan simple como cambiar el href de nuestros links. Por ejemplo en contact:

```javascript
a(href='home') Enlace a home
```

Y en home:

```javascript
a(href='contact') Enlace a Contactos
```

No necesitamos ni recomendamos usar la url completa dado que puede cambiar tanto de puerto como dirección.

Como ven es muy sencillo, y podemos enlazar todas las vistas que queramos siempre que tengamos el ruteo adecuado en nuestro _index.js_.
Rails: Add a column to a table
Published: 2022-12-07 15:20:37

To add a column to an existing table on Ruby on Rails you would need to create a rails command to generate that migration. Also, there will be an opportunity to name your migration under the context of what you need.
```
rails generate migration AddImageColumnToListings image:string
```
This commands adds the image column to your listings table with the string content. A file would be added to your migrate folder.
```
class AddImageColumnToListings < ActiveRecord::Migration[6.1]
  def change
    add_column :listings, :image, :string
  end
end
```
At this point you can make any changes to the files before running ```rails db:migrate```
Integration vs Unit Testing. ELI5
Tags: programming, webdev, javascript, beginners
Published: 2022-12-07 15:09:00

Unit testing and integration testing are two different types of software testing that are used to evaluate the quality and reliability of a computer program.

Unit testing is a type of testing that focuses on individual units or components of a program, and it is used to verify that each unit or component is working correctly and as expected. Unit tests are typically small and focused, and they are designed to test a specific piece of functionality or behavior of a program.

Integration testing, on the other hand, is a type of testing that focuses on the integration of multiple units or components of a program, and it is used to verify that the different units or components are working together correctly and as expected. Integration tests are typically larger and more complex than unit tests, and they are designed to test the interactions and dependencies between different units or components of a program.

To understand the difference between unit testing and integration testing, imagine you are building a toy house with your friends.

Unit testing:

You might test the individual parts of the toy house, such as the walls, the roof, and the doors, to make sure that they are built correctly and fit together properly.
You might test the windows and doors of the toy house, to make sure that they open and close smoothly and securely.
You might test the different colors of paint that you use to decorate the toy house, to make sure that they are applied evenly and do not run or fade.
Integration testing:

You might test the toy house as a whole, to make sure that all the parts are put together correctly and that the toy house is stable and safe to play with.
You might test the toy house with other toys, such as furniture and dolls, to make sure that they fit inside the toy house and can be used safely and comfortably.
You might test the toy house in different environments, such as outdoors and indoors, to make sure that it performs well and is suitable for different conditions.
Overall, unit testing and integration testing are two different types of software testing that are used to evaluate the quality and reliability of a program. Unit testing focuses on individual units or components of a program, while integration testing focuses on the interactions and dependencies between different units or components.
Convert a Number to Roman Numeral in a Easy Way
Published: 2022-12-07 15:00:03

Roman numerals initially appeared during the time of ancient Rome. They serve only to depict decimal numbers and are not used for mathematical computations. To represent various numbers in the Roman numeral system, symbols are utilized. These symbols resemble English letters very well, with I standing for 1, V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1,000.

Since Roman numerals are frequently ordered from greatest to smallest, divide the number you're converting into groups of thousands, hundreds, tens, and ones, and then convert each group separately. Group form is another name for this distribution. There is another method for implementing it in expandable form, in which each symbol will be changed into its equivalent number form.

Since the tutorial could be a bit confusing, I will use this online [roman numeral converter](https://romantonumber.com/) tool.  I suggest you to check out the website since all the images and screenshots are taken from this website. Lets take an example of number 2023.

[2023 in words](https://www.tonumbers.com/2023-in-words) = two thousand and twenty-three
[2023 in roman numerals](https://romantonumber.com/2023-in-roman-numerals) = MMXXIII

**Group Form**
In the group form, each symbol represents a number which is multiple of 10. As shown in the image below, each valid symbol is highlighted in green.
MM = 2000
XX = 20
III = 3

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8mzh3ynfpqpufoshem5u.PNG)
**Expandable Form**
In the expandable form slight calculation is required. As shown in the image, we just need to convert each symbol into ins numeric form and combine it.
M = 1000
M = 1000
X = 10
X = 10
I = 1
I = 1
I = 1

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/59gz2yk5b25g1lc9bg9y.PNG)
Believe me, the calculation and conversion are not as difficult as they appear. I advise you to look at the website mentioned above and other helpful internet resources to gain further understanding.

_Resources_
[Roman Numeral Converter](https://romantonumber.com/)
[Number to Words Converter](https://www.tonumbers.com/)
Advent of Code 2022
Tags: development, adventofcode2022, c
Published: 2023-02-01 14:58:30

---
title: Advent of Code 2022
published: true
date: 2022-12-07 15:00:00 UTC
tags: Development,AdventofCode2022,C
canonical_url: https://barretblake.dev/2022/12/advent-of-code-2022/?utm_source=rss&utm_medium=rss&utm_campaign=advent-of-code-2022
---

I’m participating in the [Advent of Code](https://adventofcode.com/2022) again this year. We’ll see if I get further than I did last year, which was about halfway before I quit. You can follow my progress in my [GitHub repo over here](https://github.com/barretb/AdventOfCode2022 "GitHub repo over here"). As usual, my solutions are written in C#.

The post [Advent of Code 2022](https://barretblake.dev/2022/12/advent-of-code-2022/) first appeared on [Barret Codes](https://barretblake.dev).
Framework vs Library
Tags: beginners, programming
Published: 2022-12-07 14:57:23

## Framework 
You have to write your code by rules like saving the specific file to a specific directory or using the tag in right place etc. 
If you don't it does not work.
If you use a framework your flow will be controlled by the framework(제어의 역전(IoC, Inversion of Control)).
Everybody uses frameworks because easy to catch bugs and easy to find bugs.



## Library
You bring the tools whenever you want and you can choose how to use it.
If you use a library you can control the library.



## Easy to understand
A framework like you have to go that space, that space has many tools and you have to use tools by that space rules.
A library likes you to bring the toolbox and use it for your purpose(Even if it looks weird).



---
{% embed https://www.youtube.com/watch?v=2Ja7wYIZEtI %}
Nignx ssl certificates error
Tags: nginx
Published: 2022-12-07 14:53:30

Hi Guys,

I have hosted two sites on a single server both are django applcations. I have my one site hosted on the domain and other on the public ip of the server. 


For domain i am using the certificate from letsencrypt and for IP based site I am using the selfsigned certificates from openssl. 

The issue I am facing is that when I hit the site hosted on public ip it loads the certificate of the site hosted on domain.
We are using seperate virtual hosts file for both the sites.

Please help me out I am new to the nginx.
The algorithm used to calculate prime numbers
Tags: algorithms, computerscience, programming, python
Published: 2022-12-07 14:50:30

Here's a coding challenge, find all the prime numbers with a range of numbers. How would you go about this problem? Could you come up with an efficient algorithm to solve this problem? Don't bother because about two thousand years ago a mathematician named ~~Erastosenes~~ ~~Erathosense~~ Eratosthenes developed an efficient algorithm for calculating prime numbers within a given range.

In this article, I will be discussing his algorithm known as **The sieve of Eratosthenes**.

## The algorithm

We are given the number 1 through 10 and we are asked to find all prime numbers within that range. 

```
numbers = [1,2,3,4,5,6,7,8,9,10]
```
One requirement of the algorithm is that the first number in the range should be prime. We have to remove one from the list because it [isn't a prime number](https://www.wgtn.ac.nz/science/ask-a-researcher/is-1-a-prime-number).

```
numbers = [2,3,4,5,6,7,8,9,10]
           ^
```

Take the first prime find all multiples of it and remove them from the list. 

```
numbers = [2,3,5,7,9]
             ^  
```

Now we move to the next number which is 3. Find all multiples of it in the list and remove it.

```
numbers = [2,3,5,7]  
               ^
```

We move to the next prime number check for all multiples of it in the list. Since there isn't any multiple of 5 in the list we move to the next number.

```
numbers = [2,3,5,7]
                 ^
```

We are at the end of the list and there isn't any other number. All the numbers in the list are currently prime. That's why it is called a sieve because it filters all non-prime numbers.

## Implementation

Here's a python implementation of the sieve of Eratosthenes.

```python
# maximum number in the range
n = 100

# prime numbers
primes = []

# list of numbers
numbers = list(range(2, n+1))

while numbers:

    # Assume the first number is prime
    prime = numbers.pop(0)
    # Add prime numbers to the list
    primes.append(prime)

    # remove all numbers divisible by the prime number
    numbers = [ x for x in numbers if x % prime != 0 ]

print(primes)

# [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
```

## Time complexity

The time complexity of the algorithm is `O(n * log(log(n)))`. This means it is almost linear but also depends on the logarithm of the logarithm of n.
Pots & Pans Set Gotham Steel 20 Piece Pots & Pans Set Complete Kitchen Cookware
Published: 2022-12-07 14:48:36

## Gotham Steel 20 Piece Pots & Pans Set Complete Kitchen Cookware

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

## Gotham Steel Pots & Pans
omplete Kitchen In A Box Includes everything you need to fully rig your kitchen and take cuisine and baking to the coming position, including full cookware set with frying kissers, skillets, saucepans, stock pots with tempered glass lids, deep frying, and dish visage with a steamer charger, shindig handbasket, and lid plus a complete PRO incinerating set with cookie distance/ jelly roll visage, loaf visage, muffin drum, square visage and further! El case Que no's coupe treat ulna situation a base an ulna presanction de error informatic que da pore fallecido an Isaac, oven de 21 naoses, el coal quad affected pore divers as problematics, yes que hank vulnerable diversions Derechos fundamentals.
Embodiment Utensil Safe The covering of the appearance is contributed with jewels, the most grounded material on earth which makes it sufficiently sturdy to repulse pith carries out, spatulas, spoons, whisks and to be sure electric blenders while conveying seasons of exceptional, nonstick use.
Burner and Broiler Safe: Viable with gas, electric, and glass cooktops, and stove protected up to a sizzling up to 500° Fahrenheit, covers included!
Remain Cool Handles: The hardened steel handles are ergonomically intended for both righty and lefties and the exceptional Y molded handles we should warm getaway and keeps the handles cool to the touch.
Strong Aluminum Piece: Stepped from a solitary sheet of aluminum in a weighty press guarantee even intensity conductivity and conveyance all around with no man's lands or problem areas.
Contents: This set incorporates an 8.5" sear dish, a 10.25" skillet with a safety glass top, a 1.5-quart sauce container with a treated glass top, a 2.5-quart sauce container with a top, a 5-quart stock pot with top, hardened steel liner rack, 9.5" square shallow dish, 9.5" profound square meal dish with safety glass top, tempered steel broiling bin, liner embed, 12" x 17" XL treat sheet, 9.5" x 9.5" square baking dish, portion dish, 9.5" round baking container, 12 cup standard measured biscuit skillet.
Long-term Assurance - our cookware is worked for quite a long time of purpose and is upheld by a 10-year restricted ensure.
Recipe book excluded - downloadable PDF record will be incorporated.

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

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d300m10hhawfoeqe0w3e.jpg)
[Read More](https://www.specialcookware.online/2022/11/gotham-steel-20-piece-pots-pans-set.html)
Welcome Thread - v203
Tags: welcome
Published: 2022-12-07 14:46:51

---
title: Welcome Thread - v203
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---

![Lionel Richie saying hello on the phone in the music video for "Hello"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jq8ecjl1cldsduashh8u.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Cyber icons lib for vue/react just release v1 (demo available) with 🧡. Lets support opensource by ⭐
Tags: react, vue, svg, opensource
Published: 2022-12-07 14:46:27

Hi friends, after quite a lot of effort I have first version of cyber icons lib for react and vue, wanted to share with you, I have currently +250 svg icons, and Im adding more each week. this is just for free and open source, so far I have made all alone, if you want to contribute to put this also on angular/svelte/etc you can create a PR there, I earn no money with this, but if you can hit the ⭐ star/like button at https://github.com/avastjs/cyber-icons would be very nice for the project. why cyber icons? just to have some different icons for other purposes rather than just enterprise apps, like gaming pages or other stuff, and also because I like futuristic shapes. this is the demo page: https://cyber-icons-demo.vercel.app/. lets support open source projects 💫💙

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hkhdk91j5yj7bz37qjih.png)
ML Roadmap
Tags: machinelearning, python, datascience, ai
Published: 2022-12-07 14:42:22

# ML stack

## Programing Langauges
1. Python
2. R
3. C++
4. SQL
5. Scala

### Libraries
1. Pytorch
2. Pundas
3. Numpy
4. Matplotlib
5. PySpark
6. OpenCv
7. Keras
8. scikit-learn
9. Microsoft Cognitive Toolkit
10.Tensorflow

### Mathematics Required
1. Statistics
2. Linear Algebra
3. Calculus
4. Probability
5. General Physics

#IDEs
1. Pycharm
2. Dataspell
3. Datagrip
4. Clion

###Further tools you must know
1. Excel
\
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2255va11scnl5dkks6yu.jpg)
What is JAMstack, and why you should consider it for your next project
Tags: jamstack, serverless, webdev, javascript
Published: 2022-12-07 14:41:00

## **What does jam have to do with developing?**

Luckily, JAM doesn’t stand for food.

**J is for JavaScript.** As a developing language handling any dynamic programming during the request/response cycle.

**A is for APIs.** Server-side operations are abstracted into reusable APIs and accessed over HTTPS with JavaScript. These can be third-party services or your custom function.

**M is for Markup**

. Templated markup should be pre-built at build time, usually using a site generator for content sites or a build tool for web apps.

In a nutshell, JAMstack is a new way of building websites and apps that deliver better performance, higher security, and lower scaling costs.

## **How does it work?**

**What JAMstack does is generate the HTML once and serve it to all requests. It fetches HTML from CDN, where an HTML file has been pre-built and is ready to be downloaded. No server is involved in the process, and the API does all the heavy lifting.**

To put it visually, it looks like this:

![JAMStack infographic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8lrm1b8d0poj3gqlwhh.png)

What confuses most people is when someone says JAMstack is **static**. You must be asking now what does it mean to be “static”? Does it take “dynamic” server data and “dynamic” user input?

The static JAMstack app is only a fairly generic term.

JAMstack is a general web app without the server part and served with static site generator HTML plus JavaScript. With all that, it’s able to do dynamic things.

Static refers to static assets, for example, JavaScript and Markup from the name, rather than a dumb static page.

## **Why do developers love JAMstack?**

### **The main benefits of JAMstack are better performance, higher security, cheaper scaling, and better developer experience. All pretty valid reasons to start using JAMstack.**

**That’s the JAMstack power.** 

But is the JAMstack just at the top of its glory, or will it become the standard? Read more here.
3 ways to add npm package in chrome extension.
Tags: javascript, chromeextensions, webdev, npm
Published: 2022-12-07 14:39:58

When you try to add npm packages in chrome extension.
Chrome extension show error
`Import path must start with ./ or /`

You might think then how node.js find path ??
When you run npm command. NPM replaces package name with real path.
You need to just find pkg's real path so that Chrome browser will find it.
Real path like this:

`/node_modules/pkg-name/dist/main.js`

I show you 3 different methods, how to add npm packages in your chrome extension?

**Method 1: find Manually**

   First, Go to node_modules directory then
   go to npm package directory and open package.json.
   Find **exports** key value and copy **import** file value or 
    file with .js or .mjs file extension.

   example:

   ```json
   "exports": {
   ".": {
     "require": "./lib/postcss.js",
     "import": "./lib/postcss.mjs",
     "types": "./lib/postcss.d.ts"
   },
   }
   ```

   This is a relative path. Chrome browser cannot find this path.
   We need to convert this into absolute path by joining path.
   `/node_modules/{pkg_name}/{copied_path}`

   Example:
   `/node_modules/postcss/lib/postcss.mjs`
   Now use this file path in place of package_name.

**Method 2: nodejs API**
   Create path.js file and add this line.

```js
const fullPath = await import.meta.resolve("package_name");
const path = fullPath?.match(/(\/node_modules.*)/)[0];
console.log(path);
```

Then add this line inside `scripts` in package.json and run `npm run path`.
`"path": "node --experimental-import-meta-resolve path.js"`,
Copy console output text.
Now use this file's real path in place of package_name.

**Method 2: Automatic find and replace**
   Install other npm package to find and replace
   npm packages' virtual path to real path so that chrome browser will find it.

Install [Path-fixxer](https://www.npmjs.com/package/path-fixxer)

`npm i path-fixxer`

**path-fixxer** provide 3 api to find and fix path.

- **Generate path.json file with absolute path of all dependencies.**

```js
import { pkgPathJson } from "path-fixxer";
pkgPathJson();
```

- **Auto-fix virtual path to real path of all dependencies**

```js
import setAllPkgPath from "path-fixxer";
setAllPkgPath();
```

- **Auto-fix virtual path to real path of one dependency**

```js
import { realPath } from "path-fixxer";
setPkgPath("package_name");
```
For contribute or create new issues, visit github page [path-fixxer](https://github.com/anilkumarum/path-fixxer).
Thanks for reading