01100111 01100001 01110010 01111001

Gary in Binary

A simple blog about technical things.

Some of my sites to check out:
GitHub
LinkedIn
Top Coder Profile

JavaScript30 Complete

20190519 - 1730

I'm about two weeks out from my internship with SIXGEN and super excited to start working and learning in the civilian world.

Just wrapped up Wes Bos's Javascript 30 course. Learned some good fundamentals (I think), but really learned a lot more about how CSS works and it's interaction with JS. Time to add another goal Make my site pretty. I think with the basics in JS30, I could make my site a bit more than what it currently is. I'm glad I was able to finish this within 30 days (even with a week long cruise to the Bahamas).

Other random thoughts:
  Kali Linux Revealed has a lot of good basic Linux stuff in it. I've cleared up a bit more on the file system layout with Linux and learned that you can setup a custom auto-install for Debian based Linux. Can't say that I have a use case now for a custom auto-install but it's good to know.
  I had issues with running Kali-Live on my MSI because it has an NVIDIA card in it. Learned that you can throw Kali some extra options at the boot menu to modify the boot. When you get to the boot menu, you can press 'e' and it give you the commands being run to boot. To enable boot on my MSI, I had to change 'splash' to 'nouveau.modeset=0'. From my understanding, this has something to do with the power drawn by the GPU on boot. Either way it works, which has allowed me to turn an external 1TB SSD (using Kali-Live with persistence) into my portable Kali SSD. The goal will be setting up a Dev environment on it, but first I need to lock it down and configure it a bit more.

Ruby MiniTest and Running Bash in Docker

20190504 - 0618

Took on a Ruby issue from Operation Code's Backend to do some url validation when creating/updating a listing in their Code Schools. The validation part was simple enough using some Regular Expression for the 'format' part of the model validation and ensuring the school was using HTTPS. The tricky part came when I had to go clean up the tests. The individual test I wrote for the validation worked fine but not a few other tests were broken from the change. Turns out, the FactoryGirl Faker they were using to mock data for testing was generating HTTP urls. Tests were throwing errors every time they created a new mock code school to test against. This was good, because that meant my validation was working, but then I had to go learn how to update the FactoryGirl so it would spit out HTTPS.

Before figuring out the FactoryGirl stuff, I wanted to see what was going on in the tests. However, in the Makefile for make test, it was using docker-compose run ${RAILS_CONTAINER} bash -xc 'export RAILS_ENV=test && bundle exec rake db:test:prepare && bundle exec rake test && bundle exec rubocop'.
Let's break that down a bit:

All said and done, it was about 18 lines of code and I wrote my first test, which failed, then passed, but broke other things, but then passed everything. As of this writing, the PR is approved and just awaiting merge. Fingers crossed and time to move onto the next project.

As it stands right now my goals/ideas to work towards are:

JavaScript30 and Problem Solving

20190422 - 0549

