teleren/devto huggingface dataset:
Domains in NFT
Published: 2022-01-09 12:15:23

One of the benefits of domain in NFT is that it doesn't need a physical presence. In the event that you are not close enough to a store, you can still purchase Domain from your home, laptop or some other remote location. This is significant for people who cannot make it to stores no matter how hard they try because they have a disability or some other ailment. For these people, ordering items online has been a godsend because this does not require any physical contact from them.

The second benefit is that many of these sites offer more competitive rates than stores do and quality assurances on their products. For example, one site offers a variety of items at a very low price while another site sells itself with the quality of its products.
DOMAIN: [ZHSUICEL](https://www.zhsuicel.com/)
The third benefit is that at times such websites have incentives that make it easy to get certain deals. This is not always the case but there are some websites where you can buy items at a reduced rate in addition to receiving bonuses or special privileges by spending more money or after making purchases on other sites. Sometimes, this happens just because the person who owns the website wants something which they do not have in stock and they want you to pay for it so they can sell it to someone else. And this makes them look good when they later sell it on other sites.
How prepared statement prevent SQL Injection ?
Tags: programming, security, sql, go
Published: 2022-01-09 12:47:00

## Motivation
Have you ever heard about sql injection ?. For the nutshell sql injection performed by user/client by *injecting additional sql query to gain access to your system that you built*. consider you have a database table with 2 field username and password to authenticate user to login into you system. You also provide a backend to query the user's data to database and then you construct string query like this.
```
sql := fmt.Sprintf("SELECT * FROM users WHERE username = '%s' AND password = '%s'", username, password)
```
with this query, the system will be hacked by an irresponsible person.
## How to prevent using prepared statement ?
let say that an irresponsible user send username = `user' or '1' = '1` and password = `pass' or '1' = '1`. The result of concatenation of that sql query will be.
```
SELECT * FROM users WHERE username = 'user' or '1' = '1' AND password = 'pass' or '1' = '1'"
```
What ever username and password that user will be passed to backend always makes that query resulting success.
So to avoid this, we need to use prepared statement.
```
stmt, err := db.Prepare(`SELECT * FROM users WHERE username=? AND password=?`)
row = stmt.QueryRow(username, password)
```
*Prepared statement will treat the username and password input always as an argument not as a query statement*. So the user password is literally `pass' or '1' = '1`. Prepared statement will pre compiled the string query with the placeholder. Then the argument will be placed later on when you are using that precompiled prepared statement.
React Native- Theming made easy(2022)
Tags: reactnative, theming, react, darkmode
Published: 2022-01-09 12:37:28

### GitHub Link: 
https://github.com/KJ-GM/theme-csx

---
> A React Native theming framework that makes it easy to create themeable components.

# Features

- Similar to standard react native styling, but with additional props that can be added to make it themeable.
- Can be implemented for Views + Texts + Images + Icons...
- Light & Fast
- Expo & ReactNative
- Typescript & JavaScript 

## Installation

```sh
npm install theme-csx
```


```sh 
yarn add theme-csx
```

## Get Started - _Three Steps:_

> **StyleSheet**

- Is used in the usual styling format, but now you have additional props to make style themeable.

> **T() Function**

- Apply **only** your themed styles using the T() function wrapper.

> **appearanceHook**

- Use the appearanceHook to switch theme from anywhere in your app.

## Usage

```js

// Styles
import { StyleSheet, T, appearanceHook} from "theme-csx";

// Components 
import { Text, View } from 'react-native';
import { Button } from '@components/atoms';

const DemoComponent = () => {

// Theme switch
const switchTheme = () => {
appearanceHook.switch(appearanceHook.activeTheme === 'dark' ? 'light' : 'dark')
}

return (
   <View style={T(styles.THEMED_CONTAINER)}>
   
      <Text style={styles.NORMAL_TEXT}>Hey, I am normal text</Text>
      
      <Text style={T(styles.THEMED_TEXT)}>Hey, I am themed text</Text>
      
      <Button text={'Switch theme'} onPress={switchTheme} />
   
   </View>
)}


const styles = StyleSheet.create({
    THEMED_CONTAINER: {
    flex: 1,
    backgroundColor: 'white',
    backgroundDark: 'gray', // backgroundDark porp was added to make it themeable
    alignItems: 'center',
    justifyContent: 'center',
   },
   NORMAL_TEXT: {
   fontWeight: 'bold',
   fontSize: 14,
   color: 'green',
   },
   THEMED_TEXT: {
   fontWeight: 'bold',
   fontSize: 14,
   color: 'black',
   colorDark: 'white'  // colorDark porp was added to make it themeable
   },
})

```
## Theme Types:


> TViewStyle:

- Has the following extra props: _backgroundDark_, _borderDark_ 

> TTextStyle:

- Has the following extra props: _colorDark_, _backgroundDark_, _borderDark_ 


> TImageStyle:

- Has the following extra props: _tintColorDark_, _backgroundDark_, _borderDark_ 

> appearanceHook.switch():

- Has the following options: _system_, _light_, _dark_ 

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

Apache-2.0 License
[MongoDB Submission Post Placeholder Title]
Tags: atlashackathon
Published: 2022-01-09 12:18:18

[Instructions]: # (To submit to the MongoDB Atlas Hackathon on DEV, please fill out all sections.)


### Overview of My Submission
[Note]: # (Please make sure the project links to the appropriate GitHub repository, and includes the [Apache-2 permissive license](https://www.apache.org/licenses/LICENSE-2.0)  and README.)


### Submission Category: 

[Note]: # (E-Commerce Creation, Prime Time, Action Star, Automation Innovation, or Choose Your Own Adventure)


### Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)


### Additional Resources / Info

[Note:] # (Be sure to link to any open source projects that are using your workflow!)

[Note:] # Screenshots/demo videos are encouraged!

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any. Prizes for winning projects with multiple collaborators will be sent to the person who posts this submission and they will distribute the prize evenly.)

