teleren/devto huggingface dataset:
MySQL/MyBatis | Using Dynamic Query
Tags: mysql, mybatis
Published: 2021-11-24 15:48:58

## 🍞 Context
It is used to join and look up tables corresponding to a service called A. B and C services will also be added for commonization later. A, B and C services should all be commonized so that they can work in a single query.

Suppose that the table has `all_hist`, `a_request`, `a_response`, `b_request`, `b_response`, `c_request`, `c_response` that corresponds to each service.


## 🥫 Solution

If there is a variable that flags in the `DTO`, you can add a condition to check the variable in the SQL statement `FROM` clause. Suppose `ReqDTO` has a variable called `type` that acts as a flag. You can use `<choose>`, `<when>` in the `From` clause as shown below.

```sql
SELECT *
FROM all_hist ah
<choose>
    <when test="type != null and type == 'A_REQUEST'">
        , a_request areq, a_response ares
    </when>
</choose>
```

I'll compare it with the code before and after the modification.

### Before

```sql
<select id="selectList" parameterType="ReqDTO" resultType="ResDTO">
    /* allHist.selectList */
    SELECT ah.id AS id,
        areq.name AS name,
        ares.ymdt AS ymdt
    FROM all_hist ah, a_request areq, a_response ares
    WHERE ah.id = areq.id
    AND areq.id = ares.id
    AND ah = #{id}
    AND ah.type = #{type}
    ORDER BY id DESC
</select>
```

### After

```sql
<select id="selectList" parameterType="ReqDTO" resultType="ResDTO">
    /* allHist.selectList */
    SELECT ah.id AS id,
        areq.name AS name,
        ares.ymdt AS ymdt
    FROM all_hist ah
    <choose>
        <when test="type != null and type == 'A_REQUEST'">
            , a_request areq, a_response ares
        </when>
    </choose>
    WHERE ah.id = areq.id
    AND areq.id = ares.id
    AND ah = #{id}
    AND ah.type = #{type}
    ORDER BY id DESC
</select>
```

If B and C are added, it will be code as below.

```sql
SELECT * 
FROM all_hist ah
<choose>
    <when test="type != null and type == 'A_REQUEST'">
    	, a_request areq, a_response ares
    </when>
    <when test="type != null and type == 'B_REQUEST'">
    	, b_request areq, b_response ares
    </when>
    <when test="type != null and type == 'B_REQUEST'">
    	, c_request areq, c_response ares
    </when>
</choose>
```

## 🍮 Retrospective

I've seen the use of Dynamic Query in the `WHERE` section, but I've rarely seen it in the `FROM` section, so I've been lost. I didn't understand until I heard the explanation from my colleague. I didn't know the keyword `Dynamic Query` because it was unfamiliar and I haven't used it very well. At first, I thought about whether I should write the `DAO` corresponding to A, B and C three times, but I found out again. I'll review the Dynamic Query later.

## 🍊 Reference