On a recommendation from some Slack friends I started Wes Bos's JavaScript30 course. As of today, I've completed 5 of the 30 courses and I'm feeling much better about Javascript. Having went through the watchandcode videos, these videos feel familiar and aren't too hard to follow along with. JS30 is also diving into CSS (something I've avoided learning) in an easy way. I decided to start on some more JS since I'll be working with Node.js in my upcoming internship.

As it stands right now my goals to work towards are:

On to the topic of problem solving.
I think when encountering problems, the best solution doesn't have to be knowing the answer, but rather knowing where to find the answer. Knowing the answer definitely helps, especially when time is of the essence, but most of the time an immediate answer is not needed. In today's interconnected world, the answer is probably sitting in your pocket a browser click away. By using the right search engine and search string, one can usually find the answers they seek. This doesn't always apply to abstract or conceptual problems, but I think when seeking technical answers, it is crucial. This way of thinking also helps in retaining "answers" but essentially creating an index for your brain. You only keep the information in there that can get you to the answer, not the answer itself. This has been extremely useful as I hop around to different programming languages. I don't need to remember the exact syntax for an "if" statement in Python, Ruby, C#, JS, etc. if I can just give it a quick Google. Same thing with some of the Object Oriented Programming concepts such as Inheritance. This does become hard though when beginning with a new framework that has unique syntax or structuring that's not similar to anything else. The idea that comes to mind currently is React. It's JS but seems (to me at this point in time) to have a very unique way of doing things that isn't exactly intuitive coming from another language or framework, so will require a bit more digging/learning before I can learn the right questions to ask to get the job done. One last thing on problem solving: there is always a solution, it's just not might be within your control.

Journey So Far

20190415 - 0537

Just wanted to take second to catalog my developer journey so far. More as a reference for myself in the future than for any curious readers that stumble across my page.

It started with Python at the end of 2012. I began learning at the behest of my friend Justin, who told me it would be useful for parsing the massive CSV files we were dealing with. I began by browsing some books on Safari Books, and signing up for a Coursera course. It was fun and exciting and I learned some basics while making a game and scripting out some workflows, but I didn't take it super serious and all my scripts were one file because getting them to work together was hard.

My dabbling in Python went on for some time before things got serious. I moved to a new job that still dealt with some data management but was much more technical (involving RF, Linux, wireless protocols, and a heap of other tech). This technical new job also had me linking up with a lot more technically minded people and attending some pretty awesome tech courses. In and out of work, I was tinkering with networks and security which lead me to Kali Linux. Again, I was introduced but didn't take it too serious and I'd still say I'm no pentesting expert, but I got a good taste of exploiting vulnerabilities starting 2014.

By 2017, I was finally looking for something serious to work on. I planned my exit from the Navy and on recommendation from a good friend (who's now at Microsoft) I started learning C# and the .NET framework. Starting with a few Udemy courses from Mosh Hademi, I began a rigorous study. Around the same time I was afforded the opportunity to get my Security+ certification. Mosh's courses were awesome and set a good foundation to branch into other books and online videos. I began doing some Unity3D courses as well, since I do enjoy a good video game now and then. While I was downloading Visual Studio and learning C#, my sister asked me to write a simple CRUD app for her to manage an inventory at work. Seemed easy enough, I would just follow along with one of the books I find online and adjust it to my needs... Close to 8 months later at this point and I have a backend REST API that kind of does what I want and the beginnings of a frontend written in an experimental framework (Blazor). I was able to get it runnning in Docker so that was a win and a learning experience for sure.

Now we come to 2019. I'm on the way out of the Navy and heading into my first real world job this summer. An internship with a cyber security firm that has some dev work and other projects. I'm excited to begin since the company seems to have projects relating to everything I'm interested in: Unity3D development, web development, and pentesting. I've also began attending Meetups on a regular basis. They're FANTASTIC. Just showing up and listening to other people talk is super helpful for picking up on terms I'm unfamiliar with. I also think community is an important thing to be a part of.

Dual-Pivot Quick Sort using Ruby

20190405 - 1546EST

Algorithms. Something you'd learn during your CS degree, which I don't currently have. Which was a good reason to register for a Top Coder challenge creating a dual-pivot quick sort using Ruby. Since I'm also studying Ruby (on Rails), it was a good way to kill two birds with one stone. Learn an algorithm and also practice with a new language.

Learning the algorithm was the hard part. The Challenge Overview was:

The idea of dual pivot quick sort is to take two pivots, one in the left end of the array and the second, in the right end of the array. The left pivot must be less than or equal to the right pivot, so we swap them if necessary. Then, we begin partitioning the array into three parts: in the first part, all elements will be less than the left pivot, in the second part all elements will be greater or equal to the left pivot and also will be less than or equal to the right pivot, and in the third part all elements will be greater than the right pivot. Then, we shift the two pivots to their appropriate positions as we see in the below bar, and after that we begin quicksorting these three parts recursively, using this method.

Which sounds easy enough. If you understand Ruby already. My first couple of tries resulted in a final array of arrays. Luckily they were all sorted arrays within the array but it still wouldn't work properly. I caved and googled dual-pivot quicksort and came across this article which outlined the algorithm but using C. After studying that for a bit and learning how variables/parameters were passed in Ruby (reference vs. value), I was able to write a functioning sorrting method.

I won the challenge and had some good feedback from it. I used my code comments as a document of my own understanding of what was going on which resulted in a whole lot of unnecessary comments. Cleaned them up but it'll be good to go back and reference at a later time when I go to study other algorithms. I also got in touch with one of the other entrants via a common Slack channel. After exchanging notes, his implementation was sooooo much cleaner and more "Ruby" than mine. It'll be another thing I reference when I look to write some quality Ruby code in the future.

MagicMirror and YNAB API

20190325 - 2036EST

Finally had some time at home today to just tinker. Broke out the Magic Touch 10in Touchscreen and got it working with a Raspberry Pi 3. Luckily, Mimo had an excellent guide for setting up their monitors with a RPi3. Followed along with this for a bit until I couldn't for the life of me persist the "Coordinate Transformation Matrix" (needed to calibrate the touchscreen input appropriately). I could run a command after boot and it worked fine but no persistence. After some Google Fu involving Linux exorg and determining Device Vendor, I used this stackexchange to get the answer I needed. Lo-and-behold! The touchscreen settings now persist after reboot. The next step was to install MagicMirror on my RPi3. SUPER EASY, since the author put a RPi3 Section in his README.md. Got it installed and running but it only runs on the primary monitor (HDMI output) so I'll have to do some more tinkering later to have it auto-boot onto my touchscreen display. End goal is to have a Google calendar HUD for the family and use the YNAB API to populate some data regarding out family budget at a glance.

Update 20190326 0636EST
Just had to change some things in /etc/X11/xorg.conf - Per the guides above, in the "ServerLayout" for the screens, it had "HDMI" set as Screen 0. By telling it to set "UGA" as Screen 0 and setting HDMI as Screen 1, we now have the main task bar on our tiny touchscreen. That got the display to be primary but now the touchscreen calibration is off. We have to adjust the "Coordinate Transformation Matrix" again.

Let's look at that:
We have a 24in monitor that I've set to have a static (static should make this stick across setups) resolution of 1280x720 and a 10in touchscreen with 1024x600.
According to this helpful wiki entry we need to calculate a matrix of c0 0 c1 0 c2 c3 0 0 1 using

c0 = touch_area_width / total_width
c2 = touch_area_height / total_height
c1 = touch_area_x_offset / total_width
c3 = touch_area_y_offset / total_height

For my setup:
c0 = 1024 / 2304 ~= 0.44444
c2 = 600 / 720 ~= 0.83
c1 = 1280 / 2304 ~= 0.55555
c3 = 0 / 720 = 0

This got the calibration we needed. Onto implementing and changing up the MagicMirror itself!

Update 20190327 2042EST
Had to install xscreensaver on the RPi to make it stop blanking itself after 10-15min. That was simple. Then, finally got it running! Linked up the family calendar and put nice things to know.

Time to start writing my own module!

Top Coder update and Ruby on Rails

20190324 - 0541EST

I came in second place for the Top Coder. There were a few bugs... err... features in my game that I had a few points deducted for. Still a pretty cool site and I think I'll try for some more challenges in the future. I suppose I can call my self a professional developer now. Based solely on the definition of: if you get paid to do it, you're a "professional".

Also have been diving into "Learn Rails 5.2: Accelerated Web Development with Ruby on Rails". So far so good, the MVC pattern that Rails uses is exactly what I learned when digging into the ASP.NET Core project/API that I built. Of course, it'll be good to actually dig into the 'V' part of that acronym since I only finished the 'MC' part of my project. As nice and clean as .NET and C# is, Rails seems so much more friendly with the "rails console". So many things you can do from the console that make building out your models a breeze. Maybe I missed a tool for .NET that would give me similar functionality, but I enjoy the rails console. Then there is the easy to read language of Ruby. Since it's all designed to be human readable from a language standpoint, it's easy enough to pick up on what's happening by just reading the code. I think I'll recommend this to anyone that's got some programming experience but looking for a new language since it's easy to understand but you still need to understand programming concepts for it to make sense.

Haven't forgotten that React course, just putting it on pause for a moment...

garykrause.dev and Top Coder

I bought a few different .dev names in the recent release. Maybe you used one to get to this page? That would be neat! There was a lot of buzz in the different Slack channels I'm in about the .dev namespace and I definitely jumped on that bandwagon.

Also just finished my first Top Coder challenge for the Veteran community. It's a Breakout Remix. It was fun to make, I used some pre-generate GameObjects from a previous Unity3D tutorial and slapped some new scripts on them. The most challenging part was handling the Upgrades in the game. There was a lot of state management and manipulation to ensure upgrades weren't all over the place and that the gracefully entered and exited the game when appropriate. Maybe it will be my first Software Dev paycheck? That would be neat and would nicely justify and offset my domain name purchases, haha!

I stopped the React course to start doing Top Coder and probably won't get back to React for a while. Based on a future prospect, I'll be Learning Ruby the Hard Way. Probably not as useful as learning React but we'll see.

Let's learn Go... oh wait a React tutorial!

20190307 - 0617EST

Being sick is usually great, get to stay home from the day job and practice coding... unless you get the flu and your whole body aches. Anyway, I'm alive and well and on the tail end of the sickness started up a Go tutorial but promptly go distracted and began browsing the web. However, Go seems like it's a nice language to use. I like that they take away all the flame war things about spacing and formatting of the code and just force their will on you. I imagine for some, that's a non-starter.

Onto React! In my browsing and subsequent podcast> listening, I came across Zac Braddy's React in Motion course. And I finally caved, I began learning more about JS front end development. It's going quite nciely, Zac structured the course to start with high level concepts that he (supposedly) will dive into deeper later in the course. Either way, I think this should be a good structured way to continue the JS journey I've been refusing to start. Perhaps followed up by a different book or course that can further reinforce what I'm learning.

Serverless is a lie

20190303 - 1914EST

Went to a DevOps meetup (Devops Columbia) and listed to a good presentation about what "Serverless Functions" are. Turns out, they still use a server! But, that server isn't sitting there waiting to run code. The code is sitting there waiting to be run. You pay by usage and can set various triggers based on anything from time to file changes to Http messages. It seemed pretty cool. It seemed like I should have wrote my REST API as functions so it would be cheaper. But then again, I should probably get my API actually working with a Front-End before I go breakin.... err changing things.

Bogus and Mocking Data

20190220 - 1157EST

Today my first child is 10 months old! But you're not here for that. Let's talk Bogus

I was going to manually go in and hand-jam a bunch of test SQL data for use while testing and demoing. But then I stumbled upon Bogus. Which is a lovely C# library for creating all kinds of random data but with intent. For instance, you can have it generate Lorem Ipsum sentences or sentence, a username, an email, pick from a list, etc. etc. I'm really happy to have found this.

I did have to do some weird stuff in Program.cs because I'm calling two additional functions to populate the data. The intent is to comment out or remove those two lines before sending this thing out into the wild.

Blazor, CORS, and JS

20190218 - 1657EST

I've been stalling a lot in building this front end for the API, but just wanted to muse a bit about what I've learned recently. I went through the 'Practical Javascript' @ watchandcode.com> and learned a bit about JS. There's a lot more to it though. Really seems daunting but I suppose that's because I've never done it.

On a long drive home I listened to a .NET Rocks podcast about Blazor and that got me thinking that I could just write the front end using Blazor and skip learning more JS. Not sure if that's the best idea but it's an idea for now.

This all led me to asking around int he Operation Code Slack channel about doing dev on a web-page. One thing led to another and I don't know anything about making a web page. yet. Regardless of that, I did get some clarification on somethign within my API that I was clueless on. CORS. I learned that it basically tells a browser when to enable using data from a certain API. So if I tell my API to app.UseCors() but .WithOrigins("http://foo.com") then the browser will know to only use my API's data when working with foo.com

Git Enlightenment via Slack

20190213 - 0751EST

I recently was helping someone out in a Slack chat I'm part of (CodingBlockPodcast) and while showing them my example Terminal ouptut they commented on my 'repo' folder being in my Dropbox. After a bit more discussion, they enlightened me. Don't use Dropbox and Git source control or you'll end up saturating your Dropbox with all the various versions and branches of your code. This had never occurred to me so I dove deeper into the question. How do I move from one computer to the next and still keep my changes and such?? Git of course! My initial reason to not use solely Git was not commiting nonsense as I move between computers, but my good friend on Slack pointed out I could just branch off 'master' into 'nonsense' and do what I please. Then rebase 'nonsense' into 'master' when I'm done. It blew my mind! I understand source control a bit more now and will also be jumping into the CLI for Git more.

I'm hosted with GitHub pages.