Jekyll2019-03-10T00:16:20+00:00http://johnsanchez.me/atom.xmlJohn SanchezSnippets Of Get It Done.John SanchezClearing Local Mac DNS Cache2016-12-21T19:48:24+00:002016-12-21T19:48:24+00:00http://johnsanchez.me/snippets/clearing-local-mac-dns<p>When updating a website’s DNS records I often find the following command line commands useful.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dig domainname.com
<span class="nb">sudo </span>dscacheutil <span class="nt">-flushcache</span>
<span class="nb">sudo </span>killall <span class="nt">-HUP</span> mDNSResponder
</code></pre></div></div>
<p>What are those commands and why are they useful?</p>
<p>If you know about DNS records, you know that updating them will update the DNS servers around the world. Now, what can happen is that the DNS servers near you are updated but your computer’s DNS records aren’t. They’ll probably get updated the next time you restart your computer or within a few hours.</p>
<p>If you’re actively developing a website and you’re waiting on your DNS cache to update… It can be a real pain!</p>
<p>The following command will pull the DNS records to see if your records have been updated. This doesn’t use the same cache that your browser uses. So, often times, it’ll pull up the most up-to-date information.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dig domainname.com
</code></pre></div></div>
<p>Then, we use the following to clear your computer’s DNS cache.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>dscacheutil <span class="nt">-flushcache</span>
<span class="nb">sudo </span>killall <span class="nt">-HUP</span> mDNSResponder
</code></pre></div></div>
<p>If you’d like more details about exactly what each command does, consult the man pages.</p>
<p>For example:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>man dig
man dscacheutil
man mDNSResponder
</code></pre></div></div>John SanchezWhen updating a website’s DNS records I often find the following command line commands useful.Empty Gems From RVM Gemset2015-02-11T19:48:24+00:002015-02-11T19:48:24+00:00http://johnsanchez.me/snippets/empty-gems-from-rvm-gemset<p>When experimenting in ruby, sometimes I forget to create a Gemset before I install gems. In which case, the Gems accidentally get install in the default gemset.</p>
<p>Eventually, you’ll end up with a ton of unnecessary gems in the default gemset. You can clean it up using the empty command:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">rvm gemset empty <span class="s2">""</span></code></pre></figure>
<p>If you need to clean up another gemset, just add the gemset name in between the qoutation marks. For example:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">rvm gemset empty <span class="s2">"gemset_name"</span></code></pre></figure>John SanchezWhen experimenting in ruby, sometimes I forget to create a Gemset before I install gems. In which case, the Gems accidentally get install in the default gemset.How to Keep Your Mac From Falling Asleep2014-11-08T19:59:49+00:002014-11-08T19:59:49+00:00http://johnsanchez.me/snippets/how-to-keep-your-mac-from-falling-asleep<p>One day, you’ll want to keep your Mac up with you. Give it some caffeine with the “caffeinate” command.</p>
<p>What’s “caffeinate” do?</p>
<p>Open up Terminal or iTerm 2 and check out the man pages:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">man caffeinate</code></pre></figure>
<p>How would I use it?</p>
<p>Just type in:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">caffeinate</code></pre></figure>
<p>and your Mac will stay awake until you press Control + C to stop the command.</p>
<p>If you’d like, a timer to automatically shut it off is available.</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">caffeinate <span class="nt">-u</span> <span class="nt">-t</span> 120</code></pre></figure>
<p>Remember the “120” above is in seconds. In the above example, it would stay up for two minutes.</p>John SanchezOne day, you’ll want to keep your Mac up with you. Give it some caffeine with the “caffeinate” command.Toggle Displaying Hidden Files on Mac2014-11-04T22:09:27+00:002014-11-04T22:09:27+00:00http://johnsanchez.me/snippets/toggle-displaying-hidden-files-on-mac<p>There are times when I’d like to see the hidden files within Finder on my mac. Sure, I could jump into Terminal or iTerm 2 and browser through the file structure… But, something, you just want to use a GUI.</p>
<p><em>Small Disclaimer: Only mess around in a command line application if you’re confident in what you’re doing.</em></p>
<p>Here’s what you do:</p>
<h3 id="turning-hidden-files-display---on">Turning Hidden Files Display - On</h3>
<p>Open up your Mac command line utility. I prefer <a href="http://iterm2.com/">iTerm 2</a>. Then, paste in the following command:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">defaults write com.apple.finder AppleShowAllFiles <span class="nt">-bool</span> YES</code></pre></figure>
<p>Click “Enter” on your keyboard to run it. Copy, paste, and run:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">killall Finder</code></pre></figure>
<h3 id="turning-hidden-files-display---off">Turning Hidden Files Display - Off</h3>
<p>All you really do here is change “YES” to “NO.”</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">defaults write com.apple.finder AppleShowAllFiles <span class="nt">-bool</span> NO</code></pre></figure>
<p>Click “Enter” on your keyboard to run it. Copy, paste, and run:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">killall Finder</code></pre></figure>
<h3 id="ive-added-it-as-an-alias-in-my-zshrc-file-for-easy-access">I’ve added it as an alias in my .zshrc file for easy access:</h3>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">alias </span><span class="nv">hiddenon</span><span class="o">=</span><span class="s1">'defaults write com.apple.finder AppleShowAllFiles -bool YES && killall Finder'</span>
<span class="nb">alias </span><span class="nv">hiddenoff</span><span class="o">=</span><span class="s1">'defaults write com.apple.finder AppleShowAllFiles -bool NO && killall Finder'</span></code></pre></figure>
<p>I’ll explain aliases in a future episode on <a href="http://docasts.com">DOCasts.com</a></p>John SanchezThere are times when I’d like to see the hidden files within Finder on my mac. Sure, I could jump into Terminal or iTerm 2 and browser through the file structure… But, something, you just want to use a GUI.Upgrade RVM Ruby to Another Version2014-11-02T23:22:27+00:002014-11-02T23:22:27+00:00http://johnsanchez.me/snippets/upgrade-rvm-ruby-to-another-version<p>Recently, there was an important security update for Ruby. As a result, <a href="http://rvm.io/">RVM</a> was updated.</p>
<h4 id="i-updated-rvm-to-load-the-new-list">I updated RVM to load the new list:</h4>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rvm get stable
</code></pre></div></div>
<h4 id="then-i-checked-the-known-list">Then, I checked the known list:</h4>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rvm list known
</code></pre></div></div>
<h4 id="now-upgrade-to-the-version-of-your-choice">Now, upgrade to the version of your choice:</h4>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rvm upgrade [current-version] [desired-version]
</code></pre></div></div>
<p>Example:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rvm upgrade 2.1.3 2.1.4
</code></pre></div></div>
<p>At this point, you’ll be prompted on whether you would like to delete the previous version and move it’s gemsets to the new version. Be sure to read through those instructions carefully.</p>
<h4 id="clean-up-clean-up-everybody-clean-up">Clean up, clean up, everybody clean up</h4>
<p>Now, clean up after yourself.</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rvm cleanup all
</code></pre></div></div>
<p>This will clean up any unnecessary files or other information taking up disk space.</p>
<p>If you’re a ruby developer by hobby or by title, be sure that you’re subscribed to the updates on <a href="https://www.ruby-lang.org/en/news/">Ruby-Lang News</a></p>John SanchezRecently, there was an important security update for Ruby. As a result, RVM was updated.Increase Email Security by Installing Mailpile on Your Mac2014-10-27T10:14:12+00:002014-10-27T10:14:12+00:00http://johnsanchez.me/blog/increase-email-security-by-installing-mailpile-on-your-mac<p>Mailpile is an amazing new open source platform that allows you to encrypt messages and gives you more control over your privacy.</p>
<p>Jump right in and let’s get it installed on Mac!</p>
<iframe width="560" height="315" src="//www.youtube.com/embed/FvZbvuWyjLo" frameborder="0"> </iframe>
<p>To increase awareness, please spread the word about Mailpile.</p>
<h3 id="resources">Resources</h3>
<p><a href="http://mailpile.is">Mailpile.is</a></p>
<p><a href="http://docasts.com">DOCasts.com</a></p>
<p><a href="http://blog.com">Blog</a></p>John SanchezMailpile is an amazing new open source platform that allows you to encrypt messages and gives you more control over your privacy.Update Your Ubuntu Server with Apt-Get2014-10-26T10:52:44+00:002014-10-26T10:52:44+00:00http://johnsanchez.me/snippets/update-your-ubuntu-server-with-apt-get<p>Updating your Ubuntu server is important since updates can include security patches and usability improvements (bug killing enhancements).</p>
<h3 id="open-up-your-commandline-interface-for-your-server-and-type-in-the-following">Open up your commandline interface for your server and type in the following:</h3>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">apt-get update</code></pre></figure>
<h3 id="if-youre-not-logged-in-as-root-youll-have-to-add-sudo">If you’re not logged in as root, you’ll have to add “sudo”</h3>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">sudo </span>apt-get update</code></pre></figure>John SanchezUpdating your Ubuntu server is important since updates can include security patches and usability improvements (bug killing enhancements).Add a Space to Dock in Mac2014-10-25T10:48:37+00:002014-10-25T10:48:37+00:00http://johnsanchez.me/snippets/add-space-to-dock-in-mac<p>I’m one to constantly organize my files and documents on my Mac. Throw the following line into Terminal and then restart your Dock to apply.</p>
<h3 id="1-copy-and-paste-the-following-into-terminalapp-or-itermapp">1. Copy and paste the following into Terminal.app or iTerm.app</h3>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">defaults write com.apple.dock persistent-apps <span class="nt">-array-add</span> <span class="s1">'{"tile-type"="spacer-tile";}'</span></code></pre></figure>
<h3 id="2-restart-dock">2. Restart Dock</h3>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">killall Dock</code></pre></figure>
<p>You should now see a new space in your Dock area. The end result may look similar to:</p>
<p><img src="/images/snippets/2014-10-25-snippet_space.jpg" alt="Space In Dock" title="Space in Dock" /></p>
<p>Cheers!</p>John SanchezI’m one to constantly organize my files and documents on my Mac. Throw the following line into Terminal and then restart your Dock to apply.