<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Greg Back</title><link href="https://gregback.net/" rel="alternate"/><link href="https://gregback.net/feeds/all.atom.xml" rel="self"/><id>https://gregback.net/</id><updated>2021-06-26T15:26:00-04:00</updated><entry><title>macOS Keyboard Symbols</title><link href="https://gregback.net/macos-keyboard-symbols.html" rel="alternate"/><published>2021-06-26T15:26:00-04:00</published><updated>2021-06-26T15:26:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2021-06-26:/macos-keyboard-symbols.html</id><summary type="html"/><content type="html">&lt;p&gt;A handy reference for myself for every time I forget these&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;⌘&lt;/td&gt;
&lt;td&gt;Command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;^&lt;/td&gt;
&lt;td&gt;Control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⌥&lt;/td&gt;
&lt;td&gt;Option&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⇧&lt;/td&gt;
&lt;td&gt;Shift&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</content><category term="macOS"/></entry><entry><title>Homebrew `depends_on` errors</title><link href="https://gregback.net/homebrew-depends_on-errors.html" rel="alternate"/><published>2021-06-26T15:08:00-04:00</published><updated>2021-06-26T15:08:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2021-06-26:/homebrew-depends_on-errors.html</id><summary type="html"/><content type="html">&lt;p&gt;If you're trying to install (or more likely uninstall) an old Homebrew Cask, you might get an error like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="go"&gt;Error: Cask &amp;#39;spectacle&amp;#39; definition is invalid: invalid &amp;#39;depends_on macos&amp;#39; value: unknown or unsupported macOS version: :lion&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To fix this, you can run the following command to "fix" the manifests of all currently-installed Casks:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/usr/bin/find&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;brew&lt;span class="w"&gt; &lt;/span&gt;--prefix&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/Caskroom/&amp;quot;&lt;/span&gt;*&lt;span class="s1"&gt;&amp;#39;/.metadata&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-type&lt;span class="w"&gt; &lt;/span&gt;f&lt;span class="w"&gt; &lt;/span&gt;-name&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;*.rb&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-print0&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/usr/bin/xargs&lt;span class="w"&gt; &lt;/span&gt;-0&lt;span class="w"&gt; &lt;/span&gt;/usr/bin/perl&lt;span class="w"&gt; &lt;/span&gt;-i&lt;span class="w"&gt; &lt;/span&gt;-pe&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;s/depends_on macos: \[.*?\]//gsm;s/depends_on macos: .*//g&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Source: &lt;a href="https://github.com/Homebrew/homebrew-cask/issues/58046"&gt;Homebrew/homebrew-cask#58046&lt;/a&gt;&lt;/p&gt;</content><category term="macos"/></entry><entry><title>The `-o` option to `grep`</title><link href="https://gregback.net/the-o-option-to-grep.html" rel="alternate"/><published>2021-04-11T19:18:00-04:00</published><updated>2021-04-11T19:18:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2021-04-11:/the-o-option-to-grep.html</id><summary type="html">&lt;p&gt;I don't know how I made it this long in my technical career without knowing about the &lt;code&gt;-o&lt;/code&gt; option to &lt;code&gt;grep&lt;/code&gt;, which prints only the part of the line that matches the regular expression, not the entire line. I have spent way too much time post-processing the results with &lt;code&gt;sed …&lt;/code&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;I don't know how I made it this long in my technical career without knowing about the &lt;code&gt;-o&lt;/code&gt; option to &lt;code&gt;grep&lt;/code&gt;, which prints only the part of the line that matches the regular expression, not the entire line. I have spent way too much time post-processing the results with &lt;code&gt;sed&lt;/code&gt;, &lt;code&gt;awk&lt;/code&gt;, etc. (and learned a lot in the process), but hopefully this will save me (and you) some time in the future.&lt;/p&gt;
&lt;p&gt;Source: &lt;a href="https://www.man7.org/linux/man-pages/man1/grep.1.h"&gt;&lt;code&gt;grep&lt;/code&gt;(1) man page&lt;/a&gt;&lt;/p&gt;</content><category term="linux"/></entry><entry><title>Exploring Sqlite databases</title><link href="https://gregback.net/sqlite.html" rel="alternate"/><published>2021-03-28T23:15:00-04:00</published><updated>2021-03-28T23:15:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2021-03-28:/sqlite.html</id><summary type="html">&lt;p&gt;Some common commands for exploring sqlite databases&lt;/p&gt;</summary><content type="html">&lt;p&gt;It's often useful to peek around a sqlite database file from the command line,
especially those that applications use for storing their own internal data. In
this case, I was interested in looking at how Firefox stores a user's browsing history (which happens to be in the file called &lt;code&gt;places.sqlite&lt;/code&gt; inside the Firefox profile directory). Anyway, here are some commands you can run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;sqlite&lt;span class="w"&gt; &lt;/span&gt;places.sqlite
sqlite&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;.help
sqlite&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;.tables
sqlite&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;.dbinfo
sqlite&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;PRAGMA&lt;span class="w"&gt; &lt;/span&gt;table_info&lt;span class="o"&gt;(&lt;/span&gt;moz_places&lt;span class="o"&gt;)&lt;/span&gt;
sqlite&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;.quit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;moz_places&lt;/code&gt; is the name of the specific table I was interested in.&lt;/p&gt;</content><category term="Linux"/><category term="sqlite"/><category term="cli"/></entry><entry><title>Rebase warning when running `brew update`</title><link href="https://gregback.net/brew-update-rebase-warning.html" rel="alternate"/><published>2021-03-19T23:03:00-04:00</published><updated>2021-03-19T23:03:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2021-03-19:/brew-update-rebase-warning.html</id><summary type="html">&lt;p&gt;What to do when Homebrew warns that you're in the middle of a rebase.&lt;/p&gt;</summary><content type="html">&lt;p&gt;If you run &lt;code&gt;brew update&lt;/code&gt; and see output that looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
        rm -fr &amp;quot;.git/rebase-merge&amp;quot;
and run me again.  I am stopping in case you still have something
valuable there.