[Reminder]: # (Submissions are due on January 13th, 2022 @ 11:59 PM PT/2 AM ET on January 14th, 2022/6 AM UTC on January 14th, 2022).
Machine learning explained in 1-minutie videos!
Tags: machinelearning, datascience, ai, videos
Published: 2022-01-09 11:58:07

---
title: Machine learning explained in 1-minutie videos!
published: true
description: YouTube channel which explains machine learning concepts in videos of length 1 minute!
canonical_url: https://www.youtube.com/channel/UCLwgYZJ5ieGQAmbWjpNSc3g
tags: machinelearning, datascience, ai, videos
//cover_image: https://direct_url_to_image.jpg
---

YouTube channel which explains machine learning concepts in videos of length 1 minute! Check it out here: https://www.youtube.com/channel/UCLwgYZJ5ieGQAmbWjpNSc3g
Setting my bash prompt for WSL
Tags: devjournal, programming, linux, devops
Published: 2022-01-09 11:55:36

This is just a dump of my settings for bash prompt for my WSL terminal. I didn't like to show the whole path since it takes up the whole line already but I do want to see the directory where I'm currently at.

Appended this to the bottom of **~/.bashrc** and then re-opened my terminal.
```bash
$ vim ~/.bashrc

export PS1="[\[\e]0;\u@\h: \W\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\] \W\[\033[00m\]]$ "
```

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

Also, the **desktop** and **dloads** are aliases I added to the same file.
```bash
$ addalias

alias addalias='sudo vi /home/joseeden/.bashrc'
alias desktop='cd /mnt/c/Users/Eden\ Jose/Desktop'
alias dloads='cd /mnt/c/Users/Eden\ Jose/Downloads'
```
1041. Robot Bounded In Circle
Tags: java, 100daysofcode, algorithms, programming
Published: 2022-01-09 11:54:08

# [Description](https://leetcode.com/problems/robot-bounded-in-circle/)

On an infinite plane, a robot initially stands at `(0, 0)` and faces north. The robot can receive one of three instructions:

