teleren/devto huggingface dataset:
Developer Friendly Podcasts
Tags: lists, programming, podcast
Published: 2021-07-22 12:06:16

---
title: Developer Friendly Podcasts
published: true
date: 2021-07-15 02:42:00 UTC
tags: lists,programming,podcasts
canonical_url: https://dils.blog/developer-friendly-podcasts/
cover_image: https://images.unsplash.com/photo-1501808503570-36559610f95e?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDQ3fHxwb2RjYXN0fGVufDB8fHx8MTYyNjE3MjIxMA&ixlib=rb-1.2.1&q=80&w=2000
---
I used to commute a lot before the pandemic. Here are some of the best developer friendly podcasts that kept me entertained in the train.

- [Accidental Tech Podcast](https://atp.fm/)
- [Automators](https://automators.fm/)
- [Developer Tea](https://developertea.com/)
- [Indie Bites Podcast](https://indiebites.co/)
- [Indie Hackers Podcasts](https://www.indiehackers.com/podcasts)
- [Inner Work with Steli Efti](https://pod.link/steli)
- [Mac Power Users Archives - Relay FM](https://www.relay.fm/mpu/archive)
- [Podcasts | Side Hustle School](https://sidehustleschool.com/podcasts/)
- [Podcasts for developers |> Changelog](https://changelog.com/podcasts)
- [Syntax Podcast](https://syntax.fm/)
- [Techkatha – Sri Lankan Tech Podcast in Sinhala](https://techkatha.com/)
- [The REWORK podcast](https://www.rework.fm/index.html)
- [The Stack Overflow Podcast](https://stackoverflow.blog/podcast/)
- [Maintainable](https://www.maintainable.fm/)
- [PODCAST | Legacy Code Rocks!](https://www.legacycode.rocks/podcast-1)

## More Lists 😮

- [Podcasts - DEV Community](https://dev.to/pod)
- [GitHub - rShetty/awesome-podcasts: Collection of awesome podcasts](https://github.com/rShetty/awesome-podcasts)
- [Awesome Geek Podcasts | awesome-geek-podcasts](https://ayr-ton.github.io/awesome-geek-podcasts/)
C# For Beginners - Lesson 3: Data Types
Tags: csharp, dotnet, beginners, programming
Published: 2021-07-15 02:37:20

> At the end of this lesson, you should be able to answer the following:
> 
> * What is a data type?
> * What are some of the commonly used data types in C\#?

---

C\# is a very meticulous language. Every piece of data it encounters must have a _type._

The type of the data determines the set of values that it can have, and also which _operations_ can be performed with it. Depending on the syntax, C\# can sometimes infer the type of the data.

Remember our [Hello, World program](https://dev.to/coding_mama/c-for-beginners-introduction-5ami) earlier? We needed to enclose the text `Hello, World!` in double quotes \(`""`\) for it to be a valid value. Enclosing the text in double quotes made that entire piece of data be of the **string** type.

C\# has many built-in data types. Some types have a special keyword in C\#.  We'll learn where these keywords are used later.

Here is a subset of the basic types you will likely encounter:

### String

The string type can contain text values. The text can have letters, numbers, and symbols.

The length of the string can range from a single character to a whole paragraph - it can even be empty. They need to be enclosed in double quotes.

C\# keyword:  `string`

```csharp
"To you, 2000 years from now"
```

### Integer

The integer type can contain integer \(whole number\) values. Integers can have a negative value and can be written as-is.

C\# keyword:  `int`

```csharp
99
```

### Boolean

The boolean type has only two possible values, true or false. Booleans are used in conditional expressions \(which we'll learn in another lesson.\)

C\# keyword: `bool`

```text
true
```

### Character

The character type can contain a single character. Characters can be letters, numbers, and symbols. They need to be enclosed in single quotes \(`''`\).

C\# keyword: `char`

```csharp
'a'
```

### Floating-Point Numeric

The floating-point numeric type can contain numbers with fractional values, represented in decimal format. Like integers, they can be written as-is.

C\# keyword: `double` \(short for double-precision floating-point\)

```csharp
3.1416
```

`Console.WriteLine()` doesn't just take string values. It can also print out values of other types.

Try printing out each example above by calling `Console.WriteLine()` and replacing the value in the round brackets.

```csharp
// String
Console.WriteLine("To you, 2000 years from now");

// Integer
Console.WriteLine(99);

// Boolean
Console.WriteLine(true);

// Character
Console.WriteLine('a');

// Floating-Point Numeric
Console.WriteLine(3.1416);
```

Run the program - you should see the values in the console output.

![Printing out different data types](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfxzsc12apo8qxvhtr04.png) 

---

> **Question**
> 
> What is the data type of each value below?
> 
> 1. `"true"`
> 2.  `-24601`
> 3. `false`
> 4. `1.38064852`
> 5. `' '`

---

> **Challenge**
> 
> Try to come up with your own values for each data type! Replace the code above with your values to print them out.
AlgoExpert Coding Interview Problems + solutions
Tags: algorithms, datastructures, algoexpert, code
Published: 2021-07-15 02:31:12

Hi guys, here is a compilation of all AlgoExpert coding interview problems and solutions in Python. Please have a look if required. It is up to date with all questions taken care of.

Repo link: https://github.com/das-jishu/algoexpert-data-structures-algorithms
Mode for Partially Sighted People
Published: 2021-07-15 02:21:45

I noticed that many websites make a special mode for partially sighted audience. The mode can differ visually, or have an audio version of the content to be played. I think it's a great trend for both websites as it helps to attract new people, and sighted people as it makes the website and information more accessible. 

If someone here know any special plugin or have a guide on this topic, you are more than welcome to share it. 
The website, that I want to apply it to is here https://www.coffee-statistics.com
Automatically Setting Your Computer's time with Python
Tags: python, time, automation
Published: 2021-07-15 00:40:56

---
title: Automatically Setting Your Computer's time with Python
tags: python, time, automation
published: true
description: Learn how to make a python script which can set your computer's time correctly whenever it goes wrong
canonical_url: https://www.kudadam.com/blog/setting-time-python
cover_image: https://kudadam.sirv.com/blog/setting_time_python/hero.jpg
---
A few months ago, when the CMOS battery inside my computer died, I was having a problem with my PC's time.
I had to set it on each boot and it was very boring so I decided to make a python script to automate the whole process

## How it Works?

So, here's how the script works,
On every reboot:
  * The script makes a call to an API to get the current time based on my I.P address,
    If my computer is not connected to the internet, it sleeps and check again in five minutes time :cool:

  * It then sets the time using the value it got from the API

## Writing the code

So, we are going to write the code used to generate the program.
Open your IDE and create a new python file and name it whatever you want and let's start coding

```python
import requests #Module for handing the request to the API
from time import sleep #The sleep is used to make the program wait if there is no internet connection
import json #For parsing the JSON response from the server
import re # Regex for extracting the current time
from subprocess import Popen

def set_current_time():
  """Function to return the current time"""
  try:
    res = requests.get("http://worldtimeapi.org/api/ip")
    data = res.text
    time_regex = r"\d+:\d+:\d+"
    datetime =  json.loads(data)['datetime'];
    date = re.search(time_regex,datetime).group()
    Popen(['time',date],shell = True)
  except requests.exceptions.ConnectionError:
    #This code is executed incase there is a connection error.
    sleep(3000)

set_current_time()

```

So, that's the code for the program.
We get the datetime and extract the time using a regular expression. Then we use the subprocess module to run a shell command which then set's the time.
If the request is made to the API and there is no internet connection, it will wait for 3000 seconds (5 minutes) before making another request to the server.

When you are done, save this file with a `.pyw` extension instead of `.py`, this will prevent the application from lauching the console when it is running.
Finally, place this file inside `%appdata%/Microsoft/Windows/Start Menu/Startup`.
Restart your computer and see the magic.
Interface Segregation Principle
Tags: beginners, csharp
Published: 2021-07-15 00:34:02

The Interface Segregation Principle (ISP) states:

> A client should not implement interfaces that are not necessary for the application.

In other words, it's preferably that instead of one big interface, the developer creates smaller more manageable interfaces.

Let's say we're tasked to create a game about robots, at first, we design our interface:

```csharp
public interface IRobot
{
	string Name { get; set; }
	void Walk();
	void Fly();
	void Attack();
}
```

Perfect! We created our contract for what makes a robot... that violates the Interface Segregation Principle, because not all robots can `Walk`, `Fly` or `Attack`.

```csharp
public class FriendlyRobot : IRobot
{
	public string Name { get; set; }
	
	public void Walk()
	{
		// Code
	}

	public void Fly()
	{
		Console.WriteLine("This robot can't fly!");
	}

	public void Attack()
	{
		Console.WriteLine("This robot can't attack!");
	}
}
```

To solve this issue, we need to break down into smaller interfaces:

```csharp
public interface IRobot
{
	string Name { get; set; }
}

public interface IWalkable
{
	void Walk();
}

public interface IFlyable
{
	void Fly();
}

public interface IAggressive
{
	void Attack();
}
```

Now we can create a Robot the way we want, without implementing extra code that's not necessary, so our `FriendlyRobot` will be implemented in a different way:

```csharp
public class FriendlyRobot : IRobot, IWalkable
{
	public string Name { get; set; }
	
	public void Walk()
	{
	    // Code
	}
}
```
Liskov substitution principle
Tags: beginners, csharp
Published: 2021-07-15 00:33:52

Created by created by Barbara Liskov and Jeannette Wing, the Liskov Substitution Principle or (LSP for short) states that:

> You should be able to use any derived class instead of a parent class and have it behave in the same manner without modification

In other words, each derived class must maintain the behaviour from the parent class along new behaviour unique to the child class. Making new classes that inherit from the parent class, works without any change to the existing code.

```csharp
static void Main()
{
	Apple orange = new Orange();
	Console.WriteLine(orange.GetColor());
	// outputs: "Orange";
}

public class Apple
{
	public string GetColor() => "Red";
}

public class Orange
{
	public string GetColor() => "Orange";
}

```

Let's implement the Liskov Substitution Principle:

```csharp
static void Main()
{
	Fruit orange = new Orange();
	Console.WriteLine(orange.GetColor());
	// outputs: "Orange"
	Fruit apple = new Apple();
	Console.WriteLine(apple.GetColor());
	// outputs: "Red"
	Orange fruit = new Apple();
	Console.WriteLine(fruit.GetColor());
	// outputs: "Red"
}

public abstract class Fruit
{
	public abstract string GetColor();
}

public class Apple: Fruit
{
	public override string GetColor() => "Red";
}

public class Orange: Fruit
{
	public override string GetColor() => "Orange";
}
```

Here, the Liskov Substitution is satisfied by our code. The application don't need to change to support a new Fruit, since the subtype (Apple and Orange) that inherit from the type Fruit, can be replaced with each other without raising errors.
Open-closed principle
Tags: beginners, csharp
Published: 2021-07-15 00:33:42

Open-Closed Principle (or OCP for short) states:

> Objects or entities should be open for extension but closed for modification.

The "Open for Extensions" means that we need to develop our code to add functionalities when new requirements are created, and "Closed for Modifications" means that we already developed our code, that went through testing and validations, this could should only be altered in case a bug has been found.

```csharp
public class Rectangle
{
	public double Height { get; set; }
	public double Width { get; set; }
}
```

```csharp
public class AreaCalculator
{
	public double TotalArea(Rectangle[] rectangles)
	{
		double result = 0;
		foreach(Rectangle rectangle in rectangles
			result += rectangle.Height * rectangle.Width;
		
		return result;
	}
}
```

But our application recieved a new requirement for calculating the area of a circle.

```csharp
public class Circle
{
	public double Radius { get; set; }
}
```

For this to work, we also need to change the `AreaCalculator` class.

```csharp
public class AreaCalculator
{
  public double TotalArea(object[] shapes)
  {
	  double result = 0;
	  
	  foreach(object shape in shapes)
	  {
		  if(shape is Rectangle)
		  {
			  Rectangle rectangle = (Rectangle)obj;
			  result += rectangle.Height * rectangle.Width;
		  }
		  if(shape is Circle)
		  {
			  Circle circle = (Circle)obj;
			  result += circle.Radius * circle.Radius * Math.PI;
		  }
	  }
	return result;
  }
}
```

With these modifications, we added a `Circle` to our application. 
But what if we need to add a `Triangle` or a `Square`? We would need to add more and more  `if` statements to our `TotalArea` method.
This is where the Open-Closed Principle comes into our aid.
In this example, `Rectangle`and `Circle`can derive from the same abstract concept, a `Shape`.

```csharp
public abstract class Shape
{
	public double CalculateArea();
}
```

Now, let's use the `Shape` class in our "Shapes".

```csharp
public class Rectangle: Shape
{
	public double Height { get; set; }
	public double Width { get; set; }

	public double CalculateArea()
	{
		return Height * Width;
	}
}

public class Circle: Shape
{
	public double Radius { get; set; }

	public double CalculateArea()
	{
		return Radius * Radius * Math.PI;
	}
}
```

With our Shapes implementing the `CalculateArea` from our `Shape` class, we need to update the `AreaCalculator` class.

```csharp
public class AreaCalculator
{
  public double TotalArea(Shape[] shapes)
  {
	  double result = 0;
	  
	  foreach(Shape shape in shapes)
	  {
		  result += shape.CalculateArea();
	  }
	  
	return result;
  }
}
```

With these changes, now we're implementing the Open-Closed principle. Our application is open for extensions (creating a `Triangle` class for example) but closed for modifications, only modifying if any bugs were founds.
Single Responsibility Principle
Tags: beginners, csharp
Published: 2021-07-15 00:33:34


Single Responsibility Principle (or SRP for short), states that:

> A class should have one and only one reason to change, meaning that a class should have only one job.

This doesn't mean that a class should contain only one method or one property, but its members must relate to its responsibility.

For this example, we're going to create an `UserService`, its responsibility, is to manage User data in a system.

```csharp
public class UserService
{
  public void CreateUser(string email, string password)
  {
    if(string.isNullOrEmpty(email)
     throw new NullArgumentException("E-mail cannot be null or empty.");
     
    if(string.IsNullOrEmpty(password)
     throw new NullArgumentException("Password cannot be null or empty.");

    User user = new User(email, password);

    var smtpClient = new SmtpClient("smtp.gmail.com")
	{
	    Port = 587,
	    Credentials = new NetworkCredential("email", "password"),
	    EnableSsl = true,
	};
    
	smtpClient.Send("our.app@gmail.com", email, "Welcome!", "Welcome to our system!");
  }
}
```

The example above violates the SRP principle because the `CreateUser`method is responsible for two things, creating an user and sending an e-mail.

Let's change it so it respects the SRP principle.

```csharp
public class UserService
{
  private readonly IEmailService _emailService;

  public UserService(IEmailService emailService)
  {
    _emailService = emailService;
  }

  public void CreateUser(string email, string password)
  {
    if(string.isNullOrEmpty(email)
     throw new NullArgumentException("E-mail cannot be null or empty.");
     
    if(string.IsNullOrEmpty(password)
     throw new NullArgumentException("Password cannot be null or empty.");

    User user = new User(email, password);

    _emailService.SendEmail(email, "Welcome!", "welcome to our system!");
  }
}
```

Now the `UserService` is only responsible to create the user, and it delegates the e-mail to another class.
Introduction
Tags: beginners, csharp
Published: 2021-07-15 00:33:23

First compiled by Robert C. Martin in 1990s, SOLID is a acronym that stands for:

* S: Single Responsibility Principle (SRP)
* O: Open closed Principle (OCP)
* L: Liskov substitution Principle (LSP)
* I: Interface Segregation Principle (ISP)
* D: Dependency Inversion Principle (DIP)

These are a set of **golden rules for object-oriented programming**, that make it easier for developers to develop applications that are easy to maintain, refactor and expand.

In this series, we'll dive into what each of these principles are and how they are implemented
There is a better alternative for serverless caching
Published: 2021-07-27 19:04:02

---
title: There is a better alternative for serverless caching
published: true
date: 2021-07-14 23:21:00 UTC
tags: 
canonical_url: https://blog.kapic.io/serverless_redis/
---

The other day, I was really excited because I thought of a great idea for a service: I was going to create a SaaS that handled caching for serverless applications (targeting Netlify specifically, but other platforms could use it as well). In my mind, serverless caching was the one thing that was still lacking from modern serverless stacks, and it was a problem that I needed to solve for [TickerTab](https://tickertab.io/). I wrote an [article](https://blog.kapic.io/grow_netlify_app_with_a_private_api) about how I planned on solving this problem, and funnily enough, I will probably be changing my solution.

Unfortunately for me (because I wanted to build this business idea), there already is a company providing serverless caching. Enter [Upstash](https://upstash.com/), a serverless database for Redis. Upstash has a free tier for up to 10,000 daily commands, which seems amazing, and after that it is only $0.02/100,000 commands. If you want persistance, it is $0.25/GB/month. Not bad.

Technically speaking, Upstash probably has the insecurity problem I mentioned in my original article about working with a serverless cache, but it still might be worth using for the sake of simplicity. If I choose to migrate TickerTab, my new stack will be:

- Netlify (Hosting, Identity, Functions) - Free until 1,000 MAU, then $100/month
- Stripe (Billing) - 2.9% + $0.30 per successful charge
- [EOD Historical Data](https://eodhistoricaldata.com/) - $40/month (for the data necessary for TickerTab)
- Upstash - Free until >10,000 daily commands
- Chat server - Starting at $10/month, hosted on [Vultr](https://www.vultr.com/?ref=8752906), and scaling as needed (manually)
- Mailgun - I am not actually sure if I will need this for a pure operational cost, but I anticipate using it to send receipts for Stripe transactions.

In which case I will launch with an operational cost of $50/month until TickerTab grows large enough to have 1,000 MAUs (which will bump me up to $150/month).

The only other thing I might consider switching is my hosting provider. When I started developing TickerTab, Netlify seemed like the obvious choice, but as I have learned more, it might be the case that [Cloudflare](https://www.cloudflare.com/) is better. If I were to switch to Cloudflare for hosting and functions, I would use [Supabase](https://supabase.io/) for authentication. However, I probably will not switch; I mostly just want to be done developing TickerTab since I have worked on it for so long.

To be honest, I still may try to compete with Upstash because I think there is a lot of opportunity in the market, but I will likely try my other ideas first. I still need to finish working on TickerTab, and I have another idea that could be _really good_.
Adding relative img paths to mdx
Tags: nextjs, mdx
Published: 2021-07-18 12:01:26

---
title: Adding relative img paths to mdx
published: true
date: 2021-07-15 00:00:00 UTC
tags: nextjs, mdx
canonical_url: https://jokens.me/posts/2021/07/mdx-relative-img-import
---

I was migrating my blog from Gatsby to Nextjs today (which just migrated from Hexo), and I found that I had problems using relative paths for images.

My stack for MDX rendering was `@mdx-js/loader` + `@next/mdx`

My directory structure was as follows:

```
pages
├── 404.tsx
├── _app.tsx
├── _document.tsx
├── about.tsx
├── api
│   └── atom.xml.tsx
├── friends.tsx
├── index.tsx
├── posts
│   ├── 2020
│   │   ├── 06
│   │   │   ├── build-blog
│   │   │   │   ├── ahei-wechat.png
│   │   │   │   └── index.mdx
│   │   │   └── hello-blogging.mdx
│   │   └── 07
│   │   └── new-short-domain.mdx
│   └── 2021
│   ├── 01
│   │   └── zinit-selective-loading
│   │   ├── index.mdx
│   │   └── pipenv.png
│   └── 07
│   └── mdx-relative-img-import.mdx
├── projects.tsx
└── tags
    ├── [tag].tsx
    └── index.tsx

11 directories, 17 files

```

I've decided that I would not give up either markdown image syntax nor relative imports in next.js.

So, after a morning of testing, this was what I came up with.

A custom loader to translate markdown syntax:

```jsx
const replaceAll = require("string.prototype.replaceall");

module.exports = function (content, map, meta) {
  return replaceAll(
    map
    content,
    /\!\[(.*)\]\((.+)\)/g,
    `<NextImage alt="$1" src={require('$2').default} />`
  );
};

```

and a component to render:

```tsx
const components = {
  NextImage: (props: any) => {
    return <Image alt={props.alt || "Image"} {...props} />;
  },
};

```

The fundamental magic here is that the `<NextImage />` component actually runs in-place of the mdx file, giving it access to the `require().default` syntax.
When scaling up looks like scaling down
Tags: linters, automation, scale
Published: 2021-07-18 20:37:39

---
title: When scaling up looks like scaling down
published: true
date: 2021-07-15 00:00:00 UTC
tags: linters,automation,scale
canonical_url: https://jhall.io/archive/2021/07/15/when-scaling-up-looks-like-scaling-down/
---

I was listening to [a podcast episode](https://devchat.tv/adventures-in-devops/gaining-stability-with-rule-based-policies-with-shimon-tolts-devops-075/) where the guest was explaining problems scaling to hundreds of engineers, and one of the tools they found useful was essentially automatic linters for configuration files (Kubernetes manifests in this case).

This got me thinking: Sometimes the same tools that help an organization scale to hundreds or thousands of engineers are the exact same tools that help scale down, perhaps all the way to one engineer.

The main problem I gather the podcast guest was aiming to solve for large teams was one of communication. Teaching hundreds of developers to all follow the same standards for correctness is a daunting task. But by solving that problem, they also solved another problem that applies equally to small teams: Providing shorter feedback loops, and automating toil.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._