teleren/devto huggingface dataset:
what is Google dork query
Published: 2021-02-06 11:17:11

A Google dork query, sometimes just referred to as a dork, is a search string that uses advanced search operators to find information that is not readily available on a website.

Google dorking, also known as Google hacking, can return information that is difficult to locate through simple search queries. That description includes information that is not intended for public viewing but that has not been adequately protected. 

As a passive attack method, Google dorking can return usernames and passwords, email lists, sensitive documents, personally identifiable financial information (PIFI) and website vulnerabilities. That information can be used for any number of illegal activities, including cyberterrorism, industrial espionage, identity theft and cyberstalking.

A search parameter is a limitation applied to a search. Here are a few examples of advanced search parameters:

site: returns files located on a particular website or domain.
filetype: followed (without a space) by a file extension returns files of the specified type, such as DOC, PDF, XLS and INI. Multiple file types can be searched for simultaneously by separating extensions with “|”.
inurl: followed by a particular string returns results with that sequence of characters in the URL.
intext: followed by the searcher’s chosen word or phrase returns files with the string anywhere in the text.
Multiple parameters can be used, for example, to search for files of a certain type on a certain website or domain. The Public Intelligence website provides this example:

“sensitive but unclassified” filetype:pdf site:publicintelligence.net

Those search parameters return PDF documents on that website’s servers with the string “sensitive but unclassified” anywhere in the document text.

Access to internal documents can yield further sensitive information. For example, document metadata often contains more information than the author is aware of, such as revision history, deletions, dates and author / updater names.  Because an intruder with the requisite know-how and / or tools can access such information, it’s a good practice to ensure that it is actually removed from documents before they are published or shared. The practice of document sanitization is designed to make sure that only the intended information can be accessed.

In August 2014, the United States Department of Homeland Security (DHS), the FBI and the National Counterterrorism Center issued a bulletin warning agencies to guard against the potential for Google dorking on their sites. One of the first intrusion prevention measures proposed is to conduct Google dorking expeditions using likely attack parameters to discover what type of information an intruder could access.
Deploy a Static Website with Docker and Nginx
Tags: nginx, docker
Published: 2021-02-06 11:12:09

บทความนี้จะเป็นการใช้งาน Docker เบื้องต้น เหมาะสำหรับผู้เริ่มต้นใช้งาน Docker สามารถนำไปใช้สำหรับงานเล็กๆได้ เนื่องจากเป็นบทความแรก เลยขอเริ่มต้นกันแบบง่ายๆ ด้วยการนำ Static Website ไป Run บน Docker มาเริ่มกันเลย

1.Pull Image ของ Nginx ลงเครื่องกันก่อนเลย
```docker
$ docker pull nginx:alpine
```

2.หลังจากมี Image ในเครื่องแล้วลองทดสอบ Run ด้วย
```docker
$ docker run -d --name static-web -p 8080:80 nginx:alpine
```
`-d Run container in background`
`-p Publish a container's port -p จากตัวอย่าง จะทำการ expose port 80 ใน container มาที่ port 8080 บน localhost`
`--name กำหนดชื่อให้ container`

3.ลองดูว่าในเครื่องของเรานั้นมี Container อะไร Run อยู่บ้าง
```docker
$ docker container ls
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS         PORTS                  NAMES
181930d29e68   nginx:alpine   "/docker-entrypoint.…"   10 seconds ago   Up 9 seconds   0.0.0.0:8080->80/tcp   static-web
```
จะเห็นได้ว่ามี Container ชื่อ static-web Run อยู่ สามารถไปที่ Browser ลองพิมพ์ localhost:8080 จะเห็บ Static Website แสดงแบบนี้ โดยจะแสดงหน้า Default ของ Nginx 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ispvqrma3f2y93dcocjw.png)

4.เมื่อถ้าต้องการ Edit หน้านี้แบบง่ายๆ ลองเข้าไปที่ Container ใช้คำสั่งดังนี้
```docker
$ docker exec -it static-web sh
/ # vi usr/share/nginx/html/index.html
```
`exec คือการเข้าไปใน container ที่กำลัง run อยู่`

ลองแก้ข้อความให้เหลือแบบนี้
```html
<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
```
และลอง Reload ที่ Browser อีกครั้งก็จะเห็นข้อความที่เราแก้แบบนี้
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/aqfc1ef6mb9k6pdcraxv.png)

อ้าว! แล้วถ้าไม่อยากเข้าไปแก้ HTML ใน Container แบบนี้ละทำยังไงละ