- `"G"`: go straight 1 unit;
- `"L"`: turn 90 degrees to the left;
- `"R"`: turn 90 degrees to the right.

The robot performs the `instructions` given in order, and repeats them forever.

Return `true` if and only if there exists a circle in the plane such that the robot never leaves the circle.

## Example 1:

```
Input: instructions = "GGLLGG"
Output: true
Explanation: The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0).
When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.
```

## Example 2:

```
Input: instructions = "GG"
Output: false
Explanation: The robot moves north indefinitely.
```

## Example 3:

```
Input: instructions = "GL"
Output: true
Explanation: The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0) -> ...
```

## Constraints:

- `1 <= instructions.length <= 100`
- `instructions[i]` is `'G'`, `'L'` or, `'R'`.

---

# Solutions

## Solution 1

### Intuition

if back to start point or direction is not to up/north after one set of instructions, it means it returns true

### Code

```java
class Solution {

    private final int[][] DIRECTIONS = new int[][] {
            { 1, 0 }, // up
            { 0, 1 }, // right
            { -1, 0 }, // down
            { 0, -1 }// left
    };

    public boolean isRobotBounded(String instructions) {
        // start point
        int x = 0, y = 0;
        // default direction index is 0, means go up
        int index = 0;
        for (char instruction : instructions.toCharArray()) {
            switch (instruction) {
                case 'L':
                    // index = 3 means go left
                    index = (index + 3) % 4;
                    break;
                case 'R':
                    // index = 1 means go right
                    index = (index + 1) % 4;
                    break;
                default:
                    // move towards direction
                    x += DIRECTIONS[index][0];
                    y += DIRECTIONS[index][1];
            }
        }
        // back start point or direction is not go up
        return x == 0 && y == 0 || index != 0;
    }
}
```

### Complexity

- Time: O(n)
- Space: O(1)
Discoveries in Ruby(and Rails): Case equality operator
Tags: ruby
Published: 2022-01-09 11:52:35

Ruby provides mechanisms for controlling the control-flow of a program. They consist of the if-statement families, `if`, `elsif`, `else`, and `unless`. Along with `case/when`.

_“The basic idea of the case/when structure is that you take an object and cascade through a series of tests for a match, taking action based on the test that succeeds.”_. Black, D. A., &amp; Leo, J. (2019). The well-grounded Rubyist. Manning. 

A typical case statement looks like this

```ruby
tool = "google"

case tool
when "google"
   puts "tool is google"
when "basecamp"
   puts "tool is basecamp"
else
  puts "unknown tool"
end
```

Every ruby object has a _case equality_ method, called `===`, triple equal sign, sometimes called as _case subsumption or threequal operator_

instead of doing `when tool.=== "google"`. The `when "google"` keyword provides a syntactical sugar over the previous approach.

The threeequal operator is defined everywhere on every built-in class. You can also implement in classes that you define.

Let's define a `Car` class.

```ruby
class Car
  attr_accessor :brand, :type
  def initialize(brand, type)
    self.brand = brand
    self.type = type
  end

  def ===(other_car)                               
    self.brand == other_car.brand
  end
end
```

Now, we can use them along with case/when.

```ruby
ford = Car.new "Ford", "F-150"
jeep = Car.new "Jeep", "Wrangler"
tesla_model_x = Car.new "Tesla", "Model-X"
tesla_model_y = Car.new "Tesla", "Model-Y"

case tesla_model_x
when ford
    puts "It's a ford"
when jeep
    puts "It's a Jeep"
when tesla_model_y
    puts "Both are Tesla made"
else
    puts "unknown manufacturer"
end
```

running this through a ruby session, we get the following 

```
Both are Tesla made
=> nil
```

Underneath, the ruby interpreter makes a call to the `===` method on the object, which we defined inside the `Car` class

```ruby
  def ===(other_car)                               
    self.brand == other_car.brand
  end
```

With tripleequal sign operator or case subsumption operator you can allow your classes to work elegently with Ruby's case/when control-flow operators.

Thanks for reading, and Happy Coding.