* I'm not fluent in writing in English, but I'm trying because I want to do well. Feedback is always welcome.
* 만약 이 글을 한국어로 읽고 싶다면 [MySQL/MyBatis | 동적 쿼리(Dynamic Query) 사용하기](https://yian.tistory.com/15) 글을 참고해 주세요.
How to stop DDoS attacks?
Tags: discuss, security, performance
Published: 2021-11-24 15:44:00

The truth is, there is no solution that works in all cases.

Attackers are getting smarter every day and their botnet armies more numerous.

In this article you can read about the most reliable ways someone can protect their network from DDoS attacks!

https://botmenot.com/blog/how-to-stop-ddos-attacks-in-2021/
Get started with discord.py!
Tags: python, discord, discordpy, programming
Published: 2021-11-24 15:39:12

`[](url)`Discord.py is a very fantastic API. It helps us in creating Discord bots easily. People have made game bots, RPG bots, Moderation Bots, Economy bots, and even more! Using this guide, you can learn how to use it.
### Install discord.py
Make sure you have python installed on your computer. You have to install discord.py with
```py
pip install discord.py
```
voilà! discord.py has been installed!

For making bots you'll need to have a developer account. You can [check this](https://discordpy.readthedocs.io/en/latest/discord.html#creating-a-bot-account) guide!
### Basics of developing a bot
When starting you have to choose weather to use `discord.Client` or `commands.Bot`.

`discord.Client`:
• Is more lightweight than commands.Bot
• Is best if you're not going to be using commands

`commands.Bot`:
• Is best if your bot is going to have commands
• Supports easy discord object conversion

In this series we will make a bot with `commands.Bot`.

We have to start by importing `discord` and `discord.ext.commands`
```py
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="$")

bot.run('YOUR TOKEN HERE')
```
We initialized a class as an object. We defined this class to the variable bot, which can be named whatever you want. Most people use `bot` or `client`.

Now when our bot is defined, we can start with our first command. In discord.py we make commands like this:
```py
@bot.command(name='command_name', description="description for help command")
async def command(ctx, other_arguments_here):
   # Tell bot what to do here
```
Let's make a command which will greet the user with a hello. We'll use `ctx.author` for doing this:
```py
@bot.command(name='Hello', description="Greets the sender")
async def hello(ctx):
    await ctx.reply(f"Hello {ctx.author.name}!")
# f-string
```
Now, when we greet the user, it will say Hello USER!

Congrats!! You've just written a bot using discord.py! Run the code. When you'll type `$hello` it should respond!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ruh32pmb5uexvjxvfxyi.png)
Source Code:
{% gist https://gist.github.com/TejasDev1/2d426775a53f099876c30c304aec2a09 %}
Wednesday Links - Edition 2021-11-24
Tags: java, spring, micronaut, microservices
Published: 2021-11-24 15:33:43

Consumer-driven Contracts: TDD between services (4min)📃
https://nurkiewicz.com/58

Refining The Return Type Of Java Methods Without Breaking Backwards-Compatibility (4 min)🪅
https://www.morling.dev/blog/refining-return-type-java-methods-without-breaking-backwards-compatibility/

Spring Boot 2.6 is now available (1 min)🎉
https://spring.io/blog/2021/11/19/spring-boot-2-6-is-now-available

Continuously Verify Your Startup Times, so You Won’t Be Surprised Badly (3 min)🤦
https://www.steadybit.com/blog/continuously-verify-startup-times/

Moving towards Micronaut (10 min)⛵
https://blog.allegro.tech/2021/11/micronaut.html

Dokka Is In Beta – Try It Now and Share Your Feedback! (2 min)🎉
https://blog.jetbrains.com/kotlin/2021/11/dokka-beta/

Pragmatic tests parallelization with JUnit 5 (7 min)🔀
https://mikemybytes.com/2021/11/24/pragmatic-test-parallelization-with-junit5/

HTTP - Content negotiation (3 min)🤝
https://www.mscharhag.com/api-design/http-rest-content-negotiation

Tabs or Spaces? (20sec)😱
https://twitter.com/starbuxman/status/1462211670227369992

Amazon MemoryDB for Redis – Where speed meets consistency (8 min)🟥
https://www.allthingsdistributed.com/2021/11/amazon-memorydb-for-redis-speed-consistency.html

Dockershim removal is coming. Are you ready? (3 min)🏁
https://kubernetes.io/blog/2021/11/12/are-you-ready-for-dockershim-removal/
Обезьянки автомат онлайн
Published: 2021-11-24 15:31:14

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

Игровой автомат Crazy Monkey имеет 9 игровых линий и 5 барабанов. Этот онлайн-слот на тему животных демонстрирует свою работу в производстве с логотипом игры, львом, ананасом, наковальней, змеей, бананами и бабочкой, а также сумасшедшей обезьяной. Слот [обезьянки автомат онлайн](https://eurogame.online/game-demo/crazy-monkey) позволяет вам делать ставки от одного рубля, гривны на линию. Кроме того, вы также можете использовать все 9 линий, чтобы увеличить ставку до 900. Дикие символы, состоящие из золотого черепа, будут использоваться в качестве значений всех символов, кроме обезьяны, увеличивая ваши шансы на крупный выигрыш. Символы разброса, используемые в Crazy Monkey, не являются обычными, этим обезьянам не обязательно попадать в комбинации, чтобы выиграть. Если ваши линии выплат не совпадают, всегда есть шанс получить выигрыш по разбросу.
5-reasons-why-you-should-move-from-on-premise-to-cloud-computing
Published: 2021-11-24 15:26:57

5 Reasons Why You Should Move to the Cloud One of today’s primary locations for businesses to store data is the cloud. Check out this guide to find out five reasons why you should move to the cloud. Keyword(s): move to the cloud The majority of businesses now use cloud computing instead of on-premises legacy systems. The cloud hosts 95% of IT workloads. Seventy-eight percent of small businesses currently adopt cloud computing in their operations. Why is the popularity of traditional systems dwindling? What are the benefits of cloud computing? Why should I move to the cloud? Read on to discover 5 reasons why you should adopt cloud systems. Learn how the cloud can cut your monthly IT expenses. Discover how to securely back up your data and access it from anywhere. See how the cloud will scale in tandem with your company’s needs.
I poop. You scoop. Got it?
Tags: dogs, integrity, community
Published: 2021-11-24 15:20:03

---
title: I poop. You scoop. Got it?
published: true
description: 
tags: dogs, integrity, community
// cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8p5hwqtdh45vnwwshmf.png
---

![You poop. I Scoop. Got it?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8p5hwqtdh45vnwwshmf.png)

Despite the clearly posted sign near the trail entrance, which says "I poop. You scoop. Got it?", and simple explanation of what the dog poop can do to you and the other dogs, I counted at least 3 poops on that trail. 


I like hiking and I do see it over and over again, and, when I bring it to the attention of the dog owners, they usually start to get defensive.  Their typical response is -- "Me? Never! I always pick my dogs stuff up! It's not me, it's not mine."


Famous quote refresher -- "Integrity is doing the right thing, even when no one is watching."


Well, just like in Engineering, no matter how much effort you put into securing your system, it will always be as secure as its weakest component.  In this case, if everyone is doing what they are supposed to do -- it takes only one irresponsible individual to ruin it for  all.


May be I'm preaching to the choir here, but, I would like to propose 3 potential solutions to the problem. Which one of these options do you think may work best?

1. Educate irresponsible dog owners, and train them to pick their stuff. I'm a bit skeptical it will work, if it has not happened yet -- all the information is available and everyone does know by now. 
1. Create national  dog  DNA database to penalize  slacking owners. There are certain attempts already implemented by some property managers. But it will only be effective if it becomes a nation wide mandate.  I always thought that carrot works better than the stick, but, perhaps this case is different and stick is the only things that will make a meaningful impact?
1. Have responsible dog owners pick somebody else's poop. My personal believe is, that "Good example is as contagious as the bad one".  It's a possibility, that no single method will cover the need 100%, then, supplementing it with option 3 may be final thing to securing the weakest link.

Would love to hear your thoughts. Please reply in comments.

![Integrity is doing the right thing, even when no one is watching.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjiqqcq8jqsezg4l353m.png)


------------------------
Originally posted https://www.echowaves.com/post/i-poop-you-scoop-got-it

https://www.wisaw.com/photos/21778
IntelliJ Hacks: Save Run Configurations to Source Control
Tags: java, programming, beginners
Published: 2021-11-24 15:19:48

---
title: IntelliJ Hacks: Save Run Configurations to Source Control
published: true
description: IntelliJ can be insanely useful sometimes... 
series: IntelliJ Life Hacks
tags: java,programming,beginners
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onwfyw57970drsygytnv.jpg
---

We've already covered [instant Javadoc](https://dev.to/scottshipp/two-ways-to-integrate-javadoc-into-intellij-idea-leb), [prettifying JSON](https://dev.to/scottshipp/prettify-json-with-intellij-scratch-files-pna), and [multi-line editing](https://dev.to/scottshipp/column-selection-simultaneous-multi-line-editing-with-intellij-2ddn), all within IntelliJ. Now let's cover [shared run configurations](https://www.jetbrains.com/help/idea/run-debug-configuration.html#share-configurations). 

If you've been an IntelliJ user for some time, you've probably collected quite a few of your own run configurations. What is a run configuration? It's simply a collection of metadata about a run of any kind. It could the metadata for creating a Docker image, running a web service, running a suite of tests, or something else entirely.

Your run configurations always appear at the top of your screen with a green "play" (triangle) button next to them.

They look like this, when you click the dropdown box:

![Screenshot of IntelliJ run configurations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggraghd7yeo5z3528oml.png)

They get [created in various ways](https://www.jetbrains.com/help/idea/run-debug-configuration.html#created-permanent), but the most common way is simply clicking that little green play button when you see it in the left margin next to some code.

## The Hack

Now, for the hack. Most people don't know that you can save these run configurations to files, and check them into source control! That way they can be shared among a team. This is actually a very [simple thing to set up](https://www.jetbrains.com/help/idea/run-debug-configuration.html#created-permanent):

1. Navigate to "Edit configurations" in the Run configurations dropdown.
1. Navigate to the run configuration you would like to save.
1. Check the "Store as project file" box.
1. Commit it to your source control the normal way.

More information about this is [documented in the help](https://www.jetbrains.com/help/idea/run-debug-configuration.html#created-permanent).

## Final tip

Don't forget to scrub any secrets out of your run configurations before you check them in. A good way to do this is to replace them with environment variables. 

Now go share those things with each other and save your team some time!
3 Ways to CENTER a div in CSS
Tags: css, codenewbie, beginners, html
Published: 2021-11-24 15:11:19

3 ways to center a div in HTML/CSS!!

### With Position

```css
/* Using positions */

.parent {
    position: relative;
}
.child {
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
}
```

```html
<div
     class="parent"
     style="background: blue; width: 500px; height: 250px;"
     >
    <div
         class="child"
         style="color: white;"
         >
      I'm center  
    </div>
</div>
```

{% codepen https://codepen.io/codeozz/pen/jOLoKYE %}

### With Flexbox

```css
/* Using flexbox */
.container-flexbox {
    align-items: center;
    display: flex;
    justify-content: center;
}
```

```html
<div
     class="container-flexbox"
     style="background: green; width: 500px; height: 250px;"
     >
    <div
         style="color: white;"
         >
      I'm center  
    </div>
</div>
```

{% codepen https://codepen.io/codeozz/pen/mdMYKQv %}

### With Grid

```css
/* Using Grid */

.container-grid {
    display: grid;
    place-content: center;
}

```

```html
<div
     class="container-flexbox"
     style="background: orange; width: 500px; height: 250px;"
     >
    <div
         style="color: white;"
         >
      I'm center  
    </div>
</div>
```

{% codepen https://codepen.io/codeozz/pen/vYJwrMv %}

---

I hope you like this reading!

🎁 You can get my new book `Underrated skills in javascript, make the difference` for FREE if you follow me on [Twitter](https://twitter.com/code__oz) and send message to me 😁 and **SAVE 19$** 💵💵

Or get it [HERE](https://codeoz.gumroad.com/l/RXLYp) 

🇫🇷🥖 For french developper you can check my [YoutubeChannel](https://www.youtube.com/channel/UCC675U1ZUPFASsK9-FjawtA)

🎁 [MY NEWSLETTER](https://www.getrevue.co/profile/code__oz)

☕️ You can [SUPPORT MY WORKS](https://www.buymeacoffee.com/CodeoZ) 🙏

🏃‍♂️ You can follow me on 👇

🕊 Twitter : [https://twitter.com/code__oz](https://twitter.com/code__oz)

👨‍💻 Github: https://github.com/Code-Oz

And you can mark 🔖 this article!
Php Smarty template ternary operator to reduce code in html tags
Tags: php, html, smarty
Published: 2021-11-24 15:09:42

Hi Sweet People!
I've googled this, and found a solution with no explanation so I tested and came up with this example.

```
<head>
{$bloke = true}
{$sex = ($bloke) ? 'Male' : 'Female'}
</head>
```
After entering {debug} mode, I can see this returning 'Male' all right.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tizt2s9csd5m9e04o36.png)
Drawing with Mr. Fourier and Typescript
Tags: webdev, javascript, typescript, programming
Published: 2021-11-24 15:06:59

What if we connect a couple of rotating sticks together and trace the shape they make? We can get something like this.

![Rotating Sticks](https://media.giphy.com/media/VDbjh7etUnHmXXE05U/giphy.gif)

The most interesting part about this is if we get enough sticks we can draw anything we want!

You can try it yourself [here](https://fourier-painter.nordicbeaver.io/). Just draw a **closed** (that's pretty important) shape and press 'Start'.

This is based on a thing caller *Fourier Transform*. Basically, every complex function on a set interval can be represented as an infinite sum of exponents:

{% katex %}
f(t) = \sum_{n=-\inf}^{\inf}c_n e^{n 2 \pi i t}, 
0 \le t \le 1
{% endkatex %}

Where

{% katex %}
c_n = \int_0^1 f(t) e^{-n 2 \pi i t}
{% endkatex %}

But if we look closer we may notice that every element of that sum is actually a rotating vector Cn. So if we manage to represent a shape as a complex function, we could find these vectors (maybe not all, since there is infinite number of them, but we don't need all) and that would mean drawing the shape just by rotating those vectors!

I made a video where I tried to explain this in more detail and code it in TypeScript.

{% youtube sGwtJzLh6_k %}

Enjoy!
Caching Anaconda environments on GitHub Actions
Tags: actionshackathon21
Published: 2021-11-24 15:03:39

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon 2021, please fill out all sections.)


### My Workflow
[Note]: # (Please make sure the project links to the appropriate GitHub Actions repository, and includes [an open source license](https://choosealicense.com/) and README.)

One of the most time-consuming tasks on my workflows is the solving, download and installation of Anaconda environments. In some cases, just solving the dependencies can take up to 10 minutes depending on the platform you are building on.

This workflow aims to save time and computational resources by caching deployed Anaconda environments using the [`actions/cache`](https://github.com/actions/cache) task and the [`conda-incubator/setup-miniconda`](https://github.com/conda-incubator/setup-miniconda) action.

Shorter build times and better resource management will benefit not just your organization but also the environment.


### Submission Category: 

[Note]: # (Maintainer Must-Haves, DIY Deployments, Interesting IoT, Phone Friendly, or Wacky Wildcards)

Maintainer Must-Haves


### Yaml File or Link to Code

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

{% github epassaro/cache-conda-envs %}


### Additional Resources / Info

I'm glad to say that the results of my work have been [recently added](https://github.com/conda-incubator/setup-miniconda/pull/200) to the `conda-incubator/setup-miniconda` action's [documentation](https://github.com/conda-incubator/setup-miniconda#caching-environments) and should reach more developers soon.

It's worth mentioning that the documentation of `actions/cache` included examples for many package managers, but not for `conda`. On the other hand, the `setup-miniconda` documentation described a way to cache the downloaded packages, but that method makes pipelines even slower.

Finally, I published a post describing the workflow step-by-step.

{% link https://dev.to/epassaro/caching-anaconda-environments-in-github-actions-5hde %}

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

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any)

[Reminder]: # (Submissions are due on December 8th, 2021 (11:59 PM PT or 2 AM ET/6 AM UTC on December 9th)
Dates difference
Published: 2021-11-24 14:53:02

  const date1 = new Date('12/13/2021');
  const date2 = new Date('12/15/2021');
  const diffTime = Math.abs(date2 - date1);
  const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 *24)); 
  console.log(diffDays);
Difference between Constructors and Methods in Java
Tags: java, beginners, oop
Published: 2021-11-24 14:39:48



The main difference is

1.Constructor are used to initialize the state of object,where as method is expose the behaviour of object.

2.Constructor must not have return type where as method must have return type.

3.Constructor name same as the class name where as method may or may not the same class name.

4.Constructor invoke implicitly where as method invoke explicitly.

5.Constructor compiler provide default constructor where as method compiler does't provide.
Twig - The Ultimate Guide to the Premier PHP Templating Language
Tags: twig, php, drupal, symfony
Published: 2021-11-24 14:30:35


Learn how to make the code for your site’s frontend simpler, cleaner, dryer, more logical, and secure with Twig.

![Twig website banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tceijj5v88v6lmm31smw.png)

##WHAT’S IN THIS ARTICLE FOR YOU?


You will discover Twig’s history and what the language is.

You will see why you should use it.

You will begin learning how to use it.

Twig is a PHP templating language that outputs variables into the HTML of views in MVC (models, views, controllers) programming. So, it contributes to the structure of a website’s frontend.

For your future reference, here’s the link to the [official TWIG repository on GitHub](https://github.com/twigphp/Twig). I will link to it at the bottom of the article as well.

[Read the full article on Symfony Station](https://symfonystation.com/Twig-Ultimate-Guide-PHP-Templating-Language).