<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Bob Matcuk</title>
    <description>The latest articles on Forem by Bob Matcuk (@bmatcuk).</description>
    <link>https://forem.com/bmatcuk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F240492%2F1f58ed0e-69df-4c79-a16b-8fb3dfcbb8d4.png</url>
      <title>Forem: Bob Matcuk</title>
      <link>https://forem.com/bmatcuk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bmatcuk"/>
    <language>en</language>
    <item>
      <title>Examine SSL Cert</title>
      <dc:creator>Bob Matcuk</dc:creator>
      <pubDate>Mon, 15 Feb 2021 18:09:33 +0000</pubDate>
      <link>https://forem.com/bmatcuk/examine-ssl-cert-20lo</link>
      <guid>https://forem.com/bmatcuk/examine-ssl-cert-20lo</guid>
      <description>&lt;p&gt;Need to check when your SSL cert will expire?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; &lt;span class="nv"&gt;$SERVER&lt;/span&gt;:&lt;span class="nv"&gt;$PORT&lt;/span&gt; &lt;span class="nt"&gt;-servername&lt;/span&gt; &lt;span class="nv"&gt;$SERVER&lt;/span&gt; 2&amp;gt;/dev/null | openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-dates&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$PORT&lt;/code&gt; will likely be 443 - &lt;code&gt;-servername&lt;/code&gt; is required if the server is hosting multiple websites.&lt;/p&gt;

</description>
      <category>ssl</category>
      <category>cert</category>
    </item>
    <item>
      <title>Comparing package-lock Changes</title>
      <dc:creator>Bob Matcuk</dc:creator>
      <pubDate>Mon, 31 Aug 2020 14:12:55 +0000</pubDate>
      <link>https://forem.com/bmatcuk/comparing-package-lock-changes-3de9</link>
      <guid>https://forem.com/bmatcuk/comparing-package-lock-changes-3de9</guid>
      <description>&lt;p&gt;I recently updated some dependencies in a node project and some things broke. I wanted to get a list of every dependency (and dependencies of dependencies) that changed, so I came up with this little one-liner.&lt;/p&gt;

&lt;p&gt;You'll see that I'm passing two "files" into &lt;code&gt;diff&lt;/code&gt; via I/O redirection. I'm using &lt;code&gt;git&lt;/code&gt; to retrieve the two files - the commit that updated the dependencies had a &lt;code&gt;git&lt;/code&gt; hash of &lt;code&gt;735e8cd3c&lt;/code&gt;. So, the first file is &lt;code&gt;735e8cd3c^:package-lock.json&lt;/code&gt; (notice the caret - that means the parent commit of &lt;code&gt;735e8cd3c&lt;/code&gt; - ie, the version before I updated dependencies). The second file is &lt;code&gt;735e8cd3c:package-lock.json&lt;/code&gt; (no caret - ie, the version where I updated dependencies).&lt;/p&gt;

&lt;p&gt;I then pipe each file into &lt;code&gt;jq&lt;/code&gt; (&lt;code&gt;jq '.dependencies | map_values(.version)'&lt;/code&gt;) to extract the name and version of every package my project depends on (that includes dependencies of dependencies).&lt;/p&gt;

&lt;p&gt;Finally, &lt;code&gt;diff&lt;/code&gt; will tell me what changed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;diff &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;git show 735e8cd3c^:package-lock.json | jq &lt;span class="s1"&gt;'.dependencies | map_values(.version)'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;git show 735e8cd3c:package-lock.json | jq &lt;span class="s1"&gt;'.dependencies | map_values(.version)'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>node</category>
    </item>
    <item>
      <title>iPad Sidecar Issues Over USB with VPN</title>
      <dc:creator>Bob Matcuk</dc:creator>
      <pubDate>Mon, 03 Feb 2020 20:16:17 +0000</pubDate>
      <link>https://forem.com/bmatcuk/ipad-sidecar-issues-over-usb-with-vpn-3m7</link>
      <guid>https://forem.com/bmatcuk/ipad-sidecar-issues-over-usb-with-vpn-3m7</guid>
      <description>&lt;p&gt;When I'm working away from home, I like to use my iPad as a second monitor using Apple's "sidecar" feature. However, I noticed that, if the wifi network isn't great, there can be some performance issues or disconnects. So, I wanted to use a USB cable instead.&lt;/p&gt;

