Read the original blog on dev.to

Mypy is a static type checker for Python. It acts as a linter, that allows you to write statically typed code, and verify the soundness of your types.

All mypy does is check your type hints. It’s not like TypeScript, which needs to be compiled before it can work. All mypy code is valid Python.

This gives us the advantage of having types, as you can know for certain that there is no type-mismatch in your code, just as you can in typed, compiled languages like C++ and Java, but you also get the…


Read the original on dev.to

Photo by Roman Synkevych on Unsplash

I’ve been practicing my Data Structures and Algorithms on LeetCode for a few months now, and it’s an awesome platform. The quality of the questions is generally great, there’s very nice explanations for most of the solutions, and there’s a very motivated and active community around all of it. Overall, LeetCode is a great platform.

BUT, I had two slight problems with it:

  1. I personally never understood the idea of writing your code and testing it on a web editor. I mean, I have my own programming environment tailored to exactly how I like to…

So someone at Google released a tool called zx a couple days ago, and…

Well, take a look at it for yourself:

I can’t be the only one who hates:

  1. The idea of having to install nodejs and npm on my servers just to run a shell script.
  2. The await $`...` syntax used for every. single. command.

And I thought I could do better, so I tried. And this is what I came up with:

Introducing zxpy

#! /usr/bin/env zxpy
~'echo Hello world!'
file_count = ~'ls -1 | wc -l'
print("file count is:", file_count)

It fixes the two problems I had in…


I’m a huge fan of Python. It’s by far the simplest general purpose language, that you can just pick up and start building amazing things with.

But for the past year or so, I’ve been working on frontend projects, and I’ve really enjoyed using TypeScript. It’s essentially JavaScript, but with fancy features built on top of it like Static Type checking and Null safety, and it was awesome how much it helped in writing robust, bug free code.

So I went out to find if Python has such an equivalent, and sure enough, there was.

It’s called mypy, and it…


This guide is here just because I’ve messed up the installs on arch before, and turns out it’s actually pretty easy to do.

Photo by Caspar Camille Rubin on Unsplash

Step 1 — Install the dependencies

sudo pacman -S yay
yay postgresql pgadmin4

This should automatically setup your postgres user and group.

Step 2 — Setup postgres service

sudo -u postgres -i # login as postgres
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/'
exit
sudo systemctl enable --now postgresql
sudo systemctl status postgresql # to check for any errors

Step 3 — Setup password

psql -U postgrespostgres=# \password # to set password

Step 4 — Setup connection security

$ su# cd /var/lib/postgres/data
# cp pg_hba.conf pg_hba.conf.backup # in case you mess up
# nano pg_hba.conf

Your default pg_hba.conf…


Original Post on dev.to

P.S. if you’re in a hurry, find the correct solution here

I was working on a full stack side project a few months ago, and I wanted to make API requests from my android app to my desktop, and for some reason localhost:8000 wasn't simply accessible by my phone.

Well, understandable, I know that every device’s localhost is independent and cannot be accessed by your home network (your Wi-Fi, for example). So the localhost on my laptop won’t be able to access the localhost on my phone.

So, I asked Google for help. And I got…


URL shorteners are great. You can take a long URL and make it 6–8 characters, you know the drill.

And the free URL shorteners are pretty nice too! bit.ly is what I used, and it did its job pretty well, but free public shorteners have a few issues:

  • Finding the perfect short URL is hard: most of the short ones that make sense, are usually already taken.
  • the URLs are hard to update: (and I don’t know if this is a bit.ly specific issue), but you can’t change the URL the short link points to, once it has been created.


Hi!

So, Flutter. Flutter is a cross-platform mobile SDK, which allows you to build android as well as iOS apps from the same codebase. The apps are light, performant and run natively on both devices. Pretty cool, right?

This post will guide you through some of the basics of Flutter while making a simple Login page. This post does assume you have flutter installed and you’ve made a fresh project. So let’s dive right in.

Part 1: Widgets

Everything in flutter is going to be a widget. From windows to text boxes, down to the themes and padding. …

Tushar Sadhwani

i write code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store