teleren/devto huggingface dataset:
You are making a mistake by not using Serverless
Tags: serverless, webdev, programming, architectures
Published: 2022-03-29 05:11:06

This article is on our 2nd episode of Canopas Podcast —[Introduction to Serverless approach](https://blog.canopas.com/canopas-podcast-2-you-are-making-a-mistake-by-not-using-serverless-694e4e9ee6fc).

Nowadays, most developers prefer a [Serverless](https://blog.canopas.com/golang-serverless-microservices-with-gin-f3c2a4943a6d) approach rather than managing a server.

Serverless architecture frees developers from having to think about server provisioning, like scaling up to meet increasing workloads or over-provisioning and paying for unused resources.

Serverless architectures dynamically use only what they need, and customers are only billed for what they use.

The below podcast will guide you about how you can adopt a Serverless approach.

{% embed https://youtu.be/yXqCKe2TFzs %}
Keyoxide Proof
Tags: security
Published: 2022-03-29 05:02:51

This is an OpenPGP proof that connects [my OpenPGP key](https://keyoxide.org/2a420f2982e589326ca49d1b0644b87ed144c988) to [this dev.to account](https://dev.to/hosaka). For details check out https://docs.keyoxide.org/advanced/openpgp-proofs/

[Verifying my OpenPGP key: 2a420f2982e589326ca49d1b0644b87ed144c988]
How React-Native Cross-Platform Works?
Published: 2022-03-29 04:09:37


React-Native. https://github.com/facebook/react-native

This Blog Post started as a curiosity on how cross-platforming features work in React Native, but while [researching](https://betterprogramming.pub/react-native-under-the-hood-281df5f548f), I discovered that this blog post should be a work in progress about something more.

About https://webkit.org WebKit engine.
About hidden JavaScriptCore framework. https://www.cyberark.com/resources/threat-research-blog/the-mysterious-realm-of-javascriptcore
https://github.com/WebKit/webkit/tree/main/Source/JavaScriptCore 
About Why every browser switching to Blink could be bad news for the web https://medium.com/@stouff.nicolas/why-every-browser-switching-to-blink-could-be-bad-news-for-the-web-aea773059e84
About Gecko.https://developer.mozilla.org/en-US/docs/Glossary/Gecko
About Chrominum&V8&Blink. https://www.chromium.org/chromium-projects/
https://v8.dev
How I decided to switch for only Chrominium based architecture browsers.
I will call this blog post a work in progress. 
There are a lot of things to research. 
If you're curious how cross-platform systems work, across Linux,osx, windows, ios, android or different processors, leave a comment or ideas. Thanks.
p.s I knew JavaScript was weird, but why so why sooooo odd. 

https://www.cyberark.com/wp-content/uploads/2021/03/Figure1.png








### Conclusion

> TL;DR

⚠️ Next Blog Post.

### Links

🖇 Follow me on [GitHub](https://github.com/aserputov) 

🖇 Follow me on [Twitter](https://twitter.com/aserputov) 

_p.s This post was made out of my curiosity
.append vs .appendChild in JS
Tags: javascript, beginners, programming, webdev
Published: 2022-03-29 03:38:01

What's the difference between .append and .appendChild?
The distinction has robbed me of a couple of hours so here's to hopefully saving you a little bit of time.

First of all, we can see the full functions at MDN:

- Element.append(), inserts a set of Node objects or DOMString objects after the last child of the Element

- Node.appendChild(), adds a node to the end of the list of children of a specified parent node


.append can work with multiple Node or DOMString objects and must be called on an element, whereas .appendChild can only add a single Node to a parent Node and cannot work with DOMstrings.

Another distinction is that .appendChild actually returns the child element so it cannot be used in a function chain, while .append returns nothing and thus can be chained.

Lastly, .append is the more general method and can produce the same functionality as .appendChild, which serves a more specific purpose.
A Node.js Developer Tries .NET
Tags: javascript, dotnet, hasura
Published: 2022-03-29 03:27:30

"You put up quite a fight .NET, you wore me down and made me cry, but I eventually overcame your extraordinarily unhelpful help and won!", I proudly thought. Then I added up the amount of hours it took to port my Node app to .NET. This was a miserable failure.

- How hard can it be to make an API endpoint that takes accepts a simple POST request?
- How hard can it be to run that API on the port I want?
- What if I try and configure that port number with an environment variable?
- How hard can it be to cache some data with Redis?
- How hard can it be to send emails in the background?

Working with .NET it turns out the answer to all the above is to give up, turn off your computer, go home, learn how to crochet, start selling little crocheted figures on etsy, that's your new job now.

The goal was simple. I wanted to create a clone of my [NodeJS API that I run as a support service behind Hasura](https://github.com/aaronblondeau/hasura_starters/tree/master/dotnet). It does things like authenticate requests, add custom actions to the GraphQL API, and execute background jobs. All of this is pretty simple everyday stuff. Since deciding to re-visit .NET (after a 10 year absence) I thought this would be a good project to help me re-learn the platform.

However, there was one huge issue I failed to foresee : I could not find an intuitive way to do **anything** with .NET. If I were to invest the enormous time it takes to get into the framework then I'm sure I could get a lot of things memorized and move around pretty well. But, who has time for that?

Take for example, this super hip password reset page I made : https://github.com/aaronblondeau/hasura_starters/blob/master/dotnet/Pages/PasswordReset.cshtml#L3

Should be easy enough:
- Basic HTML for a form
- Post route to handle form
- Re-render form on error, redirect on success

I spent at least four hours trying to get this to work. Turns out that you must have this little "@addTagHelper" statement along with an "asp-for" attribute in the form. It absolutely would not submit a raw form post to my [OnPostAsync](https://github.com/aaronblondeau/hasura_starters/blob/master/dotnet/Pages/PasswordReset.cshtml.cs#L28) without this magical combination. **WHY???** How come I can't make a super simple form like this.

I'm sure most of this has to do with my perspective.  I've primarily worked with Node, Python, and Dart (Flutter) for the past year.  Dart and Python I learned recently and they did not get in my way like .NET does. Maybe the Microsoft tools try to do too much for you, and the loss of freedom that causes is too much for me to get my head around.

Maybe I need an easier intro project to help me learn. Suggestions?
fetch( kungFu )
Tags: beginners, codenewbie, javascript, todayilearned
Published: 2022-03-29 03:26:32

Aloha amigos!

I hope this blog is the start of an exciting tradition. I have always been a bit shy when writing about myself. I feel weird even keeping a journal. I don't know where I picked up on the habit of disregarding documentation but here's to making progress and writing it down.

It has been a while since I took time out to pursue rigorous study. I have often wished I could jump back into the thick of it. But, we all know what it's like, being somewhere a while and then dreaming of a greener pasture. So here I am, trying my hand at uncovering the mysteries of computer magic.

The title of this post may be a bit confusing to those of you who haven't completed an introductory course in Javascript, so let me explain. First, there is no shortcut to learning. But, if there were, maybe it would look like this. 

When we utilize a fetch request, we ask an outside source, a server, for information. We do this by providing the fetch function with a URL to a destination containing the data we want to use. Once the GET request is received, a response fires back to the fetch called a promise. Think of a promise as a gift certificate. After we use the .then() method to verify whether we are exchanging our certificate for a lovely present or not, we are ready to unwrap our gift using .json(). We do so, and after another .then() request (where we figure out what to do with the damn thing), we are ready to use our brand new data!

Wouldn't it be nice if we could send a fetch request in our mind and instantly learn something new in a snap? Maybe one day, we will all blow on the dusty card of a mortal combat cartridge and click that sucker into the back of our heads. Like Neo said... "I know kung fu."
SQL-Quick tip #6 - Find table or column
Tags: tsql, sqlserver, sql, mssql
Published: 2022-03-29 03:19:04

## Sql Server tips and tricks

This is part of a series of quick tips and tricks I have accumulated over the year, that I think can be useful for others.
If you have similar short tips and tricks please leave a comment.

### Find table by name

If you have ever worked on a big database with a huge number of tables and you are not yet familiar with the whole data model, you know how hard it is to locate that specific table you are looking for. Or maybe you just need to get a list of tables that have similar names to put into that Power Point presentation you are working on. 
Then the following query may be useful to you.

```sql
SELECT *
  FROM sys.tables
 WHERE name LIKE '%partOfTableName%'
```

![Sql Server Management Studio screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/euiq7siwpnqwpztosyr5.png)

### Find table that have a specific column

If you have been a programmer for some time and worked on different projects for different customers then you have probably some across databases with few or entirely without foreign key constraints. There can be a lot of reasons for not having foreign keys constraint and I won't go into them here, but one consequence of not having them is that finding tables that is related to other tables becomes hard so you need another way of finding related tables i to hope that the person who implemented the tables named the columns relating the tables by the same name or a similar name. And if this is the case you can query all your database tables to find all tables containing columns with a specific name. This query below does that.

```sql
USE Northwind

DECLARE @searchText VARCHAR(200) = 'address'

 SELECT SCHEMA_NAME(schema_id) + '.' + t.name AS [Table name],
        c.name AS [Column name]
   FROM sys.tables AS t
   JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
  WHERE c.name LIKE '%'+ @searchText +'%'
  ORDER BY [Table name];
```

![Sql Server Management Studio screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8prb8ej9vqqbi6cnqgm.png)
Cache a python function with lru_cache
Tags: python
Published: 2022-03-29 03:18:51

---
canonical_url: https://waylonwalker.com/til/python-lru-cache/
published: true
tags:
- python
title: Cache a python function with lru_cache
---

The easiest way to speed up any code is to run less code.  A common technique to reduce the amount of repative work is to implement a cache such that the next time you need the same work done, you don't need to recompute anything you can simply retrieve it from a cache.

## lru_cache

The easiest and most common to setup in python is a builtin functools.lru_cache.

```python
from functools import lru_cache

@lru_cache
def get_cars():
    print('pulling cars data')
    return pd.read_csv("https://waylonwalker.com/cars.csv", storage_options = {'User-Agent': 'Mozilla/5.0'})
```

## when to use lru_cache

Any time you have a function where you expect the same results each time a function is called with the same inputs, you _can_ use lru_cache.

> when same *args, **kwargs always return the same value

lru_cache only works for one python process.  If you are running multiple subprocesses, or running the same script over and over, lru_cache will not work.

> lru_cache only caches in a single python process

## max_size

lru_cache can take an optional parameter `maxsize` to set the size of your cache.  By default its set to `128`, if you want to store more or less items in your cache you can adjust this value.

The `get_cars` example is a bit of a unique one.  As [anthonywritescode](https://www.youtube.com/watch?v=K0Q5twtYxWY) points out this implementation is behaving like a singleton, and we can optimize the size of the cache by allocating exactly how many items we will ever have in it by setting its value to 1.

```python
from functools import lru_cache

@lru_cache(maxsize=1)
def get_cars():
    print('pulling cars data')
    return pd.read_csv("https://waylonwalker.com/cars.csv", storage_options = {'User-Agent': 'Mozilla/5.0'})
```

## My example stretches the rule a little bit

The example above does a web request.  As a Data Engineer I often write scripts that run for a short time then stop.  I do not expect the output of this function to change during the runtime of this job, and if it did I may actually want them to match anyways.

> web request do change their output

If I were building webapps, or some sort of process that was running for a long time.  Something that starts and waits for work, this may not be a good application of lru_cache.  If this process is running for days or months my assumption that the request does not change is no longer valid.

## There's also a typed kwarg for lru_cache

This one is new to me but you can cache not only on the value, but the type of the value being passed into your function.

> (from the docstring)
> If *typed* is True, arguments of different types will be cached separately.
> For example, f(3.0) and f(3) will be treated as distinct calls with distinct
> results.
A Simple Way to Explain HTML, CSS and Javascript and How They Relate
Tags: html, css, javascript, frontend
Published: 2022-03-29 02:56:24

This article was originally published in my blog www.exceptionalprogramming.com

Want to know a simple way to understand three of the most important front-end elements of software web development?

This article will do just that as it will explain how Hypertext Markup Language (HTML), Cascading Style Sheets (CSS), and Javascript work in harmony to bring about the beautiful web pages we all interact with every day.

First, let’s read over the sentence “The Brown Dinosaur Danced.” In this sentence we could use HTML to represent “Dinosaur(noun)”, CSS for “Brown (adjective)”, and Javascript for “Danced (verb).”  

HTML consists of items like paragraphs, and headings which are like the nouns in a sentence as they are the main structures/characters. CSS, you can think of as adjectives because they describe and give a deeper understanding of HTML. 

For example, if you have a heading on a website with CSS you can add a number of styles to it like making it bold, capitalizing, making it a particular font, etc.

Finally, we can look at Javascript as the verb because it allows the user to see and do actionable steps on the screen like computing numbers or pressing a button on a screen that leads to another website link. That is why the example sentence at the beginning of the article that “danced” was used to describe Javascript as it shows the brown Dinosaur doing something like dancing.

This was a brief synopsis of how HTML, CSS, and Javascript work together. It’s not meant as an exhaustive deep dive into the concepts but just a simple way for beginners on these concepts to better understand how they relate with one another.

Please like and share this article if you found helpful. 

You can check out some of my other articles on my blog [www.exceptionalprogramming.com   ](http://www.exceptionalprogramming.com/)
What is a unit test?
Tags: qa, softwaretesting, unittesting, softwaredevelopment
Published: 2022-03-29 02:45:14

---
title: What is a unit test?
published: true
date: 2022-03-29 02:41:08 UTC
tags: #qa #softwaretesting #unittesting #softwaredevelopment
canonical_url: https://blog.seancoughlin.me/what-is-a-unit-test
---

## Unit Testing Background

**Tl;dr** : a unit test is code that tests other code.

[Unit tests](https://en.wikipedia.org/wiki/Unit_testing) are the smallest type of software testing. They are meant to verify that a single piece of code is working as intended. Unit testing is typically automated, and developers run tests as part of the development process to make sure everything is working appropriately.

Unit tests are commonly run on every build or change to the codebase.

Unit testing can fall into the category of [TDD or test-driven development](https://dev.to/scc33/what-is-tdd-1mi7). TDD is a common method in [extreme programming](https://en.wikipedia.org/wiki/Extreme_programming) and [agile](https://en.wikipedia.org/wiki/Agile_software_development) where unit tests are written before the code.

Unit tests can sometimes be difficult to write because code often relies on outside components. In these cases, [stubbing](https://en.wikipedia.org/wiki/Method_stub) or [mocking](https://en.wikipedia.org/wiki/Mock_object) are common techniques to implement unit tests.

## Unit Testing Frameworks

There are hundreds of testing frameworks in existence because unit testing is so common. Wikipedia maintains a [long list of testing frameworks](https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C++) for many languages. Some of the most popular frameworks are [Junit](https://en.wikipedia.org/wiki/JUnit) for Java, [Mocha](https://en.wikipedia.org/wiki/Mocha_(JavaScript_framework)) for JavaScript, and [PyTest](https://docs.pytest.org/en/7.1.x/) for Python.

## Advantages

- Unit tests are small and typically quick to run. The speed makes them easier to check and hastens development.
- Unit testing can be helpful documentation because it shows how the code is properly used and can give insight into functionality.
- Developers can use unit tests as a helpful sanity check to make sure their code is working as intended and under many scenarios.

## Disadvantages

- Since unit tests are checking only small chunks of code, they cannot catch large errors that exist on the system level. Other testing methods like [integration tests](https://en.wikipedia.org/wiki/Integration_testing) are required for verifying the system behavior.
- Writing and maintaining unit tests can often be difficult because developers are focused on writing deliverable code for customers.
- Unit tests, like all testing, may not cover every edge case or may be incorrect. Therefore, relying too heavily on unit tests creates a false sense of security that the code is working as intended.

## Further Reading

Unit tests are just the first level of testing. More types of testing can be read about in [my series on software testing and its methods](https://blog.seancoughlin.me/series/software-testing).
SPO600 Project - Candidate Selection final summary
Tags: spo600, projectstage1
Published: 2022-03-29 02:40:34

Hello, this is Tecca, with regard to previous post, in this [post](https://dev.to/pykedot/11-24m9) I will do an update on two candidate packages that I was looking into, and summarize with what my approaches are towards optimization in the end.

1. FFmpeg

- FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.

[FFmpeg website](http://ffmpeg.org/)
[FFmpeg Github repo](https://github.com/FFmpeg/FFmpeg)

2. Rtm - Realtime Math

- This library is geared towards realtime applications that require their math to be as fast as possible. Much care was taken to maximize inlining opportunities and for code generation to be optimal when a function isn't inlined by passing values in registers whenever possible. 
  
  [Rtm Github repo](https://github.com/nfrechette/rtm)

3. libjpeg-turbo

- libjpeg-turbo is a JPEG image codec that uses SIMD instructions to accelerate baseline JPEG compression and decompression on x86, x86-64, Arm, PowerPC, and MIPS systems, as well as progressive JPEG compression on x86, x86-64, and Arm systems.

[libjpeg-turbo repo](https://github.com/libjpeg-turbo/libjpeg-turbo)

I came across these three packages feeling they could greatly benefit from utilizing sve2, both of them does not have SVE/SVE2 optimization implemented. After doing a bit of research, I decided to go with libjpeg for this project. 

This(libjpet-turbo) package utilizes SIMD operations, and is already supporting SIMD instructions (MMX, SSE2, AVX2, Neon, AltiVec) and ARM64 architectures. Implementing SVE2 for ARM-v9 seems to be a valid optimization.

# Strategy - optimization approach
## Three options implementing SVE2 optimizations

- auto vectorization
- inline assembler
- using SVE2 intrinsic

My plan is to start with something small, within the file that utilizes SIMD operation, I will try to implement auto vectorization to it.
Faster multi-line jumps in VSCode-Vim
Tags: vscode, vim
Published: 2022-03-29 02:37:27

---
title: "Faster multi-line jumps in VSCode-Vim"
description: "Jumping down lines with `<number><arrow>` (eg, `42(down)`) is slow in VSCode-Vim, this is how I fixed it."
published: true
tags: [vscode, vim]
---

One of the things that bothered me with VSCode-Vim was with how slow it was to use `(number)(arrow)` (eg, `42(down)`) to move multiple lines down. In the screencast below, notice how it goes line-by-line rather than skipping ahead instantly.

![](https://i.imgur.com/FRIxRsP.gif)

> ☝ Figure 1: VSCode scrolls slooowly line-by-line when pressing `42(down)`.

---

## Solution: use j/k
TIL that VSCode-Vim already accounts for this with `hjkl` movements, so `42(down)` can be pressed at `42j`.

![](https://i.imgur.com/WOcSdkS.gif)

> ☝Figure 2: Using j/k keys (eg, `3j` instead of `3(down)`) hops to the target line instantly. I also did a trick to make this work with arrow keys (see below).

---

## Making it work with arrow keys
To make this work with `(up)` and `(down)` arrow keys too, I rebound my arrow keys to j/k movements.

```json
/* settings.json */
{
  "vim.normalModeKeyBindings": [
    // Make "9j 9k" work faster
    { "before": ["Down"], "after": ["j"] },
    { "before": ["Up"], "after": ["k"] },
}
```