&lt;p&gt;This worked fine, until I switched on my company's VPN. Within seconds, sidecar disconnected with a cryptic error message. Any attempt to reconnect failed with odd behavior (I'd get an error in OSX, but a black screen would load on the iPad).&lt;/p&gt;

&lt;p&gt;Turns out: VPN clients will disable IPv6 unless the VPN configuration has explicit support for IPv6. The reason for this is that a large majority of VPNs are &lt;em&gt;not&lt;/em&gt; configured for IPv6, so any IPv6 traffic will bypass the VPN. If you're attempting to use the VPN to secure all of your internet traffic, this is a problem! All of your IPv6 traffic will "leak".&lt;/p&gt;

&lt;p&gt;It also turns out that connecting your iPad via USB makes it appear as a virtual ethernet device, configured to use IPv6. So, connecting to the VPN disables IPv6 and sidecar can no longer communicate with the iPad.&lt;/p&gt;

&lt;p&gt;However, I'm not using a VPN to secure &lt;em&gt;all&lt;/em&gt; of my traffic—just the traffic to my company's network. All of that traffic is IPv4 anyway, so, this security feature is lost on me. Disabling it solves all my sidecar issues! Woo!&lt;/p&gt;

&lt;p&gt;So, if you're in the same boat as me, trying to use sidecar with a VPN, try searching through your VPN client's settings or documentation for this feature and disable it. Here's how to do that with tunnelblick:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on tunnelblick's icon in the menu bar&lt;/li&gt;
&lt;li&gt;Select "VPN Details"&lt;/li&gt;
&lt;li&gt;Click on "Configurations" at the top&lt;/li&gt;
&lt;li&gt;Select your VPN configuration from the left-hand side&lt;/li&gt;
&lt;li&gt;Uncheck "Disable IPv6 unless the VPN server is accessed using IPv6"&lt;/li&gt;
&lt;li&gt;You may need to restart the VPN?&lt;/li&gt;
&lt;li&gt;Profit.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ipad</category>
      <category>sidecar</category>
      <category>vpn</category>
      <category>usb</category>
    </item>
    <item>
      <title>Debugging Rust with rust-lldb</title>
      <dc:creator>Bob Matcuk</dc:creator>
      <pubDate>Mon, 20 Jan 2020 04:19:38 +0000</pubDate>
      <link>https://forem.com/bmatcuk/debugging-rust-with-rust-lldb-j1f</link>
      <guid>https://forem.com/bmatcuk/debugging-rust-with-rust-lldb-j1f</guid>
      <description>&lt;p&gt;This is a quick and dirty primer to debugging rust applications with &lt;code&gt;rust-lldb&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start the Debugger
&lt;/h2&gt;

&lt;p&gt;Assuming you are using &lt;code&gt;cargo&lt;/code&gt; to build your executable, the first problem you'll run into is that you cannot debug &lt;code&gt;target/debug/BIN&lt;/code&gt;; instead, you need to debug &lt;code&gt;target/debug/deps/BIN-HASH&lt;/code&gt; where &lt;code&gt;BIN&lt;/code&gt; is the name of your program, and &lt;code&gt;HASH&lt;/code&gt; is a random hash... you'll probably have a ton of builds in the &lt;code&gt;deps&lt;/code&gt; directory; just use the latest (something like &lt;code&gt;ls -lt target/debug/deps/BIN-*&lt;/code&gt; should help you find the latest).&lt;/p&gt;

&lt;p&gt;If you're trying to debug an example program, they'll live under &lt;code&gt;target/debug/examples/BIN&lt;/code&gt; - no hash nonsense.&lt;/p&gt;

&lt;p&gt;Ok, now you can start the debugger:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rust-lldb target/debug/deps/BIN-HASH -- arg1 arg2 ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;arg1 arg2 ...&lt;/code&gt; are command line arguments to your application. If your application needs no arguments you can just leave them off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breakpoints
&lt;/h2&gt;

