teleren/devto huggingface dataset:
Reading and Writing Files in C: Part 4
Tags: c, io, file
Published: 2019-01-14 00:35:49

For the last three posts, we have only handled text and nothing more. But now we will delve into binary files and how to read from and write to it. I'm sure the first question if don't know what a binary file is, "What is it?". Good question especially for something we are about to use.

A binary file is a file that isn't intended to be read like text. Instead, they are based more on numerical values.

When opening a binary file, the mode is additionally set to binary and we do this by simply appending a 'b' to the end.

Example:

```cpp
FILE *binary_file = fopen(path, "rb");
```

Two functions you will be familiarized with are `fread()` and `fwrite()`. Usually, they are reserved for working with binary files but are as capable of operating on text files. 

Both have the same number of arguments and all but the first have the exact same purpose. The first argument for `fwrite()` is where the data will be transferred from to the file whereas in `fread()` it is the destination for any data read from a file. Because the first argument's type is a `void` pointer, we can receive or transmit any type of data. The second is the size of each object. The third is how many objects we want to read/write. And finally, the fourth and last is the file stream.

I feel like you now deserve an example:

```cpp
#include <stdio.h>

int main(void)
{
    FILE *file = fopen("test", "wb");

    int numbers[4] = { 65, 66, 67, 10 };
    fwrite(numbers, sizeof(int), 4, file);
    fclose(file);
}
```

Output:

```cpp
~/Desktop 
➜ clang main.c 

~/Desktop 
➜ ./a.out 

~/Desktop 
➜ cat test 
ABC

~/Desktop 
➜ 
```

If you try to open the file that was written with a text editor, most likely it will complain at you with the error "Unknown encoding" or something similar. If you use a terminal command like `cat` you will see the contents is A, B, and C.

Even though we didn't write any text, we used the character's corresponding ASCII value. And if you didn't know, the number 10 is the ASCII value for a newline.

## Next

For the next post, we'll leverage them a bit more to read and write entire C structures!
Let's Encrypt with SSL Certificates
Tags: ssl, sslcertificate, security
Published: 2020-09-21 07:18:58

---
title: Let's Encrypt with SSL Certificates
published: true
date: 2019-01-14 00:00:00 UTC
tags: SSL,SSLCertificate,Security
canonical_url: https://www.loginradius.com/engineering/blog/lets-encrypt-with-ssl-certificates/
---

