teleren/devto huggingface dataset:
4. Operators, Operands, Expression, Operator Precedence 
Tags: java
Published: 2020-12-03 06:04:04

Example of operators
```
        int result = 1 + 2; // addition
        result = result - 1; // subtraction
        result = result * 10; // multiplication
        result = result / 5; // division
        result = result % 3; // modulus
```
# Abbreviating of operators
```
        // result = result + 1;
        result++;

        // result = result - 1;
        result--;

        // result = result + 2;
        result += 2;

        // result = result * 10;
        result *= 10;

        // result = result / 3;
        result /= 3;

        // result = result % 2;
        result %= 2;
```
# Arithmetic operators
+, -, *, /, %, ++, --
# Assignment operators
=, +=, -=, *=, /=, %=, &=, |=, ^=, >>=, <<=
# Comparison operators
==, !=, >, <, >=, <=
# Logical operators
&&, ||, !
# Bitwise operators
&, |, ~, ^, <<, >>, >>>

Another operator is **Ternary Operator**
```
boolean loggedIn = false;
String userStatus = loggedIn ? "User is loggedIn" : "User is not logged in";
System.out.println(userStatus);
```
More details can be found in
[w3schools.com](https://www.w3schools.com/java/java_operators.asp)
[oracle.com](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html)
# Java Operator Precedence
[Link](http://www.cs.bilkent.edu.tr/~guvenir/courses/CS101/op_precedence.html)
How to operator overload in Rust.
Tags: rust, operations, systems, codenewbie
Published: 2020-12-03 05:55:41

In Rust, types that have certain traits implemented for them are able to be added, subtracted, multiplied, divided, and much more from each other.

In order to operator overload custom types one must implement these traits for their types.

The traits in question come from the standard library at `std::ops::*;` and can be implemented by doing the following...

First let's create two structs that we can use.

```rust
struct Foo(i32);
struct Bar(i32);
```
Don't forget to use the traits from the standard library.
(You do not have to use them but for convenience I will import them)

```rust
use std::ops::{Add};

struct Foo(i32);
struct Bar(i32);
```

For the purposes of this I will only show adding. After you learn adding the rest should be easy to implement.

Next let's implement these traits that we just imported for our structs.

```rust
impl Add<Bar> for Foo {
   /// Todo
}
```
Above you can see how we implemented Add for the struct Foo + Bar. Now we just have to add the functionality.

```rust
impl Add<Bar> for Foo {
    type Output = i32;
    fn add(self, b: Bar) -> i32 {
        self.0 + b.0
    }
}
```
That is all for adding now to see how it works.

The first thing that might look odd is the type Output, this is simply because if you have a trait and you want the implementor to be able to add any return type to a function within the trait you have to set the return type to a type you create that the implementor can then go and change.

The other thing that might seem odd is that we are creating a function called add, add is already defined within the Add trait, we are simply adding new code to the inside of it so that it works for out type, to do that we have to create the function within our scope.

Let's see if it works now!

```rust
fn main() {
    let f = Foo(10);
    let b = Bar(20);
    println!("{}", f + b);
}
```

Now when you `cargo r` your program you should get an output of 30!

That is how you operator overload in Rust.
3 Best Tools and Security Protocols for a Successful IAM
Tags: iam, devops, cloud, security
Published: 2020-12-03 05:51:19

Criminal hacking, phishing, and other malware threats are growing at a fast pace. Today, it has become an alarming situation for every organization. Not only does it lead to financial loss, but it also results in brand value loss. To combat this, we need a robust solution like the IAM solution.  Why? Have a look:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rpdk784vynvmvmmlroiz.png)

Now that you’re familiar with the benefits of IAM to your business. Let us move forward and discuss the best IAM tools and security protocols that can help your organization effectively manage complete privacy and cybersecurity concerns. Keep reading.

**Top 3 IAM Tools for Business**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ktoe2e6crtjfl9vsb72o.png)
*Robust Security Protocols for Successful IAM*

There are three significant protocols for IAM that controls data access without hampering operations and productivity.

###Multi-Factor Identification

It is a security system that incorporates multiple authentication methods. It uses different and independent categories of credentials to validate the user’s identity for login, transactions, and other activities.

