Newsletter # 2 - Using BSD Sockets in Swift Sep 27 2019

This week was fun. It was the first time I got an award for one of my posts on Reddit. It's always fun to receive messages from people that find my posts useful.

You can see the post with the little badges on top :) here:
https://www.reddit.com/r/swift/comments/d915ja/using_bsd_sockets_in_swift/(https://www.reddit.com/r/swift/comments/d915ja/usingbsdsocketsinswift/)

I usually share my posts on Reddit. I find it less cluttered with random posts (unless you subscribe to random subreddits). I don't use Twitter much, but I think I'll start using it as Seth Godin(https://twitter.com/ThisIsSethsBlog) uses Twitter, mostly a feed for the blog. I want to share more content but spending time on Twitter takes time from researching and writing. So I'll probably won't pay much attention to it. Anyways, let me know if you have any thoughts on using Twitter.

Coming back to this week's post. The post described how to use BSD Sockets in Swift, here is the link:  https://rderik.com/blog/using-bsd-sockets-in-swift (https://rderik.com/blog/using-bsd-sockets-in-swift "https://rderik.com/blog/using-bsd-sockets-in-swift")

I also took some time to explain some of the memory management required when we interact with C code. I think it is important to understand these concepts. So we can not only appreciate but understand what is going on when we use frameworks that provide higher-level APIs.

I wonder what is going to happen when fewer and fewer people understand the inner working of the systems we rely on. For example, Cobol. Did you know that a lot of the financial systems and transport infrastructure are still written in Cobol? If you want to listen more about it, you can check Command line heroes podcast(https://www.redhat.com/en/command-line-heroes)(by RedHat) Season 3 Episode 7(https://www.redhat.com/en/command-line-heroes/season-3/talking-to-machines). I have a lot of fondness for Perl so listen to that episode too :).

Alright, that's it for this week. I'll be going to San Francisco next week so if you are in the Bay Area, send me a message maybe we can meet for a coffee. Also, if you can share the content I create, it will help me reach more people and who knows maybe someday I can make a living of it ;) , we can only hope.

Enjoy your weekend.

Derik

PS. If you use vim and like to use SourceKit-LSP, you can check my updated post on how to set it up.
https://rderik.com/blog/setup-swift-lsp-and-vim/(https://rderik.com/blog/setup-swift-lsp-and-vim/)

Tip of the Week:

Have you ever been writing a command on bash, only to realize that you miss some key information or that you need to run another process before?

What I used to do before was to cancel the whole command (<Ctr-c>) run the previous command and then re-write my command again... (Like a caveman), so frustrating.

If that happens to you, remember those bash instructions are the same that you would use in your bash scripts. That means that comments work too!

For example, imagine you want to run a psql script.

1
$ PGPASSWORD=password psql -U username -d dbname -c "select * from my_table"  

But right before you press return, you remember you forgot to run the script that would populate the table!

Instead of cancelling and retyping all the commands. You can do the following, jump to the beginning of the line and comment the line. It will be stored in your history so you can later go back to it and remove the #.

1
2
3
4
5
# Use <Ctrl+a> to go to the beginning of the line and add a hash symbol.
$ PGPASSWORD=password psql -U username -d dbname -c "select * from my_table"
# Press enter, to save it to history. Run the command you previously forgot
$ ./run_my_script

And now you can press the up arrow to go back to the previous command. And press <Ctrl+a> to go to the beginning of the line to remove the comment and re-run it.

I hope this helps you avoid retyping commands unnecessarily.


** If you want to check what else I'm currently doing, be sure to follow me on twitter @rderik or subscribe to the newsletter. If you want to send me a direct message, you can send it to derik@rderik.com.