เราก็ใช้วิธีการ Bind mount a volume เข้าไปเลย โดยทำแบบนี้
โดยก่อนใช้วิธีนี้เราต้องมีไฟล์ index.html ในเครื่องของเราก่อน

```
$ ls
index.html
```
`ls: list directory contents`

และใช้คำสั่งนี้
```
$ docker run -d -v /$(pwd)/index.html:/usr/share/nginx/html/index.html -p:8080:80 —name static-web nginx:alpine
```
`-v Bind mount a volume จากตัวอย่างจะทำการ Bind /$(pwd)/index.html เข้าไปที่ /usr/share/nginx/html/index.html ของ Container`
`$(pwd) คือ full path`

หลังจาก Run เสร็จแล้วไปที่ Browser พิมพ์ localhost:8080 ก็จะเห็นเป็น Output ของ index.html ของเรา โดยตอนนี้เราสามารถแก้อะไรใน $(pwd)/index.html ที่อยู่ในเครื่องของเราก็ได้ หลังจากนั้นก็กด Reload ที่ Browser ก็จะเห็นความเปลี่ยนแปลงตามที่เราแก้ได้เลยทันที

ทั้งหมดนี้ก็เป็นวิธีง่ายๆ ในการนำ Static Website ไป Run บน Docker
Python3 Programming - Exercise 13 - Some built-in functions
Tags: python, beginners, tutorial, programming
Published: 2021-02-06 11:08:14

## Some built-in functions

> We do recommend you check out the [python doc][pydoc-site], see the library reference and click on the built-in functions.

In the previous exercise, `Exercise 12 (Functions)`, we looked into functions and we created a couple of our own. Python comes packaged with some function and these functions are known as the built-in functions.

## Some built-in functions

1. abs(x)
1. divmod(a, b)
1. float(x)
1. int(x)
1. input(prompt)
1. len(x)
1. list(x)
1. max(x)
1. min(x)
1. pow(a, b)
1. print(a)
1. range(start, end, step)
1. reversed(x)
1. round(x)
1. sorted(x)
1. str(x)
1. sum(x)
1. type(x)
1. chr(i) and ord(s)

## Examples

```python
# abs - returns an absolute value of a number
print(abs(2.34), abs(-23.4))

# round - take a number x, rounds it to y decimal places
print(round(23.23567, 2))

# divmod - Take two args and return their quotient and remainder
print(divmod(23, 6))

# pow - take 2 args and returns x raised to the power y
print(pow(2, 3))

# max, min, sum, sorted, reversed
# the above functions are used on iterables
my_list = [7, 2, 4, 5, 1]

print(f"The largest number is: {max(my_list)}")
print(f"The smallest number is: {min(my_list)}")

print(f"The sum of the numbers is: {sum(my_list)}")

print(f"sorted list: {sorted(my_list)}")

# returns a reversed iterator object - castr to a list
print(f"reversed list: {list(reversed(my_list))}")
# [i for i in reversed(my_list)]

# these function does not alter the object

# chr and ord
# chr - returns a character when a number is passed as arg
print(chr(65))  # this are Unicode related

# ord does the opposite of chr
print(ord('A'))

# float, int, str, list, dict, set
# these converts objects to their types
# type returns the (data) type of an object
# len, range
# we have seen these two before, for the size and also looping

# input, print
# we have also seen them before

```

## Practicals

- Implement a function known as `all_f(iterable)` . This function returns `True` if all of the elements of the `iterable` is `True` or the `iterable` is empty, else `False`. This is the same as the built-in `all` function.
- Implement a function known as `any_f(iterable)` . This function returns `True` if any of the elements of the `iterable` is `True` else `False`. If the iterable is empty, return False.
- Implement the function `abs_f(x)` which behaves like the `abs` function, where `x` , is a number.
- Implement a function, `min_max_f` that returns the minimum and maximum numbers in a given list passed as an argument. Don't use the built-in function `min` and `max`.

## Summary

- Built-in functions make working in python much easier and flexible. We don't have to implement our own version of any of those function.
- Built-in functions do not change the object.

#