Already up-to-date.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can fix it by running &lt;code&gt;brew update-reset&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This happened to me today and I spent way too long looking for the solution.&lt;/p&gt;
&lt;p&gt;[Source: &lt;a href="https://github.com/Homebrew/brew/issues/6288#issuecomment-550411122"&gt;GitHub comment&lt;/a&gt; by &lt;strong&gt;&lt;a href="https://github.com/joshuapinter"&gt;@joshuapinter&lt;/a&gt;&lt;/strong&gt;]&lt;/p&gt;</content><category term="macOS"/><category term="Homebrew"/></entry><entry><title>The `date` command</title><link href="https://gregback.net/date.html" rel="alternate"/><published>2021-03-19T22:43:00-04:00</published><updated>2021-03-19T22:43:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2021-03-19:/date.html</id><summary type="html">&lt;p&gt;Common usages for the &lt;code&gt;date&lt;/code&gt; command&lt;/p&gt;</summary><content type="html">&lt;p&gt;The Linux &lt;code&gt;date&lt;/code&gt; command can be used to get the current date (and also to modify
the date of your machine, but I've never used it for that). It's useful if you
want to programmatically add a date to a filename, either one time or as part of
a regularly-scheduled or repeated task.&lt;/p&gt;
&lt;p&gt;Here are some of the frequently used formats I use:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Sample Output&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;date +%F&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2021-03-19&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;If you just need the date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;date +"%F %R"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2021-03-19 22:43&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Like the date and time of this post&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;date +"%Y-%m-%dT%H:%M:%S%z"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2021-03-19T22:43:52-0400&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://en.wikipedia.org/wiki/ISO_8601"&gt;ISO 8601&lt;/a&gt; time in the local time zone.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;date -Iseconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2021-03-19T22:43:52-04:00&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Same, except including a ":" in the offset (does not work on macOS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;date -u +"%Y-%m-%dT%H:%M:%S%z"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2021-03-20T02:43:52+0000&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ISO 8601 date in UTC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;date -u +"%Y-%m-%dT%H:%M:%SZ"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2021-03-20T02:43:52Z&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Same, but using &lt;code&gt;Z&lt;/code&gt; instead of &lt;code&gt;+0000&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;date -u -Iseconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2021-03-20T02:51:58+00:00&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Same with colon in the output (does not work on macOS)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;For more information, see &lt;a href="https://unix.stackexchange.com/questions/164826/date-command-iso-8601-option"&gt;this Stack Exchange post&lt;/a&gt; or the
&lt;a href="https://man7.org/linux/man-pages/man1/date.1.html"&gt;&lt;code&gt;date&lt;/code&gt; man page&lt;/a&gt; (along with the &lt;a href="https://man7.org/linux/man-pages/man3/strftime.3.html"&gt;&lt;code&gt;strftime&lt;/code&gt; man page&lt;/a&gt;
for formatting options).&lt;/p&gt;</content><category term="Linux"/></entry><entry><title>Careful with those Backslashes!</title><link href="https://gregback.net/careful-with-those-backslashes.html" rel="alternate"/><published>2018-06-21T10:59:00-04:00</published><updated>2018-06-21T10:59:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2018-06-21:/careful-with-those-backslashes.html</id><summary type="html">&lt;h1&gt;Brainteaser of the day&lt;/h1&gt;
&lt;p&gt;Given a MySQL database, what value will be put in the database for each of the
following Python statements?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# normal string, 4 backslashes&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\\\&lt;/span&gt;&lt;span class="s2"&gt;y&amp;#39;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# raw string, 2 backslashes&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;y …&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;h1&gt;Brainteaser of the day&lt;/h1&gt;
&lt;p&gt;Given a MySQL database, what value will be put in the database for each of the
following Python statements?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# normal string, 4 backslashes&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\\\&lt;/span&gt;&lt;span class="s2"&gt;y&amp;#39;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# raw string, 2 backslashes&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;y&amp;#39;);&amp;quot;&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# normal string, 3 backslashes&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;\y&amp;#39;);&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# raw string, 3 backslashes&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;\y&amp;#39;);&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Take a guess, or try it out before looking at the answer below. If you want
to set up a database yourself, the following snippets should help.&lt;/p&gt;
&lt;details&gt;
    &lt;summary&gt;Code to set up a database and table&lt;/summary&gt;

    from sqlalchemy import create_engine
    engine = create_engine('mysql://root@localhost/')
    db = engine.connect()
    db.execute("""
        DROP DATABASE IF EXISTS test_db;
        CREATE DATABASE test_db;
        USE test_db;
        CREATE TABLE `test` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `text` char(8) NOT NULL,
            PRIMARY KEY (`id`)
        ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;"""
    )
    db.close()

&lt;/details&gt;

&lt;details&gt;
    &lt;summary&gt;Code to dump contents of database&lt;/summary&gt;

    from sqlalchemy import create_engine
    engine = create_engine('mysql://root@localhost/test_db')
    db = engine.connect()
    # Put insert commands here.
    res = db.execute("""SELECT text FROM test;""").fetchall()
    for row in res:
        print(row)
    db.close()

&lt;/details&gt;

&lt;p&gt;Here are some adorable Basset Hound pictures for you to look at before scrolling
down to see the answer.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Basset puppy" src="https://upload.wikimedia.org/wikipedia/commons/1/19/Cara_de_quem_caiu_do_caminh%C3%A3o....jpg"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Best friends" src="https://upload.wikimedia.org/wikipedia/commons/5/52/Bassets_hound_%2C_basset-hound.jpg"&gt;&lt;/p&gt;
&lt;h1&gt;Answer&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;All four&lt;/strong&gt; will result in the &lt;strong&gt;same&lt;/strong&gt; data being in the database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;x\y
x\y
x\y
x\y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Crazy, huh!?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I was confused too until I looked a bit more at the documentation and did some
experimentation.&lt;/p&gt;
&lt;h2&gt;Backslashes in Python&lt;/h2&gt;
&lt;p&gt;Backslashes in Python string literals &lt;em&gt;sometimes&lt;/em&gt; need to be escaped.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;a&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# =&amp;gt; a\a&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&lt;/span&gt;&lt;span class="se"&gt;\a&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# =&amp;gt; a (\a is the escape for BEL)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\s&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# =&amp;gt; a\s (\s is not a valid escape, so Python assumes the backslash is literal - DANGER!)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;s&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# =&amp;gt; a\s&lt;/span&gt;
&lt;span class="s1"&gt;&amp;#39;a&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;s&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;a\s&amp;#39;&lt;/span&gt;    &lt;span class="c1"&gt;# True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left in the result. (This behavior is useful when debugging: if an escape sequence is mistyped, the resulting output is more easily recognized as broken.) It is also important to note that the escape sequences only recognized in string literals fall into the category of unrecognized escapes for bytes literals.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals"&gt;Python 3 documentation&lt;/a&gt; 
(and similar for Python 2)&lt;/p&gt;
&lt;p&gt;This is part of the reason that "raw" string literals (prefixed with 'r') are useful:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;a&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# =&amp;gt; a\\a&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\a&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# =&amp;gt; a\a&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\s&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# =&amp;gt; a\s&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;s&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# =&amp;gt; a\\s&lt;/span&gt;
&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;s&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\s&amp;#39;&lt;/span&gt;  &lt;span class="c1"&gt;# False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Backslashes in MySQL&lt;/h2&gt;
&lt;p&gt;MySQL similarly uses backslash as an escape. However, differently from Python,
if a backslash is not part of a recognized escape sequence, the backlash is just
dropped.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\\a&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;-- a\a&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\aa&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;-- aaa&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\ta&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;-- a  a (literal tab character between two a&amp;#39;s)&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a\a&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="c1"&gt;-- aa&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;MySQL recognizes the escape sequences shown in Table 9.1, "Special Character Escape Sequences". For all other escape sequences, backslash is ignored. That is, the escaped character is interpreted as if it was not escaped. For example, \x is just x. These sequences are case-sensitive. For example, \b is interpreted as a backspace, but \B is interpreted as B.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="https://dev.mysql.com/doc/refman/5.7/en/string-literals.html"&gt;MySQL 5.7 documentation&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Putting it together&lt;/h2&gt;
&lt;p&gt;This combination leads to confusing results. So in the example below (different
than the four original statements):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;y&amp;#39;);&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is not using a raw string, so the actual command passed to SQL is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;x\y&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Since &lt;code&gt;\y&lt;/code&gt; is not a valid escape sequence for MySQL, the table just contains &lt;code&gt;xy&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Both of the following (the first two examples at the top) will insert &lt;code&gt;x\y&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\\\&lt;/span&gt;&lt;span class="s2"&gt;y&amp;#39;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;y&amp;#39;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;because the SQL command in both cases is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;x\\y&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Confusingly, the other two examples also both result in the same data in the
database, but for vastly different reasons:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;\y&amp;#39;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In this case, it's because Python will see the first two backslashes as a
single properly-escaped backslash, but also leave the third backslash in,
resulting in the same SQL command as the first two examples.&lt;/p&gt;
&lt;p&gt;The last example is perhaps the most confusing, because it generates a different
SQL command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;INSERT INTO `test` (`text`) VALUES (&amp;#39;x&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;\y&amp;#39;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="o"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;x\\\y&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In this case, MySQL treats the first two backslashes as a single
properly-escaped backslash, but then "drops" the third one, so the resulting
data in the table is still &lt;code&gt;x\y&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Go forth and be careful with those backslashes!&lt;/p&gt;
&lt;h2&gt;Image credits&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;By Anderson Nascimento [&lt;a href="https://creativecommons.org/licenses/by/2.0"&gt;CC BY 2.0&lt;/a&gt;], &lt;a href="https://commons.wikimedia.org/wiki/File:Cara_de_quem_caiu_do_caminh%C3%A3o....jpg"&gt;via Wikimedia Commons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;By eda [Public domain], &lt;a href="https://commons.wikimedia.org/wiki/File:Bassets_hound_,_basset-hound.jpg"&gt;from Wikimedia Commons&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><category term="Python"/><category term="python"/><category term="mysql"/><category term="backslash"/></entry><entry><title>ssh-keygen</title><link href="https://gregback.net/ssh-keygen.html" rel="alternate"/><published>2014-08-01T19:27:00-04:00</published><updated>2014-08-01T19:27:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2014-08-01:/ssh-keygen.html</id><content type="html">&lt;p&gt;I always forget the exact syntax and options I need for this. I don't create
new keys frequently enough to remember without looking up what to run each
time.&lt;/p&gt;
&lt;h3&gt;The command&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ssh-keygen&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;rsa&lt;span class="w"&gt; &lt;/span&gt;-b&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2048&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;[Source: &lt;a href="http://security.stackexchange.com/a/23385"&gt;Security StackExchange&lt;/a&gt;]&lt;/p&gt;</content><category term="Security"/><category term="Linux"/><category term="ssh"/></entry><entry><title>Run Wireshark as non-root user</title><link href="https://gregback.net/run-wireshark-as-non-root-user.html" rel="alternate"/><published>2014-03-04T11:46:00-05:00</published><updated>2014-03-04T11:46:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2014-03-04:/run-wireshark-as-non-root-user.html</id><summary type="html">&lt;p&gt;I frequently get frustrated when Wireshark won't run as a non-root user due
to permissions on the dumpcap process. Here's the fix:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;groupadd&lt;span class="w"&gt; &lt;/span&gt;wireshark
sudo&lt;span class="w"&gt; &lt;/span&gt;usermod&lt;span class="w"&gt; &lt;/span&gt;-a&lt;span class="w"&gt; &lt;/span&gt;-G&lt;span class="w"&gt; &lt;/span&gt;wireshark&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;
sudo&lt;span class="w"&gt; &lt;/span&gt;chgrp&lt;span class="w"&gt; &lt;/span&gt;wireshark&lt;span class="w"&gt; &lt;/span&gt;/usr/bin/dumpcap
sudo&lt;span class="w"&gt; &lt;/span&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;754&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/usr/bin/dumpcap
sudo&lt;span class="w"&gt; &lt;/span&gt;setcap&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;CAP_NET_RAW+eip CAP_NET_ADMIN+eip&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/usr …&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;I frequently get frustrated when Wireshark won't run as a non-root user due
to permissions on the dumpcap process. Here's the fix:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;groupadd&lt;span class="w"&gt; &lt;/span&gt;wireshark
sudo&lt;span class="w"&gt; &lt;/span&gt;usermod&lt;span class="w"&gt; &lt;/span&gt;-a&lt;span class="w"&gt; &lt;/span&gt;-G&lt;span class="w"&gt; &lt;/span&gt;wireshark&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;
sudo&lt;span class="w"&gt; &lt;/span&gt;chgrp&lt;span class="w"&gt; &lt;/span&gt;wireshark&lt;span class="w"&gt; &lt;/span&gt;/usr/bin/dumpcap
sudo&lt;span class="w"&gt; &lt;/span&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;754&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/usr/bin/dumpcap
sudo&lt;span class="w"&gt; &lt;/span&gt;setcap&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;CAP_NET_RAW+eip CAP_NET_ADMIN+eip&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;/usr/bin/dumpcap
&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;su&lt;span class="w"&gt; &lt;/span&gt;-l&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# reload groups for user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Alternatively, you can log out and log back in to refresh the groups the user
is in.&lt;/p&gt;</content><category term="Linux"/><category term="Wireshark"/></entry><entry><title>Ubuntu Default Folders</title><link href="https://gregback.net/ubuntu-default-folders.html" rel="alternate"/><published>2013-03-24T00:39:00-04:00</published><updated>2013-03-24T00:39:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2013-03-24:/ubuntu-default-folders.html</id><summary type="html">&lt;p&gt;I recently switched my primary machine from Windows 7 to Ubuntu. I'd always
used an Ubuntu VM for development. Now I just have a Windows 7 VM for
Windows-only applications, and do the majority of my work in Ubuntu. I'm fairly
comfortable on the command line, but &lt;em&gt;extremely dislike&lt;/em&gt; capital …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I recently switched my primary machine from Windows 7 to Ubuntu. I'd always
used an Ubuntu VM for development. Now I just have a Windows 7 VM for
Windows-only applications, and do the majority of my work in Ubuntu. I'm fairly
comfortable on the command line, but &lt;em&gt;extremely dislike&lt;/em&gt; capital letters in
file paths. So the Ubuntu defaults ("Documents", "Downloads", etc.) just
weren't doing it for me. Fortunately, I found a &lt;a href="https://silverwav.wordpress.com/2010/03/21/note-ubuntu-default-folders/"&gt;blog post&lt;/a&gt; which
explained which file sets these names
(&lt;code&gt;$HOME/.config/user-dirs.dirs&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;My complete configuration is shown below.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# This file is written by xdg-user-dirs-update&lt;/span&gt;
&lt;span class="c1"&gt;# If you want to change or add directories, just edit the line you&amp;#39;re&lt;/span&gt;
&lt;span class="c1"&gt;# interested in. All local changes will be retained on the next run&lt;/span&gt;
&lt;span class="c1"&gt;# Format is XDG_xxx_DIR=&amp;quot;$HOME/yyy&amp;quot;, where yyy is a shell-escaped&lt;/span&gt;
&lt;span class="c1"&gt;# homedir-relative path, or XDG_xxx_DIR=&amp;quot;/yyy&amp;quot;, where /yyy is an&lt;/span&gt;
&lt;span class="c1"&gt;# absolute path. No other format is supported.&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="nv"&gt;XDG_DESKTOP_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/desktop&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;XDG_DOWNLOAD_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/dl&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;XDG_TEMPLATES_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/templates&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;XDG_PUBLICSHARE_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/public&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;XDG_DOCUMENTS_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/docs&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;XDG_MUSIC_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/music&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;XDG_PICTURES_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/pics&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;XDG_VIDEOS_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/videos&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Linux"/><category term="Ubuntu"/><category term="GNOME"/></entry><entry><title>Building Git from scratch</title><link href="https://gregback.net/building-git-from-scratch.html" rel="alternate"/><published>2013-02-03T00:17:00-05:00</published><updated>2013-02-03T00:17:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2013-02-03:/building-git-from-scratch.html</id><summary type="html">&lt;p&gt;This is running on Ubuntu 12.04, using the most recent versions as of
2013-02-02.&lt;/p&gt;
&lt;p&gt;Install git:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;wget&lt;span class="w"&gt; &lt;/span&gt;http://git-core.googlecode.com/files/git-1.8.1.2.tar.gz
&lt;span class="gp"&gt;$ &lt;/span&gt;tar&lt;span class="w"&gt; &lt;/span&gt;xf&lt;span class="w"&gt; &lt;/span&gt;git-1.8.1.2.tar.gz
&lt;span class="gp"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;git-1.8.1.2/
&lt;span class="gp"&gt;$ &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;libcurl4-gnutls-dev&lt;span class="w"&gt; &lt;/span&gt;libexpat1-dev&lt;span class="w"&gt; &lt;/span&gt;gettext&lt;span class="w"&gt; &lt;/span&gt;libz-dev
&lt;span class="gp"&gt;$ &lt;/span&gt;make …&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;This is running on Ubuntu 12.04, using the most recent versions as of
2013-02-02.&lt;/p&gt;
&lt;p&gt;Install git:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;wget&lt;span class="w"&gt; &lt;/span&gt;http://git-core.googlecode.com/files/git-1.8.1.2.tar.gz
&lt;span class="gp"&gt;$ &lt;/span&gt;tar&lt;span class="w"&gt; &lt;/span&gt;xf&lt;span class="w"&gt; &lt;/span&gt;git-1.8.1.2.tar.gz
&lt;span class="gp"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;git-1.8.1.2/
&lt;span class="gp"&gt;$ &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;libcurl4-gnutls-dev&lt;span class="w"&gt; &lt;/span&gt;libexpat1-dev&lt;span class="w"&gt; &lt;/span&gt;gettext&lt;span class="w"&gt; &lt;/span&gt;libz-dev
&lt;span class="gp"&gt;$ &lt;/span&gt;make&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local&lt;span class="w"&gt; &lt;/span&gt;all
&lt;span class="gp"&gt;$ &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;make&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local&lt;span class="w"&gt; &lt;/span&gt;install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Install the manpages:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;wget&lt;span class="w"&gt; &lt;/span&gt;http://git-core.googlecode.com/files/git-manpages-1.8.1.2.tar.gz
&lt;span class="gp"&gt;$ &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;tar&lt;span class="w"&gt; &lt;/span&gt;xf&lt;span class="w"&gt; &lt;/span&gt;git-manpages-1.8.1.2.tar.gz&lt;span class="w"&gt; &lt;/span&gt;-C&lt;span class="w"&gt; &lt;/span&gt;/usr/local/man
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Linux"/><category term="git"/><category term="Linux"/><category term="ubuntu"/></entry><entry><title>Using REMnux for Forensic Puzzle #6</title><link href="https://gregback.net/using-remnux-for-forensic-puzzle-6.html" rel="alternate"/><published>2011-03-17T23:00:00-04:00</published><updated>2011-03-17T23:00:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2011-03-17:/using-remnux-for-forensic-puzzle-6.html</id><summary type="html">&lt;p&gt;I thought it would be interesting to use Lenny Zeltser's excellent
&lt;a href="http://zeltser.com/remnux/"&gt;REMnux distribution&lt;/a&gt; to solve &lt;a href="http://www.forensickb.com/2011/02/forensic-puzzle-6.html"&gt;this puzzle&lt;/a&gt;posted by ForensicKB.
I'll admit that I saw &lt;a href="http://www.forensickb.com/2011/03/answers-to-forensic-puzzle-6.html"&gt;the solution&lt;/a&gt; before solving it, but since I
don't have a copy of EnCase lying around, I wanted to use some free
tools to accomplish …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I thought it would be interesting to use Lenny Zeltser's excellent
&lt;a href="http://zeltser.com/remnux/"&gt;REMnux distribution&lt;/a&gt; to solve &lt;a href="http://www.forensickb.com/2011/02/forensic-puzzle-6.html"&gt;this puzzle&lt;/a&gt;posted by ForensicKB.
I'll admit that I saw &lt;a href="http://www.forensickb.com/2011/03/answers-to-forensic-puzzle-6.html"&gt;the solution&lt;/a&gt; before solving it, but since I
don't have a copy of EnCase lying around, I wanted to use some free
tools to accomplish the same thing.&lt;/p&gt;
&lt;h3&gt;Getting REMnux&lt;/h3&gt;
&lt;p&gt;Follow the instructions at the link above to get REMnux as a LiveCD or
VMware-compatible virtual machine. Once you get it up and running
(either just the console or the XFCE interface), we can get going...&lt;/p&gt;
&lt;h3&gt;Getting set up&lt;/h3&gt;
&lt;p&gt;Download the file into a new directory and unzip it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;remnux@remnux: ~$ &lt;/span&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;Forensic&lt;span class="w"&gt; &lt;/span&gt;Challenge6
&lt;span class="gp"&gt;remnux@remnux: ~$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ForensicChallenge6
&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;wget&lt;span class="w"&gt; &lt;/span&gt;http://www.lancemueller.com/blog/evidence/Suspicious_File.zip
&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;unzip&lt;span class="w"&gt; &lt;/span&gt;Suspicious_File.zip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Initial Steps&lt;/h3&gt;
&lt;p&gt;Just for fun, we can run "xorsearch" to see if we have an executable by
looking for the string "This program cannot be run in DOS mode", a
standard feature in Windows executables.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;xorsearch&lt;span class="w"&gt; &lt;/span&gt;Suspicious_File&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;This program&amp;quot;&lt;/span&gt;
&lt;span class="go"&gt;Found XOR 6A position 0A4E: This program cannot be run in DOS mode....$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It's much later than we expected in the file, though (HINT: it's
typically in the first 0x100 bytes.)&lt;/p&gt;
&lt;p&gt;We'll use the "file" command along with the useful TrID to determine
what type of we have.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;file&lt;span class="w"&gt; &lt;/span&gt;Suspicious_File
&lt;span class="go"&gt;Suspicious_File: CDF V2 Document, corrupt: Cannot read summary info&lt;/span&gt;
&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;trid&lt;span class="w"&gt; &lt;/span&gt;Suspicious_File
&lt;span class="go"&gt;TrID/32 - File Identifier v2.00/Linux - (C) 2003-06 By M.Pontello&lt;/span&gt;
&lt;span class="go"&gt;Definitions found:  3887&lt;/span&gt;
&lt;span class="go"&gt;Analyzing...&lt;/span&gt;

&lt;span class="go"&gt;Collecting data from file: Suspicious_File&lt;/span&gt;
&lt;span class="go"&gt;100.0% (.) Generic OLE2 / Multistream Compound File (8000/1)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Looks like an OLE2 Compound Binary File. I didn't want to write my own
parser, so I started looking for a good command line one and found a
&lt;a href="http://www.decalage.info/python/olefileio"&gt;good python script&lt;/a&gt;to do it for me.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;wget&lt;span class="w"&gt; &lt;/span&gt;http://www.decalage.info/files/OleFileIO_PL-0.21.zip
&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;unzip&lt;span class="w"&gt; &lt;/span&gt;OleFileIO_PL-0.21.zip
&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;OleFileIO_PL-0.21/
&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6/OleFileIO_PL-0.21$ &lt;/span&gt;python
&lt;span class="go"&gt;Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)&lt;/span&gt;
&lt;span class="go"&gt;[GCC 4.4.1] on linux2&lt;/span&gt;
&lt;span class="go"&gt;Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;A quick python interpreter session extracted the files from this
compound file format.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;OleFileIO_PL&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;OleFileIO_PL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isOleFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;../Suspicious_File&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;ole&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;OleFileIO_PL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OleFileIO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;../Suspicious_File&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="n"&gt;ole&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;listdir&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="go"&gt;[[&amp;#39;Details&amp;#39;], [&amp;#39;File_0&amp;#39;]]&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;../Details&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;w&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ole&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;openstream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Details&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;../File_0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;w&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ole&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;openstream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;File_0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now we have two files to analyze. We can use "xorsearch" again with the
"-s" switch to perform the XOR on the executable file (File_0) and
write the transformed file to disk.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6/OleFileIO_PL-0.21$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;..
&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;xorsearch&lt;span class="w"&gt; &lt;/span&gt;-s&lt;span class="w"&gt; &lt;/span&gt;File_0&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;This program&amp;quot;&lt;/span&gt;Found&lt;span class="w"&gt; &lt;/span&gt;XOR&lt;span class="w"&gt; &lt;/span&gt;6A&lt;span class="w"&gt; &lt;/span&gt;position&lt;span class="w"&gt; &lt;/span&gt;004E:&lt;span class="w"&gt; &lt;/span&gt;This&lt;span class="w"&gt; &lt;/span&gt;program&lt;span class="w"&gt; &lt;/span&gt;cannot&lt;span class="w"&gt; &lt;/span&gt;be&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;DOS&lt;span class="w"&gt; &lt;/span&gt;mode....$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;
To convert the other file, we assume the same XOR key and use Perl to
perform the conversion. I'm by no means a Perl guru, but some Googling
helped a lot. It takes advantage of a lot of Perl's built-in default
operators, to minimize the size of the commad.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;cat&lt;span class="w"&gt; &lt;/span&gt;Details&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;perl&lt;span class="w"&gt; &lt;/span&gt;-e&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;while (&amp;lt;STDIN&amp;gt;) { foreach (split //) {print chr(ord ^ 0x6a)}}&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;Details.XOR.6A
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now we have the two files, and we can perform the required MD5 hash
calculations, or any other analysis desired (i.e. on the executable).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;remnux@remnux: ~/ForensicChallenge6$ &lt;/span&gt;md5sum&lt;span class="w"&gt; &lt;/span&gt;File_0,XOR.6A
&lt;span class="go"&gt;8dc601710e3e68b8d78b5cd73fb28616  File_0.XOR.6A&lt;/span&gt;
&lt;span class="gp"&gt;remnux@remnux:~/ForensicChallenge6$ &lt;/span&gt;md5sum&lt;span class="w"&gt; &lt;/span&gt;Details.XOR.6A
&lt;span class="go"&gt;f93a7bb8e02a8a23f87dad22b9ecd578  Details.XOR.6A&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;I certainly learned a lot about REMnux, and got to write a bit of code
in the process. Hopefully you learned a thing or two reading this as
well.&lt;/p&gt;
&lt;h3&gt;More reading&lt;/h3&gt;
&lt;p&gt;If you love file specifications as much as I do, you'll love these
documents.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[&lt;a href="http://msdn.microsoft.com/en-us/library/dd942138%28PROT.13%29.aspx"&gt;MS-CFB&lt;/a&gt;] : Microsoft's description of the OLE2 format&lt;/li&gt;
&lt;li&gt;&lt;a href="http://http://msdn.microsoft.com/en-us/windows/hardware/gg463119"&gt;PE/COFF&lt;/a&gt;: Specification of the Windows standard executable file
    format (Portable Executable/Common Object File Format)&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;</content><category term="Security"/><category term="Linux"/><category term="perl"/><category term="python"/><category term="remnux"/></entry><entry><title>Double-buffered Panels in C#</title><link href="https://gregback.net/double-buffered-panels-in-c.html" rel="alternate"/><published>2011-01-23T17:08:00-05:00</published><updated>2011-01-23T17:08:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2011-01-23:/double-buffered-panels-in-c.html</id><summary type="html">&lt;p&gt;Having panels which update quickly without flickering requires
double-buffering. To accomplish this in C#, you'll have to derive from
the standard &lt;code&gt;Panel&lt;/code&gt; class as shown below, and then replace the
declaration and instantiation of the panel with your new class.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;System.Windows.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;WindowsFormsApplication1&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;DoubleBufferedPanel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Panel …&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;Having panels which update quickly without flickering requires
double-buffering. To accomplish this in C#, you'll have to derive from
the standard &lt;code&gt;Panel&lt;/code&gt; class as shown below, and then replace the
declaration and instantiation of the panel with your new class.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;System.Windows.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;WindowsFormsApplication1&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;DoubleBufferedPanel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Panel&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;DoubleBufferedPanel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SetStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ControlStyles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AllPaintingInWmPaint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;ControlStyles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OptimizedDoubleBuffer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;ControlStyles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UserPaint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and then replace &lt;code&gt;System.Windows.Forms.Panel&lt;/code&gt; with &lt;code&gt;DoubleBufferedPanel&lt;/code&gt; in
the &lt;code&gt;Designer.cs&lt;/code&gt; class.&lt;/p&gt;</content><category term="Programming"/><category term=".NET"/><category term="C#"/><category term="WinForms"/></entry><entry><title>Size of Frame around a default C# Windows Form</title><link href="https://gregback.net/size-of-frame-around-a-default-c-windows-form.html" rel="alternate"/><published>2011-01-23T16:36:00-05:00</published><updated>2011-01-23T16:36:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2011-01-23:/size-of-frame-around-a-default-c-windows-form.html</id><summary type="html">&lt;p&gt;So here's the scenario. I was looking to have the a panel with exact
dimensions on a C# form (&lt;strong&gt;700x400&lt;/strong&gt;). I wanted even and default
spacing around the panel on the form. I figured out the default spacing
was 12, so I set the size of the form to &lt;strong&gt;724x424 …&lt;/strong&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;So here's the scenario. I was looking to have the a panel with exact
dimensions on a C# form (&lt;strong&gt;700x400&lt;/strong&gt;). I wanted even and default
spacing around the panel on the form. I figured out the default spacing
was 12, so I set the size of the form to &lt;strong&gt;724x424&lt;/strong&gt;, only to find that
something still looked wrong.&lt;/p&gt;
&lt;p&gt;Turns out that the dimensions of the form include the border and title
bar (seems obvious in retrospect, doesn't it). What I really wanted was
to have the form's &lt;strong&gt;ClientSize&lt;/strong&gt; equal to 724x424. To figure out what I
needed the form dimensions to be in order to have a correctly-sized
Client area to place my frame in, I used the following snippet:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;MessageBox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;{0}, {1}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;                              &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Width&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ClientSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;                              &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Height&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ClientSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Height&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The final result:&lt;/p&gt;
&lt;p&gt;The frame takes up 16 pixels horizontally (8 on each size) and 38
vertically (8 on the bottom and 30 on top), so the final size of the
form I needed was &lt;strong&gt;740x462&lt;/strong&gt;.&lt;/p&gt;</content><category term="Programming"/><category term=".NET"/><category term="C#"/><category term="WinForms"/></entry><entry><title>Setting Outlook to Display Plain Text Email</title><link href="https://gregback.net/setting-outlook-to-display-plain-text-email.html" rel="alternate"/><published>2011-01-19T20:56:00-05:00</published><updated>2011-01-19T20:56:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2011-01-19:/setting-outlook-to-display-plain-text-email.html</id><summary type="html">&lt;p&gt;Although definitely not the only step to stopping malicious email, not
displaying HTML or rich text in messages goes a long way. Here's the
summary of where the settings are located:&lt;/p&gt;
&lt;h3&gt;Outlook 2003&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt; menu, &lt;strong&gt;Options&lt;/strong&gt;, &lt;strong&gt;Preferences&lt;/strong&gt; tab, &lt;strong&gt;E-mail&lt;/strong&gt; area, &lt;strong&gt;E-mail
Options&lt;/strong&gt;, &lt;strong&gt;Message Handling&lt;/strong&gt; area.&lt;/p&gt;
&lt;h3&gt;Outlook 2007&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt; menu, &lt;strong&gt;Trust …&lt;/strong&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;Although definitely not the only step to stopping malicious email, not
displaying HTML or rich text in messages goes a long way. Here's the
summary of where the settings are located:&lt;/p&gt;
&lt;h3&gt;Outlook 2003&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt; menu, &lt;strong&gt;Options&lt;/strong&gt;, &lt;strong&gt;Preferences&lt;/strong&gt; tab, &lt;strong&gt;E-mail&lt;/strong&gt; area, &lt;strong&gt;E-mail
Options&lt;/strong&gt;, &lt;strong&gt;Message Handling&lt;/strong&gt; area.&lt;/p&gt;
&lt;h3&gt;Outlook 2007&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt; menu, &lt;strong&gt;Trust Center&lt;/strong&gt;, &lt;strong&gt;E-mail Security&lt;/strong&gt;, &lt;strong&gt;Read as Plain
Text&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;Outlook 2010&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;File&lt;/strong&gt; tab, &lt;strong&gt;Options&lt;/strong&gt;, &lt;strong&gt;Trust Center&lt;/strong&gt;, &lt;strong&gt;Trust Center Settings&lt;/strong&gt;,
&lt;strong&gt;E-mail Security&lt;/strong&gt;, &lt;strong&gt;Read as Plain Text&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;For more information, check out this &lt;a href="http://support.microsoft.com/kb/831607"&gt;Microsoft KB article&lt;/a&gt;.&lt;/p&gt;</content><category term="Security"/><category term="email"/><category term="outlook"/><category term="security"/></entry><entry><title>Useful One-Line PHP files</title><link href="https://gregback.net/useful-one-line-php-files.html" rel="alternate"/><published>2010-05-14T17:37:00-04:00</published><updated>2010-05-14T17:37:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-05-14:/useful-one-line-php-files.html</id><summary type="html">&lt;p&gt;Here are a couple useful PHP commands that you can run on your server to
get useful information.&lt;/p&gt;
&lt;p&gt;This one gives basic information about the PHP installation, which can
be used for troubleshooting or just verifying that PHP is running.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="nb"&gt;phpinfo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This one tells you the name of the …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Here are a couple useful PHP commands that you can run on your server to
get useful information.&lt;/p&gt;
&lt;p&gt;This one gives basic information about the PHP installation, which can
be used for troubleshooting or just verifying that PHP is running.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="nb"&gt;phpinfo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This one tells you the name of the web server user, which can be used to
verify file permissions on particular files or directories.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="sb"&gt;`whoami`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hope this is useful!&lt;/p&gt;</content><category term="Programming"/><category term="php"/></entry><entry><title>PuTTY SSH Tunnel for MySQL</title><link href="https://gregback.net/putty-ssh-tunnel-for-mysql.html" rel="alternate"/><published>2010-05-09T14:42:00-04:00</published><updated>2010-05-09T14:42:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-05-09:/putty-ssh-tunnel-for-mysql.html</id><summary type="html">&lt;p&gt;I just stumbled across the &lt;a href="http://dev.mysql.com/downloads/gui-tools/5.0.html"&gt;MySQL GUI Tools Bundle&lt;/a&gt; which is very
useful for managing a MySQL databases. In my opinion, it's much easier
than using phpMyAdmin, which I had been doing previously. The only
problem is that using it "requires" the machine the database is on (my
web server …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I just stumbled across the &lt;a href="http://dev.mysql.com/downloads/gui-tools/5.0.html"&gt;MySQL GUI Tools Bundle&lt;/a&gt; which is very
useful for managing a MySQL databases. In my opinion, it's much easier
than using phpMyAdmin, which I had been doing previously. The only
problem is that using it "requires" the machine the database is on (my
web server) having an open external port (typically 3306) for the
applications to have access to the database. "Requires" is in quotes
because you can use PuTTY to open an SSH tunnel from your local machine
to the database server, so that requests to port 3306 on your local
machine are forwarded to the remote machine through the PuTTY
connection.&lt;/p&gt;
&lt;p&gt;Quick summary:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In PuTTY (before connecting to the server), go to Connections-&amp;gt;
    SSH-&amp;gt; Tunnels.&lt;/li&gt;
&lt;li&gt;Add Source: "3306" (the local port you'll be using) and Destination:
    "127.0.0.1:3306" (the connection to be made from the other side of
    the tunnel.&lt;/li&gt;
&lt;li&gt;Log into the server using PuTTY as you normally would. (Don't forget
    this step!)&lt;/li&gt;
&lt;li&gt;Open MySQL Query Browser (or another of the tools), and for the
    connection info use Server: "localhost" and Port: "3306" (the local
    side of the tunnel), along with the appropriate username and
    password information.&lt;/li&gt;
&lt;li&gt;The MySQL GUI tools should now work as normal. Enjoy.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;/p&gt;
For more information and screenshots, check out the link below.&lt;/p&gt;
&lt;p&gt;[Source: &lt;a href="http://realprogrammers.com/how_to/set_up_an_ssh_tunnel_with_putty.html"&gt;realprogrammers.com&lt;/a&gt;]&lt;/p&gt;</content><category term="Programming"/><category term="database"/><category term="mysql"/><category term="putty"/></entry><entry><title>Django Admin Media Files on Apache</title><link href="https://gregback.net/django-admin-media-files-on-apache.html" rel="alternate"/><published>2010-05-02T22:26:00-04:00</published><updated>2010-05-02T22:26:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-05-02:/django-admin-media-files-on-apache.html</id><summary type="html">&lt;p&gt;I had quite a bit of fun trying to get Apache to serve the admin files
for my Django install. Here are the settings I used to finally get it to
work. Note that the site is in a subdirectory of my domain. I'm not
currently hosting any other media …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I had quite a bit of fun trying to get Apache to serve the admin files
for my Django install. Here are the settings I used to finally get it to
work. Note that the site is in a subdirectory of my domain. I'm not
currently hosting any other media, so that will be another bridge to
cross in the future.&lt;/p&gt;
&lt;p&gt;In the Django settings.py file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;ADMIN_MEDIA_PREFIX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/genweb/admin/media/&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In the Virtual Host file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;Alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sx"&gt;/genweb/admin/media&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sx"&gt;/usr/share/python-support/python-django/django/contrib/admin/media&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;Location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/genweb/admin/media&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;SetHandler&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;none&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Location&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Programming"/><category term="apache"/><category term="django"/><category term="python"/></entry><entry><title>PHP Equal-Sign Operators</title><link href="https://gregback.net/php-equal-sign-operators.html" rel="alternate"/><published>2010-04-22T21:51:00-04:00</published><updated>2010-04-22T21:51:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-04-22:/php-equal-sign-operators.html</id><summary type="html">&lt;p&gt;Reading some php code, you might get confused about the difference
betweeen =, ==, and === (this single, double, and triple equal signs).
Here's a quick summary.&lt;/p&gt;
&lt;p&gt;= (Assignment) Just like in (pretty much) every other programming
language.&lt;/p&gt;
&lt;p&gt;== (Equality) Returns true if the two variables have the same value.&lt;/p&gt;
&lt;p&gt;=== (Identity) Returns true if the …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Reading some php code, you might get confused about the difference
betweeen =, ==, and === (this single, double, and triple equal signs).
Here's a quick summary.&lt;/p&gt;
&lt;p&gt;= (Assignment) Just like in (pretty much) every other programming
language.&lt;/p&gt;
&lt;p&gt;== (Equality) Returns true if the two variables have the same value.&lt;/p&gt;
&lt;p&gt;=== (Identity) Returns true if the two variables have the same value AND
the same type (integer 0 is not equal to, in the === sense, float 0 or
string 0).&lt;/p&gt;
&lt;p&gt;Hope that clears up confusion. It did for me.&lt;/p&gt;
&lt;p&gt;[Source: &lt;a href="http://www.wellho.net/mouth/406_Assignment-equality-and-identity-in-PHP.html"&gt;Wellho.net&lt;/a&gt;]&lt;/p&gt;</content><category term="Programming"/><category term="php"/></entry><entry><title>Cannot start Microsoft Office Outlook. Cannot open the Outlook window.</title><link href="https://gregback.net/cannot-start-microsoft-office-outlook-cannot-open-the-outlook-window.html" rel="alternate"/><published>2010-04-09T10:11:00-04:00</published><updated>2010-04-09T10:11:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-04-09:/cannot-start-microsoft-office-outlook-cannot-open-the-outlook-window.html</id><summary type="html">&lt;p&gt;I got this annoying error message this morning when trying to open
Outlook 2007.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Cannot start Microsoft Office Outlook. Cannot open the Outlook window.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I tried logging out and back in, which didn't help. Neither did a
restart. A quick Google search revealed the following solution:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click Start, then Run …&lt;/li&gt;&lt;/ol&gt;</summary><content type="html">&lt;p&gt;I got this annoying error message this morning when trying to open
Outlook 2007.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Cannot start Microsoft Office Outlook. Cannot open the Outlook window.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I tried logging out and back in, which didn't help. Neither did a
restart. A quick Google search revealed the following solution:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click Start, then Run (alternatively, press WINDOWS-R). On Windows
    7, just click on the start button and use the quick search box.&lt;/li&gt;
&lt;li&gt;Type "Outlook.exe /resetnavpane" and press Enter.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;/p&gt;
Voila. Outlook fixed.&lt;/p&gt;
&lt;p&gt;[Source: &lt;a href="http://social.answers.microsoft.com/Forums/en-US/vistaprograms/thread/baf53169-0514-4dd3-808f-d8437c898e67"&gt;Microsoft Answers&lt;/a&gt;]&lt;/p&gt;</content><category term="Windows"/><category term="outlook"/></entry><entry><title>Debuggers as Pesticides</title><link href="https://gregback.net/debuggers-as-pesticides.html" rel="alternate"/><published>2010-04-08T12:47:00-04:00</published><updated>2010-04-08T12:47:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-04-08:/debuggers-as-pesticides.html</id><summary type="html">&lt;p&gt;I thought this was funny:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Historical footnote: DDT was developed at MIT for the PDP-1 computer
in 1961. At that time DDT stood for "DEC Debugging Tape". Since then,
the idea of an on-line debugging program has propagated throughout the
computer industry. DDT programs are now available for all DEC …&lt;/p&gt;&lt;/blockquote&gt;</summary><content type="html">&lt;p&gt;I thought this was funny:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Historical footnote: DDT was developed at MIT for the PDP-1 computer
in 1961. At that time DDT stood for "DEC Debugging Tape". Since then,
the idea of an on-line debugging program has propagated throughout the
computer industry. DDT programs are now available for all DEC
computers. Since media other than tape are now frequently used, the
more descriptive name "Dynamic Debugging Technique" has been adopted,
retaining the DDT abbreviation. Confusion between DDT-10 and another
well known pesticide, dichloro-diphenyl-trichloroethane C14H9Cl5
should be minimal since each attacks a different, and apparently
mutually exclusive, class of bugs.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;[Source: &lt;a href="http://www.catb.org/~esr/jargon/html/D/DDT.html"&gt;The Jargon File&lt;/a&gt;]&lt;/p&gt;</content><category term="Other"/><category term="humor"/></entry><entry><title>Matlab Primes to File</title><link href="https://gregback.net/matlab-primes-to-file.html" rel="alternate"/><published>2010-03-30T21:36:00-04:00</published><updated>2010-03-30T21:36:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-03-30:/matlab-primes-to-file.html</id><content type="html">&lt;p&gt;The MATLAB script below will export 10000 primes to a file named
'primes.txt':&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;primes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c"&gt;% Insert your own value here&lt;/span&gt;
&lt;span class="nb"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;primes.txt&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;w+&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c"&gt;% Insert the file name heref&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;ans&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;%d\n&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c"&gt;% Prints a new line between each prime (C-style formatting)&lt;/span&gt;
&lt;span class="nb"&gt;fclose&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Math"/><category term="matlab"/><category term="primes"/></entry><entry><title>MySQL Change current auto-increment value</title><link href="https://gregback.net/mysql-change-current-auto-increment-value.html" rel="alternate"/><published>2010-02-20T13:30:00-05:00</published><updated>2010-02-20T13:30:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-02-20:/mysql-change-current-auto-increment-value.html</id><summary type="html">&lt;p&gt;You can use the following SQL query to set the next value to be used by
an auto-incrementing field in MySQL. Useful if you make a mistake and
want to delete a value you just added without leaving a gap in the
sequence numbers, or if you want to start …&lt;/p&gt;</summary><content type="html">&lt;p&gt;You can use the following SQL query to set the next value to be used by
an auto-incrementing field in MySQL. Useful if you make a mistake and
want to delete a value you just added without leaving a gap in the
sequence numbers, or if you want to start with an index higher than 1.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TABLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tablename&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AUTO_INCREMENT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Programming"/><category term="mysql"/><category term="sql"/><category term="database"/></entry><entry><title>Firefox Updating Fix</title><link href="https://gregback.net/firefox-updating-fix.html" rel="alternate"/><published>2010-02-11T22:59:00-05:00</published><updated>2010-02-11T22:59:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2010-02-11:/firefox-updating-fix.html</id><summary type="html">&lt;p&gt;This is a problem I used to have with Firefox updates failing when I was
running as a Limited User in Windows XP.&lt;/p&gt;
&lt;p&gt;Here are the steps to fix the problem:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Close all running instances of Firefox.&lt;/li&gt;
&lt;li&gt;Open an Administrator command prompt by right-clicking on a Command
    Prompt icon, choose …&lt;/li&gt;&lt;/ol&gt;</summary><content type="html">&lt;p&gt;This is a problem I used to have with Firefox updates failing when I was
running as a Limited User in Windows XP.&lt;/p&gt;
&lt;p&gt;Here are the steps to fix the problem:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Close all running instances of Firefox.&lt;/li&gt;
&lt;li&gt;Open an Administrator command prompt by right-clicking on a Command
    Prompt icon, choose Run As... and enter the credentials of a user
    with administrator rights.&lt;/li&gt;
&lt;li&gt;Launch Process Monitor from the administrator command prompt by
    typing the full path to the executable (wherever you installed it).
    For example: c:\apps\procmon.exe (tab completion can be very
    helpful for this step).&lt;/li&gt;
&lt;li&gt;Within Process Monitor, turn off "Show Registry Activity" and "Show
    File System Activity" from the toolbar. Only "Show Process and
    Thread Activity should be enabled". This step is not absolutely
    necessary, but it will eliminate a lot of extra noise.&lt;/li&gt;
&lt;li&gt;Start Firefox, and click through the "Software Update Failed" dialog
    until the browser opens.&lt;/li&gt;
&lt;li&gt;Switch back to Process Monitor and press CTRL-E or the click the
    toolbar button to stop capturing events. Close any Firefox windows
    that might be open.&lt;/li&gt;
&lt;li&gt;Scroll through the list of processes and double-click on the first
    instance of "updater.exe" (it should have the value "Process Start"
    in the Operation column). Switch to the Process tab of the Event
    Properties window that opens.&lt;/li&gt;
&lt;li&gt;Select the entire contents of the "Command Line:" textbox and copy
    it (CTRL-C or right-click, Copy). It should look something like this
    (all one line): "C:\Documents and Settings\Josh\Local
    Settings\Application Data\Mozilla\Firefox\Mozilla
    Firefox\updates\0\updater.exe" "C:\Documents and
    Settings\Josh\Local Settings\Application
    Data\Mozilla\Firefox\Mozilla Firefox\updates\0" "3824"
    "C:\Program Files\Mozilla Firefox" "C:\Program Files\Mozilla
    Firefox\firefox.exe"&lt;/li&gt;
&lt;li&gt;Switch back to the administrator command prompt and right-click,
    Paste to paste the command-line. Press Enter.&lt;/li&gt;
&lt;li&gt;You should see a dialog indicating that Firefox is updating. Close
    the browser that opens since it is still running as the
    administrator.&lt;/li&gt;
&lt;li&gt;Now open Firefox normally. It should start up without the annoying
    error message.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Source: &lt;a href="http://flimflan.com/blog/FirefoxErrorResolvedOneOrMoreFilesCouldNotBeUpdated.aspx"&gt;Flimflan.com&lt;/a&gt;&lt;/p&gt;</content><category term="Windows"/><category term="firefox"/><category term="xp"/></entry><entry><title>Adding a User to Sudoers in Fedora 11</title><link href="https://gregback.net/adding-a-user-to-sudoers-in-fedora-11.html" rel="alternate"/><published>2009-12-12T14:21:00-05:00</published><updated>2009-12-12T14:21:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2009-12-12:/adding-a-user-to-sudoers-in-fedora-11.html</id><summary type="html">&lt;p&gt;The following shows how to add a user to the "sudoers" file in Fedora 11
(and likely other versions of Fedora), allowing normal users to execute
elevated commands with &lt;code&gt;sudo ...&lt;/code&gt; instead of needing to switch to root
(&lt;code&gt;su -&lt;/code&gt;).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;[greg@fedora ~]$ &lt;/span&gt;su&lt;span class="w"&gt; &lt;/span&gt;-
&lt;span class="gp"&gt;[root@fedora ~]# &lt;/span&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;+w&lt;span class="w"&gt; &lt;/span&gt;/etc/sudoers
&lt;span class="gp"&gt;[root@fedora ~]# &lt;/span&gt;&lt;span class="nb"&gt;echo …&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;The following shows how to add a user to the "sudoers" file in Fedora 11
(and likely other versions of Fedora), allowing normal users to execute
elevated commands with &lt;code&gt;sudo ...&lt;/code&gt; instead of needing to switch to root
(&lt;code&gt;su -&lt;/code&gt;).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp"&gt;[greg@fedora ~]$ &lt;/span&gt;su&lt;span class="w"&gt; &lt;/span&gt;-
&lt;span class="gp"&gt;[root@fedora ~]# &lt;/span&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;+w&lt;span class="w"&gt; &lt;/span&gt;/etc/sudoers
&lt;span class="gp"&gt;[root@fedora ~]# &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;greg ALL=(ALL) ALL&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;/etc/sudoers
&lt;span class="gp"&gt;[root@fedora ~]# &lt;/span&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;-w&lt;span class="w"&gt; &lt;/span&gt;/etc/sudoers
&lt;span class="gp"&gt;[root@fedora ~]# &lt;/span&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/p&gt;</content><category term="Linux"/><category term="commandline"/><category term="fedora"/></entry><entry><title>DOS/Windows Environment Variables</title><link href="https://gregback.net/doswindows-environment-variables.html" rel="alternate"/><published>2009-12-03T16:07:00-05:00</published><updated>2009-12-03T16:07:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2009-12-03:/doswindows-environment-variables.html</id><content type="html">&lt;p&gt;To view all environment variables&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;set&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To view a specific environment variable, use one of the following&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;set &lt;/span&gt;&lt;span class="n"&gt;VARIABLE&lt;/span&gt;
&lt;span class="nb"&gt;echo &lt;/span&gt;&lt;span class="k"&gt;%&lt;/span&gt;&lt;span class="n"&gt;VARIABLE&lt;/span&gt;&lt;span class="p"&gt;%&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To set an environment variable&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;set &lt;/span&gt;&lt;span class="n"&gt;VARIABLE&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="n"&gt;VAUE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Windows"/><category term="commandline"/><category term="DOS"/></entry><entry><title>Sine-Cosine-Exponential Identities</title><link href="https://gregback.net/sine-cosine-exponential-identities.html" rel="alternate"/><published>2009-11-04T20:21:00-05:00</published><updated>2009-11-04T20:21:00-05:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2009-11-04:/sine-cosine-exponential-identities.html</id><content type="html">&lt;p&gt;Useful in my Digital Signal Processing class...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;img src="https://upload.wikimedia.org/math/4/b/3/4b331f79eaadfba81f95d40a6e80b88a.png" alt="\cos x = \mathrm{Re}\{e^{ix}\} ={e^{ix} + e^{-ix} \over 2}" /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src="https://upload.wikimedia.org/math/8/8/6/8866fe5a9a001e109cf5d7bbb19e08ab.png" alt="\sin x = \mathrm{Im}\{e^{ix}\} ={e^{ix} - e^{-ix} \over 2i}." /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src="https://upload.wikimedia.org/math/9/1/f/91fc7a888736b55389bdbeed2593ee84.png" alt="e^{ix} = \cos x + i \sin x \;" /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src="https://upload.wikimedia.org/math/9/2/8/9282c566a35d832719e52e1b42d51d73.png" alt="\mathrm{sinc}(x) = \frac{\sin(\pi x)}{\pi x}.\,\!" /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Source: &lt;a href="http://en.wikipedia.org/wiki/Euler's_formula"&gt;Wikipedia - Euler's formula&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Source: &lt;a href="http://en.wikipedia.org/wiki/Sinc_function"&gt;Wikipedia - Sinc function&lt;/a&gt;&lt;/p&gt;</content><category term="Math"/><category term="cosine"/><category term="exponential"/><category term="Math"/><category term="sinc"/><category term="sine"/></entry><entry><title>How to Compress or Decompress .tar.gz (or .tgz) files</title><link href="https://gregback.net/how-to-compress-or-decompress-targz-or-tgz-files.html" rel="alternate"/><published>2009-10-17T13:47:00-04:00</published><updated>2009-10-17T13:47:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2009-10-17:/how-to-compress-or-decompress-targz-or-tgz-files.html</id><content type="html">&lt;p&gt;To compress a folder of files into a single tar-zip file, use the
command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;tar&lt;span class="w"&gt; &lt;/span&gt;-czvf&lt;span class="w"&gt; &lt;/span&gt;archive.tgz&lt;span class="w"&gt; &lt;/span&gt;files/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To extract a tar-zip file into the current directory, use the command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;tar&lt;span class="w"&gt; &lt;/span&gt;-xzvf&lt;span class="w"&gt; &lt;/span&gt;archive.tgz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Linux"/><category term="gz"/><category term="tar"/></entry><entry><title>Using Google Image Search to Find Desktop Backgrounds</title><link href="https://gregback.net/using-google-image-search-to-find-desktop-backgrounds.html" rel="alternate"/><published>2009-09-01T10:59:00-04:00</published><updated>2009-09-01T10:59:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2009-09-01:/using-google-image-search-to-find-desktop-backgrounds.html</id><summary type="html">&lt;p&gt;I don't remember where I first saw this, but you can use the "imagesize"
parameter in Google Image Search to find pictures that fit your desktop
perfectly. In my case I have two size-by-side 19" monitors (not
widescreen). Therefore my total screen space is 2560 x 1024. A Google
image …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I don't remember where I first saw this, but you can use the "imagesize"
parameter in Google Image Search to find pictures that fit your desktop
perfectly. In my case I have two size-by-side 19" monitors (not
widescreen). Therefore my total screen space is 2560 x 1024. A Google
image search for "&lt;a href="http://images.google.com/images?q=beach+sunset+imagesize%3A2560x1024"&gt;beach sunset imagesize:2560x1024&lt;/a&gt;" gives me a wide
variety of pictures to choose from without having to navigate desktop
wallpaper sites.&lt;/p&gt;
&lt;p&gt;[&lt;a href="http://http://images.google.com/imghp?hl=en"&gt;Google Image Search&lt;/a&gt;]&lt;/p&gt;</content><category term="Other"/></entry><entry><title>Determining Uptime for Windows</title><link href="https://gregback.net/determining-uptime-for-windows.html" rel="alternate"/><published>2009-08-14T16:32:00-04:00</published><updated>2009-08-14T16:32:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2009-08-14:/determining-uptime-for-windows.html</id><summary type="html">&lt;p&gt;After my computer restarted overnight I became curious as to what time
it restarted (I had something running overnight and was upset that it
didn't finish. A quick Google search revealed that there are several
ways to reveal this information:&lt;/p&gt;
&lt;h3&gt;Uptime.exe Utility&lt;/h3&gt;
&lt;p&gt;Microsoft provides a small utility that determines …&lt;/p&gt;</summary><content type="html">&lt;p&gt;After my computer restarted overnight I became curious as to what time
it restarted (I had something running overnight and was upset that it
didn't finish. A quick Google search revealed that there are several
ways to reveal this information:&lt;/p&gt;
&lt;h3&gt;Uptime.exe Utility&lt;/h3&gt;
&lt;p&gt;Microsoft provides a small utility that determines uptime based on
events in the Event Log. If the Event Log has been cleared then this
method will not work. More information and the download link can be
found &lt;a href="http://support.microsoft.com/kb/q232243/"&gt;here&lt;/a&gt;. You can copy it into the system directory (i.e.
C:\WINDOWS) and run it from the command line anywhere or (if you don't
have administrative privileges) save it in any directory and then run it
using the command line from that directory.&lt;/p&gt;
&lt;h3&gt;SystemInfo command&lt;/h3&gt;
&lt;p&gt;Although uptime does not appear in the GUI System Information
(Start-&amp;gt;Programs-&amp;gt;Accessories-&amp;gt;System Tools-&amp;gt;System Information),
the command line tool "systeminfo" contains a line with the system
uptime.&lt;/p&gt;
&lt;h3&gt;Batch Script&lt;/h3&gt;
&lt;p&gt;The following batch script will use the "systeminfo" command and find
the uptime within the output of that command.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="k"&gt;echo&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;systeminfo &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;find &lt;span class="s2"&gt;&amp;quot;System Up Time:&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="k"&gt;echo&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="k"&gt;pause&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;[Source : &lt;a href="http://www.hardforum.com/archive/index.php/t-717665.html"&gt;HardForum.com&lt;/a&gt;]&lt;/p&gt;
&lt;h3&gt;Network Connections&lt;/h3&gt;
&lt;p&gt;If you have a persistent network connection, typically it will start
nearly as soon as the computer does. Therefore you can get a rough
estimate using the information found in Start-&amp;gt;Settings-&amp;gt;Network
Connections-&amp;gt;(Connection Name) under the "Duration:" field.&lt;/p&gt;
&lt;p&gt;(The above path is for Windows XP with the Classic Start Menu). Other
versions of Windows have a slightly different path. Usually there is a
"Network Connections" link on the left side of an Explorer Window.
Otherwise there may be an icon representing your network connection in
the system tray. Clicking on either of these should give an option to
bring up the information for that connection.&lt;/p&gt;</content><category term="Windows"/><category term="uptime"/></entry><entry><title>TOP (Linux Program) CPU States</title><link href="https://gregback.net/top-linux-program-cpu-states.html" rel="alternate"/><published>2009-08-12T07:36:00-04:00</published><updated>2009-08-12T07:36:00-04:00</updated><author><name>Greg Back</name></author><id>tag:gregback.net,2009-08-12:/top-linux-program-cpu-states.html</id><summary type="html">&lt;p&gt;The Unix/Linux program "top" is used to determine various information
about processes your computer is executing. It is comparable to the "ps"
command, but I prefer using top. It a good equivalent of the Task
Manager on Windows, but much more powerful and customizable, if you're
comfortable with the …&lt;/p&gt;</summary><content type="html">&lt;p&gt;The Unix/Linux program "top" is used to determine various information
about processes your computer is executing. It is comparable to the "ps"
command, but I prefer using top. It a good equivalent of the Task
Manager on Windows, but much more powerful and customizable, if you're
comfortable with the command line (though not as good as Process
Explorer, in my opinion). I plan to write a more detailed comparison
between ps and top in the future, but until then, here is the first
question I had about top, as well as the solution I found on the web:&lt;/p&gt;
&lt;p&gt;What do the "us/sy/ni", etc. abreviations mean in the (default) third
line of top output (the one that begins with "Cpu(s):") ?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;us&lt;/strong&gt;- &lt;em&gt;User CPU time&lt;/em&gt;. The time the CPU has spent running users’
    processes with default priorities&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;sy&lt;/strong&gt;- &lt;em&gt;System CPU time&lt;/em&gt;. The time the CPU has spent running the
    kernel and its processes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ni&lt;/strong&gt;- &lt;em&gt;Nice CPU time&lt;/em&gt;. The time the CPU has spent running users’
    proccess that have been prioritized up using &lt;strong&gt;nice&lt;/strong&gt;command&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;wa&lt;/strong&gt;- &lt;em&gt;I/O wait&lt;/em&gt;. Amount of time the CPU has been waiting for I/O
    operations to complete&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;hi&lt;/strong&gt;- &lt;em&gt;Hardware IRQ&lt;/em&gt;. The amount of time the CPU has been
    servicing hardware interrupts&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;si&lt;/strong&gt;- &lt;em&gt;Software Interrupts&lt;/em&gt;. The amount of time the CPU has been
    servicing software interrupts&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;st&lt;/strong&gt;- &lt;em&gt;Steal Time&lt;/em&gt;. The amount of CPU ’stolen’ from this virtual
    machine by the hypervisor for other tasks (such as running another
    virtual machine) – a fairly recent addition to the top command,
    introduced with the increased virtualization focus in modern
    operating systems&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;[Source: &lt;a href="http://www.unixtutorial.org/commands/top/"&gt;UnixTutorial.org&lt;/a&gt;]&lt;/p&gt;</content><category term="Linux"/><category term="top"/></entry></feed>