Advent of Code Day 3
03 Dec 2018Day 3 of Advent of Code1.
This is kind of a mess. I was really rushing to try to see if I could land on the leaderboard at least once this year.
Day 3 of Advent of Code1.
This is kind of a mess. I was really rushing to try to see if I could land on the leaderboard at least once this year.
Day 2 of Advent of Code1.
The following is my solution for Part 2. Part 1 was some modification of this.
As I had labeled in the comment, sorting the lines didn’t appear to cause a noticeable difference in performance for the input size. I haven’t looked at the effects on larger or smaller inputs, but from what I gathered from a friend that running similar code in Clojure, sorting did have a magnitude of performance increase.
I started playing around with Advent of Code1 this year.
For part 1, I used a spreadsheet to sum the numbers :P Here’s my solution for part 2:
For a while, I’ve been using specific IDEs for each individual language that I program in. It was feeling cluttered juggling between IntelliJ, Sublime, ZBStudio, et al.
I wanted to give Atom a try to see how it sets itself apart from the rest and to see how I could make it more useful for myself as I switch contexts between all the languages.
One of the great things on Atom is how extensible it is with the package explorer. I loved the feature of having the console in ZBStudio and Sublime. Though Sublime was difficult to configure and ZBStudio was only for Lua. The terminal on Atom’s PlatformIO-IDE-Terminal opens a Powershell window when opened. This was good and I really wanted a way to open bash at my project folder’s location.
The following details the simple steps to add bash to your Path and be able to use bash at your project folder’s location:
First, make a link to bash. I created the C:\Links directory after realizing how powerful these steps are for adding any binary to my PATH
Second, add this folder to your PATH.
Third, open any terminal whether its Atom’s terminal, cmd, or powershell and just type bash.
This will open bash at that location.
This is great because you no longer have to open the Bash application and cd all the way to your project folder.
I never knew until now that mklink
existed on Windows and will probably use it more to keep my PATH clean by linking everything to my C:\Links
directory.
At work, I run an Nginx server that is configured for 2-way authentication. The following are notes that I took to show how to use Wireshark to inspect the tcp stream of encrypted traffic.
First, we need to have both client and server certificates. With Wireshark it is preferred that we have PKCS12 format files so we need to convert our certificates to that format. The client in this case is a Tomcat server but sometimes a JMeter client which is used for testing.
To convert a JKS file to PKCS12 format:
To convert a PEM file to PKCS12 format:
In my environment, the backend server is behind an AWS Elastic Load Balancer so we need to find the IP addresses of the ELB:
Use the ELB IP addresses to form the tcpdump command:
If you want to be specific about the port then a more advanced command:
To properly capture 2-way authentication and be able to decrypt the tcp stream in Wireshark, the traffic must be encrypted with RSA. Traffic encrypted with any version of Diffie-Hellman will not work.
On the server, list the available ciphers and narrow down to the relevant ones that will work for Wireshark inspecting:
With the listed ciphers from the server, form the curl request and specify a compatible cipher:
Unfortunately, if you are on a Mac, the curl request will not work. Since Mavericks, the Transport Security Layer disables the ignores the option to set the cipher suite.1 In my case, I was able to restrict the encryption to RSA by setting the Nginx server configuration:
After setting the Nginx server to only accept RSA encryption, I could send requests from JMeter with no issue or further configuration.
Finally, once the pcap file has been created which captures the traffic sent from curl or JMeter, open it in Wireshark. Open the Wireshark preferences and select SSL from the protocol list. Select “Edit…” for the RSA Key List and add both the client certificate and the server certificate that we generated earlier in this tutorial. Afterward, you should now be able to see the unencrypted traffic. If you right-click and select “Follow > SSL Stream”, then you should see the requests made in clear text including header values and body data.