&lt;p&gt;You are now in the lldb debugger. You'll probably want to set some breakpoints before your program starts: you do that with the &lt;code&gt;breakpoint set&lt;/code&gt; command (shorthand: &lt;code&gt;b&lt;/code&gt;). There are lots of ways to set your breakpoint (specific file and line number, function name, etc). Type &lt;code&gt;help breakpoint set&lt;/code&gt; to see documentation. The shorthand, &lt;code&gt;b&lt;/code&gt;, actually accepts a simpler syntax from which it will guess the right thing to do. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;breakpoint set --name func
b func
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These two commands will do the same thing. So will:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;breakpoint set -f src/path/to/file.rs -l linenr
b src/path/to/file.rs:linenr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;help b&lt;/code&gt; to see the simplified syntax.&lt;/p&gt;

&lt;p&gt;You can see a list of your breakpoints with &lt;code&gt;breakpoint list&lt;/code&gt;. There are additional things you can do with breakpoints: see &lt;code&gt;help breakpoint&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running
&lt;/h2&gt;

&lt;p&gt;Once you've set your breakpoints, you can start the program with &lt;code&gt;run&lt;/code&gt; (shortcut &lt;code&gt;r&lt;/code&gt;). Execution will continue until a breakpoint is hit or the program ends (intentionally or not).&lt;/p&gt;

&lt;h2&gt;
  
  
  Examining Program State
&lt;/h2&gt;

&lt;p&gt;Ok, so your program is running and it hits a breakpoint. Now what? You'll probably want to examine the state of your program to get an idea of what's going on. Here are some commands to get you started:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;frame variable&lt;/code&gt; will show you all the variables in the current "frame"; ie, variables in scope.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;expression &amp;lt;expr&amp;gt;&lt;/code&gt; (shortcut &lt;code&gt;expr&lt;/code&gt; or just &lt;code&gt;p&lt;/code&gt;) will execute &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; and display the result. This can be used to examine the value of a variable or execute some code to see what the result is.&lt;/p&gt;

&lt;p&gt;You may have noticed when execution first paused that a listing of your code is shown, pointing to the current line that execution paused on. You can get that listing back with &lt;code&gt;list&lt;/code&gt; (shortcut &lt;code&gt;l&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;n&lt;/code&gt; will "step over" the current line, ie, the current line will execute and then the program will pause again.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;s&lt;/code&gt; will "step into" the current line, ie, the innermost function will be called and execution will pause at the start of that function.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;c&lt;/code&gt; will continue execution until another breakpoint is reached or the program exits.&lt;/p&gt;

&lt;p&gt;Finally, if you're debugging a program that interops with another language (ffi), it might be useful to examine specific memory addresses. That can be done with &lt;code&gt;x &amp;lt;addr&amp;gt;&lt;/code&gt;. This will show a hex-dump of memory at that address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some Other Helpful Things
&lt;/h2&gt;

&lt;p&gt;If you would normally invoke your program by piping something into stdin (ie, &lt;code&gt;cat file.txt | my-program&lt;/code&gt;), you won't be able to do that when running your program under rust-lldb. Instead, run rust-lldb with your program (ie, &lt;code&gt;rust-lldb my-program&lt;/code&gt;) and then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;settings set target.input-path &amp;lt;path-to-file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This is just barely scratching the surface of debugging. lldb is very powerful; judicious use of &lt;code&gt;help&lt;/code&gt; is encouraged. But hopefully this little primer will get you started!&lt;/p&gt;

</description>
      <category>rust</category>
      <category>debug</category>
      <category>lldb</category>
    </item>
    <item>
      <title>Disabling GateKeeper (OSX) for a Single App</title>
      <dc:creator>Bob Matcuk</dc:creator>
      <pubDate>Sat, 18 Jan 2020 16:12:12 +0000</pubDate>
      <link>https://forem.com/bmatcuk/disabling-gatekeeper-osx-for-a-single-app-48mf</link>
      <guid>https://forem.com/bmatcuk/disabling-gatekeeper-osx-for-a-single-app-48mf</guid>
      <description>&lt;p&gt;If you have an app that won't run on OSX (you get an error about it being "damaged" and it suggests that you should delete it), you can disable GateKeeper for that app by running the following command in a terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xattr -rd com.apple.quarantine "path/to/file"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, before you go this route, make sure you trust the app! GateKeeper exists for a reason.&lt;/p&gt;

</description>
      <category>osx</category>
      <category>gatekeeper</category>
    </item>
  </channel>
</rss>
