Wed, 12 Nov 2008

Backup your Blackberry on Linux

There are a few tools in the Linux toolbox that can help you backup your Blackberry. I've tested this on the Blackberry 8330 and 8830.

In Debian, apt-get install the following:

barry-util
libbarry0

Connect your BB via the USB cord.
Run the following command:

kevin@laptopibm:~/tmp$ btool

Blackberry devices found:
Device ID: 0x9bcd6d0. PIN: 52c09285, Description: RIM BlackBerry Device
Using device (PIN): 52c09285
You should see your device as shown above.

Next list your databases:
kevin@laptopibm:~/tmp$ btool -t
You'll see a long list of all of the databases on your BB. The names of the databases are in single quotes like 'Address Book'.

Load a database and dump it to stdout with:
btool -d 'Address Book'
You'll see the contents of your address book scroll by.

Backup a database with:
btool -d 'Address Book' -f my_bb_address_book
Restore a database with:
btool -s 'Address Book' -f my_bb_address_book
There are a few more commands that can be found in man btool.

Posted at: 09:54 | category: /other | Comments ()

Mon, 28 Apr 2008

Why we go to school

In 1861, one William Cory, a Master at Eton, made the following observation:

"You are not engaged so much in acquiring knowledge as in making mental efforts under criticism. A certian amount of knowledge you can indeed with average faculties acquire so as to retain; nor need you regret the hours that you have spent on much that is forgotten, for the shadow of lost knowledge at least protects you from many illusions. But you go to a great school, not for knowledge so much as for arts and habits; for the habit of attention, for the art of expression, for the art of assuming at a moment's notice a new intellectual posture, for the art of entering quickly into another person's thoughts, for the habit of submitting to censure and refutation, for the art of indicating assent or dissent in graduated terms, for the habit of regarding minute points of accuracy, for the habit of working out what is possible in a given time, for taste, for discrimination, for mental courage and mental soberness. Above all, you go to a great school for self-knowledge."

This was actually a test question that I was asked to write about in a class on International Law at George Washington University. It was a terrific class that I still remember today and kudos to the instructor, David A. Peterson, for encouraging us to think in new ways.

Posted at: 20:43 | category: /other | Comments ()

Thu, 08 Mar 2007

Accessing a PostgreSQL database from OpenOffice.org base under Debian.

Solution:
apt-get install unixodbc odbc-postgresql
# odbcinst -i -d -f /usr/share/psqlodbc/odbcinst.ini.template
$ cat /usr/share/doc/odbc-postgresql/examples/odbc.ini.template >> ~/.odbc.ini

   1. Set connection parameters in ~/.odbc.ini (username, password, host...)
   2. Check "Connect to an existing database" from the oobase Database Wizard, select ODBC, click on "Browse".

At this point your PostgreSQL database should be listed among the available data sources. 

Posted at: 08:05 | category: /database | Comments ()

Sat, 23 Dec 2006

postfix: delete all mail in the queue

    Easy way: as root, type -- postsuper -d ALL
                               postfix reload
    
Note:  this is a very powerful command as it deletes 
ALL mail in the queue.

## get the mail-ID and other junk in the first column
mailq | nawk '{print $1}' > tmp-mailq

## remove the junk line starting with (tra
## repeat as necessary if other junk lines are present
## repeat once also for blank lines
## manually edit to remove any other extraneous lines
cat tmp-mailq  | sed '/^(tra/d' > tmp-mailq-2
cat tmp-mailq2 | sed '/^$/d'    > tmp-mailq-3

## write a short script to loop through postsuper -d
## with the mail-ID's

   #!/bin/sh
   exec < tmp-mailq-3
   while read line
   do
      postsuper -d $line
   done

## run the script; mailq should be clean

Posted at: 13:01 | category: /mail | Comments ()

Mail Server Open Relay Check

1.  From the mail server, simply:

    telnet relay-test.mail-abuse.org

    and watch output.

2.  http://members.iinet.net.au/~remmie/relay/

3.  http://www.abuse.net/relay.html

Cheat sheet for configuring Postfix to stop UCE:

http://jimsun.linxnet.com/misc/postfix-anti-UCE.txt

Posted at: 12:59 | category: /mail | Comments ()

postfix

postcat msgID                   // read the message
postsuper -d msgID              // delete the message
postconf                        // print conf value on stdout
postfix check                   // check the config values
postfix reload                  // reload teh config files
mailq                           // check the queue
postfix flush                   // send all mail for delivery now

/var/spool/postfix/deferred     // where pending mail hangs out
/var/spool/postfix/defer

/var/log/mail.info              // log files to check
/var/log/mail.warn
/var/log/mail.err

Posted at: 12:59 | category: /mail | Comments ()

mairix


mairix -p -v -a -t	// -p purges empty holes left by deletions
			// -v verbose during indexing
			// -a augment the vfolder rather than write-over
			// -t return the entire thread in a successful search

mairix 	t:pointer	// To: header
	c:pointer	// Cc: header
	a:pointer	// To:, Cc: or From: headers
	f:pointer	// From: header
	s:pointer	// Subject header
	s:pointer=2	// allow up to 2 errors in subject keyword
	b:pointer	// message body
	d:3m-1m		// msgs between 3 mths and 1 mth ago
	d:-2y		// msgs older than 2 yrs
	d:2w-		// msgs within last 2 wks
	z:1m-		// msgs larger than 1 megabyte
	z:10k-20k	// msgs between 10k and 20k bytes
	p:/archive/	// msgs with /archive/ in their path

Example:	assume e-mail address richard@doesnt.exist

mairix d:3m- f:richard+doesnt+exist s:chrony

	// matches all msgs newer than 3 mths from richard and word chrony in 
	// the subject line

mairix d:6m- f:richard s:chrony=2

	// matches a wider range in the e-mail address, newer than 6 mths,
	// and allows up to 2 errors in the keyword in subject search

In Mutt, access mairix as follows:

	!		// open shell
	mairix f:kevin	// enter search criteria
	c=vfolder	// change folder to see results in vfolder

Make sure you run mairix -tp occasionally to update the DB.

Files:  ~/.mairixrc
	/usr/share/doc/mairix/mairix.html

Posted at: 12:59 | category: /mail | Comments ()

Delivery of each email is done
by your ISP mail server, first establishing a conversation
through (port 25) of each of your recipient ISP mail server

 


How email works?

How does my email gets to the recipient?

Before you can send out email messages from your PCs, you need to access the Internet through your ISP network via a dial-up modem that usually utilizes the telephone line or with always-on ISDN, DSL, ADSL, Network or Cable connection.

SMTP (Simple Mail Transport Protocol) is a protocol governing electronic mail transmission and reception. It is used for sending email to and between mail servers (sending and receiving email messages). See rfc 821

Using email clients like: Outlook Express or Eudora etc. to send out email to your ISPs mail server--which collects them--put them in queue and then relay them to your recipients ISP mail server--for retrieval from their mailbox.

