<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Notes on traviscj/blog</title>
    <link>https://traviscj.com/blog/tags/notes/</link>
    <description>Recent content in Notes on traviscj/blog</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 17 Oct 2018 03:51:27 +0000</lastBuildDate>
    <atom:link href="https://traviscj.com/blog/tags/notes/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>jquery selectors</title>
      <link>https://traviscj.com/blog/post/2018-10-17-jquery_selectors/</link>
      <pubDate>Wed, 17 Oct 2018 03:51:27 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-10-17-jquery_selectors/</guid>
      <description>&lt;p&gt;This is silly, but I always forget this:&lt;/p&gt;&#xA;&lt;!-- raw HTML omitted --&gt;&#xA;&lt;p&gt;I also learned you can specify things like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// @require https://code.jquery.com/jquery-2.1.4.min.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in a Tampermonkey script, even when a given site doesn&amp;rsquo;t already have jquery.&lt;/p&gt;</description>
    </item>
    <item>
      <title>regex in java</title>
      <link>https://traviscj.com/blog/post/2018-02-23-regex-in-java/</link>
      <pubDate>Fri, 23 Feb 2018 13:41:22 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-02-23-regex-in-java/</guid>
      <description>&lt;p&gt;I can never remember how to do java regexes with Pattern.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Pattern pattern &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; Pattern.&lt;span style=&#34;color:#a6e22e&#34;&gt;compile&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;x_(yy|zz)&amp;#34;&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;String input &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;x_yy&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;boolean&lt;/span&gt; m &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pattern.&lt;span style=&#34;color:#a6e22e&#34;&gt;asPredicate&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;test&lt;/span&gt;(input);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;System.&lt;span style=&#34;color:#a6e22e&#34;&gt;out&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;println&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;matches: &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; m);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Matcher matcher &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pattern.&lt;span style=&#34;color:#a6e22e&#34;&gt;matcher&lt;/span&gt;(input);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;while&lt;/span&gt; (matcher.&lt;span style=&#34;color:#a6e22e&#34;&gt;find&lt;/span&gt;()) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  System.&lt;span style=&#34;color:#a6e22e&#34;&gt;out&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;println&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;whole matched string: &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; matcher.&lt;span style=&#34;color:#a6e22e&#34;&gt;group&lt;/span&gt;(0));&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  System.&lt;span style=&#34;color:#a6e22e&#34;&gt;out&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;println&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;matched group: &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; matcher.&lt;span style=&#34;color:#a6e22e&#34;&gt;group&lt;/span&gt;(1));&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I also learned a really cool thing IntelliJ can do with pattern matches!&lt;/p&gt;&#xA;&lt;p&gt;![java regex]({{ site.baseurl }}/assets/java-regex.png)&lt;/p&gt;</description>
    </item>
    <item>
      <title>_useful</title>
      <link>https://traviscj.com/blog/post/2017-04-03-_useful/</link>
      <pubDate>Mon, 03 Apr 2017 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2017-04-03-_useful/</guid>
      <description>&lt;p&gt;I often create a directory/file called &lt;code&gt;_useful&lt;/code&gt;/&lt;code&gt;_useful.org&lt;/code&gt;/&lt;code&gt;_useful.txt&lt;/code&gt;.&#xA;I have one in my Dropbox, for example, that contains:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;My apartment lease&lt;/li&gt;&#xA;&lt;li&gt;My car/motorcycle insurance details&lt;/li&gt;&#xA;&lt;li&gt;A textfile with my vehicle plate numbers/VINs/insurance policy numbers.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;At work, I have one with&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the top visited links for logs/metrics/admin interfaces for the services I work with most&lt;/li&gt;&#xA;&lt;li&gt;a list of links of &amp;ldquo;typical&amp;rdquo; or &amp;ldquo;exemplar&amp;rdquo; things&#xA;&lt;ul&gt;&#xA;&lt;li&gt;links to our internal tool views for typical payments, merchants, etc&lt;/li&gt;&#xA;&lt;li&gt;typical size (in bytes) of various protobuf messages we use a lot, size of 1M messages, #messages in 1MB/GB&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;common coding idioms, like several variants of &lt;code&gt;@RunWith&lt;/code&gt; that we use in various cases in our test code.&lt;/li&gt;&#xA;&lt;li&gt;useful commands for doing stuff (curl/SQL/plain old shell)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Plain text is great for all the reasons it usually is.&#xA;But it&amp;rsquo;s especially useful here (see what I did there?) because the file loads much faster than Google Docs or wiki pages, it&amp;rsquo;s grep-able, it&amp;rsquo;s trivial to copy to a new machine, there&amp;rsquo;s no fuss about futzing with the document to get it to format properly, and soforth.&lt;/p&gt;</description>
    </item>
    <item>
      <title>launchd as cron crash course</title>
      <link>https://traviscj.com/blog/post/2014-08-08-launchd_as_cron_crash_course/</link>
      <pubDate>Fri, 08 Aug 2014 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2014-08-08-launchd_as_cron_crash_course/</guid>
      <description>&lt;p&gt;insert&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&#xA;&amp;lt;!DOCTYPE plist PUBLIC &amp;quot;-//Apple//DTD PLIST 1.0//EN&amp;quot; &amp;quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&amp;quot;&amp;gt;&#xA;&amp;lt;plist version=&amp;quot;1.0&amp;quot;&amp;gt;&#xA;&amp;lt;dict&amp;gt;&#xA;        &amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt;&#xA;        &amp;lt;string&amp;gt;com.whatever.five_after&amp;lt;/string&amp;gt;&#xA;        &amp;lt;key&amp;gt;ProgramArguments&amp;lt;/key&amp;gt;&#xA;        &amp;lt;array&amp;gt;&#xA;                &amp;lt;string&amp;gt;echo just ran &amp;gt; /tmp/whatever_five_after&amp;lt;/string&amp;gt;&#xA;        &amp;lt;/array&amp;gt;&#xA;        &amp;lt;key&amp;gt;StartCalendarInterval&amp;lt;/key&amp;gt;&#xA;        &amp;lt;dict&amp;gt;&#xA;                &amp;lt;key&amp;gt;Minute&amp;lt;/key&amp;gt;&amp;lt;integer&amp;gt;5&amp;lt;/integer&amp;gt;&#xA;        &amp;lt;/dict&amp;gt;&#xA;&amp;lt;/dict&amp;gt;&#xA;&amp;lt;/plist&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;into &lt;code&gt;$HOME/Library/LaunchAgents/com.whatever.five_after.plist&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you call a script in the ProgramArguments section, remember to make it executable and define the script properly.&lt;/p&gt;&#xA;&lt;p&gt;Run&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;launchctl load $HOME/Library/LaunchAgents/com.whatever.five_after.plist&#xA;launchctl start com.whatever.five_after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can also run every N seconds with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;key&amp;gt;StartInterval&amp;lt;/key&amp;gt;&amp;lt;integer&amp;gt;N&amp;lt;/integer&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can also check the status with&lt;/p&gt;</description>
    </item>
    <item>
      <title>black box machine learning</title>
      <link>https://traviscj.com/blog/post/2014-07-15-black_box_machine_learning/</link>
      <pubDate>Tue, 15 Jul 2014 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2014-07-15-black_box_machine_learning/</guid>
      <description>&lt;p&gt;During my Ph.D. I studied optimization algorithms.&#xA;Optimization algorithms are typically an integral part of machine learning algorithms, and we discussed many machine&#xA;learning algorithms, but somehow I made it through without doing very much actual machine learning training or&#xA;prediction tasks.&lt;/p&gt;&#xA;&lt;p&gt;It turns out that it isn&amp;rsquo;t very hard to do some very basic machine learning:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pip install -U numpy scipy scikit-learn&#xA;ipython&#xA;from sklearn.ensemble import RandomForestClassifier&#xA;from sklearn import datasets&#xA;iris_data = datasets.load_iris()&#xA;rfc = RandomForestClassifier()&#xA;rfc.fit(iris_data[&#39;data&#39;], iris_data[&#39;target&#39;])&#xA;rfc.predict([6.1,2.6,5.6,1.4])    # yields array([2])&#xA;rfc.predict([5.7,4.4,1.5,0.4])    # yields array([0])&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>some setup notes</title>
      <link>https://traviscj.com/blog/post/2013-10-27-some_setup_notes/</link>
      <pubDate>Sun, 27 Oct 2013 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2013-10-27-some_setup_notes/</guid>
      <description>&lt;h2 id=&#34;zsh&#34;&gt;zsh&lt;/h2&gt;&#xA;&lt;p&gt;Zsh is an amazing (mostly) drop-in replacement for bash.&lt;/p&gt;&#xA;&lt;p&gt;On OSX, just run&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; brew install zsh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You also want to install oh-my-zsh.&lt;/p&gt;&#xA;&lt;p&gt;I went a little crazy with plugins. My list is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;plugins=(autojump brew git git-flow gnu-utils gpg2 osx textmate zsh-syntax-highlighting history-substring-search)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;ssh&#34;&gt;SSH&lt;/h2&gt;&#xA;&lt;p&gt;I ssh a lot. So I have a bunch of host entries in my .ssh/config file. Each looks like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Host [shortname]&#xA;     Hostname [hostname]&#xA;     User     [username for hostname]&#xA;     IdentityFile [my home directory]/.ssh/[id_rsa file for this host]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You also need identity files for hosts you use. I tend to use a different one on each host I connect to; some might consider this overly paranoid. Probably it&amp;rsquo;d be better to use 1 key but only for a shorter period of time. In any case, you need to use&lt;/p&gt;</description>
    </item>
    <item>
      <title>C/C&#43;&#43; Values, Pointers, and References</title>
      <link>https://traviscj.com/blog/post/2013-09-20-c_cpp_values_pointers_and_references/</link>
      <pubDate>Fri, 20 Sep 2013 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2013-09-20-c_cpp_values_pointers_and_references/</guid>
      <description>&lt;p&gt;I had an embarrassing realization: While C does have an address-of operator, it does not include reference variable or pass-by-reference syntax. It&amp;rsquo;s embarrassing because I should have realized that it was a C++ invention; I guess some of my “C” code actually really has been C++ code.&lt;/p&gt;&#xA;&lt;p&gt;For future reference, here&amp;rsquo;s the current summary of my understanding:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;&lt;/th&gt;&#xA;          &lt;th&gt;var&lt;/th&gt;&#xA;          &lt;th&gt;*var&lt;/th&gt;&#xA;          &lt;th&gt;&amp;amp;var&lt;/th&gt;&#xA;          &lt;th&gt;&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;int xv=3;&lt;/td&gt;&#xA;          &lt;td&gt;value&lt;/td&gt;&#xA;          &lt;td&gt;invalid&lt;/td&gt;&#xA;          &lt;td&gt;memory location of value&lt;/td&gt;&#xA;          &lt;td&gt;&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;int *xp=&amp;amp;xv;&lt;/td&gt;&#xA;          &lt;td&gt;memory location&lt;/td&gt;&#xA;          &lt;td&gt;value&lt;/td&gt;&#xA;          &lt;td&gt;memory location of pointer.&lt;/td&gt;&#xA;          &lt;td&gt;&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;int &amp;amp;xr=xr;&lt;/td&gt;&#xA;          &lt;td&gt;value&lt;/td&gt;&#xA;          &lt;td&gt;invalid&lt;/td&gt;&#xA;          &lt;td&gt;memory location of value&lt;/td&gt;&#xA;          &lt;td&gt;(all invalid in C)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;As one other note, there are three ways you can pass things in C:&lt;/p&gt;</description>
    </item>
    <item>
      <title>cplex matlab interface</title>
      <link>https://traviscj.com/blog/post/2012-02-01-cplex_matlab_interface/</link>
      <pubDate>Wed, 01 Feb 2012 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2012-02-01-cplex_matlab_interface/</guid>
      <description>&lt;p&gt;Just for my own reference, I&amp;rsquo;m documenting the interface to CPLEX.&lt;/p&gt;&#xA;&lt;p&gt;CPLEX expects a problem in the form&#xA;(&#xA;\begin{split}&#xA;\min \qquad &amp;amp; g^Td + \frac12 d^TWd\&#xA;\text{subject to} \qquad &amp;amp; c_L \leq Ad \leq c_U\&#xA;&amp;amp; d_L \leq d \leq d_U&#xA;\end{split}&#xA;)&#xA;and is called by&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;cplex = Cplex(&amp;#39;test&amp;#39;);&#xA;cplex.Param.feasopt.tolerance.Cur = 1e-8;&#xA;if params.printLevel &amp;lt; 8&#xA;    cplex.DisplayFunc = [];&#xA;end&#xA;cplex.Model.sense = &amp;#39;minimize&amp;#39;;&#xA;cplex.Param.qpmethod.Cur = 1;&#xA;cplex.addCols(gk,[],bl-xk,bu-xk);&#xA;cplex.addRows(-ck, A0, -ck);&#xA;cplex.Model.Q = W;&#xA;cplex.Model.obj = g;&#xA;cplex.Model.lb = d_L;&#xA;cplex.Model.ub = d_U;&#xA;cplex.Model.lhs= c_L;&#xA;cplex.Model.rhs= c_U;&#xA;cplex.solve();&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Getting GnuPlot to compile on OSX</title>
      <link>https://traviscj.com/blog/post/2010-05-27-getting_gnuplot_to_compile_on_osx/</link>
      <pubDate>Thu, 27 May 2010 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2010-05-27-getting_gnuplot_to_compile_on_osx/</guid>
      <description>&lt;p&gt;I misunderstood an officemate’s question yesterday and set out to compile gnuplot. Stock GNUPlot will fail to compile on OSX due to an incompatibility in the readline library. So when you compile, let GNUPlot know to use the one included:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&amp;gt; tar xzvf gnuplot*&#xA;&amp;gt; cd gnuplot-4.2.39&#xA;&amp;gt; ./configure --prefix=/usr/local --with-readline=builtin&#xA;&amp;gt; make&#xA;&amp;gt; sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Pylab PDF</title>
      <link>https://traviscj.com/blog/post/2010-05-25-pylab_pdf/</link>
      <pubDate>Tue, 25 May 2010 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2010-05-25-pylab_pdf/</guid>
      <description>&lt;p&gt;I’m in the process of kicking the MATLAB habit and replacing it with Python. Pylab is a reasonable approximation to the 2D plotting capabilities of MATLAB, but by default Pylab doesn’t run on headless(ie, non-GUI) boxes. So on my macbook, where I’m often running things interactively, I have&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;backend : macosx&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and on the faster core2quad machine I send off longer-running jobs to, I used&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;backend : PDF&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;in the .matplotlib/matplotrc file.&lt;/p&gt;</description>
    </item>
    <item>
      <title>MySQLdb module in Python on Ubuntu</title>
      <link>https://traviscj.com/blog/post/2009-05-30-mysqldb_module_in_python_on_ubuntu/</link>
      <pubDate>Sat, 30 May 2009 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2009-05-30-mysqldb_module_in_python_on_ubuntu/</guid>
      <description>&lt;p&gt;To install the mysqldb module in python on Ubuntu:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;sudo apt-get install python-mysqldb&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>A Quick MySQL Reference</title>
      <link>https://traviscj.com/blog/post/2009-05-27-a_quick_mysql_reference/</link>
      <pubDate>Wed, 27 May 2009 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2009-05-27-a_quick_mysql_reference/</guid>
      <description>&lt;p&gt;I got frustrated with not being able to write MySQL because I don&amp;rsquo;t do it often enough to be seeing it in my nightmares like MATLAB. But recently my datasets got annoyingly huge and it seemed like SQL might be a boon to me. So I set out to write a quick little program, and ended up writing this little reference along the way.&lt;/p&gt;&#xA;&lt;p&gt;Also, Sharvil Shah contributed some comments to it, so thanks to him for that!&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
