Because everything’s better with bacon

Tuesday, December 9, 2008

patch

(This is on solaris, no -N option to diff for me!)

This produces the easiest-to-read diff IMO:
diff -btu [oldfile] [newfile] > patchfile
-b = ignore blanks
-t = preserve source indentation
-u = 3 lines of context with the + and - in front of changed lines

But the -t option interferes with proper patch application, so just use:
diff -u [oldfile] [newfile] > patchfile
…where oldfile is the file you want to patch, and newfile is the file with the changes you want to apply.

patch -b -p0 < patchfile
-b = make a backup ;)

If you are asked for the patch filename - you probably don’t have the depth set right with -p.  Try increasing it.

If you get the message “Reversed (or previously applied) patch detected!”, somebody messed with your stuff between creating the patch & applying it, OR you did the diff backwards (common Monday morning mistake.)

posted by gabrielle at 10:37 am  

Wednesday, December 3, 2008

Data from the PostgreSQL JTA

Data from the PostgreSQL Job Task Analysis survey.

I shortened some questions and answers to better fit on the page; see original data if you are concerned about potential shifts in meaning. In many cases, I re-ordered the answers in a way that makes sense to me. Again, please see the original data if this concerns you.  Not all data has been graphed.  Graphs created in OpenOffice Calc.  I would have rather used Gnuplot, but I preferred the horizontal bar chart style & gnuplot can’t do that yet without a lot of gymnastics.

PostgreSQL JTA - Graphs

posted by gabrielle at 7:37 pm  

Saturday, November 29, 2008

NULL in Python and Perl

I’m learning a little Python for a side project. I wrote a SELECT statement that would produce NULLs and rather than use COALESCE to prevent returning NULLs, I wanted the application to be able to detect and then replace the value with a default.

In Perl, this is a no-brainer to me - the NULL value would be ‘undef’, and I could write something like:

$value = $default if (! defined $value);

So, after a bit of struggling, I found out that the ‘None’ object is returned when a value is NULL in python.

To determine whether you’ve got a NULL, you write something like:

if $value is None:
    $value = $default

Generally speaking, Python considers an undefined object to be a rare occurrence.

posted by selenamarie at 10:14 am  

Friday, November 14, 2008

Cisco Syslog Parser - slides

Here are the slides from my PDX.pm talk this week. A link to the accompanying podcast will be along soon.

Other fun things we discussed at the meeting:
Cisco::Reconfig
trapgen
logger
logwatch

Thanks for the lively discussion!

[edit] podcast!

[edit] Clarification of two items from the podcast:
- multiline messages do indeed come in multiple packets. There is a message counter that increments for each message, so you could use the host name + message counter to match up multi-line messages. For what I’m doing, the important part is in that first line, so the payoff isn’t worth the investment.
- re hypens in the mnemonic field of the system message: I went back through and wasn’t able to find any examples of this, so I retract my statement. (I do have examples of system messages with hyphens in the facility field.)

posted by gabrielle at 9:41 am  

Monday, November 10, 2008

Quick Guide: Ubuntu box as syslog server

You need:
root/sudo access to a statically-addressed Ubuntu machine.  (It will need to be on whenever your router is on in order to get anything good out of this.)
Enable access to your Cisco router.

Part 1: Set up your log host.

Step 1: before editing any of the files discussed below, be sure to back them up, e.g.:
cp /etc/syslog.conf /etc/syslog.conf.dontmessthisup

Step 2: edit /etc/syslog.conf to include this:
#router logging
local6.debug                    /var/log/cisco.log

This means “send all messages from facility local6, with a priority of debug or greater, to /var/log/cisco.log”.

(Note that the default facility for Cisco is local7; if you want/need to use the Cisco default, change the above accordingly.)

Step 3: create the log file I specified above:
sudo touch /var/log/cisco.log
(more…)

posted by gabrielle at 1:16 pm  

Wednesday, October 1, 2008

What to expect, when you’re expecting to go to PostgreSQL Conference West 2008

I just wrote way too much about the talks I’ll attend to at PostgreSQL Conference West. Check it out!

Let me know what you’re planning to see in the comments!

-selena

posted by selenamarie at 5:00 pm  

Wednesday, September 24, 2008

Git is my hero

Last night, an incredible number of people showed up to Code-N-Splode to hear about Git.

I was not at all prepared for that number of people, but grateful that a couple experts were on hand to help - Sarah Sharp, Audrey Eschright and Michael Schwern (and others) all contributed to the discussion. Thanks for all the great questions! I’m looking forward to Sarah’s advanced tutorial next month.

posted by admin at 8:05 am  

Monday, September 22, 2008

Vim tidbits of the day - 9/22/08

:bd - closes the current buffer window

CTRL-F - page down; CTRL-B - page up; CTRL-D - put current line in the center of your screen

CTRL-R - Redo (plus COUNT for redoing a number of changes); ‘u‘ is for undo; ‘U‘ is for undoing all changes on a particular line

:set undolevels=NUM - number of changes saved in memory (can set to negative number if running out of memory

:split - split your current window into two; switch between windows with CTRL-W CTRL-W

!{cmd} - run a shell command, shows you the output and prompts you before returning to your current buffer; ‘:!‘ by itself runs the last external command; ‘:!!‘ repeats the last command; :silent !{cmd} eliminates the need to hit enter after the command is done; ‘:r !{cmd}‘ puts the output of $cmd into the current buffer.

posted by selenamarie at 4:57 pm  

Friday, September 19, 2008

Linux Plumbers Conference: Filesystem I/O under a database workload

Gabrielle and I are at it again, talking about Filesystem I/O and Linux at the Linux Plumbers Conference.  Mark Wong is the evil performance genius working with us behind the scenes, and a copy of what we brought to the conference today is here.

Takeaway: Set your read ahead buffer size higher in the kernel - maybe even 8MB.

posted by selenamarie at 7:30 am  

Monday, September 15, 2008

Command-line trick to help your memory

I’m learning the PostgreSQL system catalog tables right now, and was wishing that I had some catalog flashcards.  I made my wish ‘aloud’ on IRC today, and @davidfetter managed to blow my mind with this simple command-line switch for psql: -E. Now, every time I use a command, the tool tells me what the underlying SQL query is. Great for jogging the memory, and I’ll be putting off making my catalog flashcards for a few more days. Now I wonder what other revealing command-line switches I’ve overlooked!

See screenshot:

posted by admin at 11:08 pm  
Next Page »

Powered by WordPress