Posts

Showing posts from September, 2020

What Is Entropy In Cryptography?

Image
The post What Is Entropy In Cryptography? first appeared on Qvault . If you are familiar with the laws of thermodynamics , you may recognize the second law as dealing with entropy. In the realm of physics, entropy represents the degree of disorder in a system. Because systems tend to degrade over time, thermodynamic energy becomes less available to do mechanical work. In cryptography, entropy has a distinct but similar meaning. In cryptography, entropy refers to the randomness collected by a system for use in algorithms that require random data. A lack of good entropy can leave a cryptosystem vulnerable and unable to encrypt data securely. For example, the Qvault app generates random coupon codes from time to time. If the coupon codes weren’t generated with enough randomness, attackers could pre-compute the codes and steal all the gems! Computers are Deterministic Deterministic machines are machines that do exactly what we tell them to do. Every. Single. Time. In mathemat

How to Make a Simple Vue Custom Select Component

Image
The post How to Make a Simple Vue Custom Select Component first appeared on Qvault . Creating a custom select tag is with your own styling is notoriously difficult. Sometimes it’s impossible without building your own from scratch using a combination of styled divs and custom JavaScript. In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault , and you can see it in action on the playground . Code Sandbox Demo The HTML <template> <div class="custom-select" :tabindex="tabindex" @blur="open = false"> <div class="selected" :class="{ open: open }" @click="open = !open"> </div> <div class="items" :class="{ selectHide: !open }"> <div v-for="(option, i) of options" :key="i"

Running Python in the Browser with Web Assembly

Image
The post Running Python in the Browser with Web Assembly first appeared on Qvault . We’ve been wanting to expand Qvault’s course curriculum , and one of the most requested programming languages has been Python. Because our courses allow students to write and execute code right in the web browser, we decided to look into existing projects that allow a Python interpreter to run in the browser using Web Assembly. We settled on a tool called Pyodide , which does just that. To see it in action, check out the finished product, a Python playground . What is Pyodide? Pyodide is an open-source project that comprises a Python interpreter that has been compiled to Web Assembly. WebAssembly (abbreviated  Wasm ) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. webassembly.org In other words, normally only JavaScript can run in a b

Running Go in the Browser with WASM and Web Workers

Image
The post Running Go in the Browser with WASM and Web Workers first appeared on Qvault . We’ve recently made big changes to how we execute Go in the browser on Qvault and want to explain the enhancements. Web Workers are the reason we’ve been able to solve some of the serious browser-related coding problems that were holding us back. Consider this article a sequel to Running Go in the Browser with Web Assembly . While publishing our latest course, Big-O Algorithms , we needed a way to print console output while code is still executing. We ran into a problem when running computationally expensive algorithms in the browser; the browser gets so bogged down that it can’t render new lines of output. We decided to implement web workers, and they solved the problem handily. The Problem In the old Qvault, console output was all printed at once. The program executed, then the output was displayed. We found this to be less than ideal because it is often useful to see when something prints

Practical Patterns for Technical Writing

Image
The post Practical Patterns for Technical Writing first appeared on Qvault . Writing technical documents like API or architectural documentation which exceeds a simple flow diagram can be a daunting task. If you have some experience with technical documents, you will probably agree that there is nothing more frustrating than bad documentation. Lately, technical writing became a more important part of my job, so I put together some of my findings. I use the following checklist and hopefully, it can help you as well. Overview We will work our way from a very high-level view of the document to a detailed analysis of how various word choices can make a technical document more readable. We’ll go over: Your audience Structuring your document into paragraphs Active voice vs. passive voice Writing clear and concise sentences Simple but undervalued: lists & tables The actual words Iterate and review Conclusion Your Audience Before you start writing, you should be clear abo

Go’s Major Versioning Sucks – From a Fanboy

Image
The post Go’s Major Versioning Sucks – From a Fanboy first appeared on Qvault . I’m normally a fan of the rigidity within the Go toolchain. In fact, we use Go on the front and backend at Qvault . It’s wonderful to have standardized formatting, vetting, and testing across the entire language. The first real criticism I’ve had is with the way Go modules handle major versions. It’s over-the-top opinionated and slows down development in a significant number of scenarios. Refresher on “Go Mod” Go modules, and the associated commands go mod and go get can be thought of as Go’s equivalents to NPM and Yarn. The Go toolchain provides a way to manage dependencies and lock the versions that a collection of code depends on. One of the most common operations is to update a dependency in an existing module. For example: # update all dependencies go get -u ./... # add missing and remove unused dependencies go mod tidy # save all dependency code in the project's "vendor" folde

“Big-O Algorithms” Course Released

Image
The post “Big-O Algorithms” Course Released first appeared on Qvault . We’ve launched our new Big-O Algorithms course! We wrote this course for engineers who need a refresher on computer science basics, or want to learn the fundamentals for the first time. The study of algorithmic complexity is often overlooked by new developers, and we’ve found that get-rich-quick boot camps often skimp on these details. It’s impossible to become a senior developer without being familiar with the concepts in this course, so we figured it was high time we published it. Get Started What’s Included? The course has three modules covering the following topics: Big-O intro and mathematics overview Sorting algorithms and implementations Complexity theory – P vs NP We are already planning a sequel to this course, so keep an eye out for that. The sequel will cover data structures and how they play a major role in popular algorithms. Coding? Coding projects in this course are all written in