###Identity Management Assessment

It is crucial to safeguard user identities via an access control mechanism. Enterprises various strategies and assessment services that help in:

###Meeting business goals & objectives

1.Decreasing the risk of identity fraud and insider threat
2.Empowering collaboration and productivity
3.Managing regulatory compliances
4.Improving operational efficiency and cost-effectiveness

###Implementation and Integration

It includes advanced integrations like ML, AI, biometrics, and risk-based assessment across multiple devices and geographic locations. Also, it ensures the safety of organizational data from both external and internal threats.

##Summing Up

With the fully-fledged tools and protocols integrated into your [IAM solution](https://successive.tech/devops-and-cloud-services), you'll get robust security for your business.  An effective and scalable IAM implementation requires excellent domain specialists.

At, [Successive Technologies](https://successive.tech/services/), you will get the best and certified IAM specialists who will take your business to the next level with their security-driven solutions. We help enterprises implement security protocols that manage data access control without hampering productivity. [Contact us](https://successive.tech/contact-us/) to get started.
Hey devs - have you seen this before - parameters done two ways?
Published: 2020-12-03 05:38:28

An honest question.  We find it very very handy to be able to provide arguments to classes, methods and functions in two different ways.  The first is parameters as usual in order.  The second is a single parameter that is an object literal (config object) where the properties match the parameter names.

So we are wondering if any framework out there other than ZIM has this ability. It was tricky to code but we have open sourced it.  I swear - it is so handy and all that use ZIM love it.

```javascript
// traditional parameters in order:
const rect = new Rectangle(100, 100, red, null, null, 20);

// or as a configuration object:
const rect = new Rectangle({
   width:100, 
   height:100, 
   color:red, 
   corner:20
});
```

---

This allows ZIM to provide a lot of parameters - take a look at our docs: https://zimjs.com/docs

I would say, half the time I use one way and half the time I use the other.  That really proves that it is handy.

Cheers!  Any comments or questions are welcome.

---

If you have not checked out the Canvas recently - you simply must!  Here is the [ZIM&nbsp;Dev&nbsp;Site](https://dev.zimjs.com) and some [In-depth&nbsp;Guides](https://drabstract.medium.com/) by Dr&nbsp;Abstract including [Your Guide to Coding Creativity on the Canvas](https://drabstract.medium.com/your-guide-to-coding-creativity-on-the-canvas-ada0996298f6).
JavaScript Console commands other than console.log()

Tags: javascript, webdev
Published: 2020-12-03 05:36:28

Tired of using console.log() for everything while debugging your code? We often print the messages in browser console to debug the wired problems in our codes. But why use only console.log() when we have lot of other commands as well which could make our lives easier.
So here are few console commands we could make use to make our debugging process lot easier.

***
###1. console.error() — 
Sends message to the console window. The message text is red and prefaced by an error symbol.

![Alt text of image](https://miro.medium.com/max/492/1*C0CkdWSxCwUWGOWbRfKQng.png)

###2. console.warn() — 
ends message to the console window, prefaced by a warning symbol.

![Alt text of image](https://miro.medium.com/max/486/1*2xVWh0psPJhRsjTHJg_d1w.png)

###3. console.table() — 
Displays the JSON / Array in table format which is easier to read.

![Alt text of image](https://miro.medium.com/max/1050/1*IRTSjLANsm9AjQgO69o7Bg.png)

###4. console.group() and console.groupEnd() — 
console.group() and console.groupEnd() are used to group the messages.

![Alt text of image](https://miro.medium.com/max/929/1*M57rstRkOa5sABurjjiN9A.png)


> NOTE: The console.groupCollapsed( ) can be used instead of console.group() to make it appear in a collapsed view by default.

###5. console.dir() — 
It displays the JSON in an object visualizer. Makes it easier to inspect properties in the console window.
![Alt text of image](https://miro.medium.com/max/1050/1*S38KtM94uzpEAzTSlWZnUQ.png)

###6. console.assert(expression, message)—
Sends a message to the console window if expression evaluates to false.
![Alt text of image](https://miro.medium.com/max/1050/1*IKH0BSsGalpydGsQuM7ORQ.png)

###7. console.time(‘name’) and console.timeEnd(‘name’) — 
These are used to track time of the codes between them to get executed. It calculates the time that elapses between time and timeEnd, and sends the result (measured in ms) to the console using the name string as a prefix.
![Alt text of image](https://miro.medium.com/max/648/1*_WUbmdaPJWL--qHutY_Kug.png)

###8. console.clear() — 
This command is used to clear the console messages. Just run this command and your console will be clear as new.

And that sums it up..

*Thank you*
What features would you want for a `q` Querystring parser? (e.g. full-text-search, or more?)
Tags: discuss, search, fts, database
Published: 2020-12-03 05:29:50

It might also govern which database you will choose... just MongoDB with full-text-search, or do you need Elasticsearch or something else? Will the data be duplicated?

Not sure about PostGres, MySQL, MariaDB, but SQLite does have an awesome full-text-search engine (e.g. [FTS5](https://www.sqlite.org/fts5.html)).

```sql
CREATE TABLE IF NOT EXISTS files (
  id            TEXT PRIMARY KEY,
  lastRead      FLOAT,            -- +new Date() number; nullable
  rating        FLOAT DEFAULT 0
);

CREATE INDEX IF NOT EXISTS files_lastRead ON files(lastRead);
CREATE INDEX IF NOT EXISTS files_rating ON files(rating);

CREATE VIRTUAL TABLE IF NOT EXISTS q USING fts5(
  fileId,         -- REFERENCES files(id)
  author,         -- ', ' joined Set
  title,          -- ', ' joined Set
  tag,            -- ', ' joined Set
  frontmatter,    -- other searchable frontmatter
  content         -- cleaned markdown-to-plaintext
);
```

But, is only full-text-search really enough? Some of other features I would be dying for includes

- Search by fields
- Number fields
- Datetime fields
- Boolean operators / brackets
- Wildcards
- Fuzzy search
- Language-specific normalizations

{% github patarapolw/qsearch no-readme %}

Personally, I don't care about [field boosting](https://lunrjs.com/guides/searching.html#boosts) much, but it is featured in some search engines.
Как найти что-то в тексте
Tags: nlp, machinelearning, java, scala
Published: 2020-12-03 05:16:52

Найти объект или распознать понятие в тексте — с этого начинается решение большинства NLP задач. Если вы проектируете поисковую систему, создаете голосового помощника или классифицируете пользовательские запросы, прежде всего вы должны разобрать входной текст и попытаться найти в нем [именованные сущности](https://www.wikiwand.com/en/Named_entity), которые могут быть универсальными, такими как даты, страны и города, или специфичными для конкретной модели. Обратите внимание, мы сейчас говорим лишь о тех видах задач, для которых заранее известно, что именно вы ищете или что может встретиться в тексте.

https://habr.com/ru/post/530878/
JavaScript array join() method
Tags: javascript
Published: 2020-12-03 05:12:05

Another Array method, and this time the `join()` method, we have seen this in use in yesterdays [four-digit pincode](https://daily-dev-tips.com/posts/vanilla-javascript-four-digit-pincode-field/).

What it does is it combines an array with a delimiter you specify.

## Using the Javascript join() method

In the most basic example let's convert this array into a string.

```js
const input = ['Hello', 'world', 'how', 'are', 'you'];
const output = input.join(' ');
// 'Hello world how are you'
```

In this example we used a empty string to join the words, we can use anything really:

```js
const input = ['Hello', 'world', 'how', 'are', 'you'];
const output = input.join('👀');
// 'Hello👀world👀how👀are👀you'
```

It can only take one argument which is the separator. This is a optional parameter, if we leave it empty we get the following result:

```js
const input = ['Hello', 'world', 'how', 'are', 'you'];
const output = input.join();
// 'Hello,world,how,are,you'
```

## Real-world example

An example where one would use this, is of course, like in the [four-digit JavaScript input](https://daily-dev-tips.com/posts/vanilla-javascript-four-digit-pincode-field/).

But another really good one is converting titles into slugs.
A slug would be a URL friendly version of your title.

Let's say we have the following title.

```js
const title = 'this is my article title';
```

Notice how this is not an array, so how can we join this into a slug?

First let's split it on each space:

```js
const output = title.split(' ');
// [ 'this', 'is', 'my', 'article', 'title' ]
```

Now we can join this with a dash.

```js
const output = title.split(' ').join('-');
// 'this-is-my-article-title'
```

There you go!
Super awesome function and very useful!

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
100 Days of Code: Day 1
Tags: swift, ios, codenewbie, beginners
Published: 2020-12-03 05:04:01

Today was focused on building a better understanding of **classes**, how they are made, how to **subclass**, why/how they are done.

It may seem obvious, but I have to constantly remind myself to focus on the fundamentals. There's a place that I want to be, but I have to understand and accept that it takes time, hard work, and starting from the bottom up. The last two are easy for me, however I can be impatient with myself.

On March 16th, 2020, I quit my job of 13yrs in Sales Management. At the time, I thought that I had enough FrontEnd WebDev skills to land a junior position. I had money saved up to help me get through for a while, I had interviews lined up, I had networked pretty solidly for several months. I was golden. Then COVID hit. Interviews were cancelled, the labor pool got A LOT more competitive. 

Eventually, thanks to networking and base understanding of [TailwindCSS](https://tailwindcss.com), I was able to pick up some freelance work for a local agency. First project was handed to me with mittens. I was only needed for a week and the project shipped. The second... was different. 

I was brought in with other developers in my area to help with a project that was way under estimated in its hours to MVP, plagued with feature creep, constant redesigns and additional components. It felt like at every stand up, there were new components be built and the repo was getting updated with new tickets all the while the designers acted like it had always been there. I remember the exact moment I realized that I did not have the skills I thought I had. I won't go into the details of it, but it was humbling.

I really enjoyed WebDev when it was something I was doing for myself, not so much when it got down to the nut-cutting. What made it not fun was my lack of fundamental programming and JS skills. So I devoted my time after that project to build my knowledge, but it never clicked. I never had that "A-HA!" moment. I was able to build [this](https://meltonlogan615.github.io/Pong/) in vanilla from scratch. And that's when I decided to move into Swift.

I finally found a WFH job in sales. I'm trying to spend at least one hour every day doing iOS projects. I'm almost done reading the Swift manual. I will not be caught off guard like that again. I want that foundation where when I'm hit with a problem, I can resolve it. Not that I'll immediately know how to (logically, it wouldn't be a problem), but that I can leverage my core understanding to find better answers.

The one thing that I want to express is that nothing just happens. There are no brute facts. Everything comes from a base, a frame, a seed. If you are on the same journey as myself, regardless of language or platform, be patient with yourself. Take one step at a time. If you need to take a step back to get your footing, do it. If you need to spend more time on one subject, do it. Don't beat yourself up. Have fun.

And remember, there is no finish line. It's a constant learning process.
Perfection is a process, not the result
Published: 2020-12-04 03:14:12

---
title: Perfection is a process, not the result
published: true
date: 2020-12-03 04:33:24 UTC
tags: 
canonical_url: https://phongduong.dev/blog/perfection-is-a-process-not-the-result/
---
For me, perfection is that I don't want to have any errors in what I do. It's hard and exhausted to keep everything perfect. When I publish a piece of content, I want it to be perfect. But I always feel something was wrong and afraid someone would point out the error. After all, I just make a little modification and leave it behind because it's wasting time.

I have so much content I want to create. I don't want to stick with a piece of content for too long. When I start creating another piece of content, I try to avoid previous mistakes. I also try something new in it. The joy of creating content is you can try something new and see if it works.

This is the issue that makes me hesitate to create content. I want my content to be useful to my audiences. I also want to create as much content as possible. After trying some ways, I think I should prioritize the quantity rather than quality. Because I can improve my content by creating more.

Now, perfection for me is not the result of a piece of content. It's a process in which I try, modify, and improve pieces by pieces. If I satisfy with a blog post or video, I just publish it and create another. When I find a mistake, I will fix it.
What's the difference between including `new type[]` and not including it?
Tags: java, help, watercooler
Published: 2020-12-03 04:20:36

I know it's needed when making an array with no initial value, but, what's the difference between
```java
char[] carr = {'a', 'b', 'c', 'd'};
```
and
```java
char[] carr = new char[] {'a', 'b', 'c', 'd'};
```
?
บันทึกการโหลด vdo จาก teachable
Published: 2020-12-03 03:49:05

เนื่องจากได้สมัครคอร์สใน teachable เอาไว้หลายคอร์ส โดยส่วนใหญ่จะเปิดดูใน Tablet แต่เวลาเดินทางจะไม่มีอินเตอร์เน็ต เลยต้องหาวิธีดาวน์โหลดเก็บเอาไว้แทน

###สิ่งที่ต้องมี

- Google Chrome และ extension ที่ชื่อว่า [cookies.txt](https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid?utm_source=chrome-ntp-icon)
- โปรแกรม [youtube-dl](https://youtube-dl.org/)

###ขั้นตอน

- Login เข้าคอร์สของ teachable ที่เราต้องการดาวน์โหลด
- ทำการ Export cookies ออกมา

![Export cookies](https://dev-to-uploads.s3.amazonaws.com/i/fs9qf7qojcmsajfo1urs.png)

- เริ่มดาวน์โหลดโดยใช้คำสั่ง

```bash
youtube-dl --cookies cookies.txt -o "./%(chapter_number)s-%(chapter)s/%(autonumber)03d-%(title)s.%(ext)s" <URL-of-the-course-platform>/courses/enrolled/<some-number>
```

###หมายเหตุ
- กรณีมีปัญหาระหว่างการดาวน์โหลด ให้เพิ่ม option `-c` เข้าไปเพื่อให้ดาวน์โหลดต่อจากเดิม
- รูปแบบไฟล์ที่ดาวน์โหลดสามารถดูได้จาก [ที่นี่](https://manpages.ubuntu.com/manpages/bionic/man1/youtube-dl.1.html#output%20template)
Code Smell 41 - Regular Expression Abusers
Tags: oop, webdev, codenewbie, tutorial
Published: 2020-12-03 03:46:50

*RegEx are a wonderful tool, we should to use them carefully and not to look smart.*

# Problems

- Readability

- Maintainability

- Testability

- Intention Revealing

# Solutions

1. Use regular expression just for string validation. 

2. If you need to manipulate objects, don't make them strings. 

# Sample Code

## Wrong

{% gist https://gist.github.com/mcsee/d0e8d1c002a12a9f535ab2fef4440d31 %}

## Right

{% gist https://gist.github.com/mcsee/f3df119d3be0cdfee7fddd6d725f92be %}

# Detection

Regular expressions are a valid tool.
There's not much automated way of checking for possible abusers. A whitelist might be of help.
 
# Tags

- Primitive Obsession

- Abusers

# Conclusion

Regular expressions are a great tool for string validation. We must use them in a declarative way and just for strings.

Names are very important to understand pattern meanings.

If we need to manipulate objects or hierarchies, we should do it in an *object way*.

Unless we have a conclusive benchmark of **impressive** performance improvement.  
 
# Relations

{% post https://dev.to/mcsee/code-smell-06-too-clever-programmer-37lb %}

{% post https://dev.to/mcsee/code-smell-20-premature-optimization-4moe %} 

# More info

[What is in a name](https://maximilianocontieri.com/what-exactly-is-a-name-part-i-the-quest)

# Credits

Photo by <a href="https://unsplash.com/@john_jennings">John Jennings</a> on <a href="https://unsplash.com/s/photos/letters">Unsplash</a>

* * *

> A Perl program is correct if it gets the job done before your boss fires you. 

_Larry Wall_
FREE DSA COURSE
Tags: algorithms, dsa, gfg, beginners
Published: 2020-12-03 03:08:51

Hello Friends !!

Geeksforgeeks is conducting a live course - 11 Weeks Workshop on DSA.

It is absolutely FREE of Cost.

Course includes -
* Lecture from GFG experts
* Weekly Q/A sessions
* Practice questions & Assignments

Course Link - 
https://practice.geeksforgeeks.org/courses/Workshop-DSA

Invitation Code - GFGE7OR5M

Hope it helps many people.
二ヶ月前に買った微分幾何の洋書の座標近傍の向きが日本の慣習と逆で辛いお話
Published: 2020-12-03 03:08:31

## みんなもこっそりやってる数学独学
どうもこんにちは. hiroponです. 皆さんは数学好きですか? 弊学は数学科が無いことで有名ですが, 工学徒ばかりでもつまらないよねと思って私も入学したときからずっと数学を独学してきました.

## hiropon多様体を始める
3年生になる頃には(今年の話だ)一応松坂先生の集合と位相を一周して, 線形代数の素養もある程度身に付いてきたなぁと思えるようになったので(個人の感想), コロナ騒ぎでお休みだった3,4,5月は多様体とかやってたんですよ. 田舎にこっそり帰って, 山の雪解け水が流れる満開の桜の木の下で, 松島先生のやつをね. あれは今年一番のいい体験だったと思います. 松島先生の多様体入門はお堅い本で有名だったし, 読み進めるうちにやはり私の線形代数の素養が足りていないことに気づいて線形代数も平行して復習しながら学んだりしたわけです. 

## 日本流多様体の定義
n次元位相多様体Mの定義は, 
1. Hausdorff空間
2. 任意の点のある近傍が実数空間R^nのある近傍と同相
3. 第二加算公理を満たす(位相の基底の濃度が高々加算, これを仮定しない時もある)

とするのが恐らく一般的なはずです. 特に2については近傍から実数空間の近傍への同相写像が有るわけですが, その向きって普通M -> Rなわけですよ. 普通. 一般的なものから特殊なものへと矢印を伸ばすと言うか, 座標変換を定義する時も可微分写像を定義するときもこの同相写像は使われるので,最初に定めた向きと一生付き合っていくわけなんです. そんな基礎を学びながら, 多様体上の微分を定義する程度のほんの触りのところで授業が始まってしまったため, それからは夏休みまであまり出来ませんでした.

## 一般相対性理論をやりたくなった
夏休み後半あたりから, 急に一般相対性理論をやりたい欲が強まってきました.なにせ, 物理学も本当にゆっくりですが色々やっていたので. 特殊の方は持っていた電磁気の教科書の最後にあったので前期の授業の合間にMaxwell方程式と一緒にじっくり学んで(でも四元化忘れたので絶対に復習が必要. しかもまだ物質中の電磁気やってないが), 一般の方に興味が出てきたわけですね. 素人が学びやすいコンテンツは意外と洋書のほうが多いので, 一般相対性理論の洋書を漁っていたら見つけたんですよ. サムネイル画像のやつです. "An Introduction to Riemannian Geometry - With Application to Mechanics and Relativity". タイトルが完全に私の求めていたそれだったので, 10月はじめに8300円で新品を購入(手痛い出費), やってやるぞと意気込んでいた所で事件は起きたのです.

## 同相写像の向きが逆?
なんと, 先の定義の2で使われる同相写像の向きがφ:R^n -> Mだったんですよ.そのせいで松島先生の本で培った諸々の定義に対する直観みたいなものの入力を全部逆向きに考える必要が生じて, 出鼻を挫かれたわけです. まさか逆向きに定義するやつはおらんやろと思っていたので正直驚きました... この定義のせいで松島先生の本で学んだ時のままで考えると色々合わなくなりますから, 本当に面倒で辛い. まさか日本流以外の定義があっただなんて, 初心者には辛い. 下は証拠画像です.
![証拠画像](https://dev-to-uploads.s3.amazonaws.com/i/b0nk6nvylyam4wfix5gr.png)

## 線形代数再び
それだけじゃなくて, introductionというのは微分幾何へのintroductionであって外積代数とかテンソルへのintroductionではないので, それらについては一応定義はしてあるけれど他の本で一度ちゃんと学んでることが前提という暗黙の了解がひしひしと伝わるんですよ. お陰で今でも手元の線形代数の本が手放せないです... 学部卒業するまでに線形代数を完全に理解したい... いつも線形代数で躓くし, 先にやるべきは微分幾何で背伸びすることじゃなくて線形代数をきちんと理解することですね. 後輩の皆さんは背伸びしないで線形代数極めましょう. 行列で学ぶ算数の話じゃなくて, 線形代数の方です. 私みたいに苦労しないようにです.