What is an SSL Certificate? Let’s start with some working definitions of the HTTP and HTTPS protocols. HTTP is the Internet protocol over which data is sent between a browser and a server when they are communicating. HTTPS is the secure counterpart of HTTP, which encrypts data…

   
[Read On](https://www.loginradius.com/engineering/blog/lets-encrypt-with-ssl-certificates/)
High traffic app that can’t take downtime - Data migration
Tags: webdev, beginners
Published: 2019-01-13 23:50:04

---
title: High traffic app that can’t take downtime - Data migration
published: true
description: 
tags: webdev,beginners 
---

When you can't take downtime, the “trick” to data migration is: **Think small changes.**

1. New table
2. Update writes to go to old and new
3. Background job to migrate old data to new
4. Move reads to new table 
5. Stop writing to old table

Each of these steps is a deploy.
Getting started with GitHub Actions? Try Actions Toolkit
Tags: githunt
Published: 2019-01-13 23:40:51

---
title: Getting started with GitHub Actions? Try Actions Toolkit
published: true
description: 
tags: githunt
---

If you're writing your own Actions using Node.js. Save yourself some time and take a look at Actions Toolkit. Jason is collecting common tasks and extracting them to a single module you can use to build your Actions.

{% github JasonEtco/actions-toolkit %}
How do you approach knowledge gaps?
Tags: beginners, programming, javascript, rust
Published: 2019-01-13 23:08:46

It's normal to get stuck from time to time when you are trying to build something. However, when I make the same mistake again and again I know it has to do with my lack of knowledge about a topic. 

When it is a framework or library specific to problem the answer is most likely in the docs, on stack-overflow or in a tutorial. However when it has to do with build in language features or theoretical knowledge it can be harder to spot what you don't know. To be fair I bump into the right information when I need it by accident. It's usually hidden in a talk or a well written article or post.  

Two real life examples of the 'problem' I'm talking about: 

#### 1. Understanding JS 

When I stared using a lot more asynchronous JS the expectation vs reality of what I was trying to write did not always match. Some tinkering or workarounds would usually solve the problem. It wasn't until a very enthusiastic JS dev advised me to watch a talk on the event loop that I realized what a gap in my knowledge was. I had no idea how JS handled async operations under the hood and why some things wouldn't work. 

In case you haven't seen it and you like JS check out "What the heck is the event loop anyway" by Philip Roberts. He talks about a lot more than just async programming, a lot of JS related buzzwords will make sense after hearing this talk. 

{% youtube 8aGhZQkoFbQ %}


#### 2. Understanding Rust 

Something I'm struggling with right now is ownership and borrowing in Rust, even though [the book](https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html) has an entire chapter on it. It basically has to do with the memory used by your code and whether you try to use the real value, a reference or a copy. 

I frequently fight with the borrow checker when I try to do something in Rust. After some practice I started to get a little bit better and can at least understand why I am stuck. I ran into this post and if you happen to struggle with ownership this one will really help. 

{% link https://dev.to/domcorvasce/learning-rust-1-ownership-g0 %}


To be fair most things related to memory in Rust are a problem to me right now because I don't know that much about it. I guess that is the thing I'll have to understand at least a little bit better to truly understand what I'm doing. 


How do you reveal what the gaps in your knowledge are? Do you have a favorite method for learning something more theoretical and applying it? I'd love to hear from other dev's how they deal with this 😄.

~ Happy Coding :)
Database models and ERDs for Newbs Part: 1
Tags: beginners, database, sql
Published: 2019-01-13 22:56:33

---
title: Database models and ERDs for Newbs Part: 1
published: true
description: A digest-size breakdown of database modeling and entity-relationship models/diagrams.
tags: beginner, databases, SQL
---
## So why another database post?

Hi everybody, I would like to introduce something very basic to newbies or folks starting out with the backend of development. This post will be replete with diagrams because we all have different learning styles and visual aids are always a great way of breaking up the text. As an aside, I am not a database expert or DBA, I welcome and appreciate any feedback, comments, or corrections from all the code senpai out there.

So let’s get started with some working definitions.
The wiki definition of a database model is pretty good, so we’ll start there: 

>“A **database model** is a type of data model that determines the logical structure of a database and fundamentally determines in which manner data can be stored, organized and manipulated. The most popular example of a database model is the relational model, which uses a table-based format.”

A data model is used to represent or imitate an entity. An entity is basically a noun. Some are abstract like math, and others are concrete (has a physical form) like a shoe. Let's take a look at a table of students.

![Diagram of a student body](https://thepracticaldev.s3.amazonaws.com/i/xe1v1ud681pcfqcqfqgx.jpg)

This database model takes the form of a table, the rows represent distinct students while the columns represent an attribute or quality the student has. Each column is of a specific data type and that helps makes the standardized manipulating and reading of student data possible. If all entries of the columns were of a different type, writing queries would be a pain. I’m now going to introduce a couple more important terms, **normalization**, and **cardinality**. **Normalization** is the process used to reduce the redundancy of data by sometimes splitting a database into two or more tables. **Cardinality** would be considered high if there were very few duplicate bits of data in the same column, low cardinality tables have a lot of duplicates.
An **Entity-Relationship Diagram** or model is used to map the potential relationships between data models. By potential, I mean that some of these relationships are strictly optional. For example, a college professor could teach classes it does not mean they do. However, to have a class you need a professor and at least a student.

So what does this actually mean to us [developers]?

We use database models and ERDs as developers to map out the models and their relationships so that we can manipulate and read what’s stored on the database. Their design determines the level of functionality so please keep that in mind. The function determines the form in this case.

Stay tuned for next time where we will explore how to draw these diagrams using crow's notation.
Help/Intro!
Tags: react, javascript, webdev, webdeveloper
Published: 2019-01-13 22:47:43

---
title: Help/Intro!
published: true
description: 
tags: #react #javascript #webdevelopment #webdeveloper
---

Hey all! First off, let me intro myself, I'm Ty from Canada. An aspriring developer that wants to get into that space! I may ask lots of dumb questions, but please know, if I'm asking, I've done my best to read up on docs and find the answer after research. I'm excited to learn from all you seasoned vets!

To my first question, I'm trying to deploy my first React page to github pages. I can't seem to get my routes, or my relative paths to work. 

This is the route in the url: https://tpedora.github.io/myprofilepage/#/<insert other pages here>

With this being my main.js router code:

https://gist.github.com/tpedora/48ab638489f56f133451fd24fc8ff0c0

I also have my homepage set to "https://tpedora.github.io/myprofilepage" in my package.json. 

For the life of me, I can't seem to get my routes working. Any and all help would be amazing!

- T
I've created my first telegram bot with Python
Tags: python, junior, bot, telegram
Published: 2019-01-13 22:14:43

---
title: I've created my first telegram bot with Python
published: true
description: This is my first complete project since I started learning python two months ago.
tags: Python,junior,bot,telegram
cover_image: https://thepracticaldev.s3.amazonaws.com/i/986zwrvwyosiwejrggoj.png
---

you can try it right from telegram `@randomovie_bot` or through this direct telegram [link](https://t.me/randomovie_bot)

This bot basically let you set your preferred movies rules such as minimum release year, minimum IMDB rating and favourite genres.
Next the bot will suggest you a movie based on your rules with more details.
So simple!!
[Source code](https://github.com/akkk33/randomovie)
Another Tab: An open source Chrome extension built with TypeScript and React
Tags: showdev, githunt, react, typescript
Published: 2019-01-13 21:22:14

---
title: Another Tab: An open source Chrome extension built with TypeScript and React
published: true
description: 
tags: #showdev #githunt #react #typescript
---

I just published **Another Tab**: An open source Chrome extension built with TypeScript and React (with hooks, Redux and Styled-Components).   

{% github https://github.com/mmazzarolo/chrome-another-tab %}

Any kind of contribution or discussion is warmly welcome!
The Best Books for New Devs + Bonus Twitter Thread
Tags: career, beginners, discuss, learning
Published: 2019-01-13 19:08:16

---
title: The Best Books for New Devs + Bonus Twitter Thread
published: true
description: 
cover_image: https://cdn.pixabay.com/photo/2016/09/08/22/43/books-1655783_1280.jpg
tags: career, beginners, discuss, learning
---

This thread just came across my Twitter feed and it's looking like it will turn into a goldmine of resources.

{% twitter 1084141233490907136 %}

Assuming you've already got the skills to get a job and you can write some code, there are still a ton of things to learn about having a career in software development.

Professional developers benefit from learning things like design patterns, project management strategies, business tactics, and best practices.

If I could only recommend five books for a fledgling developer 👇

For people looking to build a **strong** technical foundation (in this order):

[Code: The Hidden Language of Computer Hardware and Software](http://www.charlespetzold.com/code/)

[Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)

[Cracking the Coding Interview](http://www.crackingthecodinginterview.com/)

and 

[Code Complete](https://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670)

For people who want to get better at getting along with other people:

[How to Win Friends and Influence People](https://www.amazon.com/How-Win-Friends-Influence-People/dp/0671027034)

Share some recommendations with me so I can add them to my reading list. 📚
Do you leave jokes in your code? If so, please share!
Tags: discuss, jokes
Published: 2019-01-13 18:58:04

---
title: Do you leave jokes in your code? If so, please share!
published: true
description: Sometimes I leave bad jokes in my code, do you? if so, please share!
tags: #discuss #jokes
---

Sometimes, I leave bad jokes in my code, here are some examples from a backup tool I built a while back:

When a user tries to delete a backup:

```
console.log(`Still wanna do it? just checkin'...`)
```


When trying to remove a backup but something wrong happens:

```
spinner.fail(`ummm, yeah.. this is awkward; we could't delete the backups for some reason`)
```


When the user tries to remove a backup, but then cancels at the prompt:

```
console.log(`Whew, nothing happened. That must feel good, eh?`.green)
```

When something goes wrong:

```
spinner.fail('womp womp... some error occurred *rolls eyes*')
```

Other times, I add a funny* comment to a funky looking piece of code, just because..


**I am curious if other devs do it to, do you do anything like that? funny comments? funny method/variable names? or funny messages you show to users? please share!**


*Depends on whom you ask ;)
Day 13: Swift macOS password manager for people who hate the cloud
Tags: macos, swift, passwordmanager, cloud
Published: 2019-01-13 18:53:15

---
title: Day 13: Swift macOS password manager for people who hate the cloud
published: true
description: Watch as I make a password manager for macOS this month
tags: macos, swift, password manager, cloud
series: Making a swift MacOS password manager for people who hate the cloud
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q6r73zbfbm3mpfs98bu5.jpg
---

[<- For Day 12 go here](https://dev.to/swlkr/day-12-swift-macos-password-manager-for-people-who-hate-the-cloud-1pmn)

📅 01/13/2019
🚀 17 days until launch
🔥 12 day streak
💰 $4.99 price (this keeps changing)
🤑 $0 revenue
📈 0 customers
⌚️ 8.5 hours spent
💻 19 files changed, 1068 insertions(+), 170 deletions(-)
🏁 Today's goals: **Generate strong passwords**

**10:57 AM**
Finally get around to stop consuming stuff on the twitter/youtube/hacker news and start working on this thing.

**11:39 AM**
Took me longer than it should, but I figured out how to get an NSSlider working in conjunction with a random string function and the password field. It's a pretty cool effect for not that much work: ~50 minutes. Take a look

![](https://thepracticaldev.s3.amazonaws.com/i/svar0sni8kwncasijneb.gif)

Here's the code I mostly copy and pasted to get it working:

```swift
    @IBOutlet weak var passwordLengthSlider: NSSlider!
    @IBOutlet weak var passwordLengthLabel: NSTextField!

    func randomString(_ length: Int) -> String {
        let values = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
        return String((0...length-1).map{ _ in values.randomElement()! })
    }

    @IBAction func passwordLengthChanged(_ sender: NSSlider) {
        let passwordLength = passwordLengthSlider.integerValue
        let password = randomString(passwordLength)
        passwordLengthLabel.stringValue = "\(passwordLength)"
        passwordTextField.stringValue = password
    }
```

An app dev's job is kind of like a DJ or if you want to get classy, a *composer*. You do have to do things yourself and come up with bits of originality here or there, but it's mostly remixing and a lot of trial and error. Also the thing that took me the longest is in the xib (or storyboard or whatever apple's calling it this year) you have to check "Continuous mode"

![](https://thepracticaldev.s3.amazonaws.com/i/8nuwh2qtm3a9yloyjatp.png)

I went searching around for a longer than I care to admit and then finally just decided to start trying random things and that was the thing that worked. I should keep going but I've got other things to do today. I might be back later, but I'll definitely be back tomorrow morning, 6 AM mountain time… hopefully.
Why is Linux Not More Popular on the Desktop?
Tags: discuss, linux, opensource
Published: 2019-01-13 17:06:24

---
title: Why is Linux Not More Popular on the Desktop?
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/so9hj7ey78bjmwf6kt9y.jpg
tags: discuss, linux, opensource
---
_Picture taken from [wikipedia][image]._

There are issues when it comes to Linux being more broadly adopted on the desktop. What are the main issues you think and how can they be addressed?

I think that the big issue with Linux is fragmentation. This has been especially an issue when it comes to developers publishing games on Linux.

The solution to this issue are cross-distribution installers like [Snap][snap], [AppImage][appimage] and [Flatpak][flatpak]. Every application has its own set of libraries, meaning they do not depend on distribution-specific packages.

Another issue I believe is momentum. There's some outdated opinion on how well Linux works on the desktop.

Defeating the momentum will require more effort on the PR front. I don't see this being something that will just fix itself with time.

Thoughts?

[image]: https://commons.wikimedia.org/wiki/File:Penguins_walking_-Moltke_Harbour,_South_Georgia,_British_overseas_territory,_UK-8.jpg
[snap]: https://snapcraft.io/
[appimage]: https://appimage.org/
[flatpak]: https://www.flatpak.org/
`yarn global` under the hood
Tags: javascript
Published: 2019-01-13 03:16:28

---
title: `yarn global` under the hood
published: true
description: 
tags: js
series: yarn
---

![yarn](https://yarnpkg.com/assets/feature-speed.png)

`yarn global` helps us manage global npm packages, which is especially useful for CLI tools. How does it work?

By default, it will create a directory at `~/.config/yarn/global` (on OSX and non-root Linux), and if you enter the directory, you will find its structure like this:

>├── node_modules
>├── package.json
>├── yarn-error.log
>└── yarn.lock

And in `package.json`, all global packages are defined as `dependencies`, just like  what you are familiar with in a normal JS/TS project.

In this directory, you can do whatever you would normally do, like `yarn add`, `yarn remove`, `yarn upgrade`, `yarn upgrade-interactive`, etc.

The key point that makes `yarn global` different is that it handles the binaries by creating symlinks in the directory you specify with `--prefix` option. On OSX and non-root Linux, the default prefix is `/usr/local`, which means the binaries will be symlinked to `/usr/local/bin`, which is usually in the enviroment variable `$PATH`. So if you prefer using a custom directory for symlinks, do make sure that the directory is in `$PATH`.
Introducing Square In-App Payments SDK
Tags: payments, api, mobile
Published: 2019-01-13 00:16:57

---
title: Introducing Square In-App Payments SDK
published: true
description: A secure, customizable in-app payment solution for iOS, Android, and Flutter.
tags: payments,api,mobile
---

https://medium.com/square-corner-blog/introducing-square-in-app-payments-sdk-1fc93b32814c
SDP - A scalable size unit... To the rescue 😁
Tags: githunt, discuss, kotlin, android
Published: 2019-01-13 00:14:11

---
title: SDP - A scalable size unit... To the rescue 😁
published: true
description: I found a library that solves a screen sizing issues in Android like a boss
tags: githunt, discuss, kotlin, android
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sh3377a9bzt5l0bny4q0.png
---

_My first 2019 post here on dev.to so happy new year and you're awesome_ 😎

I wrote an article here about [my side project](https://dev.to/sduduzog/side-project-success--2i3k) last year and the side effects were amazing 🙌 Downloads picked up a lot and I've been receiving great reviews.

{% link https://dev.to/sduduzog/side-project-success--2i3k %}

From the feedback the app was received on google play and emails, one issue  stood out the most.

This is used as the cover image also 😐
![google play review screenshot]
(https://thepracticaldev.s3.amazonaws.com/i/q888pkulz9n2fidrsnro.png)

Another review 🤨
![another google play screenshot](https://thepracticaldev.s3.amazonaws.com/i/ui5ycq7yi5q2jaqd0iiy.png)

Last screenshot, I swear 😑
![screenshot of an email review](https://thepracticaldev.s3.amazonaws.com/i/yynb3fyt8f4q0bcecwyq.png)

_I tinted the images to differentiate from the site background_

Basically more and more people noticed the "little thing" I thought was "not an issue" **text size on different screen sizes**

I can't really recall how many requests I received about text size issues on smaller screen devices but it got me paranoid.

See, the app is a minimalist launcher that allows you to choose 5 apps to appear on your home screen and only displays a clock plus your selection. **The problem is** on smaller screens, app text would overlap with the clock 😫

I tried creating different `dimens` resources to target different densities but that was a disaster. I knew I would never cover every use case smoothly.

**Until I came across**

{% github intuit/sdp %}
## And
{% github intuit/ssp %}

I trusted these libraries for delivering a consistent ui in all homescreens of the hundreds of users who downloaded my app.

I truly design just one layout, use probably `@dimen/_64sdp` for a margin or text size and something like `@dimen/_12ssp` for an `android:textSize` that I want consistent across a lot of screen sizes.

It supports minimum sdk version 16, and I'll be testing for tablets too.

**Be careful** not to forget that the _all screen sizes_ approach is not a solution for most ui design solutions.

Happy coding
Data Challenge! Rendering All 32,767 Invaders!
Tags: python, javascript, react, showdev
Published: 2019-01-13 00:00:09

---
title: Data Challenge! Rendering All 32,767 Invaders!
published: true
description: Using Python, JavaScript, React and p5.js to render over 32,000 90s-esque creatures!
tags: python, javascript, react, showdev
---

I've fallen down the rabbit hole that is generative art! As a first project, I challenged myself with rendering these 'Invaders'. 

Link to my blog post here:

https://chrisfrew.in/data-challenge-rendering-all-32767-invaders/

or Medium if you prefer:

https://medium.com/@frewin.christopher/data-challenge-rendering-all-32-767-invaders-d20e69e045f4

I was totally amazed just how extensive generative art has become. I've found some really neat sites and really cool artists! Anybody have their own stories with code and art? :)

I'm looking forward to developing this new interest!
Jekyll Front Matter Template
Tags: jekyll, frontmatter, template
Published: 2020-09-11 20:01:37

---
title: Jekyll Front Matter Template
published: true
date: 2019-01-13 00:00:00 UTC
tags: [jekyll, frontmatter, template]
canonical_url: https://mrpowerscripts.com/jekyll-front-matter-template/
---

This is a Jekyll front matter template free for anyone to use

```
---
---
```