teleren/devto huggingface dataset:
Wiring Micronaut beans in Grails Services
Tags: micronaut, grails, groovy
Published: 2020-04-02 15:43:28

Micronaut beans in Grails 4 are wired by type - not the default Grails users are used to using - wire by name.

For example if we have a `micronaut-http-client` bean named `MyRestClient` under `src/main/groovy/<package>/MyRestClient.groovy` and we want to wire it into the Grails service `SomeService` we must supply the type:

```groovy
class SomeService {
    // ❌ wont work, as Grails will look for a bean name that wont exist.
    // def myRestClient

    // ✅ Works!
    MyRestClient myRestClient
}
```

Tested on Grails 4.0.2.
Machine Learning -  Image Augumentation
Tags: machinelearning, beginners, computerscience
Published: 2020-04-02 15:35:43

---
title: Machine Learning -  Image Augumentation
published: true
description: Machine Learning studies
cover_image: https://i.ibb.co/gyDsXzP/0-hzqhs-KFIZNWJKhvq.jpg
tags: machinelearning, Beginners, Computer Science
series: Making Of Terminator
---
Hey there,
Its day 12 of Quarantine.

![details](https://media.giphy.com/media/aAkNru67Hh40E/giphy.gif)

Hoping everyones doing good. We talk about validation in the last post. Lets see how image augumentation works in this one.

When training a CNN to recognize particular objects in images, you want your CNN to be able to detect these objects regardless of their size or position in the image. 
For example, suppose we want to train our CNN to recognize dogs in images. 

![details](https://i.ibb.co/Wg922dP/wehre-is-the-dog.png)

In this case, we want our CNN to be able to recognize if a dog is in an image regardless of how big the dog is, or if the dog is in the middle of the picture or in the left-hand corner, or if the dog is at an angle, or if we can only see part of the dog. 

Therefore, in the ideal case, you want your CNN to see all these examples during training. If you're lucky enough to have a big training set with many different examples, your CNN will perform very well and would be less likely to overfit. 

However, it is not uncommon to find yourself working with a training set that doesn't have a lot of different examples, in which case, your CNN is likely to suffer from overfitting and won't generalize well to data it hasn't seen before. This problem can be avoided by using a technique called 
<code>image augmentation</code>. 

![details](https://i.ibb.co/YQm0jGB/ia.png)

<code>Image augmentation works by creating new training images by applying a number of random image transformations to the images in the original training set.</code> 

![details](https://i.ibb.co/1qsRzns/apply.png)

For example, we can take an image from our original training set and create a new one by applying a random rotation, or a horizontal flip, or a random zoom. 

![details](https://i.ibb.co/JHJ6fWF/effects.png)

By adding this new transformed images to our training set, we are ensuring that our CNN sees a lot of different examples during training. Consequently, our CNN will generalize better to unseen data and avoid overfitting. In the next lesson, we will learn about 
<code>dropout</code>, another technique that can be used to prevent overfitting.
Ruby change current working directory safely
Tags: misc, ruby
Published: 2020-11-02 08:46:05

---
title: Ruby change current working directory safely
published: true
date: 2020-04-02 15:21:00 UTC
tags: Misc,misc,Ruby
canonical_url: https://coderscat.com/ruby-change-current-working-directory
---

![CAPTURE-2020_04_02_ruby-change-working-directory.org_20200402_232121.png](https://coderscat.com/wp-content/uploads/CAPTURE-2020_04_02_ruby-change-working-directory.org_20200402_232121.png)

There are two ways to change the current working directory in Ruby, but you need to notice the thread-safe issue.

## Dir.chdir

[Dir.chdir](https://ruby-doc.org/core-2.7.1/Dir.html#method-c-chdir) is the most traight way:

```ruby
Dir.chdir('/tmp')

```

If you need to go back to the previous directory:

```ruby
orig_dir = Dir.pwd
Dir.chdir('/tmp')
.....

Dir.chdir(org_dir)

```

## Dir.chdir with block

A more idiomatic way is using a block to finish the task and go back to the previous directory:

```ruby
Dir.chdir('/tmp') do
    .....
end

```

The original working directory is restored when the block exits. The return value of chdir is the value of the block.

But, this is **not thread-safe**.

Dir.chdir will call the POSIX function to change the working dir of the current process, so it can never be made safe across threads.

[MRI adds a warning message](https://github.com/ruby/ruby/blob/edffe78a79dfddb6f17317b831a13dd5be919271/dir.c#L1104) for this scenario, let’s run this code snippet:

```ruby
require 'fileutils'

FileUtils.mkdir_p("/tmp/foo")

def blah(d)
  Dir.chdir(d) do
    sleep 2
  end
end

threads = []
threads << Thread.new { blah('/tmp/foo') }
threads << Thread.new { blah('/tmp/foo') }
threads.each { |t| t.join }

```

The will be a warning message printed out:

```ruby
./chdir\_demo.rb:3: warning: conflicting chdir during another chdir block
```

## How to be thread-safe

If you want to make this block to be safe-thread, you need to add Mutex for it:

```ruby
require 'thread'

M = Mutex.new

def blah(d)
  M.synchronize do
    Dir.chdir(d) do
      puts Dir.pwd
      sleep 2
    end
  end
end

threads = []
threads << Thread.new { blah('/tmp/foo') }
threads << Thread.new { blah('/tmp/foo') }
threads.each { |t| t.join }

```

The post [Ruby change current working directory](https://coderscat.com/ruby-change-current-working-directory) appeared first on [Coder's Cat](https://coderscat.com).
Announcing our full speaker lineup for our free, remote React conference
Tags: react, showdev, webdev, javascript
Published: 2020-04-02 15:18:36

👋 Kristian from Bytesized Code here – super excited to announce the speaker lineup for **[Byteconf React](https://www.bytesized.xyz/react-2020), a free live-streamed React conference!**

Byteconf React will be a great resource for React developers of all experience levels, and our speaker list is shaping up to be a really awesome group of developers from around the world 🌍🌎🌏 

At the end of February, we announced our first set of speakers – Kent C. Dodds, Ali Spittel, and Shawn Wang – [in this blog post](https://dev.to/bytesizedcode/announcing-our-first-set-of-speakers-for-our-free-remote-react-conf-106l).

**💬 Today, I'm super excited to announce our full speaker lineup, and an update to the conference: we're adding a second day of talks!**

Want to attend the conference? **Go to our website and RSVP for your free ticket** – we'll send you an email when the conference goes live, so you won't miss it. 

**[🎟 RSVP for Byteconf React →](https://www.bytesized.xyz/react-2020)**

![Byteconf React 2020](https://dev-to-uploads.s3.amazonaws.com/i/fhz0rh07e5zcl3mj6i22.png)

**Find out more about our speakers below**, and make sure to follow them on Twitter 🐦 For more announcements and updates on the conference, make sure to follow our account, [@bytesizedcode](https://twitter.com/bytesizedcode), as well! We're super excited to hear from you, so make sure to **let us know you're attending on Twitter** 👍

[![Byteconf React 2020 Speakers](https://dev-to-uploads.s3.amazonaws.com/i/iaz6xdv3vpldcbj1kuqy.png)](https://www.bytesized.xyz/react-2020)

[Learn more about our speakers at the Byteconf React 2020 website →](https://www.bytesized.xyz/react-2020)

Over the next month as we get closer to the conference, I'll continue to post updates on the talks schedule, conference announcements, and more! [Make sure to RSVP for your ticket on our website](https://www.bytesized.xyz/react-2020), and see you at Byteconf React starting May 1st!
TUNS - Twitter Unfollower Notification Service
Tags: showdev, rails, twitter, opensource
Published: 2020-04-02 15:11:11

Just developed a new funny service called T.U.N.S. - Twitter Unfollower Notification Service.

https://www.tunsapp.com

With TUNS you can keep track of your unfollower ( from registration date ). Take a look and enjoy!

<a href="https://ibb.co/qsKZxKG"><img src="https://i.ibb.co/r6YWvYP/Screenshot-2020-04-07-at-11-46-08.png" alt="Screenshot-2020-04-07-at-11-46-08" border="0"></a>


<a href="https://ibb.co/zVc4cW5"><img src="https://i.ibb.co/TMXgXDT/Screenshot-2020-04-07-at-11-41-53.png" alt="Screenshot-2020-04-07-at-11-41-53" border="0"></a>

Of course is Open Source at

https://github.com/davidesantangelo/tuns

Feedback are welcome.
AsyncAPI Online Conference CFP Ends On Friday
Tags: asyncapi, conference, stayhome, asynchronous
Published: 2020-04-02 15:05:44

After reaching [1000](https://github.com/asyncapi/asyncapi/) :star: on GitHub, [AsyncAPI Initiative](https://www.asyncapi.com/) community decided to go crazy and quickly organize a first, online AsyncAPI conference.

We just released the [conference website](https://www.asyncapiconf.com/)

You can submit your talk proposal using [this](https://forms.gle/tntZP33tJwPiECKP8) form. 
**The deadline is Friday, tomorrow, 03.04.2020**
We know it is a short time, but the conference is scheduled for 22.04.2020 so not much time left. You do not have to submit a 100% perfect proposal. If we pick you, you will have a chance to prettify it before we publish the agenda next Wednesday.

Proposals we are looking for:
- How AsyncAPI helps you
- What products you built thanks to the AsyncAPI
- AsyncAPI use cases
- non-AsyncAPI but still super important for the world of event-driven architectures


\#StayHealthy \#StayHome \#StayStrong
Solution & Explanation: Leetcode 30 Day Challenge Day 1 - Single Number
Tags: leetcode, computerscience, algorithms, javascript
Published: 2020-04-02 14:53:06

## Challenge
https://leetcode.com/explore/featured/card/30-day-leetcoding-challenge/

## Question
https://leetcode.com/problems/single-number/

## Solution

```js
/**
 * @param {number[]} nums
 * @return {number}
 */
function singleNumber(nums) {
    const num = nums[0]
    for (let i = 1; i < nums.length; i++) {
        num ^= nums[i]  
    }
    return num
};
```

## Explanation

This solution uses the properties of the XOR operation to find the number by XOR'ing all of them together. With XOR the rule is that the result is `1` if the numbers are different and `0` if they’re the same. The XOR operator is `^`.

Example:
```
1 ^ 1 = 0 (same 1s, leads to 0)
0 ^ 0 = 0 (same 0s, leads to 0)
1 ^ 0 = 1 (different 1 and 0 leads to 1)
0 ^ 1 = 1 (different 1 and 0 leads to 1)
```

Since XOR operates on the binary representation of a number, you can see the effect of doing XOR on two 2s will result in 0.

`2` in binary is `010`

`2 ^ 2` is the same as `010 ^ 010`.

If we lay it out like a multiplication problem its easier to see how the bits align. The form is similar to multiplication, addition, subtraction..etc except the operation is XOR. Similar concept, but different operation.

Example:

```
2 + 2 = 4 is equivalent to

2 +
2
—
4
```

```
2 ^ 2 is equivalent to
010 ^
010
——
?
```

Where ? Is the answer. If we work through this problem by looking at the top and bottom numbers from right to left (just like multiplication, addition, subtraction..etc) we get `000`:

```
0 ^ 0 = 0
1 ^ 1 = 0
0 ^ 0 = 0
```

```
010 ^
010
——
000
```

Since the top and bottom are the same number, each position will contain the same bit (0 or 1), we get 0 based on the rule mentioned above “0 if they’re the same”. Because of this, we get 0 if we XOR any number by itself. Another example is `4 ^ 4`

```
100 ^
100
——
?
```

```
0^0=0
0^0=0
1^1=0
```

```
100 ^
100
——
000
```

Each time you XOR a number with itself, it “zeroes out” the number. When working with decimals this happens under the hood too. The trick for this question is realizing that this “zeroing” out will happen even if you XOR another number beforehand. For example:

`2 ^ 1 ^ 2 = 1` because the `2 ^ 2` “zero” each other out

```
010 ^
001 ^
010
——
?
```

```
0^1 = 1, 1 ^ 0 = 1
1^0 = 1, 1 ^ 1 = 0
0^0 = 0, 0^0 = 0
```

```
010
001
010
——
001 <— only the 1 remains because the 2s (010) canceled each other out after the XOR
```

With this in mind you can see how you can identify a single missing number because all other pairs of numbers will “zero” each other out, just as they did in the 2 ^ 1 ^ 2 example.

`7 ^ 3 ^ 9 ^ 3 ^ 7 ^ 4 ^ 4 = 9` because the 7s, 3s, and 4s zero each other out.
100daysofcode Flutter
Tags: flutter, 100daysofcode
Published: 2020-04-02 14:52:10

day 24/100 of #100daysofcode #Flutter
Learning Flutter , courses Udemy from
@maxedapps

Implement form previous lecture, like make model, navigator between screen, constructor ,n another new widget to try, Gridview.buider, Grid.tile, GridTileBar, and send data via Navigator arguments,
https://github.com/triyono777/100-days-of-code/blob/master/log.md
OsmiCSX - An utility React Native style framework
Tags: javascript, reactnative, react, framework
Published: 2020-04-02 14:46:46

---
title: OsmiCSX - An utility React Native style framework
published: true
description: An utility React Native style framework for rapidly building custom user interfaces.
tags: javascript, reactnative, react, framework
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/e156nekqj5qusovomdx6.jpg
---
## What is OsmiCSX ?
OsmiCSX is a utility React Native style framework for rapidly building custom user interfaces. We adopted the Tailwind concept and implement it for styling in React Native. OsmiCSX designed for customizing UI in React Native and makes a reusable component with the style as you want with very simple code.

## Why OsmiCSX ?
Most Style/UI framework in React Native only focused on the UI Component and not really customizable. They come with all sorts of predesigned components like buttons, cards, and alerts that might help you move quickly at first, but cause more pain than they cure when it comes time to make your site stand out with a custom design.

OsmiCSX is different.

Instead of opinionated predesigned components, OsmiCSX provides low-level utility style that let you build completely custom designs.

## Templating Friendly
While you can do a lot with just utility classes, as a project grows it can be useful to codify common patterns into higher level abstractions.

OsmiCSX provides tools for extracting component classes from repeated utility patterns, making it easy to update multiple instances of a component from one place:
```jsx
import { connect } from '../lib/OsmiConfig' // your osmi config path

export default connect({
  container: [
    "bg-blue-500",
    "p-2",
    "pl-5",
    "pr-5",
    "rounded"
  ],
  text: [
    "text-white",
    "text-base",
    "font-bold",
    "text-center"
  ]
})
```

## More Information
Example => [OsmiCSX Example](https://snack.expo.io/@devoresyah/osmiprovider-example)
GitHub => [OsmiCSX on GitHub](https://github.com/OsmiCSX/osmicsx)
Documentation => [OsmiCSX Docs](https://osmicsx.github.io/docs/)
How to Bulk Update the “Tested up to” Version for WordPress Plugins
Tags: wordpress
Published: 2020-04-24 07:25:45

---
title: How to Bulk Update the “Tested up to” Version for WordPress Plugins
published: true
date: 2020-04-02 14:17:54 UTC
tags: WordPress
canonical_url: https://kaspars.net/blog/plugins-bulk-update-tested-up-to-version
---

{% youtube Vl0EbVnHvDs %}

Here is [a quick demo video](https://www.youtube.com/watch?v=Vl0EbVnHvDs) of [a bash script](https://github.com/wpsh/batch-mark-as-tested) for updating the “Tested up to” version of multiple WordPress plugins at the same time. This solves the pain of updating the `readme.txt` file for all your plugins whenever a new version of WordPress is released.

p.s. Background music provided by my kids 🥁🥳🤣
Dynamic html table from Json response.
Tags: json, html, jsontohtml, javascript
Published: 2020-04-02 14:12:32

Hello,
I am a newbie a want to make a simple static corona tracker website but the problem is that the data which i want to use is in `json` format.
So my question is how can i generate a dynamic html table from json response i get from the API?

- For Reference, link of json data is 
https://covid-rest.herokuapp.com/pakistan

- The api response is of the following type:
`{"code":200,"message":"OK","data":{"country_name":"pakistan","total_cases":"2291","new_cases":"173","total_death":"31","new_death":"4","total_recovered":"107","active_cases":"2153","critical_cases":"12","tot_cases_per_million":"10","tot_death_per_million":"0.1"}}`
Devart Released New dbForge DevOps Automation Bamboo Plugin
Tags: devops, database, bamboo, sql
Published: 2020-04-02 13:53:58

---
title: Devart Released New dbForge DevOps Automation Bamboo Plugin
published: true
description: Devart extended dbForge DevOps Automation solution with Bamboo plugin. Now users can benefit from continuous integration in Bamboo.
tags: DevOps, database, Bamboo, sql
---
*Devart extended dbForge DevOps Automation solution with Bamboo plugin. Now users can benefit from continuous integration in Bamboo.*

![dbForge DevOps Automation Bamboo Plugin](https://blog.devart.com/wp-content/uploads/2020/03/01_highlight1_ss-1024x501.png)

Devart, a recognized vendor of professional database management software for developers and DBAs, extended the compatibility of dbForge DevOps Automation solution with just-released **dbForge DevOps Automation Bamboo Plugin** for SQL Server.

The new plugin brings all the power of dbForge DevOps Automation for SQL Server powered by [dbForge SQL Tools](https://www.devart.com/dbforge/sql/sql-tools/) right into Bamboo and helps to tune and implement all steps of the CI process in the most simple and effective way. 

[dbForge DevOps Automation for SQL Server](https://www.devart.com/dbforge/sql/database-devops/) introduces a new approach in conventional database development. The solution drastically reduces overall database release costs, minimizes deployment risks, energizes quality & update frequency, makes the workflow consistent and safe. Along with Bamboo, it also integrates into Jenkins, TeamCity, and Azure DevOps. 

Learn more about the recent release by visiting Devart’s blog article https://blog.devart.com/adopt-flawless-continuous-integration-into-bamboo-with-new-dbforge-devops-plugin.html

**About Devart**

Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects.
For additional information about Devart, visit https://www.devart.com/
Happy number revisiting hare and tortoise. Connecting the dots ! 
Tags: javascript, interview, coding, algorithms
Published: 2020-04-02 13:51:45

Question: Give a number n, determine if it's a happy number. 
A number is called happy if it leads to 1 after a sequence of steps wherein each step number is replaced by the sum of squares of its digit that is if we start with Happy Number and keep replacing it with digits square sum, we reach 1.

So for n = 19, the sequence of steps are :
1^2 + 9^2 = 82
8^2 + 2^2 = 68
6^2 + 8^2 = 100
1^2 + 0^2 + 0^2 = 1
As we reached to 1, 19 is a Happy Number.

Brute Force: 

Brute force approach would be :
1> find sum of squares of digit of each number,
2>add them to a set
3> repeat 1 & 2 and if we come across a number which is present in a set then the number is not a happy number
4> if we reach 1, number is a happy number.

So based on this let's write our code:

```javascript
var happy = function(n){
    let set = new Set();
    while(n != 1){
         let temp = n;
         let sum = 0;
         while(temp!=0){
              sum += (temp%10) * (temp%10);
              temp = temp/10;
         }
         if(set.has(sum)) return false;
         set.add(sum);
         n = sum;
    }
    return n == 1;
}
```
If you're with me till here ? Awesome ! Now let's think about optimizing it. Here we're using O(n) space to store the number. So let's try to convert it to O(1). 

Let's revisit our question, the question states that if the number doesn't reach 1, that is it loops around then it's not a happy number.

As you might remember from my loopy linked list here: https://dev.to/akhilpokle/loopy-linkedlist-two-pointers-pattern-2fbl

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


So, since in this problem we get stuck in a loop, using hare and tortoise in this context to detect loop might be useful.

Let's try to convert the loopy linked list code to work for this problem.

```javascript
// modifying slow and fast pointers
slow = computeSquare(n);
fast = computeSquare(sumSquare(n));
```

That's it! 

```javascript

var happy = function(num){
    let slow = computeSquare(num);
    let fast = computeSquare(computeSquare(num));
    while(slow != fast){
         slow = computeSquare(slow);
         fast = computeSquare(computeSquare(fast));
    }
    return slow == 1;
}

var computeSquare = function(num){
    let temp = num;
    let sum = 0;
    while(temp != 0){
         sum += (temp%10) * (temp%10);
         temp = temp/10;
    }
    return sum;
}

```

Smart eh ? This is how you should connect the dots! When I wrote about loopy linkedlist, you might be thinking that you won't use hare and tortoise elsewhere, but here we are using the same concept again! 

github:https://github.com/AKHILP96/Data-Structures-and-Algorithms/blob/master/problems/happyNumber.js

<a href="https://www.buymeacoffee.com/aki" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-white.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>