Tag: <span>code</span>

Structured concurrency in Python with AnyIO
Post

Structured concurrency in Python with AnyIO

Originally posted on mattwestcott. How to improve your spaghetti asyncio code By now you might be familiar with the term ‘structured concurrency’. It’s a way to write concurrent programs that’s easier than manually taking care of the lifespan of concurrent tasks. The best overview is Notes on structured concurrency by Nathaniel Smith (or his video if you prefer). This post...

Make Your Python Code Fluent
Post

Make Your Python Code Fluent

Originally posted on towardsdatascience. With Function and Operator Overloading Overloading in Python allows us to define functions and operators that behave in different ways depending on parameters or operands used. Operator Overloading As an example, we can use “+” operator to do arithmetic calculations on numerical values while the same “+” operator concatenates two strings when strings operands used. This is called operator overloading and it...

How to Profile Your Code in Python
Post

How to Profile Your Code in Python

Originally posted on towardsdatascience. Finding bottlenecks and optimizing performance using cProfile If you’ve ever written a line of code (or even tens of thousands of lines), you’ve surely wondered “Why does my code take so long to run?” Answering that question isn’t always simple, but it can be easier if you search for answers the...

Jupyter is now a full-fledged IDE
Post

Jupyter is now a full-fledged IDE

Originally posted on towardsdatascience Literate programming is now a reality through nbdev and the new visual debugger for Jupyter. Notebooks have always been a tool for incremental development of software ideas. Data scientists use Jupyter to journal their work, explore and experiment with novel algorithms, quickly sketch new approaches and immediately observe the outcomes. However,...

Callbacks & Promises in Javascript
Post

Callbacks & Promises in Javascript

Javascript is a single threaded asynchronous language. What does that mean? It means it cannot multi-task, but can pause execution of one task to do something else and switch back and forth between tasks so as to maximise performance. It makes sense because javascript is a browser language, and browsers need to make network calls...

Python Pro Tip: Start using Python defaultdict and Counter in place of dictionary
Post

Python Pro Tip: Start using Python defaultdict and Counter in place of dictionary

How you could use defaultdict and Counter to make your code short and readable Learning a language is easy. Whenever I start with a new language, I focus on a few things in below order, and it is a breeze to get started with writing code in any language. Operators and Data Types: +,-,int,float,str Conditional statements: if,else,case,switch...

Building Code
Post

Building Code

How were programming languages built? Here’s a brief history. We, humans, have always been on the lookout for somebody to do our heavy and unwanted lifting. First it was simple machines, then steam powered beasts, and at the end a bunch of semiconductors and a quartz. But how do you get a simple stone to do...

Going beyond just a programming language
Post

Going beyond just a programming language

In computer science, it seems that everybody is focusing on the programming language that the teacher or department chooses – be it Java, C#, Ruby or Python. Deciding upon a programming language to teach is only one step, however. The next question is – how do we gain confidence within ourselves to learn this language, in...

5 ways static code analysis can save you
Post

5 ways static code analysis can save you

If you’re not doing static code analysis (aka static analysis), now is the time to start. Delivering code faster has dubious value if the quality degrades as development cycles shrink. On the other hand, if you’re not doing static code analysis, you’re not alone. Despite the mature age of the tool category, not a lot...

My Visual Studio Code Setup
Post

My Visual Studio Code Setup

I love the text editor setup I’ve been using for the past year and a half, so I want to show off my setup! Visual Studio Code has far surpassed my experiences with Atom, Spyder, Sublime Text, Emacs, and Idle (the built-in Python editor) which I used for the years before it. I thought I would do...

Looping through objects in JavaScript
Post

Looping through objects in JavaScript

Once in a while, you may need to loop through Objects in JavaScript. The only way to do so before ES6 is with a for...in loop. The problem with a for...in loop is that it iterates through properties in the Prototype chain. When you loop through an object with the for...inloop, you need to check if the property belongs to...

Another engineer asked me for feedback…
Post

Another engineer asked me for feedback…

Another engineer asked me for feedback on their performance. I wrote a few things down and then re-read it and realized this could apply to almost anyone. What follows is the advice I gave them. Names and technologies have been changed for their own protection… What am I doing wrong? I tend to think positively, which...

How To Review Code You Don’t Understand
Post

How To Review Code You Don’t Understand

I recently read an article by Max Bittker called “How to Review Code You Don’t Understand”, and it got me to thinking about times when I’ve been tasked with doing just that. One of the troubles I have with code review is understanding the context around a change. Given a diff, I can work through it...

React v16.4.0: Pointer Events
Post

React v16.4.0: Pointer Events

The latest minor release adds support for an oft-requested feature: pointer events! It also includes a bugfix for getDerivedStateFromProps. Check out the full changelog below. Pointer Events The following event types are now available in React DOM: onPointerDown onPointerMove onPointerUp onPointerCancel onGotPointerCapture onLostPointerCapture onPointerEnter onPointerLeave onPointerOver onPointerOut Please note that these events will only work in browsers that...