Mailbox - each mailbox is assigned a unique address ie: mymail@mydomain.com character string which identifies the user to whom the mail is to be sent. Mailboxes normally reside on mail servers that are always connected to the Internet (otherwise mails can't be received), and mails are fetch from the remote mail servers using Post Office Protocol (POP3) by the user with their mail client.

Email in queue at your ISP mail server may takes just a few seconds to be delivered--if it is not overloaded--to a few minutes or even hours, and if the network is down or the recipients mail server does not want to accept your email for some reason like: busy or mailbox full--then your ISP or your own mail server will try to deliver again...

 

 

SPAM
driving
you crazy?
In a few minutes time, you will have the easiest & most powerful way to stop it... Click here
for more info
 

Freeware

Auto-manage smtp pop3 bounce email Click here
for more info?

 


Many ISP (or your)
mail servers can be programmed to make multiple attempt delivery of undelivered email, some up-to 250 times before returning them as undeliverable.

In many countries, local legislation requires ISP service operator to grant security service access to the users correspondence--so, your emails are probably stored in your ISP's system for some time before being delivered.

MailsBroadcast send emails continuously in groups of 10 (default setting) or up to 250 emails per group to your ISP mail server or to your PCs mail server for distribution -- as fast as your ISP or mail server can cache them for distribution. Therefore, the speed of sending emails is not due to the MailsBroadcast program.
See
Email Speed

If you sent 500 emails to your ISP mail server, it will accept all (store them) and put them in queue for delivery or you may experience server-time-out (connection terminated) because many ISP mail server are programmed to limit the amount of mail that you can sent, by quantity or by limiting the server access time.

Server-time-out, if the sending and receiving mail server have different timeouts, one of them may give-up while the other is still trying and unexpectedly, terminate the connection.

Many ISP mail servers also reduce the number of concurrent connection--meaning that even thought your ISP mail server have accepted all your emails--they may not be delivered or accepted by the intended recipient ISP mail server. See: Server-time-out and identifying mail delivery failures... See: SMTP Return Error Codes

Assuming that all your 500 emails are sent to different domain recipients, for example: july_@aol.com  march_@mail.com  may_@hotmail.com etc., your ISP mail server will have to deliver each of your 500 emails to 500 different ISP mail servers...

 

 

 

 

 

 

 

 

 

 

 

 

To top of page

 


 


The Conversation

How two MTAs (Message Transfer Agent) communicate with each other using a single TCP connection?

After your ISP mail server have collected all your emails, put them in queue and then send them out--to each recipient ISP mail server by establishing a conversation with a SMTP server--connecting to port 25 on the recipient SMTP mail server and wait for it to identify itself first....

...the recipient mail server will tell the sending server if it is prepared to receive mail--if not--the sending mail server terminate the connection and try again later...

...after a predetermined undeliverable attempts, all undeliverable message will be returned (rfc 821) with an error report containing the first part (message headers) to the sender mail server.

Server-time-out, if the sending and receiving mail server have different timeouts, one of them may give-up while the other is still trying and unexpectedly, terminate the connection.

Basically, email consist of:
(1) The envelope   (2) headers   (3) Message body

(1) Envelope
rfc 821 specifies the contents and interpretation of the envelope--used by the MTAs for delivery specified by these two SMTP commands (MAIL From: and RCPT To:)

MAIL From:<mable@sun.tuc.test.org>
RCPT To:<mable@test.org>

(2) headers are used by the user agent and each header field contains a name, followed by a colon, followed by the field value.
Received: by sun.tuc.test.org. (4.1/SMI-4.1)
id AA01301; Tue, 21 May 98 11:37:22 MST

Message-Id: <6210181836.AA00502@sun.tuc.test.org.>
From: mable@sun.tuc.test.org (Mable Merliney)
Reply-To:
mable@test.org
X-Phone:
+0 202 671 2761
X-Mailer:
Mail User’s Shell (9.1.0 12/02/98)
To:
mable@test.org
Subject:
testing

Headers beginning with an X- are user-defined fields and RFC 822 specifies the format and interpretation of the header fields.

(3) Message body is the content of the message from the sender to the recipient and transferred using the DATA command--the headers are sent first, followed by a blank line, followed by the body. Each line transferred using the DATA command must be less than 1000 bytes.

The user agent takes what the sender specify as a body, adds some headers and passes the result to the MTA
The MTA adds a few headers, adds the envelope and sends the result to another MTA.

 

Operational Sequent of:
SMTP
Simple Mail Transfer Protocol

A HELO command and recipient mail server identify its self--at this stage--it may decide to terminate the connection--if it don't want to talk to the sender for example: mailbox full or blocked, etc., if it is accepted...

A Mail-FROM command is issued by the sender mail server, followed by the from (sender) address--again, the mail server may decide to terminate the connection, if it does not wish to receive mail from the sender...

...at this stage, most mail servers will conduct a reverse lookup nslookup on the domain name specified for the HELO or FROM command and if the IP address of the sender mail server is not registered (see MX records) to that domain--considered an (imposter) non-local--the connection terminated and if it is accepted...

A RCPT-TO command is issued, followed by the email address of the intended recipient--at this point, the mail server may reject emails sent to the specified address, ie; non local user--if all goes well at this stage, your ISP mail server may issue multiple RCPT-TO commands to the server thus adding more recipients to the message:

adding more--means that, if you have 100 AOL email recipients, all of them are all delivered to the mail server. When it is through with adding recipients, it issues the...

DATA command to the server and if it is accepted ....at this point--again, the mail server may reject emails being delivered...

DATA command is accepted and your ISP mail server proceeds to send the message headers, followed by a blank line, followed by the message body and file attachment data. When it is done with sending the message data, it sends a carriage return, followed by a period, followed by a carriage return, to indicate the end of the message...

QUIT command is issued to terminate the conversation If you have sent 500 emails and all of them are to 500 different email domain, the above process is repeated with each and every 500 different ISP mail server.

Email Daemon - An email software program residing in a mail server that manage incoming and outgoing mails.

If your are sending emails using your own mail server program. Emails will first be sent from your email client to your mail server for delivery and if you are off-line (not connected to the Internet) your mail server will cache or store them in queue for delivery--And follow the same SMTP protocols as described above it makes no difference, whether it is your own mail server or your ISPs mail server.

How two MTAs (Message Transfer Agent) communicate with each other using a single TCP connection. A typical transcript conversation between two mail server (below). SENDER in bold and the 5 SMTP email transaction commands. 220, 250, 345? See: SMTP Return Codes

 


 

 

 

 

 

 

 

 

 

To top of page

 

 

 

 

 

 

User Agent?
A program (ie: Eudora) or editor that let users create, edit, compose, store and send mails to a mail server, polls a mail server for mails, download and display mails, as well as using
POP3 to talk to mail servers.


 

 

 

Message Transfer Agent (MTA) the exchange of mail using TCP/IP is performed by MTA that defines how email messages are transmitted between two users.
 
220 mailhost.immxx-isp.com ESMTP Sendmail 8.8.5/1.4/8.7.2/1.13; Tue, Mar 18 1997 14:38:58 -0800 (PST)

HELO mail.sender.org
250 mailhost.immxx-isp.com  Hello mail.sender.org

 

 

 


MAIL FROM: antispam@sender.org
250 antispam@sender.org... Sender ok

 

 

 



RCPT TO: myfriend@immxx-isp.com
250 myfriend@immxx-isp.com... Recipient ok

 

 


DATA
354 Enter mail, end with "." on a line by itself
Received: from alpha.sender.org (alpha.sender.org [124.211.3.11]) by mail.sender.org (8.8.5) id 004A21; Tue, Mar 18 1997 14:36:17 -0800 (PST)
From: antispam@sender.org (Anti-Spammer)
To: myfriend@immxx-isp.com
Date: Tue, Mar 18 1997 14:36:14 PST
Message-Id: <antispam031897143614-00000298@mail.sender.org>
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
Subject: Meeting this evening?
Let's go to the movie after dinner?


--antispam.
250 LAA20869 Message accepted for delivery

QUIT
221 mailhost.immxx-isp.com closing connection



Example of undeliverable notification
in respond to a message send by
john@MAIL  via  mail2  to  mail3  with
relay instructions to mail4

S: MAIL FROM:<>
R: 250 ok
S: RCPT TO:<@MAIL2.ARPA:JOHN@MAIL.ARPA>
R: 25O ok
S: DATA
R: 354 send the mail data, end with .
S: Date:  23 Nov 19  10:21:23
S: From: SMTP@MAIL3
S: To:     JOHN@MAIL.ARPA
S: Subject: Mail System Problem
S:
S: Sorry JOHN, your message to ANN@MAIL4.ARPA lost
S: MAIL4.ARPA said this:
S: "550 No Such User"
S:
R: 250 ok

 

 

HELO
command, identifies the sending mail machine;
HELO mail.sender.org to the receiving mail machine...

and receiving mail machine to the sending machine;
250 mailhost.immxx-isp.com  Hello mail.sender.org

At this initial stage NO transaction takes place, the receiving machine can terminate the process with a 501 failure reply and the sending machine will try again or return the mail as undeliverable.
At the
HELO command, the sender can lie, nothing can prevents mail.sender.org from saying HELO makemoney.gov that's how spammers fake and mask their message headers.

--------------------------------------------------------

MAIL FROM
command, initiates mail processing and the address given turns into From: antispam@sender.org--the sender email can be valid, invalid or fake--in short; the sender can use just about any email

This is where
most mail servers will conduct a nslookup on the domain name specified for the HELO and FROM --if the sender machine IP address is not registered (see MX records) to that domain--will be considered an imposter or non-local--the connection terminated.
At this stage, the receiving mail machine can terminate the process, the sending machine will try again or return the mail as undeliverable.
----------------------------------------------------------------------------------

RCPT TO command, specifies and identify the intended recipient of the mail myfriend@immxx-isp.com and the given address becomes the To: that determines who the mail will be delivered to, regardless of what the To: line in the message says--at this point, the mail server can still reject the mail. RCPT TO is also used to identify multiple recipients within the same domain by multiple use of this command and if the mail contains a forward path (FW to someone not local) and if the receiving machine do not allow relay the mail will be returned as: 550 Unknown local user
-------------------------------------------------------------------------------

DATA command, starts the mail input and the receiving machine must process the transaction, store the mail and send an OK reply to the sending machine. If the the transaction failed (at this point) the receiving machine must send a 503 encountered bad sequence of commands failure reply to the sending machine.

When the receiving machine accepts a message either for relaying or for local delivery, it inserts a time line to indicates the identity of the host that send the mail and the host that receive the mail. (Relayed mails will have multiple time lines.
Received
: from alpha.sender.org (alpha.sender.org [124.211.3.11]) by mail.sender.org (8.8.5) id 004A21; Tue, Mar 18 1997 14:36:17 -0800 (PST)
------------------------------------------------------------------------------

QUIT command, the receiving machine must send an OK reply to the sending machine--at this point--the receiving machine do not close the transmission yet--until it receives and reply to the QUIT command from the sender machine. The sender machine will also not close the transmission until it sends the QUIT command and receives a reply.

If the connection is closed prematurely, a 504 command not implemented failure reply to the sending machine and the receiving machine will act as if a RSET command had been received, cancel pending transaction due to temporary error. RSET command, specify that; current mail transaction is to be aborted and the receiver machine must send an OK reply.

RSET command aborts current mail transaction and causes both ends to reset and any stored information about sender, recipients or mail data is discarded.

A mail transaction may be aborted by the RSET command.

 

QUIT command is the last session and it cannot be used at any other time during a session.

If the transaction beginning command argument is not acceptable a 501 failure reply must be returned.

If the commands in a transaction are out of order a 503 failure reply must be returned.

 

.

 


 

SMTP has a few more commands:

SEND command SOML command SAML command
begin a mail transaction, once started a mail transaction consists of HELO, MAIL FROM and one or more RCPT commands, follows by DATA command. They (SEND SOML SAML) replace the MAIL command and allow mails to be delivered directly to the recipient mailbox or user terminal.

Help command ask the receiver machine to send help information to the sender HELP request command.

RSET command that aborts current mail transaction and causes both ends to reset and any stored information about sender, recipients or mail data is discarded.

VRFY command lets the client ask the sender to verify a recipients address, identifies a user, name, specified mailbox and returned a reply, without sending mail to the recipient.

NOOP command force the server to respond with an OK reply code 200 - NOOP command does nothing else.

EXPN expands a mailing list, asks the receiver to confirm that the argument identifies a mailing list, and if yes, return the membership of that list with full name of the users and specified mailboxes.

TURN command lets the client and server switch roles,
to send mail in the reverse direction without having to create a new one TCP connection. The receiver
must send an OK reply and then take on the role of the sender-SMTP or send a refusal 502 reply and retain the role of the receiver-SMTP.

HELP, NOOP, EXPN, and VRFY commands can be used at any time during a session between SMTP mail machine.
 

SMTP is fully defined in RFC 821
rfc2821 for the basic specification of SMTP
It is worth reading to sheds light on the mysteries and intricacies of email processing.

<><><><><><><><>

 

 

 

 

 

 

 


 

Command - a request for mail service action sent by the sender SMTP to the receiver SMTP

 

 

 

 

 

 

 

 


Art of eMail CRM | eMail Bolts&Nuts
Home | Contact UsPrivacy Policy | Guest Book | Useful Sites
Support | Purchase | Product Info | Quick Tour | eMail CRM Freeware
Line with surfer

©Copyright June 2002  Permission to re-print, please click here

 

Keywords: Email strategy ezine email strategies Emails broadcast emails broadcasting eMails ecrm emailing eCRM E-mail Ecrm e-mail e-crm Emails crm e-mails bulk CRM e-mailing promoting marketing e-Mailing sales Mail selling  mail e-marketing shareware Mails customise Shareware mails customised freeware Mailing customize Freeware mailing anti spam customized mass group broadcast Anti Spam Spamming abuse

Any feed-back or suggestions? Please
Drop us a note
email icon

To top of page

Posted at: 12:59 | category: /mail | Comments ()

command line mail

:~ telnet 200.174.38.18 25
:~ HELO mydomainname_of_choice.com
:~ MAIL FROM: someone@yahoo.com
:~ RCPT TO: someone-else@msn.com
:~ DATA
:~    
:~ .
:~ quit

// command line mail from mutt
echo "my message" | mutt -s "my subject" -a Attach.tar someone@yahoo.com

Posted at: 12:59 | category: /mail | Comments ()

Command Line Email Reading




telnet your.pop.server 110

eg. My email address is manages@cse.mrt.ac.lk , therefore my POP server is cse.mrt.ac.lk

Now let's go through the following sample telnet session. You will get to know the commands and their usage as we progress. After you have connected to the POP server, a message similar to the below will appear. Let's continue from there.

+OK sigiri POP3 Server (Version 1.004) ready.

USER manages

Use your login name instead manages, don't use mine.

+OK please send PASS command

PASS mypassword

 Use your email password, not mine.

+OK 2 messages ready for manages in /usr/spool/mail/manages

Note: Unlike most times when you enter your password, this time you will see it as you enter it. Please make sure that no one is staring at your screen over your shoulders.

list This will display the total number of messages and size again as well as a list with each file number, a space and its size. something similar to the following:

+OK 2 messages; msg# and size (in octets) for undeleted messages:

1 607
2 1323403
.

retr 2 Displays the message-2 including headers.

top 1 20 Displays the first 20 lines of the message-1. Unlike the retr command, this will not scroll the message to the end . It just shows the first 20 lines of the message body. This is useful if you want to read the whole message. The syntax of the retr command is

retr messageNo NumberOfLines

dele 2 Deletes the message-2. This is how you delete a message. You will see the confirmation for the deletion. In fact the message-2 is a mail bomb, you can identify it from the size. It is rather unusual to have a legitimate message of over 1MB.

+OK message 2 marked for deletion

If you type list again, you will see that message number 2 is indeed gone.

There are few more commands I have not discussed, the best way to learn them is to issue an incorrect command.

blah

-ERR Invalid command; valid commands: DELE, HOST, LAST, LIST, MBOX, NOOP, RETR, RSET, STAT, TOP or QUIT

Now you can play with the rest of commands. Note that some POP servers do not give this error message.

quit ends your session. Simply closing the telnet session may hang your mailbox.



Posted at: 12:59 | category: /mail | Comments ()

clam antivirus

clamscan -r -l scanned.txt /home/kevin 
    // scans /home/kevin recursively and writes results to scanned.txt

www.eicar.com       //  get a harmless test virus here

FILES:

    /etc/cron.d/clamav
    /var/log/clam-update.log
    /usr/bin/clamscan
    /usr/bin/freshclam
    /usr/bin/sigtool

Posted at: 12:59 | category: /mail | Comments ()

bogofilter

bogoutil -d old | bogoutil -l new    // compacts the DB

cat msg | bogofilter -Ns    // if not spam, run this to 
                            // remove from spam DB and
                            // add to non-spam DB

cat msg | bogofilter -Sn    // if spam, run this to remove 
                            // from non-spam DB and add
                            // to spam DB

Posted at: 12:59 | category: /mail | Comments ()

Tue, 19 Dec 2006

Writing man pages

On a Debian system, install the following using apt-get:

    asciidoc
    xmlto

Write your man page using asciidoc.  The asciidoc homepage can be found at:

    http://www.methods.co.nz/asciidoc/

where you can also find a user manual which will show examples
on usage.

When writing your man page, start by usng the ascii.1.txt page in 
/usr/share/doc/asciidoc as an example.  Copy this file to your
working area and edit it appropriately.  Once your page is written, 
run the following command:

    asciidoc -v --doctype=manpage --backend=docbook  photon.1.txt

This produces a photon.1.xml file.  Next run this command:

    xmlto man photon.1.xml

This produces a photon.1 man page.

Check photon.1 for small corrections.  It seems to add in extra .sp tags.

Preview your new man page by running this command:

    man ./photon.1

Posted at: 09:10 | category: /dev | Comments ()

Sat, 25 Nov 2006

patch and diff

To create a patch against the most current development version when using SVN:

    svn diff > /path/to/patchfile.diff

For an individual file within SVN:

    svn diff changedfilename > /path/to/patchfile.diff

To create a patch when you are not using SVN:

    diff -Naur oldfile newfile > /path/to/patchfile.diff

    Note also the option -x to exclude files ... for example

        -x '*.po'     can be added to exclude all .po files

To apply a patch:

    patch --verbose [-p0] < /path/to/patchfile.diff

    where -p0 represents how much of the leading path will be dropped off
        -p0 = nothing is removed from the path
        -p1 = the leading '/' will be removed => path/to/patchfile.diff
        -p2 => to/patchfile.diff
        -p3 => patchfile.diff

More info can be found in the patch and diff man pages.  Note that there is a
section at the botton of the patch man that specifically discusses patch
creation.

Posted at: 07:53 | category: /dev | Comments ()

Fri, 11 Aug 2006

vi based encrypted password manager

I've played around with quite a few different password managers, most of them
being GUI based. They all worked fine, but I always wanted something I could
use easily from the console since I use SSH quite a bit from remote terminals.

The other reason I was never satisifed with a GUI solution was that the program
always had to be running. I know that some of them can sit unobtrusively in
your taskbar, but I'm not much on having lots of things running on my desktop
when I don't need them. On the other hand, I always have an xterm up, so using
the command line for password management seemed a logical approach.

So for a while I simply used vi to edit a text file that I encrypted with
bcrypt. On top of this I wrote a small shell script that would combine the
bcrypt decryption and grep'ing for a password into one comand line operation.
This worked too, but was still lacked something.

Eventually I stumbled on bits and pieces of other people's work that allowed me
to put together an console based solution that I'm now quite pleased with. It
involves the following:

    * modications to your .vimrc file specifically for .gpg files
    * active use of folding in your password file
    * a nice function for your .bashrc config file
    * and a powerful little shell script using nawk to get your password info easily

To create you own vi based encrypted password manager, do the following:

   1. Create a public/private key pair on the machine where the password file
      will reside. To create this key, make sure you have the package xxxxx. Logged
      in as yourself, issue the command

      ssh-keygen -t rsa

      It will prompt you for a passphrase. Enter something you can remember but
      is not too obvious. Accept the default (/home/username/.ssh) with regard to
      where the keys will be saved.

   2. Edit your .vimrc file and include the following:

      ----------------------------------------
      augroup encrypted
      au!
      " First make sure nothing is written to ~/.viminfo while editing
      " an encrypted file.
      autocmd BufReadPre,FileReadPre *.gpg set viminfo=
      " We don't want a swap file, as it writes unencrypted data to disk
      autocmd BufReadPre,FileReadPre *.gpg set noswapfile
      " Switch to binary mode to read the encrypted file
      autocmd BufReadPre,FileReadPre *.gpg set bin
      autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
      autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
      " Switch to normal mode for editing
      autocmd BufReadPost,FileReadPost *.gpg set nobin
      autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
      autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")

      " Convert all text to encrypted text before writing
      autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null
      " Undo the encryption so we are back in the normal text, directly
      " after the file has been written.
      autocmd BufWritePost,FileWritePost *.gpg u
      augroup END
      ----------------------------------------

   3. Using vi, create a new file called passwords.gpg.
      Set up your entries something like this:

      Forums
          UserID: myID_1
          Password: secret_1
          URL: http://www.domain_1.com
          More stuff in any format

          UserID: myID_2
          Password: secret_2
          URL: http://www.domain_2.com
          More stuff in any format

      Memberships
          UserID: myID_3
          Password: secret_3
          URL: http://www.domain_3.com
           More stuff in any format

          UserID: myID_4
          Password: secret_4
          URL: http://www.domain_4.com
          More stuff in any format

      You can experiment with the layout later, but start with this format of
      indenting. It's what makes the folding in vi look nice, which we'll set up in
      the next step. Save the file and close it.

   4. Open the file again with vi. This time, automatically, you should be
      prompted for the passphrase you used when you created your key. Enter the
      passphrase and you should be in your password.gpg file again.

   5. In this new password file, add the following line:

      vi: noswapfile bufhidden=wipe tw=0 fdm=indent nobackup nowritebackup foldclose=all

      Leave this line in place at all times and never edit it unless you know
      what you want to achieve. It sets up vi formatting, specifically the ability to
      fold lines. To learn more about folding type :help folding in a vi session

   6. Some important folding commands:
      zo open fold
      zc close fold
      zr open all folds
      zm close all folds

   7. You are now at a point where you're file is encrypted and you should be
      able to edit it at will with vi after entering your passphrase. The next step
      will give you quick command line access to query your password file.

   8. Somewhere in your path (echo $PATH), create a new shell script called searchWord.sh. Cut and paste the following:

      ---------------------------------
      #!/bin/sh
      usage()
      {
      [ $# -ne 0 ] && {
      echo "$0: $@" 1>&2
      }
      echo "usage: $0 pattern [file ...]" 1>&2
      exit 1

      }

      if [ $# -lt 1 ] ;then
      usage "missing pattern"
      fi
      pattern=$1
      shift

      nawk '

      BEGIN {IGNORECASE=1}

      NF==0 {
      if (paragraph ~ "'$pattern'") {
      print paragraph
      }
      paragraph=""

      }

      NF != 0 {
      paragraph=paragraph $0 "\n"

      }' "$@"
      ---------------------------------

      Save it and chmod 755 the file.
   9. In your .bashrc file add the following:

      ---------------------------------
      ### used for password program
      function qpass () {
      /usr/bin/gpg -d < ~/docs/passwords.gpg | ~/bin/searchWord.sh "$@"
      }
      ---------------------------------

  10. That's pretty much it. Test it out at the command line by typing a query, like ...

      $> qpass domain.com

      You should be prompted for your passphrase. Enter it, and the
      searchWord.sh script will search your password file for the term
      "domain.com". It will return multiple finds if such exist. 

      I hope this makes sense and works as well for others as it has for me.

      Credits: Thanks to Serge Roux and Wouter Hanegraaff for portions of the code.

Posted at: 09:06 | category: /vi | Comments ()

Thu, 10 Aug 2006

Using sqlobject in cherryPy

from sqlobject import *

conn = 'mysql://dbuser:dbpass@host/dbname'

class NameOfTable(SQLObject):
    _connection = conn
    _fromDatabase = True
    _style = MixedCaseStyle(longID=False)

class Newspage(Page):
    def index(self):
        article = NameOfTable.select(NameOfTable.q.field=='Joe', orderBy=-NameOfTable.q.dateAdded)


Notes:
    _fromDatabase = True means sqlobject will simply take column names from
    the DB.  It won't create any, which it is capable of doing.

    MixedCaseStyle - sqlobject uses pythonic names like my_name.  This allows
    the use of names like myName.

    longID=False - prevents sqlobject from automatically creating an ID column

    - in front of NameOfTable.q.dateAdded means reverse sort

Posted at: 21:38 | category: /database | Comments ()

Settings for uploads using PHP/Apache

In Apache httpd.conf, add the following:

    ..... other directives .....
   
       
           php_value post_max_size "71M"
           php_value upload_max_filesize "70M"
           php_value memory_limit "70M"
       
   

Posted at: 21:36 | category: /configure | Comments ()

Install Debian Source Packages

Debian can be a bit tricky if you're not familiar with its method of building
source packages.   Although this is covered in their faq somewhere, here is the
information.

    apt-get build-dep fluxbox
    apt-get source fluxbox
    apt-get install fakeroot
    apt-get install dpkg-dev
    apt-get install automake

(You may already have fakeroot and dpkg-dev installed). Although apt-get
build-dep fluxbox should also install all necessary tools, I have found that I
also have to get automake.

This will bring you three files (version number correct as of January 2004)
fluxbox_0.1.14-2.orig.tar.gz, fluxbox_0.1.14-2.diff.gz and
fluxbox_0.1.14-2.dsc. You will also have a fluxbox-0.1.14 directory.

The next step is

dpkg-source -x fluxbox_0.1.14-2.dsc

I'm assuming you have wget or something similar, if not do a quick

apt-get install wget

Now, we patch

cd fluxbox-0.1.14/src
wget kitaj.no-ip.com/files/fluxbox/fluxbox-0.1.14-menukey.patch
patch < fluxbox-0.1.14-menukey.patch


Now to build and install the package. You are in the fluxbox-0.1.14/src directory

cd ../
dpkg-buildpackage -rfakeroot -b


This will take some time. When it's done

dpkg -i ../fluxbox_0.1.14-2_i386.deb

Posted at: 21:36 | category: /configure | Comments ()

Compile a kernel the Debian way

apt-get install gcc kernel-package libc6-dev tk8.3 libncurses5-dev fakeroot

adduser kevin src

cd /usr/src

apt-get source kernel-soource-2.6.9
    [dpkg will automatically unpack it for you]

ln -s  kernel-source-2.6.9_2.6.9  linux

cd /usr/src/linux

rm -rf /debian

cd /usr/src/linux/scripts

./ver_linux
    [to see if you've got everything you need]

cd /usr/src/linux

cp /boot/config-2.4.23 .config

make menuconfig
    [do your config selection stuff]

make-kpkg clean

make-kpkg --revision $(date +'%Y%m%d') --append-to-version $(hostname) --rootcmd fakeroot clean

make-kpkg --revision $(date +'%Y%m%d') --append-to-version $(hostname) --rootcmd fakeroot kernel_image modules_image;

cd /usr/src

ls -l
    ...
    kernel-image-2.6.9chilkoot_20041220_i386.deb
    ...

dpkg -i kernel-image-2.6.9chilkoot_20041220_i386.deb

    [ if using initrd do the following ]

cd /boot

mkinitrd -o initrd.img-2.6.9chilkoot 2.6.9chilkoot

update-grub

check /boot/grub/menu.lst for correct entries of initrd and vmlinuz

reboot

Posted at: 21:36 | category: /configure | Comments ()

Create a new SSL certificate for Apache

Go to /etc/apache-ssl and backup apache.pem before you do anything else.  The
location of this file may be different depending upon your Apache setup.

Install the Debian package ssl-cert.

Check to make sure you have the standard template file:
    /usr/share/ssl-cert/ssleay.cnf

If you don't, make sure you have openssl installed.

cd over to a temporary working directory that you have write access to.

Run the command:
    make-ssl-cert /usr/share/ssl-cert/ssleay.cnf privkey.pem

This will create a private key for the server named privkey.pem.  
When complete with this process, store this file off site.

Next run the command:

    openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095

This will create a server certificate called cacert.pem, good for 3 years.

Next run the command:

    cat privkey.pem cacert.pem > apache.pem

This will create the complete certificate needed for apache.  Copy it over to
the directory where the pre-existing apache.pem was that you backed up
eariler.

Don't forget to move the privkey.pem off site.

Posted at: 21:36 | category: /configure | Comments ()

To set up CUPS based printing

apt-get install hplip hpijs

This will install quite a few other things as well, including CUPS

Then go to:
    
    http://localhost:631

and add a printer.

Present configurations include:

    HP_Laserjet_2100TN
        Device:  AppSocket/HP JetDirect
        Device URI: socket://10.10.10.99:9100
        Make:   HP (HPLIP)
        Model:  HP Laserjet 2100 Foomatic/hpijs
                or
                HP Laserjet 2100 Series Postscript

    HP_Photosmart_7960
        Device: Internet Printing Protocal (http)
        Device URL: http://10.10.10.98:631/ipp/lpt2
        Make:   HP (HPLIP)
        Model:  HP Photosmart 7960 Foomatic/hpijs

Check by going to Printers/Manage Printers/Print Test Page.

Posted at: 21:36 | category: /configure | Comments ()

Configure xterm

edit ~/.Xdefaults as appropriate

look at /etc/X11/app-defaults/XTerm for ideas about what and how to change

run 'xrdb -merge .Xdefaults' after editing to implement the changes

Posted at: 21:36 | category: /configure | Comments ()

Mailman using Postfix on Debian

    The following is a description on how to set up the list manager Mailman
    on a Debian system that uses Postfix-MySQL-Apache for virtual websites and
    email.  It uses a Python script that makes it unnecessary to make entries
    into /etc/aliases.  But for this Python script to work, you must be
    willing to prefix the FQDN portion of your listname with "lists"...

        correct:  mylist@lists.virtdomain1.org

        incorrect:  mylist@virtdomain1.org

    While this may seem a sacrifice, it can easily be overcome later by simply
    creating an alias in your MySQL table from mylist@virtdomain1.org to
    mylist@list.virtdomain1.org.  This is far easier than adding in all of the
    Mailman aliases that would normally have to be added to /etc/aliases if
    you were not using the Python script.

    1.  Make sure your virtual websites and virtual email setups are all
    working before doing anything with Mailman.

    2.  Install Mailman via apt-get using normal defaults for the base website
    that runs on the server.

    3.  Edit /etc/mailman/mm_cfg.py
        
        add:
            VIRTUAL_HOSTS.clear()
            add_virtualhost('virtdomain1.org','lists.virtdomain1.org')
            add_virtualhost('virtdomain2.org','lists.virtdomain2.org')

        change DEFAULT_EMAIL_HOST to include the prefix 'lists' to the FQDN
        as in:
            DEFAULT_EMAIL_HOST = 'lists.rustybear.com'

        change IMAGE_LOGOS from whatever default is to:
            IMAGE_LOGOS = /'icons'/ 

    4.  copy Mailman images over to default /icons/ directory for Apache

            cp /usr/share/images/mailman/*  /usr/share/apache/icons/.

    5.  Edit /etc/apache/httpd.conf

        for any  you have configured, add in:
            ScriptAlias /mailman/  /usr/lib/cgi-bin/mailman/
        in the  section.

        and in an appropriate place (not within a VirtualHost directive) in
        httpd.conf add in:

            
                Options +FollowSymLinks
            

        you'll need the above to get pipermail (archives) working.

    6.  Get this python script:

        If you are installing via Debian apt-get this section is probably
        mostly done for you, but check anyway.

        http://www.gurulabs.com/files/postfix-to-mailman-2.1.py

        and drop it in /etc/mailman/ and rename it without the version number

            mv postfix-to-mailman-x.xx.py  postfix-to-mailman.py

        edit it by changing the entry for MailmanHome
             MailmanHome = "/var/lib/mailman"; 
        
        the Mailman home directory is where the lists are kept.

        Then cd to /usr/lib/mailman/bin and symlink back to
        postfix-to-mailman.py

            cd /usr/lib/mailman/bin
            ln -s /etc/mailman/postfix-to-mailman.py

    7.  Next go to /etc/mailman/postfix-to-mailman.py and read all of the
        comments/instructions.

        Note that in the recommended changes to /etc/postfix/master.cf, that
        you must set the uid:gid as list:list, not as mailman:mailman.
        This is probably specific to Debian only as the deb package has
        Mailman using 'list' as UID/GID where source versions of Mailman
        probably have 'mailman' as a default UID.

        Note also that in the changes to master.cf, you need to change the
        argv argument to point to /etc/mailman/postfix-to-mailman.py.

        This is also a good time to:

            chmod 755 /etc/mailman/postfix-to-mailman.py
            chown root:list /etc/mailman/postfix-to-mailman.py

        The instructions in postfix-to-mailman.py point out how to set up
        /etc/postfix/tranport and mail.cf.  You can do it that way, or more
        simply, just make an entry in your existing transport setup for MySQL.
        In my case I have a table called transport, where normally I put a
        domain name (i.e. xyz.com) and transport type (usually either virtual:
        or local: ).  However, in this case, the entry I make is:

            domain:     lists.virtdomain1.org
            transport:  mailman:

        Alternatively, you could follow the instructions and make the changes
        to main.cf and transport as that works too.  If you do it that way,
        don't forget to execute

            postmap /etc/postfix/transport

        after making changes to transport to regenerate its data.

    8.  Make sure you have a DNS entry in your DNS server for
        lists.virtdomain1.org, or at least a wildcard entry, that resolves to
        virtdomain1.org.

    9.  Restart Apache and Mailman (/etc/init.d/mailman restart).

    10. To create a new list for one of the virtual websites, at the prompt
        execute:

        newlist myNewList@lists.virtdomain1.org

        It will prompt you for a couple things that are obvious.  Make sure
        you include the 'lists' prefix before the FQDN, as having 'lists'
        there is what makes this whole thing work via the python script we put
        in -- /etc/mailman/postfix-to-mailman.py.

        You should get an email regarding the newly created list you
        just made.

        Note also that simply executing 'newlist --help' gives some help too.
        Also, reading the docs at /usr/share/docs/mailman is a good idea too.
        
        You should now be able to see your admin page at:
        http://lists.virtdomain1.org/cgi-bin/mailman/admin/myNewList

    11. Thing should be working and you should be able to subscribe new users
        and send emails to be posted, etc.  Try sending test posts and
        watching /var/log/syslog or wherever you have you email logs set up
        and watching for errors as the test posts go through Postfix.  It's
        best to watch this live using 'tail -f /var/log/syslog'.

    12. Good luck!

Posted at: 21:36 | category: /configure | Comments ()

samba config

# Global parameters
[global]
        workgroup = HAWKWOOD
        server string = %h server (Samba %v)
        obey pam restrictions = Yes
        passdb backend = tdbsam, guest
        passwd program = /usr/bin/passwd %u
        passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n .
        log level = 5
        syslog = 0
        log file = /var/log/samba/log.%m
        max log size = 1000
        socket options = TCP_NODELAY  SO_RCVBUF=8192  SO_SNDBUF=819
        domain logons = Yes
        os level = 65
        domain master = Yes
        dns proxy = No
        panic action = /usr/share/samba/panic-action %d
        printing = lprng
        printer name = HP_Laserjet
[homes]
        comment = Home Directories
        read only = No
        create mask = 0775
        directory mask = 0775
        guest ok = Yes
[printers]
        comment = All Printers
        path = /tmp
        create mask = 0700
        printable = Yes
        browseable = No
[cdrom]
        comment = Samba sakura's CD-ROM
        path = /cdrom
        guest ok = Yes
        locking = No
        exec = /bin/mount /cdrom
        postexec = /bin/umount /cdrom
[kevin]
        path = /home/kevin
        write list = kosuke,akiko,kevin
        read only = No
        create mask = 0777
        directory mask = 0777
[lp]
        comment = HP_Laserjet
        path = /usr/bin/lp
        read only = No
        create mask = 0700
        guest ok = Yes
        printable = Yes
        printing = bsd
        printer name = lp
        share modes = No
    

Posted at: 21:36 | category: /configure | Comments ()

cygwin + ssh


Download and install cygwin to c:\cygwin.  Select the packages that
make sense, but make sure to include cygrunsrv and openssh packages.

Right click 'My Computer' and under Environment Variables of the Advanced tab,
in the section System variables, add 'CYGWIN' for variable, and 'ntsec tty' for
value.

Also add on to the end of the PATH variable the following: 'c:\cygwin\bin'.

Edit c:\cygwin\cygwin.bat. Make sure it contains these lines - 
you will need to add the line setting the CYGWIN environment variable.

	@echo off
	set CYGWIN=binmode tty ntsec
	C:
	chdir \cygwin\bin
	bash --login -i

Test cygwin to make sure it works. 

	 ls /bin  // to see the cygwin bin directory
	 dir c:   // to see the contents of the C: directory

Type "control d" or 'logout' to exit the shell.


If you get a message saying 'cannot create /home/userid', 
run this command from the cygwin window "mkpasswd -l >/etc/passwd".

Run ssh-host-config to set up the ssh host keys and create the 
sshd_config file in /etc/. You should see output like this:

	$ ssh-host-config
	Generating /etc/ssh_host_key
	Generating /etc/ssh_host_rsa_key
	Generating /etc/ssh_host_dsa_key
	Generating /etc/ssh_config file
	Generating /etc/sshd_config file
	Added ssh to /cygdrive/c/WINNT/system32/drivers/etc/services

Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no)

Answer 'yes' to the prompt. Press 'Return' to accept the default 
at the CYGWIN environment question (default = binmode tty ntsec). 
The service name is CYGWIN sshd.

Type 'cd' to go to your account's home directory. Run ssh-user-config 
to setup your ssh keys. Create only an SSH2 RSA identity (use a null 
passphrase - just press return). Output should be similar to this :

   $ ssh-user-config
   Shall I create an SSH1 RSA identity file for you? (yes/no) no
   Shall I create an SSH2 RSA identity file for you? (yes/no)  (yes/no) yes
   Generating /home/pswander/.ssh/id_rsa
   Enter passphrase (empty for no passphrase):
   Enter same passphrase again:
   Do you want to use this identity to login to this machine? (yes/no) yes
   Shall I create an SSH2 DSA identity file for you? (yes/no)  (yes/no) no


You will probably want to change permissions and ownership on some files:

	cd /; chmod -R og-w .    // note the period
	chmod og+w /tmp
	touch /var/log/sshd.log  // may already be there
	chown SYSTEM:SYSTEM /var/log/sshd.log
	chown SYSTEM:SYSTEM /var/empty
	chown SYSTEM:SYSTEM /etc/ssh_h*
	chmod 755 /var/empty


At the prompt type the following to install sshd as a service:

	cygrunsrv -I sshd -p /usr/sbin/sshd -a '-D' -d 'CYGWIN sshd'

And then the following to start the service:

	cygrunsrv -S sshd

And then test it with:

	ssh localhost

And then test it from another machine.

And if necessary, the following to remove the service

	cygrunsrv -R sshd

There is also more documentation at /usr/doc/Cygwin.

Posted at: 21:36 | category: /configure | Comments ()

Mounting USB devices

lsmod to see what is loaded.  You potentially need:
	usb-storage
	usbcore
	scsi_mod
	sd_mod
	usb-uhci
	input
	sr_mod

If using Debian, apt-get install sg3-utils and then use:

	sg_scan -i		// to see scsi type devices
	sg_map			// to see device associations

Mount the drive found (should be a SCSI drive):

	mount -t vfat   /dev/sdc1   /home/kevin/mnt/usbdevice

Alternatively, make an /etc/fstab entry:

	/dev/sdc1   /home/kevin/mnt/usbdevice  vfat  noauto,user 0 0

Diagnose by checking:

	/var/log/messages
	/var/log/syslog
	/proc/bus/usb		// shows what's been seen
	/proc/scsi/scsi		// to see what scsi devices are there

Notes:  Like any other hard drive, you can use other commands
on your mounted USB storage device:

	fdisk /dev/sdc1			// play with partitions
	mkfs -t vfat /dev/sdc1		// format the partition(s) in FAT
	mkfs -t ext3 /dev/sdc1		// format in Linux ext3 but not a good
					// idea for digital camera disks

Posted at: 21:36 | category: /configure | Comments ()

Nagios configuration

To add a host:
    1.  add the new host to hosts.cfg 
    2.  add the new host to a group in hostgroups.cfg
    3.  make sure the host group has a contact group
    4.  make sure contacts are separate from the site
        being checked  
    5.  check contactgroups.cfg
    6.  make selections in services.cfg 
    7.  add the new host to dependencies.cfg if it
        has any dependencies

To check config settings run
    nagios -v /etc/nagios/nagios.cfg

Posted at: 21:36 | category: /configure | Comments ()

Remap that CapsLock key to Control

Hate the Windows keyboard?  Like the Unix keyboard?
Then remap that CapsLock key.

If using Xfree86 add the following to the InputDevice section of /etc/X11/XF86Config-4

Option "XkbOptions" "ctrl:nocaps"

Also note that Ctrl-[ is the same as hitting the Esc key.

Posted at: 21:28 | category: /vi | Comments ()

Embedding vim option settings in a file

You can use modelines to add Vim option settings to the contents of a file.
For example, in a C file, you can add the following line to the top or the
bottom of the file:

    /* vim: set textwidth=76 nopaste: */

This will set the 'textwidth' option to 76 and not allow pasting, when editing
that C file.  For this to work, the 'modeline' option should be set. By
default, the 'modeline' option is set.

Posted at: 21:28 | category: /vi | Comments ()

Create a thumbnail tack sheet from a directory of pictures

     convert 'vid:*.jpg' thumbnail.png

Posted at: 21:28 | category: /graphics | Comments ()

convert

convert -size 600x480 orig-pic.jpg -resize 600x480 new-pic.jpg

Posted at: 21:28 | category: /graphics | Comments ()

qiv

qiv -fm somepicture.jpg     // view a single picture
        // -f fullscreen on/off
        // -m scale to screen on/off

qiv -fmsd 3 *.jpg           // slideshow
        // -s slideshow on/off
        // -d 3  three second delay

// while viewing, hitting 'd' will send the pic
// to the .qiv-trash directory

Posted at: 21:28 | category: /graphics | Comments ()

import


// to take a screenshot using imagemagick

import myfilename.jpg

// then with cursor either click a window or select a region

Posted at: 21:28 | category: /graphics | Comments ()

mogrify

mogrify -format xpm -geometry 32x32 -map /usr/share/pixmaps/cmap.xpm fileToConvert
	// creates a standardized icon from a pre-existing image


** To create a directory of email-able pics or thumbnails:

cd /path/to/picfolder
cd ..						// back up one level
cp -R picfolder smallpicfolder			// create a duplicate folder
cd smallpicfolder
mogrify -size 800x600 -resize 800x600 *.jpg	// mogrify to email size

Note:  the mogrify operation will overwrite the existing imgages, hence it is
important to make a duplicate folder with all of the images.

Posted at: 21:28 | category: /graphics | Comments ()

Cartoonize A Photo With Gimp

Layer->Duplicate Layer
Select the new layer, the Filters->Edge-Detect->Edge, select Sobel, Amount
should be 2.0, and Black should be checked.
Invert the edge-mask layer ... it's in Layers->Colors->Invert
Back in the Layers Dialog, change the Layer Mode to Divide

Play around with Layer mode settings.  Desaturate the top layer, blue or
otherwise mess up the bottom layer.

Posted at: 21:28 | category: /gimp | Comments ()

Add different fonts to the Gimp

Gimp uses fonts from the fontconfig program.

So simply put the new fonts in your ~/.fonts directory
and then run, as root, dpkg-reconfigure fontconfig.

Posted at: 21:28 | category: /gimp | Comments ()

Mouse double-click in Apple Gimp

If you find that you need to click a window twice to activate it when
moving from window to window in Apple Gimp, then open a terminal and
enter the following:

    defaults write com.apple.x11 wm_ffm true

This will enable "focus follows mouse.  X11 must be restarted for the
change to take effect.

Posted at: 21:28 | category: /gimp | Comments ()

Upgrade a Debian Package with new source using svn-upgrade


download a copy of the new source tarball and place it in /debian-dev/tarballs

cd /debian-dev/calcurse  (just above /debian.  this is the WC [working copy])

svn-upgrade ../tarballs/calcurse-1.2.tar.gz

You'll now have a copy of calcurse in /debian-dev/calcurse that is updated to
the latest source.

You can check changes with

    svn diff

or specific files with

    svn diff TODO

Check the status of the svn repository for calcurse with

    svn status

Go ahead and make changes to things like the debian/changelog file.  Once
you've made all your changes you can commit the changes to the svn repository
with 

    svn commit

You can also do this by specific file

    svn commit src/util.c

Once everything is committed, you can build the package with

    svn-buildpackage -k8CE11941 -rfakeroot

which is executed in the WC (just above /debian).

The packages that are built will show up in /debian-dev/build-area.  You
should linda and lintian check them.

You should also run pbuilder on the WC.  Start this process by executing

    sudo pbuilder update
    sudo pbuilder clean

Then, from the WC, run

    pdebuild

You can then go to /var/cache/pbuilder/results to linda/lintian check the
files that were created by pdebuild.

Once you are satisfied that everything is o.k. and have tested it by
installing, upgrading, etc, then from the WC, run 

    svn-buildpackage -k8CE11941 -rfakeroot --svn-tag
or
    svn-buildpackage -k8CE11941 -rfakeroot --svn-tag-only

This will prepare for the next source release by making an entry in
debian/changelog.

Send the following files to the uploader:

    calcurse_1.2-1.diff.gz
    calcurse_1.2-1.dsc
    calcurse_1.2-1_i386.changes
    calcurse_1.2.orig.tar.gz

That's it.

Posted at: 21:27 | category: /dev | Comments ()

Working with svn-buildpackage

Start by creating a svn repository.  I'm presuming you'll be working from your
home directory --

    svnadmin create svn-repo 
    
... where svn-repo can be any name you want.

Note that this repository [svn-repo or whatever you name it] will be where 
svn manages all of its work.  It is not an area that you will edit.

Next, create a directory where you will do your work.   For me it was --

    mkdir debian-dev
    cd debian-dev

Download the appropriate files:  package.dsc, package.orig.tar.gz, and
package.diff.gz

Now we'll inject an existing source file into the repository --

    svn-inject bbtime_0.1.5-9.dsc file:///home/kevin/svn-repo

You'll see a lot of stuff scroll by, the last line of which should say
something like 

"Your working directory is /home/kevin/debian-dev/bbtime - have fun!"

The svn-inject command actually makes your working directory for you.

For most purposes you'll want to work out of the directory, although you can
create other working directories if you like with the command --

    svn co file:///home/kevin/svn-repo/bbtime

Wherever you execute this command is where the working directory will be
built.  When it is built, you'll see the following tree built:

    bbtime
      |----- branches
      |----- tags
      |----- trunk

You'll want to descend into trunk, where you'll see all of the source files
and a debian/ directory with all of the rules/control files.  Later, when you
execute the svn-buildpackage command, you'll want to do so from this trunk
directory. 

Return back to /home/kevin/debian-dev (or your equivalent).  Make a directory
in here as follows --

    mkdir tarballs
    
... so you should now have:

    home/kevin/debian-dev
        |------------------- bbtime
        |------------------- tarballs

Into the tarballs directory copy the original source tarballs, which should
have a name like bbtime_0.1.5.orig.tar.gz.  You should have been able to
download a copy of this file from the same place you downloaded the .dsc file
(most likely the Package area on Debian.org).

At this point you are ready to do some work.   Remember that svn-inject did
the original checking out of the bbtime working files for you, so you can
simply go to them and start your editing --

    cd /home/kevin/debian-dev/bbtime

... and do your work, most of which will probably be in the debian/ directory.

Once you've done your editing, you'll need to execute various svn commands,
all of which should be executed from the working directory, which is
/home/kevin/debian-dev/bbtime.  Examples of some of these commands:

    svn add debian/newfile
    svn delete debian/oldfile
    svn status
    svn log
    svn diff
    svn commit

This last command - svn commit - must be executed before you can do any
building.  As you execute it, you'll be given a chance to write notes about
the changes you made.

The next step is the actual building.  The command is --

    svn-buildpackage -k8CE11941 -rfakeroot

where -k is your GnuPG key ID and -r sets up fakeroot, which you should have
installed.  

You'll see plenty of screen action, which should end with a few lines that
tell you where everything was built.  If you move up a level in the directory,
you'll now find a new sub-directory called build-area.  This is where all of
the built files are put.  So you should now have a tree like this:

    home/kevin/debian-dev
        |------------------- bbtime
        |--------------------build-area
        |------------------- tarballs

In the build-area you'll find all of your newly generated files:

    bbtime_0.8.3-3.diff.gz
    bbtime_0.8.3-3.dsc
    bbtime_0.8.3-3_i386.changes
    bbtime_0.8.3-3_i386.deb
    bbtime_0.8.3.orig.tar.gz

Obviously you'll want to test everything, including running lintian and linda.

You'll probably want to build a few times as you work out your bugs.  Each
time you change something in bbtime/debian, you'll have to svn commit it to
the repository before you can execute svn-buildpackage again.  And each time
you build, svn-buildpackage will automatically overwrite the files in the
build-area directory, so don't worrying about cleaning that out.

When you are finally happy with your results, you need to tag it as a final
build.  You can do this with one of two commands --

    svn-buildpackage -k8CE11941 -rfakeroot --svn-tag
    or
    svn-buildpackage -k8CE11941 -rfakeroot --svn-tag-only

The first command will build the package and tag it, while the latter command
will just tag it (presumes your earlier builds were satisfactory).

When you tag it, you'll also be making a new debian/changelog entry, which
essentially is preparation for the next time you rebuild the package and
release a new version.

At this point you are basically done.  Make sure you don't delete the working
copy of your package that you have in /home/kevin/debian-dev.  Leave it there
for future versions. 

Before ending this, here's a couple more things to think about that may hang
you up.

First, let's say you've just finished building, are happy with the package,
and you've tagged it, which puts a copy into the repository trunk.  You
send it to your upload sponsor, but he spots a bug and wants you to correct
it.  But you've already finalized and tagged your build.  No problem.  Go to
your working copy - /home/kevin/debian-dev/bbtime - and execute the command --

    svn update

This will refresh your working copy from the repository.  It probably already
is the latest copy, but just in case, update it anyway.  Next go into
debian/changelog and remove the next version entry that the tagging process
created for you.  Make any other bug corrections.  And then execute your svn
commit and then you can build again and eventually tag it.  Your versioning
will still be preserved.

The second hang up that may get you is if you checkout a copy of a package
into a different working area.  Say for instance that you are in /tmp and you
execute --

    svn co file:///home/kevin/svn-repo/bbtime

This will create the following tree for you:

    /tmp/bbtime
        |------- branches
        |------- tags
        |------- trunk

You can descend into trunk, where you'll find all the source files and the
debian/ directory.  You can do all the editing you need and commit all of the
changes back to the repository.  And you can even build a deb by executing the
svn-buildpackage command from the trunk/ directory.  It will create a
build-area directory for like this:

    /tmp/bbtime
        |------- branches
        |------- build-area
        |------- tags
        |------- trunk

... and in this build-area directory you'll find the results of your build.
What you won't find is a .diff.gz file.  That file is only generated if you
are working from the originally created working directory from when you
executed svn-inject.

If you, or someone else, works on a copy of the package checked out from the
repository to a working area not in the original /home/kevin/debian-dev and
commits changes, then make sure next time you work in the original work area -
/home/kevin/debian-dev/bbtime - that you execute svn update to incorporate
their changes into your working copy.   This is basic svn stuff but may be
helpful to those new to all of this.

Good luck!

Posted at: 21:27 | category: /dev | Comments ()

Subversion: new project/repository configuration and some basic commands

As root:
    svn mkdir /var/svn/repo/newproject
    chown -R myUser:svnusers /var/svn/repo/newproject
    (presumes you have a svnusers group)

As a user/owner (myUser) of the newproject:
    svnadmin create /var/svn/repo/newproject

As root:
    chown -R myUser:svnusers /var/svn/repo/newproject
    chmod 664 /var/svn/repo/newproject/db/*

As a user/owner (myUser) of the newproject:
    cd /tmp
    mkdir -p newproject/trunk
    mkdir -p newproject/branches
    mkdir -p newproject/tags

    cd /tmp/newproject/trunk
    cp -pvr /home/newproject/www .

    svn import /tmp/newproject file:///var/svn/repo/newproject -m "initial import"

    cd /tmp
    rm -rf newproject/

To verify results of the import:

    svn list --verbose file:///var/svn/repo/newproject

To export the project without .svn files

    cd [to target export directory]
    svn export file:///var/svn/repo/newproject/trunk/www [option name]

To checkout the project with .svn files

    cd [to target working copy directory]
    svn checkout file:///var/svn/repo/newproject/trunk/www [option name]

svn status [file:///var/svn/repo/newproject]
    prints the status of working copy files and directories

svn diff
    shows changes to the working copy

svn update [file:///var/svn/repo/newproject]
    brings changes from the repository to your working copy
        A == added
        D == deleted
        U == updated
        C == conflict
        G == merged

svn add PATH
    adds files/directories to your working copy and schedules them for
    addition to the repository.  will be uploaded and added to the repository
    during the next commit.  when adding a directory, the default behavior is
    to recurse

svn delete PATH
    schedules PATH for deletion on the next commit.  if PATH is a URL, it will
    immediately delete and a log message must be supplied.  

svn copy SRC DST
    copy a file/directory in your working copy or repository.

svn move SRC DST
    move a file/directory in your working copy or repository.  equivalent to
    svn copy/svn delete.  

    example:  svn move foo.c bar.c

svn commit [--message] [PATH]
    sends changes from working copy to the repository.  alias == ci.

    example:  svn commit -F message foo.c
        this only commits the foo.c file and a message

    svn commit without any args will commit everything

svn log [PATH]
    display all of the commit messages

Posted at: 21:27 | category: /dev | Comments ()