October 2008 Archives

Manually Sync Notes on iPhone or iPod Touch - Part I

| 1 Comment | 0 TrackBacks

Use at your own risk, make sure you backup your notes.db file before you proceed. I am not responsible for any loss of data.

Since the content of the iPhone or iPod Notes application is a sqlite database. You can pull the notes.db file down to your box, modify the notes.db via sqlite and push the file back to your iPhone. Here's how I do this with a mac.

Requirements:
1. Jailbrake iPhone or iPod Touch
2. Install OpenSSH on your iPhone or iPod Touch
3. Install SQLite3 on your Mac (port install sqlite3)

Note: I highly recommend you setup your public keys and modify your sshd_config on your iPhone or iPod Touch to no longer use passwords and only public keys. By now, everybody knows the password to the iPhone or iPod Touch is alpine. (I may setup another page for this later on)

From my mac:
1. Create a subdir called manual_sync_notes and change your directory
mkdir manual_sync_notes
cd manual_sync_notes

2. Pull your notes.db file & make a copy
scp mobile@IP:/private/var/mobile/Library/Notes/notes.db .
cp notes.db notes.db.orig

3. Have a quick look at the notes from your iPhone or iPod touch.
sqlite3 notes.db "select * from note;"

4. Insert a test note into notes.db using the following perl script:


#!/usr/bin/perl

use strict;

my $note_title = $ARGV[0];
my $note_content = $ARGV[1];
my $note_rownum = '';

if ( ! $ARGV[0] ) {
print "Example: $0 Note_Title Note_Content \n";
exit 1;
}

use DBI qw(:sql_types);
my $dbh = DBI->connect("dbi:SQLite:notes.db");

notes_addnote_title();
notes_rowid();
notes_addnote_content();

sub notes_addnote_title {
my $sql = qq { insert into note (creation_date, title, summary, contains_cjk)
values (strftime('%s','now'),'$note_title','$note_content',0)
};
my $sth = $dbh->prepare ( $sql );
$sth->execute();
}

sub notes_rowid {
my $sql = qq { select rowid from note where title = '$note_title' };
my $sth = $dbh->prepare ( $sql );
$sth->execute();

my ( $rowid );
$sth->bind_columns( undef, \$rowid );
while ( $sth->fetch() ) {
$note_rownum = "$rowid \n";
chomp $note_rownum;
}
}

sub notes_addnote_content {
my $sql = qq { insert into note_bodies (note_id, data)
values ('$note_rownum','$note_content')
};
my $sth = $dbh->prepare ( $sql );
$sth->execute();
}

user@osx ~/manual_sync_notes $ ./manual_notes_inject.pl NoteTest NoteTestContent

5. Run a quick query to make sure your note has been insert using the following script.


#!/usr/bin/perl

use strict;

my $note_title = $ARGV[0];
my $note_rownum = '';

if ( ! $ARGV[0] ) {
print "Example: $0 Note_Title \n";
exit 1;
}

use DBI qw(:sql_types);
my $dbh = DBI->connect("dbi:SQLite:notes.db");

notes_rowid();
notes_shownote_content();

sub notes_rowid {
my $sql = qq { select rowid from note where title = '$note_title' };
my $sth = $dbh->prepare ( $sql );
$sth->execute();

my ( $rowid );
$sth->bind_columns( undef, \$rowid );
while ( $sth->fetch() ) {
$note_rownum = "$rowid \n";
chomp $note_rownum;
}
}

sub notes_shownote_content {
my $sql = qq { select data from note_bodies where note_id = '$note_rownum' };
my $sth = $dbh->prepare ( $sql );
$sth->execute();

my ( $data );
$sth->bind_columns( undef, \$data );

while ( $sth->fetch() ) {
print "$data \n";
}
}

user@osx ~/manual_sync_notes $ ./manual_notes_query.pl NoteTest
NoteTestContent

6. Push your notes.db file back to the iPhone or iPod Touch
scp notes.db mobile@IP:/private/var/mobile/Library/Notes/.

This is the best solution I could come up with being that we have no SyncServices in the SDK.

Just in case you want to know the permissions of the file for notes.db. The file should be owned by mobile:wheel with the file permissions of -rw-r--r-- aka 644.

I hope to create a Part II where I can use a native Cocoa app on the Mac to handle the modification of the notes.db and automate the sync to the iPhone or iPod Touch.

Workaround for hellanzb session idle

| 0 Comments | 0 TrackBacks

If your hellanzb session is idle and you have confirmed your news account is fine. Then you may be having an issue with the nzb file itself. You can confirm this by enabling the hellanzb debug log.

An example of what you would see is the following:


Parsed: 22 files (543 posts), 192.7MB
Queued: 192.7MB
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[Total] 0.0KB/s, 192 MB queued, ETA: 00:00:00

As a short & quick workaround, do this:


in NZBParser.py change

elif name == 'group':
newsgroup = self.parseUnicode(''.join(self.chars))
self.file.groups.append(newsgroup)
with