Is AES-256 Quantum Resistant?

Image
The post Is AES-256 Quantum Resistant? first appeared on Qvault . With quantum computers getting more powerful each year, many worry about the safety of modern encryption standards. As quantum computers improve in performance and the number of qubits used for calculations increases, current cryptosystems are under threat. AES-256 is one of the most powerful symmetric ciphers, but will it remain secure in a post-quantum world? What will break post-quantum? Many asymmetric encryption algorithms have been mathematically proven to be broken by quantum computers using Shor’s algorithm . Shor’s algorithm solves the following problem: Given an integer N , find its prime factors. https://en.wikipedia.org/wiki/Shor%27s_algorithm Because algorithms like RSA rely heavily on the fact that normal computers can’t find prime factors quickly, they have remained secure for years. With quantum computers breaking that assumption, then it may be time to find new standards. The following a

How to Make Pure Functions (Go)

Image
The post How to Make Pure Functions (Go) first appeared on Qvault . Pure functions are often hyped up in the JavaScript world, probably because of the abundance of stateful front end applications. While pure functions have their downsides (i.e. inconvenience, potentially large argument lists), they should be used as much as reasonably possible. We’ve made a lot of changes in the Qvault app codebase recently to use more pure functions, and it has helped make the code easier to understand and write tests for. What is a Pure Function? According to Wikipedia , a Pure function has the following properties: Its return value is the always same for the same arguments Its evaluation has no side effects (no mutation of data outside the function) Which means that as a developer I know two important things: When I call a pure function I will get the same result every time After calling a pure function the rest of my program will be in the same state it was before calling it Becaus

Guard Clauses – How to Clean up Conditionals

Image
The post Guard Clauses – How to Clean up Conditionals first appeared on Qvault . One of the first concepts new developers learn is the if/else statement. If/else statements are the most common way to execute conditional logic. However, complex and nested if/else statements can quickly become a cognitive burden and compromise the readability of a program. Guard Clauses Guard Clauses leverage the ability to return early from a function (or continue through a loop) to make nested conditionals one-dimensional. Instead of using if/else chains, we simply return early from the function at the end of each conditional block: func divide(dividend, divisor int) (int, error) { if divisor == 0 { return 0, errors.New("Can't divide by zero") } return dividend/divisor, nil } Error handling in Go naturally encourages developers to make use of guard clauses. When I started writing more JavaScript, I was disappointed to see how many nested cond

Create a Golang Video Streaming Server Using HLS – A Tutorial

Image
The post Create a Golang Video Streaming Server Using HLS – A Tutorial first appeared on Qvault . In this tutorial, I’m going to walk you through building a Golang video streaming API (this works for other types of media as well!). Don’t worry, its surprisingly easy to build a robust media streaming server, especially if we utilize one of the more modern protocols, HLS. What is HLS? HTTP Live Streaming is an HTTP-Based adaptive bitrate streaming communications protocol developed by Apple. https://en.wikipedia.org/wiki/HTTP_Live_Streaming HLS allows us to serve large media files as many smaller text files that are broken up into ~10-second increments. By breaking them up in this way, our user’s client-side app only needs to buffer 10 seconds in advance. This saves the user a lot of potential bandwidth and allows the song or video to start playback almost immediately. Using FFmpeg , we can easily convert mp3 files to HLS format, which consists of multiple files. One of these fil

Should You Return Empty or Nil Slices in Go?

Image
The post Should You Return Empty or Nil Slices in Go? first appeared on Qvault . In Go, we are often returning zero values. Idiomatic Go encourages the use of guard clauses, and guard clauses necessitate the need to return early. When returning early with an error, by convention all other return values should be zero values. The confusion arises with data types like maps and slices… should they be nil, or should they be empty? The question is, should we use this syntax: func getItems(url string) ([]string, error) { data, err := makeRequest(url) if err != nil { return nil, err } items, err := unpack(data) if err != nil { return nil, err } return data, nil } or this syntax? func getItems(url string) ([]string, error) { data, err := makeRequest(url) if err != nil { return []string{}, err } items, err := unpack(data) if err != nil {

Slow Is Smooth, Smooth Is Fast – 25% of Our Time Refactoring

Image
The post Slow Is Smooth, Smooth Is Fast – 25% of Our Time Refactoring first appeared on Qvault . My team has been spending less of our “free” time working on bugs and features from the backlog, and more time refactoring our codebases and test suites. As a result, and perhaps somewhat counterintuitively, we’ve noticed a significant increase in our throughput of features and bug fixes. As it turns out, its easy to find bugs and add features to a well-written codebase that the entire team is familiar with. Go figure. My team started a loose goal to spend 25% of our time refactoring, revisiting, and restyling existing code and tests. Let’s go over some of the benefits we’ve seen since making the change. Context and Caveats I’ve found that in articles like this it’s important to give as much context to the situation as possible, as certain development methodologies may work better or worse in teams with a different size, tech stack, or development process. Here are some notable thing