[pydoc-site]: (https://python.org)
Docker Multi-Stage Builds
Tags: docker, ci, devops
Published: 2023-01-02 21:57:54

---
title: Docker Multi-Stage Builds
published: true
date: 2021-02-06 11:04:50 UTC
tags: docker, CI, DevOps
canonical_url: https://samatkins.me/post/docker-multi-stage-builds/
---

At work, we’re using Docker multi-stage builds to get smaller image sizes. I thought I’d try it out with a small learning project. The headline result is I reduced a Docker image from 305MB to 12.2MB.

```
# before
docker image ls
helloworldapi latest b24c966e9bgg 6 weeks ago 305MB

# after
docker image ls
helloworldapi latest f1f76e06146h 7 seconds ago 12.2MB

```

## Multi-Stage Builds 

How do multi-stage builds work? Every instruction i.e. line in a Dockerfile adds a layer to the image. A common practice was to have a development version of your Dockerfile which included everything you needed and a slimmed down version used for production. With multi-stage builds you don’t need to maintain two Dockerfiles. Instead you can use the syntax `FROM ... AS <NAME>` to name a stage, and then copy that named stage when you want want to use it. Only what is needed is brought across in this `COPY` and all the other layers are discarded. This results in smaller image sizes.

Here’s an example from the learning [project](https://github.com/sam-atkins/helloworldapi) I mentioned earlier. This is the Dockerfile before without using multi-stage. The image size was 305MB.

```
FROM golang:1.15.5-alpine
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o main .
CMD ["/app/main"]

```

This is the Dockerfile using a multi-stage, named as `builder` and used like this `COPY --from=builder /app .` i.e. copy the named stage into the `/app` directory.

```
FROM golang:1.15.5-alpine AS builder
WORKDIR /app
COPY main.go .
RUN go build -o main .

FROM alpine:latest
WORKDIR /app
COPY --from=builder /app .
CMD ["/app/main"]

```

As a result of using this multi-stage the image size is now 12.2MB.

## Named Stages

Stages are not named by default and you can refer to each stage by an integer starting at 0 for the first `FROM`. So if the Dockerfile read `FROM golang:1.15.5-alpine` we could copy it across like this `COPY --from=0 /app .`. I prefer to use names as it makes it more obvious what is happening in the Dockerfile.

## Target a Stage 

How can you use multi-stage builds? When building an image you can target a stage. For example, a build stage named `dev` in a Dockerfile would be built like this:

```
docker build --target dev -t "${DOCKER_REGISTRY}"/${IMAGE_NAME}:"${IMAGE_TAG}-dev" .

```

The example above assumes variables are set for the Docker registry where the image is published, the image name and the image tag.

If the image is published then you can use this in Docker Compose:

```
service-name:
 image: $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_TAG-dev

```

Alternatively, if the Dockerfile and source code are available on your local machine, you can target it like this:

```
service-name:
 build:
 context: path-to-service-name-source-code
 target: dev

```
Find number of digits in range of numbers
Tags: javascript
Published: 2021-02-06 10:43:04

How many digits does it take to assign numbers to 283 employees using numbers from 1 through 283?

```
function findNumberOfDigits(n){
  let count = 0
  for(let i=1; i<=n; i++){
    // ((''+i)).length => count number of digits
    count += ((''+i)).length
  }
  return count
}
```
This function returns the number of digits from 1 to n. n should be entered by the user.

For example: if `n=12`, it returns `15`. From 1 to 12 (1,2,3,4,5,6,7,8,9,10,11,12), there is 15 digits.

`@ncutixavier`
Släpp - autogenerated changelogs for your git repository
Tags: showdev, python, github
Published: 2021-02-06 10:32:14

Hello, devs :)

Let me introduce you a small cli-tool that I have been working on lately - *Släpp* ([Github](https://github.com/0rang3max/slapp)|[PyPi](https://pypi.org/project/slapp/))

![slapp](https://dev-to-uploads.s3.amazonaws.com/i/cm2u5iwhsdqsg17wtb2b.gif)
 
Släpp iterates through your commit history, grabs messages with changelogs and write them into CHANGELOG.md file. It automatically creates tag, depending on type of your release (is it major, minor or just a patch) and pushes tags and edited CHANGELOG to your repo. 
Soon there will be a feature to generate random names for your releases, based on user-defined dictionary.

Släpp is available as python package:
`pip install slapp`

_Looking forward to your feedback and suggestions for improvement ;)_
Frontend Code Review Checklist
Tags: javascript, programming
Published: 2021-02-06 10:29:15

# General
* Look for blocks of code with more than a few lines of code that look similar. Is it possible to refactor to reduce duplication? (DRY)
* Remove unused/unreachable code.
* Remove commented out code.
* Remove console.logs (unless you have strong motivation why you need it).
* Constant values should be replaced with const variables with meaningful names

# JavaScript
* Use const over let (avoid var).
* Handle JS exceptions (JSON parsing,...) and errors
* Handle promise rejections and api errors properly
* Does a function take too many parameters? If there are more than 4 (or some number set by our team), use an object to avoid the hassle of parameter ordering and null values.
* Are values and data cached? Any string, object, etc., should be cached if it is used more than once. (example, memo() in React) Refer [this](https://coderwall.com/p/tyy7lw/function-caching-in-javascript-caching-catching) for detail
* Are variable and function names so short that they are not meaningful at a glance? Longer names (be reasonable, of course) are more likely to be meaningful and self-documenting. Furthermore, searching globally for a longer name will return fewer results, which makes code-digging easier.
* Avoid using nested if/else statements

# React
* Please try keeping components small (single responsibility)
* While adding any function, object as dependency to useEffect hook, check if it is stable (to avoid infinite render loops)
* Avoid state updates in loop
* If new library is used for a feature, check for library size (if lightweight library present then check it out)
* If any event listeners are registered in mounting phase, please unregister those in cleanup effects
* If there are any timers (setTimeout, setInterval) register in mounting phase, please unregister those in cleanup effects
* Does component handle empty, default, error and max out states ?
* If there are any React warnings reported in console, please solve that for example, Provide a key prop with a unique value for each element in array.

# Compatibility
* Check how component/page works under different network conditions
  * Slow and Fast 3G
  * No Network (Offline)
* Check how component/page looks in different browsers (Desktop and mobile)
  * Chrome (must) and incognito (if applicable in your case)
Firefox, Safari
* If using experimental browser feature, check if it supports chrome, firefox, safari for example, **Intersection Observer**

### References
https://github.com/mgreiler/all-about-code-review
https://gist.github.com/bigsergey/aef64f68c22b3107ccbc439025ebba12
https://tech.ebayinc.com/engineering/effective-front-end-code-review/

Thanks guys for reading, let me know in comment section what process/points you guys follow for great Frontend Code reviews. If you like this content please like, share and comment.
Authentication vs. Authorization
Tags: cybersecurity, security, beginners
Published: 2021-02-06 09:53:12

In this article, we will be going over two concepts people tend to confuse in the world of identity and access management. Simply put, authentication validates that users are who they say they are, while authorization permits those users to access a resource.

# What is Authentication?

Authentication is the process of validating that users are who they claim to be. Passwords are one of the most common ways to authenticate a user on a system. If the username matches the password provided by the user, it means the identity is valid, and the system proceeds to grant access to the user.

Other ways of authenticating users include:
* One-time pins (OTP) - These grant access for only one session or transaction.
* Authentication apps - They generate security codes via an outside party that grants access.
* Biometrics - Here, a user presents a fingerprint or eye scan to gain access to the system.

Some systems might require the successful verification of more than one authentication factor before granting a user access. This is called two-factor authentication (2FA) or multi-factor authentication (MFA) and is often used to increase security beyond what passwords alone can provide.

# What is Authorization?

Authorization is the process of giving a user permission to access a specific resource or function in a system. This term is often used interchangeably with access control or client privilege.

Popular authorization techniques include:
* Role-based access controls (RBAC) - They can be implemented for system-to-system and user-to-system privilege management.
* JSON web token (JWT) - This is an open standard for securely transmitting data between parties, and users are authorized using a public/private key pair.
* SAML - This is a standard Single Sign-On format (SSO). Here, authentication information is exchanged through XML documents that are digitally signed.
* OpenID authorization - This verifies user identity based on an authorization server’s authentication.
* OAuth - This allows an API to authenticate and access a requested system or resource.

# Moving Further

To learn more about authentication and authorization concepts, differences, and techniques, check out this [infographic created by LoginRadius.](https://www.loginradius.com/blog/wp-content/uploads/sites/4/2020/06/Authentication-Vs-Authorization-.png)

![infographic](https://www.loginradius.com/blog/wp-content/uploads/sites/4/2020/06/Authentication-Vs-Authorization-.png)

# Authentication and Authorization with Auth0

Auth0 is a flexible, drop-in solution to add authentication and authorization services to your applications. It allows your team and organization to avoid the cost, time, and risk that comes with building a custom solution to authenticate and authorize users. You can read more about Auth0 here <https://auth0.com/docs/get-started>
What's the Difference Between Forward Proxies and Reverse Proxies?
Published: 2021-02-06 09:31:23

Technically forward proxies and reverse proxies are almost exact opposites of each other, but that's where the comparison ends.

For all practical purposes, anyone dealing with forwarding proxies or needing forward proxies in their business need not worry about or even know about reverse proxies.

Let me explain:

Forward proxies function as a proxy for you, the end-user when you are browsing without showing your IP or web scraping without revealing your IP.

Reverse proxies function as a proxy for the servers themselves when the reverse proxy is representing a bunch of servers behind it.

It can be used in load balancing, caching requests, so the serving time is faster, etc.

In fact, behind the scenes, we at Proxies API are a reverse proxy for the millions of servers you never get to access directly. All you ever see if this endpoint which fetches the results automatically for you.
You don't need to know about this to use our service, though, as far as you are concerned, we are a forward proxy representing you to the target website that you want to scrape.
Field validator with delay of Material UI input — ReactJS / Javascript
Tags: react, javascript, angular, node
Published: 2021-02-06 09:27:21

---
title: Field validator with delay of Material UI input — ReactJS / Javascript
published: true
description: We don’t want the errors to come out while we type!
tags: react, reactjs, javascript, angular, nodejs
//cover_image: https://direct_url_to_image.jpg
---

The goal is to have a runtime validation of [Material UI Component](https://material-ui.com/components/text-fields/)‘s input with a third part library ([Validator](https://github.com/validatorjs/validator.js)).
In our example we will check the phone number with a little trick to handle a delay when we are typing.
We don’t want the errors to come out while we type!

```js
import React, { useState } from 'react';
import isMobilePhone from 'validator/libs/isMobilePhone';
import { TextField } from '@material-ui/core';

export const MyForm = () => {
    const [ phoneNumber, setPhoneNumber ] = useState("");

    const validationPhoneNumber = async(phoneNumber) => {
        let res = false;
        if (phoneNumber !== "") {
            await new Promise((resolve) => setTimeout(resolve, 800));
            res = !isMobilePhone(phoneNumber);
            setErrorPhoneNumber(res)
        }
        return res
    }

    const handleSetPhoneNumber = (event) => {
        setPhoneNumber(event.target.value);
        validationPhoneNumber(event.target.value);
    }
    return (
        <TextField
            fullwidth
            variant="filled"
            label="Phone Number"
            value={phoneNumber}
            error={errorPhoneNumber}
            onChange={(event) => handleSetPhoneNumber}
        />
    )
}
```

**validationPhoneNumber** (row 8) is an asynchronous function to handle the delay to check the error. With this logic you have the time to digit and avoid the momentary errors.

First we need to init a variable as *false* with **let** because it will be rewritable (row 9). Then we check if our field isn’t empty because as initial state we don’t wanna any type of error (row 10).

In the next line of code we need to stop code execution and wait with a keyword **await** until the promise is resolved. It will be resolved when the first parameter of **setTimeout** will be done; in this case after 800 milliseconds. This is one of the many techniques for delaying code execution (row 11).

Then we execute the validation functions that we have imported from the external library and we will save in **res** if there is an error or not, which is the opposite of the function result (row 12).

In the next line of code we will save in the component state if the **error** is present. This state will be the **error** props of **TextField** component (row 13 and row 28).
My javascript / tech / web development newsletter for 06-02-2021 is out!
Tags: javascript, tech, webdev, discuss
Published: 2021-02-06 08:49:59

---
title: My javascript / tech / web development newsletter for 06-02-2021 is out!
published: true
description: A roundup of all the best javascript, tech and web development links posted to my linkblog in the past week
tags: javascript, tech, webdev, discuss
---
In this week’s edition:

AWS SSG, Netlify edge handlers, 11ty, FB newsletters, DoctorowOnIP, system design, GCP, Bash, app architecture, estimating projects, Bezos transition, Apple Car/VR/AR, RSS, WebRTC, OSS, cool podcasts...

https://markjgsmith.substack.com/p/mark-smiths-newsletter-06-02-2021

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
How to create multiple accounts on a website using same Gmail ID
Tags: trick, gmail, hack
Published: 2021-02-06 08:45:06

Did you know? You can use same Gmail ID for a website to register multiple times.
For example, if you register on GitHub using demo@gmail.com, you can again register on GitHub using de.mo@gmail.com and you will get all the emails on your same Gmail ID.

How is that possible 🤔? Check the following link:

https://cscode.tech/how-to-create-multiple-accounts-on-a-website-using-same-gmail-id/
Bloggers where do you host images?
Tags: discuss, watercooler
Published: 2021-02-06 08:42:08

I usually upload all blog related images in a separate Google Drive folder and then use public links to add them in my blogs.

How you guys do it? Any other service?
Have you guys tried imgur? How is it?

I have been recently thinking to automate this but Google Drive API is a mess
:-|