elif name == 'group':
newsgroup = self.parseUnicode(''.join(self.chars)).strip()
self.file.groups.append(newsgroup)

The information for this workaround was found by referring to the following ticket: http://www.hellanzb.com/trac/hellanzb/ticket/393

Configuring VNC on Fedora Core 9

| 0 Comments | 0 TrackBacks
1. yum install vnc-server
2. echo "VNCSERVERS="0:myusername" >> /etc/sysconfig/vncservers
3. chkconfig vncserver on
4. su - myusername -c vncpasswd
5. Uncomment the following from ~myusername/.vnc/xstartup
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
6. echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900 -j ACCEPT" \          >> /etc/sysconfig/iptables
7. service iptables restart
8. service vncserver restart

Using raidctl on Sun T2000

| 0 Comments | 0 TrackBacks
1) boot net -s
2) raidctl -c -r 1 c0t0d0 c0t1d0
3) reboot -- "net - install"
4) jumpstart kicks in

Sun Solaris Link Aggregation (Teaming/Bonding)

| 0 Comments | 0 TrackBacks

Requirements for Link Aggregations
Your link aggregation configuration is bound by the following requirements:
- You must use the dladm command to configure aggregations.
- An interface that has been plumbed cannot become a member of an
aggregation.
- Interfaces must be of the GLDv3 type: xge, e1000g, and bge.
- All interfaces in the aggregation must run at the same speed and in
full-duplex mode.

You must set the value for MAC addresses to true in the EEPROM parameter
local-mac-address?

Example:


1. dladm show-link
2. ifconfig -a
3. dladm create-aggr -d e1000g0 -d e1000g1 1
4. dladm create-aggr -d e1000g2 -d e1000g3 2
5. dladm create-aggr -d e1000g4 -d e1000g5 3
6. ifconfig aggr1 plumb 10.0.0.11 up
7. ifconfig aggr2 plumb 10.0.0.12 up
8. ifconfig aggr3 plumb 10.0.0.13 up
9. dladm show-aggr
10. echo "10.0.0.11" >> /etc/hostname.aggr1
11. echo "10.0.0.12" >> /etc/hostname.aggr2
12. echo "10.0.0.13" >> /etc/hostname.aggr3
13. init 6

Create Sun Solaris Zone (Container)

| 0 Comments | 0 TrackBacks
zonecfg -z 
: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:> 
zonecfg:> set zonepath=/zones/
zonecfg:> remove inherit-pkg-dir dir=/lib
zonecfg:> remove inherit-pkg-dir dir=/platform
zonecfg:> remove inherit-pkg-dir dir=/usr
zonecfg:> remove inherit-pkg-dir dir=/sbin
zonecfg:> set autoboot=true
zonecfg:> add net
zonecfg::net> set address=
zonecfg::net> set physical=
zonecfg::net> end
zonecfg:> verify
zonecfg:> commit
zonecfg:> exit

Sun ALOM SMTP Alert Configuration

| 0 Comments | 0 TrackBacks
setsc if_emailalerts true
setsc sc_customerinfo
setsc mgt_mailhost smtp.example.com
setsc mgt_mailalert 2

1. Connect the console cable to the DB9 port on the T2000 (Cisco provides one which is blue from RJ-45-to-DB-9)
2. Connect the RJ-45 to another console serial device
3. Modify /etc/remote (change /dev/term/b to /dev/term/a):


hardwire:\
:dv=/dev/term/a:br#9600:el=^C^S^Q^U^D:ie=%$:oe=^D:

4. Run tip hardwire and your in

admin@sun2000 ~ $ tip hardwire

Configure SSH Public Key on NetApp Filer

| 0 Comments | 0 TrackBacks
Here's how to configure ssh public key on the Netapp filer. From your host:
ssh-keygen -t dsa -b 2048
telnet 
On the filer:
secureadmin setup ssh
On your host (Mac used an example):
mkdir /mnt
mount -t nfs FILER:/vol/vol0 /mnt
sudo mkdir -p /mnt/etc/sshd/root/.ssh
ls -ltra /mnt/etc/sshd/root/.ssh
cat id_dsa.pub >> /mnt/etc/sshd/root/.ssh/authorized_keys
ssh root@FILER "version"
NetApp Release 7.3: Thu Jul 24 14:18:45 PDT 2008
umount /mnt
rmdir /mnt

Useful MySQL Statements

| 0 Comments | 0 TrackBacks
select * from table limit 10;

drop database customer;
create database customer; 
use customer; 

create table client ( 
 date text, 
 name_last text, 
 comment text 
); 

load data infile "/tmp/customer.txt" into table client
 fields terminated by "\t" 
 lines terminated by "||" 
 ignore 0 lines; 

create database speedtest;
GRANT ALL PRIVILEGES 
       ON user.* 
       TO 'user'@'localhost'
       IDENTIFIED BY 'user' ;
FLUSH PRIVILEGES;


update table set column='B' where column='A';

Apple iPhone Rocks

| 0 Comments | 0 TrackBacks

Here's a quick blog entry written from my new iPhone... very cool!