teleren/devto huggingface dataset:
Automate AVDL to C# Generation
Tags: dotnet, avro, kafka
Published: 2021-01-24 19:56:05

---
series: Avro and .NET
---

In the previous post, you saw how to take an Avro IDL file and manually turn that into a C# class.

For a small number of files, this is fine but as soon as you start dealing with a lot of them it'll be something you'll want to automate. I've written a PowerShell script to do this will cover how to use it + what it does.

# Prerequisites

- [Java](https://jdk.java.net/)
- [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet-core)
- [Apache.Avro.Tools](https://www.nuget.org/packages/Apache.Avro.Tools/1.10.0)
- [PowerShell Core](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.1)

# Folder Structure

Create a folder called `Avro` and within that:

- Add a file called `Generate.ps1`
- Add a folder called `AVDL` and place any `.avdl` files in there

It should look something like:

```
.
└── Avro
    ├── AVDL
    │   └── ExampleMessage.avdl
    └── Generate.ps1        
```

# The Generate.ps1 Script

The PowerShell script is what does all the work. The contents can be copied from this gist:

{% gist https://gist.github.com/cainux/c0714d82855354e25b19c3ad4810b136 file=Generate.ps1 %}

## What it does:

- Downloads `avro-tools` to `$HOME/.avro-tools` if it's not there already
- Scan the contents of the AVDL folder
- For each `.avdl` file found, generate the `.avsc` and from that, the C# class
- All generated files are written to the `Avro/_generated` folder

# Running

To run the script just do:

```bash
pwsh Generate.ps1
```

The results should end up like:

```
.
└── Avro
    ├── AVDL
    │   └── ExampleMessage.avdl
    ├── Generate.ps1
    └── _generated
        └── avro
            ├── classes
            │   └── example
            │       └── avro
            │           └── ExampleMessage.cs
            └── schema
                └── ExampleMessage.avsc
```

The script also does some basic change detection so it'll only generate the files if something has changed within the `AVDL` folder. It's just a simple check of last modified dates, so it's not perfect (i.e. doesn't work with deletions) but it works for most cases.

# Summary

We took the manual steps from the previous post and automated it using PowerShell. In the final post, we'll look at adding this to a project so it gets executed as part of the build process.
Do this one thing before learning to code
Tags: codenewbie, career, productivity, beginners
Published: 2021-01-24 19:49:10

---
title: Do this one thing before learning to code
published: true
description: Start off on the right foot
tags: codenewbie, career, productivity, beginner
//cover_image: https://direct_url_to_image.jpg
---

Pick a professional username and use it for all your online accounts. It'll be your professional brand for many years, if not the rest of your career/life.

The best choice is your first name and last name. Use a website like https://namechk.com/ to check if your username is available. If your name is already taken, add a qualifier that won't change, e.g. `janedoedeveloper`. You might not want to use your location in case you move. Try not to use numbers, e.g. `janedoe90`. Apparently, it's out of fashion.
Ler a velocidade de um carro em Python
Tags: python, braziliandevs, programming, beginners
Published: 2021-01-24 19:47:14

Estou apredendo a programar, então se o código abaixo estiver com alguma informação incorreta, por favor deixe a explicação correta nos comentários.

Exercicio: 

Escreva um código em que se o automovel estiver acima do limite de velocidade, o código aplique uma multa. 
Para cada KM ultrapassado multar em R$7,00.
Considere o limite de velocidade em 80km/h


O programa abaixo pode ser realizado de duas formas: 

1 - 
```python
velocidade_max = 80
multa = 7

velocidade = float(input("Insira a velocidade do veiculo em km: "))

velocidade_total = velocidade - velocidade_max
valor_multa = velocidade_total * multa

if velocidade > velocidade_max: 
   print("Seu veiculo foi multado em R$" + valor_multa)
else:
   print("Tudo numa boa!")
```

OU

2 - 
```python
velocidade = float(input("Insira a velocidade em KM:\n"))

if velocidade > 80 :
   print("Seu veiculo foi multado. Devido ter ultrapassado o limite de velocidade irá pagar uma multa de R$ ((velocidade-80)*7:.2f)")

else:
  print("Tudo numa boa!")
```
Como o código aparecerá para o usuário:

Insira a velocidade em KM: 115
Seu veiculo foi multado. Devido ter ultrapassado o limite de velocidade irá pagar uma multa de R$245

OU

Insira a velocidade em KM:75
Tudo numa boa





Explicação do código:
```python
velocidade = float(input("Insira a velocidade em KM:\n"))
"""variável criada para armazenar a km """

if velocidade > 80 :
"""valida se a velocidade inserida para o usuário é maior que 80 se sim irá imprimir(print) a mensagem abaixo"""

   print("Seu veiculo foi multado. Devido ter ultrapassado o limite de velocidade irá pagar uma multa de R$ ((velocidade-80)*7:.2f)")

else:
  print("Tudo numa boa!")
```
My top 5 resources for UI/UX inspiration
Tags: ux, webdev, ui
Published: 2021-01-24 19:09:56

I believe as developers, we should not only take care of the beauty of our code, but also how it looks like to the visitors, meaning the visual side of what we produce.
During my freelancing career, I've had the privilege to create tens, if not hundreds of websites. In most cases, I've also had to create the design. In order to get inspired, I usually do some design research based on the project requirements.

**In this post, I share the main resources I use to get inspired regarding UI/UX.**

## 1. Behance
![https://dev-to-uploads.s3.amazonaws.com/i/l39uexsmfmnixdq091h6.png](https://dev-to-uploads.s3.amazonaws.com/i/l39uexsmfmnixdq091h6.png)

[Behance](https://www.behance.net/) by Adobe is my go-to place for any kind of design inspiration. There are tons of different filters for searching works related to graphic design, traditional design, UI/UX etc. As the authors of content are both agencies and solo-creators, the variety of search results is guaranteed.

## 2. Awwwards
![Awwwards](https://dev-to-uploads.s3.amazonaws.com/i/xi4tl7og9r0bmcpe0cer.png)
[Awwwards](https://www.awwwards.com/) is another big favourite of mine. It's a collection of the most innovative and beautiful websites in the world, as owners of websites actually submit their websites for a review. There are awards like "site of the day", "site of the month", "site of the month" etc.

As you can search by categories, tags, technologies, colors and even countries, it's definitely a resource to add to your list.

## 3. Pinterest
![Pinterest](https://dev-to-uploads.s3.amazonaws.com/i/t73t60iikywoyyj6uz8l.png)
[Pinterest](https://www.pinterest.com/) - to be honest, I think there's no explanation needed here. I just go to Pinterest, search for web design + "the industry I'm interested in" and beautiful design solutions already start pouring in.

## 4. Dribbble
![Dribble](https://dev-to-uploads.s3.amazonaws.com/i/38d6xqnvpjhtrmgd3glv.png)
[Dribbble](https://dribbble.com/search) is a place where I go for more non-conventional solutions as people do not just post ready-made works but also share small "snapshots" of their works. I've also noticed people tend to experiment more there.

## 5. Codrops
![Codrops](https://dev-to-uploads.s3.amazonaws.com/i/vbho5kn9igvmw5nkjlc6.png)
[Codrops](https://tympanus.net/codrops/) - I'm not sure how I found it, but I've been visiting their site for web design inspiration and UX tutorials for over 10 years. Definitely worth checking out for both inspiration and coding tutorials.

## Have any resources to add?
If you have some great UI/UX resources for devs, please share them in the comments!

Also, If you're interested in topics related to developer growth and universal knowledge that helps you get to the next level as a dev, check out my Youtube channel called [Developer Habits](https://www.youtube.com/channel/UCJLZwePkNHps5Bv7VwISyTA).

**Want more info like that?**
👉 Twitter: https://twitter.com/developerHabits
👉 Dev.to: https://dev.to/kethmars
👉 IG: https://www.instagram.com/developerhabits
👉 YT: https://www.youtube.com/channel/UCJLZwePkNHps5Bv7VwISyTA
Implementing a Button in Vue3 with Theme support |  Vue component Lib - part 5
Tags: vue, beginners, tutorial, typescript
Published: 2021-01-24 19:01:47

Hey,

In this part we will be implemeting a button in vue3.
we will learn how ref() works and we will add theme support!
Here is the Video:

{% youtube C-JP7ZlLgxA%}

Code Repo for youtube: https://github.com/lampewebdev/lcs-components-yt
Code Repo for the project: https://github.com/lampewebdev/lcs-components

**👋Say Hello!** [Instagram](https://www.instagram.com/lampewebdev/) | [Twitter](https://twitter.com/lampewebdev) | [LinkedIn](https://www.linkedin.com/in/michael-lazarski-25725a87) | [Medium](https://medium.com/@lampewebdevelopment) | [Twitch](https://dev.to/twitch_live_streams/lampewebdev) | [YouTube](https://www.youtube.com/channel/UCYCe4Cnracnq91J0CgoyKAQ)
Lets learn javascript... The console (1)
Tags: javascript, beginners, programming, webdev
Published: 2021-01-24 18:51:58

My goal for this year is to get to halfway decent skill level in web development(javascript). I will try to ignore the design aspects for all my effort and focus on getting some small projects working. Lets see where this will lead us. Feeling excited although javascript can be such a huge topic to grasp.

![Me with no clue abou js](https://media.giphy.com/media/VGG8UY1nEl66Y/giphy.gif)

So far I learned about the console object. It can be used to print out messages into your browsers debugging console.

When executing javascript in the browser you automatically have access to certain objects. The window Object being one of them gives you access to the console. Although you can use a shortcut and address the console directly.

```javascript
window.console.log("test1");
console.log("test1");
```

So what can be done with it?

You are able to log different error levels. And filter the output of the browser console later to see only certain error levels.

```javascript
  console.debug("debug");
  console.info("info");
  console.warn("warn");
  console.error("error");
```
Example of the filtering for firefox:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hv0rteydwixaevdv4aoq.PNG)

It's possible to print complete javascript objects:

```javascript
let person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
console.log(person)
```

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

If you use the dir function, you will get even more info: 
```javascript
let person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
console.dir(person)
```

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



Printing timestamps works like the following:

```javascript
console.time("logging");
console.log("test");
console.timeEnd("logging");
```

By the way you can run/test your js code on the command line using node:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/edovyomues53omelhkh3.PNG)

Another feature of the console is that you are able to group the output together:
```javascript
console.group("g1");
console.log("test1");
console.log("test2");
console.groupEnd("g1");
```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/414n4imnrtsajl8ih0gb.PNG)

The last feature i would like to mention is the ability to print traces, this should be very usable while debugging:

```javascript
console.log("test");
console.trace("i'm an error!");
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sjrhn0xzdklsbuw7u3e6.PNG)


That's it for now. Have a great sunday!
![Funny](https://media.giphy.com/media/QLKSt3wQqlj7a/giphy.gif)
Git error “fatal: refusing to merge unrelated histories” explanation
Published: 2021-01-24 18:47:36

When two unrelated projects are merged, you may encounter the `fatal: refusing to merge unrelated histories` Git error.  This happens when projects are not aware of each other’s existence and have mismatching commit histories.

---

**We may consider two cases that throw this :**

1. You may have cloned a project for which the `.git` directory is deleted or corrupted. In this situation, Git is unaware of your local history and will throw this error when trying to push to or pull from the remote repository.

2. You may have created a new repository and added commits to it. Now you are trying to pull from a remote repository that already exists and already has commits. Git will throw the error in this case, because it does not know how the two projects are related.

---

## "Refusing to merge unrelated histories" solution

You can solve this issue by adding the `allow-unrelated-histories` flag. After executing `git pull` or `git merge`, add the following flag:

```git pull origin master --allow-unrelated-histories```

Git provides more information regarding this : 

https://github.com/git/git/blob/master/Documentation/RelNotes/2.9.0.txt#L58-L68

*Cover Image : Markus Spiske (@markusspiske) from Unsplash*
Custom YouTube thumbnail and play button for embedded iframe video
Tags: jquery, javascript, codepen
Published: 2021-01-24 18:31:54

I searched for the perfect solution to show a custom high quality thumbnail for my embed videos. I did not want to use the more complex Youtube Javascript API solution. Here is how I archived the obstacle of using a custom thumbnail or Youtube maximum resolution thumbnail and a custom play button.

*The following code uses jQuery but this could be done in Vanilla Javascript.*

{% codepen https://codepen.io/william-solutions/pen/QWKXNGB %}

## Technical explanation to use a custom Youtube thumbnail

* First, I integrate my Youtube video with a custom `div` and custom thumbnail if needed. The data attribute tags are used to provide the Youtube video id and the custom thumbnail URL.

* Then, on page load, for each video on a page, the Javascript code creates a placeholder with the needed thumbnail (custom or Youtube maximum resolution one). A customized play button is added on top using CSS.

* Finally, a click event listener is added to the placeholder to create an embed `iframe` when clicked. When showing the `iframe` the placeholder is hidden.

---

The explanation is  short and sweet, but take a look at the code and let me know what you think !

*Youtube Custom Thumbnail Image: Cédric VT (@cedric_photography) from Unsplash*

*Cover Image: PJ Gal-Szabo (@pjgalszabo) from Unsplash*
Linear Search Examples
Tags: algorithms, datastructure, beginners, javascript
Published: 2021-01-24 18:27:01

Example in C :

```C
#include <stdio.h>

int search(int array[], int n, int x) {
  
  // Going through array sequencially

  int i;
  for (i = 0; i < n; i++)
    if (array[i] == x)
      return i;
  return -1;
}

int main() {
  int array[] = {2, 4, 0, 1, 9};
  int x = 1;
  int n = sizeof(array) / sizeof(array[0]);

  int result = search(array, n, x);

  if(result == -1)
  {
  printf("Element not found");
  }  
  else
  {
    printf("Element found at index: %d", result);
  } 
}

```

Example in JavaScript :

```javascript

function linearSearch(arr, item) {

    for (var i = 0; i < arr.length; i++) {
        if (arr[i] === item) {
            return i;
        }
    }
    return null;
}

var array = [1, 2, 3, 4];

var search = 4;

var result = linearSearch(array, search);

if(result === null)
{
    console.log('The item is not found');
}
else
{
    console.log('The item is found at index '+result)
}
```
twurl on an iPad? Yes, I can!
Published: 2021-01-24 18:23:15

I recently got to playing around with a nice iOS app - [iSH](https://apps.apple.com/us/app/ish-shell/id1436902243). iSH essentially enables a minimal Linux-like (ish!) command prompt to run as an app on iOS. It is based on [Alpine Linux](https://alpinelinux.org/) which is itself based on busybox.

So, as I got to playing with iSH, I thought to myself... what could I do with something like this? 

I've been on a bit of a personal crusade / research effort to see how close to a useful development environment I can get to on an iPad Pro, and aside from apps like [Pythonista](https://apps.apple.com/gb/app/pythonista-3/id1085978097) and [Pyto](https://apps.apple.com/us/app/pyto-python-3/id1436650069) (see - [a comparison of Python for iOS](https://leancrew.com/all-this/2020/03/thoughts-on-ios-python/)), [iCurlHTTP](https://apps.apple.com/us/app/icurlhttp/id611943891), [Working Copy](https://apps.apple.com/gb/app/working-copy-git-client/id896694807), and a few others - mostly SSH clients that let me connect to a another system where I can do the actual work - I've found it *use-able*, but rarely, *fully use-ful*.

One of my daily work tasks is testing Twitter API responses, and to do that, I typically use [`twurl`](https://github.com/twitter/twurl). I've [written about it before](https://dev.to/twitterdev/how-to-use-twurl-to-quickly-test-the-twitter-api-4n48), it's a hugely useful tool, but it was originally written as - and remains - a Ruby Gem, so that can be an overhead sometimes, in terms of where I can use it.

It turns out, following the [instructions on the iSH Wiki on GitHub](https://github.com/ish-app/ish/wiki/Running-Ruby-Programs), I was able to get twurl working - but I did discover something interesting along the way.

The minimal instructions are as follows:

```
apk add jq

# install Ruby (NB ruby-json req'd for some gems)
apk add ruby ruby-dev build-base ruby-json

gem install twurl

twurl authorize

twurl -j "/1.1/users/show.json?screen_name=andypiper" | jq
```

The interesting discovery here came as the step I've noted above. It turns out that Alpine packages the JSON Ruby stuff in a separate package, which meant that for the first few attempts and this, I was getting an error on executing twurl (`ruby 'require': cannot load such file -- json (LoadError)`), until I figured this out. I've now updated the iSH wiki with this tidbit.

This should make my mobile life / times away from my laptop, a little easier!
What you need to know about The Graph (GRT)
Tags: crypto, cryptocurrency, technology, blockchain
Published: 2021-01-31 07:24:00

---
title: What you need to know about The Graph (GRT)
published: true
date: 2021-01-24 18:21:36 UTC
tags: crypto,cryptocurrency,technology,blockchain
canonical_url: https://medium.com/coinmonks/what-you-need-to-know-about-the-graph-grt-b2c3de67450f
---

[![](https://cdn-images-1.medium.com/max/1024/0*EfvHYbY5viggVlSK)](https://medium.com/coinmonks/what-you-need-to-know-about-the-graph-grt-b2c3de67450f?source=rss----721b17443fd5---4)

What is The Graph?

[Continue reading on Coinmonks »](https://medium.com/coinmonks/what-you-need-to-know-about-the-graph-grt-b2c3de67450f?source=rss----721b17443fd5---4)
Introducing Caramel v0.1: an OCaml on the Erlang/Elixir VM
Tags: elixir, reason, opensource, ocaml
Published: 2021-01-24 17:35:05

---
title: Introducing Caramel v0.1: an OCaml on the Erlang/Elixir VM
published: true
description: Caramel v0.1 is out! Caramel is a functional language for building type-safe, scalable, and maintainable applications
tags: elixir, reason, opensource, ocaml
---

Caramel is a functional language for building type-safe, scalable, and
maintainable applications.

It's built in [OCaml 🐫](https://ocaml.org) and maintained by [Abstract Machines](https://github.com/AbstractMachinesLab).

Caramel leverages:

* the OCaml compiler, to give you with a pragmatic type system and
  industrial-strength type safety.

* the Erlang VM, known for running low-latency, distributed, and fault-tolerant
  systems used in a wide range of industries.

Aaaand we just released v0.1 y'all! 🎉🙌

Now featuring:
🌟 A narrower, more focused goal
💅 A code formatter (courtesy of ocamlformat)
📚 A [brand new Manual](https://caramel.run/manual/) with guides
📈 Many tiny improvements

Really,  after a lot of thinking around this, I've decided to scope down Caramel to:

🐫 a strict subset of [OCaml](https://ocaml.org) / [Reason](https://reasonml.github.io)
🛰️ that compiles to (Core) [Erlang](https://erlang.org)

plus:
📚 a small standard library (yes, incl. typed OTP)

The reason for this is that between work and life, I'd like to be able to ship something useful without burning out🧘‍♀️

This seems like a good first step to making Caramel actually usable for day to day work 🧙‍♂️

So be my guest, try and break it and let me know!

🙌

/ Leandro
[@leostera](https://twitter.com/leostera)
Do you plan upcoming weeks on Sundays 🏖? If yes how?🤷🏻‍♂️
Tags: discuss, watercooler, productivity
Published: 2021-01-24 17:18:40

---
title: Do you plan upcoming weeks on Sundays 🏖? If yes how?🤷🏻‍♂️
published: true
description: What do you do on your Sundays?
tags: discuss, watercooler, productivity 
//cover_image: https://direct_url_to_image.jpg
---
Sunday is day the when I sit back, relax and reflect on my past week. Then I set goals for upcoming week using my [Notion Template](https://gumroad.com/l/NVgre). One of my personal way to plan is using weekly batching recommended by Tim Ferriss and block my Calendar ahead of time. Check it out 

{% youtube ghVdzAeX0bg %}
react-activity-detector - Check if the user is idle
Tags: react, npm, idle, active
Published: 2021-01-24 17:14:39

I haven't been active in the OS community, or here, but that might change!
Most of my career I was focused on the backend (C# and partially Java), but I felt that I need push myself to something new.
New projects came, and required me to push myself from my comfort zone, and required me to learn ReactJS, and before that JavaScript.
I must say, it's a lot of fun working with ReactJS (in good and bad way).
It's pretty easy to pickup (mostly saying this since I have spend a lot of time working with strong typing languages like C# and Java).

# Now, to the package!
You can check the package on [react-activity-detector](https://www.npmjs.com/package/react-activity-detector)

What's its purpose?
If you have an app, and need to detect if the user is idle after N seconds/minutes/hours + cross tab functionality!

How to implement it
```js
import ActivityDetector from 'react-activity-detector';

const customActivityEvents = [
    'click',
    'keydown',
];

const signOut = () => {
console.log("The user is loged out");
}

<ActivityDetector activityEvents={customActivityEvents} isActive={true} timeout={5*1000} signOut={signOut}/>

```
You can find more on the [link](https://www.npmjs.com/package/react-activity-detector), and to check out the code you can visit [github.com](https://github.com/filipjelic/react-activity-detector).

Just a note, it's still in early stage and I would be grateful for any suggestions or feedbacks!