<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Code on MarkJacobsen.net</title><link>https://markjacobsen.net/tags/code/</link><description>Recent content in Code on MarkJacobsen.net</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 27 Sep 2018 13:33:00 +0000</lastBuildDate><atom:link href="https://markjacobsen.net/tags/code/index.xml" rel="self" type="application/rss+xml"/><item><title>Including the version in a Maven artifact</title><link>https://markjacobsen.net/2018/09/including-the-version-in-a-maven-artifact/</link><pubDate>Thu, 27 Sep 2018 13:33:00 +0000</pubDate><guid>https://markjacobsen.net/2018/09/including-the-version-in-a-maven-artifact/</guid><description>&lt;p&gt;Recently I wanted to include the version of an artifact generated by a Maven build into a text file in that artifact. As Google and and good friends will help you with, I was pointed to [this article][1] that was exactly what I wanted.&lt;/p&gt;
&lt;p&gt;Basically, create a /src/main/resources/version.txt file with the following content…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;${project.version}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;… then including the following snippet in your “build”…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;build&amp;gt;
 &amp;lt;resources&amp;gt;
 &amp;lt;resource&amp;gt;
 &amp;lt;directory&amp;gt;src/main/resources&amp;lt;/directory&amp;gt;
 &amp;lt;filtering&amp;gt;true&amp;lt;/filtering&amp;gt;
 &amp;lt;includes&amp;gt;
 &amp;lt;include&amp;gt;**/version.txt&amp;lt;/include&amp;gt;
 &amp;lt;/includes&amp;gt;
 &amp;lt;/resource&amp;gt;
 &amp;lt;resource&amp;gt;
 &amp;lt;directory&amp;gt;src/main/resources&amp;lt;/directory&amp;gt;
 &amp;lt;filtering&amp;gt;false&amp;lt;/filtering&amp;gt;
 &amp;lt;excludes&amp;gt;
 &amp;lt;exclude&amp;gt;**/version.txt&amp;lt;/exclude&amp;gt;
 &amp;lt;/excludes&amp;gt;
 &amp;lt;/resource&amp;gt;
 &amp;lt;/resources&amp;gt;
&amp;lt;/build&amp;gt;[1]: https://stackoverflow.com/questions/3532135/using-maven-to-output-the-version-number-to-a-text-file
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>Execute MySql script from the command line</title><link>https://markjacobsen.net/2018/03/execute-mysql-script-from-the-command-line/</link><pubDate>Mon, 19 Mar 2018 10:24:00 +0000</pubDate><guid>https://markjacobsen.net/2018/03/execute-mysql-script-from-the-command-line/</guid><description>&lt;p&gt;This tip is very similar to how to “[Execute a SQL file via the MySQL command line in one line][1]” only this time specifying the DB you want to execute the script against and being prompted for your password…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysql -u user -p -h localhost MyDb &amp;lt; ~/SQL/script.sql[1]: http://markjacobsen.net/2012/12/execute-a-sql-file-via-the-mysql-command-line-in-one-line/
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>Using sed to view and replace text on a specific file in Linux</title><link>https://markjacobsen.net/2018/03/using-sed-to-view-and-replace-text-on-a-specific-file-in-linux/</link><pubDate>Sat, 17 Mar 2018 14:26:00 +0000</pubDate><guid>https://markjacobsen.net/2018/03/using-sed-to-view-and-replace-text-on-a-specific-file-in-linux/</guid><description>&lt;p&gt;Ever need to replace very specific text on a particular line in a very large file on Linux? Enter the sed command.&lt;/p&gt;
&lt;p&gt;To view the line (let’s say line 864 in this case) in the specific file, issue this command…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sed -n '864'p myfile.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And let’s say you get back the string ” I hate cheese”. Since we all know that’s not true, you can use a different variation of the sed command to replace “hate” with “love” like so…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sed -i '864s/hate/love/' myfile.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And if you’re really curious on how this even came about, it was due to an error in the phpMyAdmin export.php script when you had to change “break 2” to “break” on line 846 as identified here: &lt;a href="https://askubuntu.com/questions/928883/500-error-on-phpmyadmin-export-on-phpmyadmin-export-php/930975" target="_blank"&gt;&lt;a class="link" href="https://askubuntu.com/questions/928883/500-error-on-phpmyadmin-export-on-phpmyadmin-export-php/930975" target="_blank" rel="noopener"
 &gt;https://askubuntu.com/questions/928883/500-error-on-phpmyadmin-export-on-phpmyadmin-export-php/930975&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Email Bookmarklets</title><link>https://markjacobsen.net/2018/01/email-bookmarklets/</link><pubDate>Fri, 26 Jan 2018 13:41:00 +0000</pubDate><guid>https://markjacobsen.net/2018/01/email-bookmarklets/</guid><description>&lt;p&gt;Ever want an easy way to email a webpage to yourself? Maybe it’s to send it to your task list, or just to share with a co-worker? Of course there are extensions for most browsers to do this, but if you would prefer a bookmarklet that doesn’t require any installation, here’s how to do it. This is the basic link structure…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;javascript:document.location='mailto:?subject='+document.title+'&amp;amp;body='+escape(document.location);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or, for simplicity sake, just drag and drop this link into your bookmarks bar… [Email][1]&lt;/p&gt;
&lt;p&gt;Of course you can go wild and start customizing the URL to your hearts content. Set a value after the “mailto:”, or maybe even a CC. For example…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;javascript:document.location='mailto:me@here.com?subject='+document.title+'&amp;amp;cc=you@there.com&amp;amp;body='+escape(document.location);[1]: javascript:document.location='mailto:?subject='+document.title+'&amp;amp;body='+escape(document.location);
&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>