### Resources
- [The Well-Grounded Rubyist](https://www.goodreads.com/book/show/3892688-the-well-grounded-rubyist)
CryptoPals Crypto Challenges Using Rust: Detect AES in ECB mode
Tags: rust, programming, cryptography
Published: 2022-01-09 11:32:45

This is [Challenge 8](https://cryptopals.com/sets/1/challenges/8) of [Cryptopals](https://cryptopals.com) challenges implemented in Rust language.

## Context
We're given a [file](https://cryptopals.com/static/challenge-data/8.txthttps://cryptopals.com/static/challenge-data/8.txt) which lists a bunch of hex-encoded ciphertexts. One of these texts is encrypted with AES-128 in ECB mode. We have to detect which one is it. I recommend to see [Challenge 7](https://dev.to/thenvn/cryptopals-crypto-challenges-using-rust-aes-in-ecb-mode-9bl) if you haven't yet.

Remember that AES-128 divides message into 16 byte blocks before encrypting. In ECB mode each block is encrypted seperately. Therefore - _the same 16 byte plaintext block will always produce the same 16 byte ciphertext_. We'll exploit this property of ECB mode.

Given the ciphertext, the more number of identical 16-byte blocks, the higher the probability of it having encrypted in ECB mode. Because that means (most probably) the text message contained some identical phrases/blocks that were repeated. And these repeated phrases/blocks encrypted to exactly same ciphertext because of nature of ECB.

```
...and there was yellow submarine...yellow submarine sank in...
                 |------ECB-----|   |------ECB-----|
              ...a733hj32hbczxsbv...a733hj32hbczxsbv....
```

## Code
In code we basically loop through each hex string. Convert it to bytes then divide these bytes into 16-byte blocks. Then count number of identical blocks among these. The hex-string that corresponds to max number of identical blocks is encrypted in ECB mode.

```rust
use hex;
use std::collections::HashSet;
use std::fs::File;
use std::io::{BufRead, BufReader};

pub fn detect_aes_ecb_encryption(path: &str) -> (usize, usize) {
    let file = File::open(path).expect("Error reading file!");
    let lines = BufReader::new(file).lines();
    let mut i_line: usize = 0;
    let mut max_identical_blocks: usize = 0;

    let mut n_identical_blocks: usize;
    for (i, line) in lines.enumerate() {
        let hex = line.unwrap();
        // Hex line to bytes vec
        let bytes = hex::decode(hex).unwrap();

        // Divide bytes into 16 byte blocks (&[u8] blocks)
        let blocks: Vec<_> = bytes.chunks_exact(16).collect();

        // Get unique blocks
        let unique_blocks: HashSet<_> = blocks.iter().cloned().collect();

        // No. of identical blocks detected
        n_identical_blocks = blocks.len() - unique_blocks.len();

        // Cipher containing most identical blocks is more likely to be
        // ECB mode encrypted
        if n_identical_blocks > max_identical_blocks {
            max_identical_blocks = n_identical_blocks;
            i_line = i;
        }
    }

    (i_line, max_identical_blocks)
}
```

And this is it. We've concluded Set 1.

See code on [Github](https://github.com/theNvN/cryptopals-crypto-challenges/blob/master/src/set_1_basics/c8_detect_aes_in_ecb_mode.rs)

Find me on:
Twitter - [@heyNvN](https://twitter.com/heyNvN)

[naveeen.com](https://naveeen.com)
2021 review and 2022 goals
Tags: webdev
Published: 2022-01-09 11:30:41

Theoretically I should have done this last week, but making fireworks felt more timely.

## 2021 review
2021 was my year of really making effort to reach my goal. Which was to have an offer of a dev job by the end of the year - I didn't have to have started it, I just needed an offer. Which gave me a bit more time.

I also wanted to learn React. I'd bought a course in the Black Friday sale, but December was so crazy at work (I was working 11 hour days and still not getting everything done) so it was not the time to learn something new. January was spent recovering from December. From February I spent five months doing React every day. Until I went mad and dropped it to six days a week.

I learnt a lot of React in that time. And then stopped doing it for four months and consequently forgot all the advanced stuff I was just starting to get my head around.

I ended up starting a dev job in November! Which I will talk about once (if?) I've passed probation in February.

## 2022 goals
2021 was a hard year. Work was so busy (and had been since June 2020) with no let up, which was unusual. And I put a lot of pressure on myself to learn a lot of things and get a job. So this year I'm taking things easy and I have no set goals.

Outside of work I will probably do some coding, but it won't matter if I don't. Spending all my free time coding for a couple of years means I'd like to spend some of my free time doing other things. Things that I used to do with my free time that I've forgotten exist, never mind enjoy.

The coding things that I may do, but are not limited to are:
- Using Advent of CSS and JS to try out new things. Things that are used a lot and/or loved a lot in the State of CSS and JS surveys are on my list. And Remix since everyone is talking about it.
- Some more game tutorials with Lua and Love2D since I loved the one I did.
- Trying out some more programming languages since it's nice to do something different.
- Get involved in Open Source. I have some bookmarked that I use and use languages I know, so they would be fun to contribute to.
- Do some more coaching at Codebar. I should be able to get some in this month as I'm not going out due to Covid worries (everything always happens on the same evenings).
- Blog every week. I still have plenty of things I want to talk about.
Suggestion for Database Finalization
Tags: mongodb, postgres, mysql
Published: 2022-01-09 11:15:41

Hi
I am looking for advice and suggestion for database selection for an application i am developing

First of all i m confused about which database to use
my application has several functions and features

its esports + onling gaming + gaming social media + community( groups , pages, audio rooms)

it has money transactions ( in and out ) + virtual currency + wallets + as well

I selected mongo db but i am confused after more research.
I dont know my data is relational or non relational

Factors to Consider
1. Concurrency ( 100 k Users) . 2 Fast data load ( read / write ) 3. Low server cost ( I am going to use VPS under $ 50/Month). No budget for cloud.


DB selections are 
1. MySQl, 2. MongoDB, 3. Postgres, 4. Neo4j 5. Cassandra 6 ArangoDB
Testability and the DB record
Tags: testing
Published: 2022-01-09 11:07:52

In her [Explore It? Explore It!](https://www.youtube.com/watch?v=9FKY1Is0lgs&ab_channel=ElisabethHendrickson) video, Elisabeth Hendrickson, author of the awesome book [Explore It!](https://www.booktopia.com.au/explore-it--elisabeth-hendrickson/book/9781937785024.html?) talks about observation, and how quality observation requires using all your resources from multiple sources to find out what actually happened. 

She lists the below as some of the places you would look to observe changes
- Access to internal storage
- Application telemetry [which prints out to the Network and Console tab on Dev Tools for example. Is it appropriately detailed for the tester?]
- Diagnostic tools
- Consoles
- Logs [for example the Terminal]
- Monitoring tools (OS, Network, etc)

I want to talk about database records - or specifically, making them as easy for non-devs to view as the devs. It requires a little dev work, but you can just splash it up there first, and then make it pretty later. The easier to read, the easier to work with! 

In particular, I find looking at the records of each individual entity on the administrative interface of platforms I've worked on helpful. Database records are created when a website is closed, so it's neat to be able to track the creation on a nice UI.

When I do 'manual testing', I'm using basically one user at a time, and so, that's the view I need. Combined with the Console Network tabs of the Dev Tools, the Terminal tab, and the user view(s), you start to get a holistic view of what's actually happening. 

I think it's an aspect of testability, to have records (nearly) as easily viewable by testers, and product/project people as they are by developers.

Back in Level 1 Tech Support, I relied on this record view heavily, and I find it just as helpful now.

Although it only works if the relationships are recorded in an up-to-date display.

So how do you find records shown on the user view that might be missing on the admin view? Open up a user view, and check off entities as you find them that are also on the admin view. Don't forgot to check that it's linked to the most recent version of each entity, if there have been updates, as may happen if there have been major changes to the application.

This can make testing more efficient over time, while maintaining accuracy.