Tuesday, May 26, 2009

Google Android - map not working in emulator? - how to fix it (in Windows) - by Alan Lupsha

Basically, you need a Google Mpas api key: http://code.google.com/android/add-ons/google-apis/mapkey.html

Example on how to do this:

1. find your debug.keystore file, for example:
C:\Documents and Settings\developer\.android\debug.keystore

2. list the md5:
C:\jdk1.6.0_13\bin>keytool -list -alias androiddebugkey -keystore "C:\Documents and Settings\developer\.android\debug.keystore" -storepass android -keypass android

androiddebugkey, May 18, 2009, PrivateKeyEntry,Certificate fingerprint (MD5): 83:4D:2C:6F:58:B3:D1:EA:2C:AF:0D:FC:70:19:57:D6

Save the fingerprint somewhere, you'll need it later.

3. Sign up for the maps API: http://code.google.com/android/maps-api-signup.html , use your generated MD5 fingerprint

Submission result:

Thank you for signing up for an Android Maps API key!

Your key is:
0h1d_-9Wwhaterver-your-key-is4yNt-SXgQ

This key is good for all apps signed with your certificate whose fingerprint is:
83:4D:2C:6F:58:B3:D1:EA:2C:AF:0D:FC:70:19:57:D6

Here is an example xml layout to get you started on your way to mapping glory:




Go to your project's layout, i.e. in main.xml, look for your MapView definition,
take out android:apiKey="apisamples" and replace it with whatever your key is,
for example: android:apiKey="0h1d_-9Wwhaterver-your-key-is4yNt-SXgQ"

or, if you didn't define your mapView in XML, but instead you did it in code, use:
mMapView = new MapView(this, "0h1d_-9Wwhaterver-your-key-is4yNt-SXgQ");

Also, make sure that in your manifest, you have this defined:

Monday, May 25, 2009

Linux: how to send emails with attachments from the command line

echo "Sending an attachment " | mutt -a my-superb-tar-file.tar -s "attachment" alan75@my-fun-domain.com

Friday, May 22, 2009

How to stop and restart subversion using a simple script

1. create the svn restart script:
sudo nano /etc/init.d/restartsvn

sudo cat /etc/init.d/restartsvn
#!/bin/bash
echo This is a startup script to stop and restart subversion - Alan

echo Now stopping previous svn instance...
sudo kill -9 `ps aux | grep -i svn | grep -i listen-host | grep -v grep | awk '{print $2}'`

echo Sleeping 3 seconds...
#sleep 3 seconds
sleep 3

echo Now starting svn for you: /usr/bin/svnserve -d --listen-host 10.0.0.10 -r /srv/svn
/usr/bin/svnserve -d --listen-host 10.0.0.10 -r /srv/svn

echo The process id of the new svn instance is:
echo `ps aux | grep -i svn | grep -i listen-host | grep -v grep | awk '{print $2}'`
echo Done


2. make the script executable
sudo chmod u+x /etc/init.d/restartsvn

3. execute the script
sudo /etc/init.d/restartsvn

Thursday, May 21, 2009

Java - how to keep your instance NamingEnumeration object and iterate through it without .next() killing it


Problem: You have a NamingEnumeration and want to keep untouched, while passing it to different methods that need to iterate through it. Error: doing a namingOperation.next() walks the object, and when you reach the end, there's no .moveToFront() method, which allows you to re-use the NamingEnumeration object.

Solution: use Collections.list( namingEnumeration ), which returns an ArrayList. Then, instantiate a new copy of the original ArrayList and then use this copy, with an Iterator, walking each element of the arrayList object.

The example below is of a NamingEnumeration A which is made up of many NamingEnumerations B, which are made up of some NamingEnumerations C. (basically it's an LDAP naming enumeration result after performing a dirContext.search( ... )


See, this won't work:

public static void printAllAttributes( NamingEnumeration originalNamingEnumeration )


// used only to create copy
ArrayList arrayListBackup = Collections.list( originalNamingEnumeration );

// create copy
ArrayList arrayList = new ArrayList( arrayListBackup );
...
because the originalNamingEnumeration gets "exhausted" after Collections.list() is called.
So, your only option is to get the original NamingEnumeration, convert it to an ArrayList:

NamingEnumeration namingEnumeration = dirContext.search( searchBase, searchFilter, searchControls );
ArrayList tempArrayList = Collections.list( namingEnumeration );
and forget about it:

namingEnumeration.close();
namingEnumeration = null;
Then, make as many copies of that tempArrayList, and use those copies:

ArrayList arrayListCopy1 = new ArrayList( tempArrayList );
... do whatever
ArrayList arrayListCopy2 = new ArrayList( tempArrayList );
... do whatever
ArrayList arrayListCopy3 = new ArrayList( tempArrayList );
In my case, I want to keep the search results of an LDAP query, which is stored
in a NamingEnumeration, and then call different methods on the search results,
which iterate on the NamingEnumeration, screwing it up. So, keeping the search results
in a globally defined ArrayList object allows me to use it later. Final search routing looks as such:


public int search( String searchBase, String searchFilter )
{
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
try
{
NamingEnumeration namingEnumeration = dirContext.search( searchBase, searchFilter, searchControls );
ArrayList tempArrayList = Collections.list( namingEnumeration );
namingEnumeration.close();
namingEnumeration = null;

this.lastSearchResultArrayList = new ArrayList( tempArrayList );
tempArrayList = null;
}
catch ( NamingException e )
{
logerror("Error while searching: " + e.toString() );
return -1;
}
return 0;
}

Thursday, May 14, 2009

Java - Rot94 - similar to rot13 - encode text





public class NinetyFiveEncode
{
public NinetyFiveEncode()
{
String testStr = "The rain in Spain falls mainly on the plain. Call me at (555)112-xxxx. {:-) Bye.";
String encoded = NinetyFiveEncode.rot94(testStr);
System.out.println( encoded );
String decoded = NinetyFiveEncode.rot94( encoded );
System.out.println( decoded );
}

/*
* Rot94 by Alan Lupsha (c)2009
*
* Takes a string of characters, and for every character
* between ASCII value 33 and 126 (! to ~), it adds 94 to
* the character value (wraps around if the result character
* is larger than 126)
*
* Any non-printable characters and the space character
* (i.e. any char smaller than 33 and larger than 126) gets
* copied over.
*
* Sample run:
*
* String testStr = "The rain in Spain falls mainly on the plain. Call me at (850)879-xxxx. {:-) Bye.";
* String encoded = NinetyFiveEncode.rot94(testStr);
* System.out.println( encoded );
* String decoded = NinetyFiveEncode.rot94( encoded );
* System.out.println( decoded );
*
* %96 C2:? :? $A2:? 72==D >2:?=J @? E96 A=2:?] r2== >6 2E Wgd_Xgfh\IIII] Li\X qJ6]
* The rain in Spain falls mainly on the plain. Call me at (850)879-xxxx. {:-) Bye.
*/
public static String rot94(String plainText)
{
if (plainText == null) return "";

// encode plainText
StringBuffer encodedMessage = new StringBuffer("");
int abyte;
for (int i = 0; i < abyte =" plainText.charAt(i);">= 33) && (abyte <= 126 ))
abyte = (abyte - '!' + 47) % 94 + '!';

encodedMessage.append( (char)abyte );
}
return encodedMessage.toString();
}


public static void main( String[] args )
{
NinetyFiveEncode ninetyFiveEncode = new NinetyFiveEncode();
}
}


Wednesday, May 13, 2009

How to check the status of your Android phone purchased from Brightstarcorp through Google

1. Go to: http://android.brightstarcorp.com/trackorder.php

If you are logged into your Google account, the page will display the status of your order right away. Ex: "Pending shipment" Else, log in and see your status.


2. Call Brightstarcorp at 877-727-9789 and ask to track your order, and give them your order number which you received in the email right after you purchased your phone. This will likely mean that they'll send out the phone today instead of waiting another 7 days to mail you your phone (even if you already paid for FedEx overnight delivery)

Thursday, April 30, 2009

How to get dates as a String

public String getToday() {
SimpleDateFormat sdfbeginDate = new SimpleDateFormat("MM/dd/yyyy");
return sdfbeginDate.format(Calendar.getInstance().getTime());
}

public String getNowAsTimestampString() {
Calendar nowCalendar = Calendar.getInstance();
java.util.Date myDate = nowCalendar.getTime(); // ex: Thu Aug 09 13:20:36 EDT 2014
SimpleDateFormat sdf = new SimpleDateFormat( "MM/dd/yyyy/HH/mm/ss");
return sdf.format( myDate );
}

public String getNowAsDateString() {
Calendar nowCalendar = Calendar.getInstance();
java.util.Date myDate = nowCalendar.getTime(); // ex: Thu Aug 09 13:20:36 EDT 2014
SimpleDateFormat sdf = new SimpleDateFormat( "MM/dd/yyyy");
return sdf.format( myDate );
}

Tuesday, April 28, 2009

How to sync all your servers to use the same date and time

1. edit the ntpdate file:

root@Knoppix:/etc# cat /etc/default/ntpdate
# The settings in this file are used by the program ntpdate-debian, but not
# by the upstream program ntpdate.

# Set to "yes" to take the server list from /etc/ntp.conf, from package ntp,
# so you only have to keep it in one place.
NTPDATE_USE_NTP_CONF=no

# List of NTP servers to use (Separate multiple servers with spaces.)
# Not used if NTPDATE_USE_NTP_CONF is yes.
#NTPSERVERS="0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org"

NTPSERVERS="swisstime.ee.ethz.ch"

# Additional options to pass to ntpdate
NTPOPTIONS=""



2. invoke a time synchronization

root@Knoppix:/etc# ntpdate-debian
28 Apr 20:33:50 ntpdate[15046]: adjust time server 129.132.2.21 offset 0.370255 sec
root@Knoppix:/etc#


3. set up a cron job to invoke the time synchronization:

root@Knoppix:/# crontab -e

# every night at 2 am, sync/update the time
0 2 * * * ntpdate-debian


4. Optionally, update your time zone, by creating a symbolic link for /etc/localtime to the timezone of your choice. Example:

root@Knoppix:/ # ln -sf /usr/share/zoneinfo/EST /etc/localtime
(this changes the timezone to EST)

root@Knoppix:/ # ln -sf /usr/share/zoneinfo/GMT /etc/localtime
(this changes the timezone to GMT)

Monday, April 6, 2009

How to call a procedure using an OracleCallableStatement

OracleCallableStatement oracleCallableStatement = null;

try
{
oracleCallableStatement = (OracleCallableStatement)connection.prepareCall( YOUR_PROCEDURE );
oracleCallableStatement.setString( 1, VARIABLE_1 );
oracleCallableStatement.setString( 2, VARIABLE_2 );
oracleCallableStatement.setString( 3, VARIABLE_3 );
oracleCallableStatement.registerOutParameter(4, oracle.jdbc.OracleTypes.CURSOR);

oracleCallableStatement.execute();
rs = (ResultSet)oracleCallableStatement.getObject(4);
}
catch ( Exception e )
{
logerror("Error while setting up Oracle procedure. Error is: " + e.toString() );
fatalexit();
}

Wednesday, April 1, 2009

Simple shell scripting - how to test 4 Seagate drives

Title: Testing 4 seagate drives concurrently, 10 times each, and dumping all the results in different files, in different directories.

Downloaded the seagate test "st" utility. The command to run an extensive test on a drive is:

./st -G device
ex:
./st -G /dev/sg0
./st -G /dev/sg1
./st -G /dev/sg2
./st -G /dev/sg3


1. create 4 directories to dump each set of tests in:
mkdir TESTsg0
mkdir TESTsg1
mkdir TESTsg2
mkdir TESTsg3

2. create a run.sh script which takes as arguments the run number (a number such as 1, 2, 3 ... ) and the device to scan, such as sg0, sg1, sg2, sg3. This script outputs the result of the run into the TESTSG# directories created above. For example, running ./run.sh 8 sg3 will dump the outputs of the test into directory and file TESTsg3/test8sg3.txt

#!/bin/sh
RUN=$1
SG=$2
if [ "$RUN" == "" ] ; then
echo "You must run with an argument of the run number: ./run.sh 5 sg0"
RETURNCODE=1
exit $RETURNCODE
fi
echo "Now executing for run $RUN"
./st -G /dev/"$SG" > ./TEST"$SG"/test"$RUN""$SG".txt


3. create a script to test each drive individually, doing 10 runs.

sg0tests.sh

#!/bin/sh
./run.sh 1 sg0
./run.sh 2 sg0
./run.sh 3 sg0
./run.sh 4 sg0
./run.sh 5 sg0
./run.sh 6 sg0
./run.sh 7 sg0
./run.sh 8 sg0
./run.sh 9 sg0
./run.sh 10 sg0

for sg1tests.sh, sg2tests.sh, and sg3tests.sh, replace the sg0 argument with sg1, sg2, and sg3, respectively.


4. To watch the processes while they're running, create a script called myps.sh:

#!/bin/sh
while true
do
clear
ps aux | grep run.sh | grep -v grep
sleep 3
done

Thursday, March 26, 2009

The Purpose

Our purpose here is not defined in nature's harmony and carbon traces.
The lab assistant who made us all, has gone to work on other cases.

We ask ourselves why we are here, yet none of us today can say,
if our purpose serves another purpose, like others just like us in Milky Way..

The neighboring swirls may have the answer, and we must find the ways to go,
and talk to all and figure out,
if we all really matter.

When we have understood all that exists, then we shall all decide.

If we exist with purpose, fine. Enlightenment will then soothe the soul.
If not, then our purpose will have been,
To search the meaning of it all.

Wednesday, March 25, 2009

Ubuntu - software Raid5: recovering from a failing drive

- Check integrity of array:
hdparm -i -v /dev/md0

- Unmount the raid:
root@gamma:~# umount /mnt/r5/
umount: /mnt/r5: device is busy
umount: /mnt/r5: device is busy

- Find out the process that's keeping the drive busy:
root@gamma:~# fuser -m /dev/md0
/dev/md0: 5670c

- Look up the process:
root@gamma:~# ps auxw | grep 5670
root 5670 0.4 0.0 8792 3200 ? S 19:25 0:34 /usr/sbin/smbd -D

- Ah, it's Samba, stop it:
root@gamma:~# /etc/init.d/samba stop
* Stopping Samba daemons...

- Try again to unmount:
root@gamma:~# umount /mnt/r5/
root@gamma:~#


- Take a detailed look at the raid array:
mdadm --query --detail /dev/md0


...

Number Major Minor RaidDevice State
0 0 0 - removed
1 8 16 1 active sync /dev/sdb
2 8 32 2 active sync /dev/sdc
3 0 0 - removed

4 8 0 - faulty /dev/sda
5 8 48 - spare /dev/sdd


Found a faulty drive: /dev/sda


- tell the array the drive that is faulty:
root@gamma:~# mdadm -f /dev/md0 /dev/sdd
mdadm: set /dev/sdd faulty in /dev/md0

- hot remove the faulty drive
root@gamma:~# mdadm --remove /dev/md0 /dev/sdd
mdadm: hot removed /dev/sdd

- walk over to server and pysically remove drive.
If you don't know which one is the right drive,
remove one at a time, and then run
mdadm --query --detail /dev/md0
and see which drive is no longer there

- insert a new (and good) hard drive. Add it:
root@gamma:~# mdadm -add /dev/md0 /dev/sdd
mdadm: hot added /dev/sdd

- watch the recovery
watch cat /proc/mdstat

Every 2.0s: cat /proc/mdstat Tue Mar 24 22:45:58 2009

Personalities : [raid5]
md0 : active raid5 sdd[4] sda[0] sdc[2] sdb[1]
1465159488 blocks level 5, 64k chunk, algorithm 2 [4/3] [UUU_]
[>....................] recovery = 0.0% (20224/488386496) finish=19245.9min speed=421K/sec

unused devices:

It seems that this will take 19,000 minutes, which is 13 days. Ugh.

Tuesday, March 24, 2009

Ubuntu - how to set up Samba

1. Install Samba:

root@gamma:~# aptitude install samba
Reading package lists... Done
Building dependency tree... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
The following packages have been kept back:
akregator apt apt-utils base-files bind9-host bsdutils bzip2 coreutils cpio cupsys cupsys-bsd cupsys-client dbus debconf debconf-i18n dnsutils
dpkg dselect e2fslibs e2fsprogs enscript file firefox gnupg gzip hpijs hplip hplip-data hplip-ppds imagemagick info initramfs-tools iptables
kaddressbook karm kdepim-kio-plugins kdepim-kresources kdepim-wizards klogd kmail kmailcvt knotes kontact korganizer libavahi-client3
libavahi-common-data libavahi-common3 libavahi-qt3-1 libbind9-0 libblkid1 libbz2-1.0 libcomerr2 libcupsimage2 libcupsys2 libcurl3 libcurl3-gnutls
libdbus-1-2 libdbus-glib-1-2 libdbus-qt-1-1c2 libdns21 libexif12 libfreetype6 libgadu3 libgnutls12 libisc11 libisccc0 libisccfg1 libjasper-1.701-1
libkcal2b libkdepim1a libkleopatra1 libkmime2 libkpimexchange1 libkpimidentities1 libkrb53 libksieve0 libktnef1 liblcms1 liblwres9 libmagic1
libmagick9 libmimelib1c2a libmysqlclient15off libnspr4 libnss3 libperl5.8 libpng12-0 libpq4 libruby1.8 libsasl2 libsasl2-modules libsnmp-base
libsnmp9 libss2 libssl0.9.8 libuuid1 libvorbis0a libvorbisenc2 libvorbisfile3 libxine-main1 libxml2 linux-image-2.6.15-26-server
linux-image-server linux-server locales login lvm2 mount mysql-client-5.0 mysql-common mysql-server-5.0 ntpdate openoffice.org openoffice.org-base
openoffice.org-calc openoffice.org-common openoffice.org-core openoffice.org-draw openoffice.org-impress openoffice.org-java-common
openoffice.org-kde openoffice.org-l10n-en-us openoffice.org-math openoffice.org-writer openssh-client openssh-server openssl passwd perl perl-base
perl-modules perl-suid popularity-contest python-crypto python-uno python2.4-crypto python2.4-dbus python2.4-libxml2 rsync ssh sysklogd tar
tcpdump tk8.4 ttf-opensymbol udev util-linux vim vim-common vim-runtime w3m xterm
The following NEW packages will be installed:
samba
0 packages upgraded, 1 newly installed, 0 to remove and 152 not upgraded.
Need to get 2852kB of archives. After unpacking 7262kB will be used.
Writing extended state information... Done
Get:1 http://archive.ubuntu.com dapper-updates/main samba 3.0.22-1ubuntu3.8 [2852kB]
Fetched 2852kB in 2m37s (18.1kB/s)
Preconfiguring packages ...
Selecting previously deselected package samba.
(Reading database ... 67170 files and directories currently installed.)
Unpacking samba (from .../samba_3.0.22-1ubuntu3.8_i386.deb) ...
Setting up samba (3.0.22-1ubuntu3.8) ...
Generating /etc/default/samba...
TDBSAM version too old (0), trying to convert it.
TDBSAM converted successfully.
account_policy_get: tdb_fetch_uint32 failed for field 1 (min password length), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 2 (password history), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 3 (user must logon to change password), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 4 (maximum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 5 (minimum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 6 (lockout duration), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 7 (reset count minutes), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 8 (bad lockout attempt), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 9 (disconnect time), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 10 (refuse machine password change), returning 0
* Starting Samba daemons... [ ok ]
root@gamma:~#


2. Create group samba:
root@gamma:~# groupadd samba

3. Add user my_user_id to group samba:
root@gamma:~# usermod -a -G samba my_user_id

4. Edit the smb.conf file, uncomment what you want to be used:
root@gamma:~# nano /etc/samba/smb.conf

5. Add users who can access samba shares:
root@gamma:/etc/samba# smbpasswd -a my_user_id
New SMB password:
Retype new SMB password:
root@gamma:/etc/samba#

6. If you need to make more changes to your smb.conf, restart samba after you're done:
root@gamma:/etc/samba# /etc/init.d/samba restart

How to set up Raid5 in Ubuntu

How to set up raid5:

Setting up raid5 with 4 drives, 500gb each. Using a SIL hardware sata drive controller, and setting up software raid.

1. update and install package mdadm
apt-get update
apt-get install mdadm

2. Use the 4 devices to create md0
mdadm --create /dev/md0 --level=raid5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

2b. If the array is already started, stop it.
mdadm --stop /dev/md0

3. Assemble the array
root@gamma:~# mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm: /dev/md0 has been started with 3 drives (out of 4) and 1 spare.

Live watch of the array building:
watch cat /proc/mdstat

Wait many hours...

I believe the wait here was about 6 hours.


4. Create the file system:

root@gamma:~# mkfs.ext3 /dev/md0
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
183156736 inodes, 366287952 blocks
18314397 blocks (5.00%) reserved for the super user
First data block=0
11179 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: 158/11179
...

This command hangs for me, waiting at 158 forever. I even tried doing a kill -9 on the process, with no luck. Even a shutdown -now didn't work, so I had to do a hard boot. Then, I tried the following command:


4b. Try, try again, use mke2fs instead of mkfs.ext3

root@gamma:~# mke2fs /dev/md0
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
183156736 inodes, 366289872 blocks
18314493 blocks (5.00%) reserved for the super user
First data block=0
11179 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: 427/11179
...
and that updated slowly, without hanging.
...

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@gamma:~#

5. use fdisk to create one partition for the whole md0
root@gamma:~# fdisk /dev/md0

Command (m for help): p

Disk /dev/md0: 1500.3 GB, 1500323315712 bytes
2 heads, 4 sectors/track, 366289872 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-366289872, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-366289872, default 366289872):
Using default value 366289872

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
root@gamma:~#


6. Restart the system:
shutdown -r now

7. Create a directory in /mnt
mkdir /mnt/r5

8. Mount the md0 device:
mount /dev/md0 /mnt/r5/

9. Check how much space is available on the drive:

root@gamma:/mnt/r5# df -h /mnt/r5
Filesystem Size Used Avail Use% Mounted on
/dev/md0 1.4T 20K 1.3T 1% /mnt/r5
root@gamma:/mnt/r5#

... and we have 1.4 Terrabytes. All ok.

Wednesday, March 11, 2009

Standard Ubuntu Setup

----
-> After installing Ubuntu:

-> log in, change root password
sudo passwd root
----
-> as root:
apt-get install ssh
apt-get install unzip zip
apt-get install build-essential



apt-get install mysql-server-5.0
* Root password is blank. To change it use:
* /etc/init.d/mysql reset-password
----
-> setup static ip
sudo vi /etc/network/interfaces
iface eth0 inet static
address 192.168.0.102
netmask 255.255.255.0
network 192.168.0.1
broadcast 192.168.0.255
gateway 192.168.0.1
----
Set up the name servers
sudo nano /etc/resolv.conf , and add:

search yahoo.com
nameserver 216.162.128.6
nameserver 216.162.128.5
(your DNS servers are specific to your internet provider)

then,
sudo /etc/init.d/networking restart

To see if it worked,
ping google.com
and it should resolve google.com to its actual IP
----
-> as username, vi .bashrc to set up paths
export PATH=/opt/jdk1.6.0_04/bin:$PATH
export JAVA_HOME="/opt/jdk1.6.0_04"
export CLASSPATH=.:/opt/jdk1.6.0_04
----
-> grab jdk from another PC
scp username@192.168.0.202:/root/software/jdk-6u4-linux-i586.bin .
----
-> benchmark Sieve
wget http://rsb.info.nih.gov/nih-image/java/benchmarks/Sieve.java
----
How to set hard drives to go into standby mode after 10 minutes:

sudo hdparm -S 120 /dev/hda
----
How to save your hard drive from being hammered by Ubuntu power saver:

- based on http://www.breakitdownblog.com/ubuntu-power-saver-settings-could-damage-hard-drive/ :

1. Make a file named 99-hdd-spin-fix.sh The important thing is starting with 99.
2. Make sure the file contains the following 2 lines (fix it if you have PATA HDD):

#!/bin/sh
hdparm -B 255 /dev/sda

3. Copy this file to 3 locations:

/etc/acpi/suspend.d/
/etc/acpi/resume.d/
/etc/acpi/start.d/
----
The "perfect" Ubuntu setup:
http://www.howtoforge.com/perfect_setup_ubuntu_6.06
----
Install mail server:

apt-get install postfix
- run through the setup
----
Install KDE or GNOME: From: http://www.psychocats.net/ubuntu/kde

> sudo aptitude update && sudo aptitude install kubuntu-desktop

During the installation process, you should be asked whether you want to use KDM or GDM as your default display manager. The default can always be changed later by modifying the /etc/X11/default-display-manager file. For KDM, the file should read /usr/bin/kdm; for GDM, the file should read /usr/sbin/gdm . When KDE is done installing, log out. If you're using 6.06 or later, once you get to the login screen, click on Options and then Select Session. In older versions of Ubuntu (5.10 or earlier), you would have a separate Session button instead of drilling down to Session from Options. In the Sessions dialogue, select KDE and then Change Session.

Finally, before you log back in again, decide whether you want to change to KDE just for this session or if you want to make KDE your default desktop environment. Then, log back in, and you should be using KDE. To switch back to Gnome, just log out and select Gnome from the session menu.

If you later decide you don't want KDE any more, go back to the terminal and paste in
> sudo aptitude remove kubuntu-desktop
----
Install VPN:

sudo apt-get install vpnc
sudo apt-get install network-manager-vpnc
----
http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
cat /proc/cpuinfo
top -n 1 -b | head
Useful admin commands: http://www.reallylinux.com/docs/admin.shtml
----
How to install mysql:

1. download mysql, ex: mysql-5.0.51a-linux-i686.tar.gz

2. add groups
shell> groupadd mysql
shell> useradd -g mysql mysql

3. gzip and untar into /usr/local/mysql
shell> cd /usr/local
shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf - shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data

4. How to start the daemon:
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &

----
How to use Xterm with Xming:

username@gamma:~$ xterm Xt error: Can't open display:
xterm: DISPLAY is not set
username@gamma:~$ export DISPLAY=gamma:0.0

In putty, under Connection, Ssh, X11, check the "Enable X11 forwarding" box, and in the X-display location field type localhost:0 Save this Putty entry, load it, open connection to server.

username@server:~$ xterm &
[1] 4513
----
Installing kde:
apt-get install kubuntu-desktop
(it's over 1200MB)
----
How to disable the kde logon screen from showing at start up:

echo "false" | sudo tee /etc/X11/default-display-manager

(simply placing the word false in the file, and then restarting, should disable the kdm logon screen)

- Another option would be to change the execute rights on the /etc/init.d/kdm startup script:
chmod a-x /etc/init.d/kdm
----
How to restart apache:
/etc/init.d/apache2 restart

Virtual hosts:
nano /etc/apache2/sites-available/default

Example of setting up a virtual host (do this for both digitalagora.com and www.digitalagora.com):

ServerName www.digitalagora.com
DocumentRoot /srv/websites/digitalagora.com
LogLevel notice
CustomLog /var/log/apache2/digitalagora.com-custom.log combined
ErrorLog /var/log/apache2/digitalagora.com-error.log

----

Sunday, March 8, 2009

Memories...

This is some text
Which I have once written,
Thinking intensely
To occupy my mind.
Yet however hard
I did try to ponder,
Over hours and hours
No thoughts could I find.

Thursday, February 26, 2009

Super awesome Java form POST command line program



/*

This posts data to myserver to a Struts action, sending form data which then
gets transmitted to the crystal reports server. If the connection to the
crystal server can't be made, an error is displayed, and email(s) are sent.

Sample run:

[lupsha@myserver ~]$ /opt/SDK/jdk/bin/javac SimplePoster.java
[lupsha@myserver ~]$ /opt/SDK/jdk/bin/java SimplePoster
OK: Crystal server is UP
[lupsha@myserver ~]$




*/

import java.net.URLConnection;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.lang.Runtime;


public class SimplePoster
{

public SimplePoster()
{
try {

String postUrlStr = "http://MyServer/MyApp/mystrutsaction.do";

URL url = null;
url = new URL( postUrlStr );


URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.2)");
urlConnection.setRequestProperty("Referer", "http://www.google.com" );
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");


String myForm = "showCriteria=Yes&rawData=Yes&methodID=*&status=*&action=Submit";
urlConnection.setRequestProperty("Content-Length", myForm.length() + "");


OutputStream os = urlConnection.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os));

writer.write(myForm);
writer.flush();
writer.close();


InputStream ins = urlConnection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
String str = "";
StringBuffer returnStringBuffer = new StringBuffer("");
while((str = reader.readLine()) != null)
{
returnStringBuffer.append(str);
}

// System.out.println( returnStringBuffer.toString() );
if( returnStringBuffer.indexOf( "CrystalCompositeViewState" ) != -1 )
System.out.println("OK: Crystal server is UP");
else
{
System.out.println("BAD: Crystal server is DOWN!");
String command = "";
command += "/bin/echo \"Crystal server is down\"";
command += " | mail -s \"Crystal Server Down\" alan.lupsha@my.awesome.domain";
Runtime.getRuntime().exec(command);
}


} catch( Exception e )
{
System.out.println("Exception: " + e.toString() );
}


}



public static void main(String args[])
{
SimplePoster simplePoster = new SimplePoster();
}


}

How to send email from the Linux shell

/bin/echo "My custom message" | mail -s "My custom topic" alan.lupsha@my.email.address

Thursday, February 12, 2009

Stock market prediction formula

Market prediction M(H,S,t) is the extrapolation of data, in market M, given a history H on the delta(S,N), where S is the symbol being watched, and N is the set of neighbor symbols, observed over time t.

Friday, February 6, 2009

Wednesday, February 4, 2009

How to invoke maven to perform a jar library install

Invoke this installjar with:
sudo -u maven /home/maven/installjar $1 $2 $3 $4
Don't forget to add your user to the sudoers file.


> cat installjar
#!/bin/sh

# ==========================================
# by Alan Lupsha, 02/04/2009
# Installs a jar into the Maven2 repository
# ==========================================

GROUP=$1
ARTIFACT=$2
VERSION=$3
JARPATH=$4

MAVEN_DIR=/home/maven
export JAVA_HOME=/opt/SDK/jdk

checkUserArgs()
{
if [ "$GROUP" = "" ] ; then
syntax
fi
if [ "$ARTIFACT" = "" ] ; then
syntax
fi
if [ "$VERSION" = "" ] ; then
syntax
fi
if [ "$JARPATH" = "" ] ; then
syntax
fi

if [ -s "$JARPATH" ] ; then
echo "[ALAN] OK: file exists: $JARPATH"
else
echo "[ALAN] Error: file does not exist: $JARPATH"
echo "[ALAN] Make sure to upload the file there first, before executing the script"
RETURN_CODE=1
exit $RETURN_CODE
fi
}

syntax()
{
echo "[ALAN] ERROR: Please use the following syntax: ./installjar group artifact version path"
echo "[ALAN] "
echo "[ALAN] EXAMPLE: "
echo "[ALAN] To install jar file called servlet1.3.jar from your local directory, by placing it "
echo "[ALAN] in group basej2ee with the name servlet and version 1.3, do the following: "
echo "[ALAN] 1. FTP your jar into your directory, example: /home/smith_j/servlet1.3.jar"
echo "[ALAN] 2. Execute: ./installjar basej2ee servlet 1.3 ~/servlet1.3.jar "
echo "[ALAN] "
echo "[ALAN] 3. In your project's pom.xml file add the following dependency: "
echo "[ALAN] <dependency>"
echo "[ALAN] <groupId>basej2ee</groupId>"
echo "[ALAN] <artifactId>servlet</artifactId>"
echo "[ALAN] <version>1.3</version>"
echo "[ALAN] </dependency>"
echo "[ALAN] "
echo "[ALAN] Good luck."
RETURN_CODE=1
exit $RETURN_CODE
}

installFile()
{
/bin/mkdir $MAVEN_DIR/projects/
cd $MAVEN_DIR/projects/

COMMAND="/maven/maven-2.0.6/bin/mvn install:install-file -DgroupId=$GROUP -DartifactId=$ARTIFACT -Dversion=$VERSION -Dpackaging=jar -Dfile=$JARPATH"
echo "[ALAN] Executing command: "
echo "[ALAN] $COMMAND"

/maven/maven-2.0.6/bin/mvn install:install-file -DgroupId=$GROUP -DartifactId=$ARTIFACT -Dversion=$VERSION -Dpackaging=jar -Dfile=$JARPATH

echo "[ALAN] "
echo "[ALAN] Don't forget to add the following dependency in your project's pom.xml file:"
echo " <dependency>"
echo " <groupId>$GROUP</groupId>"
echo " <artifactId>$ARTIFACT</artifactId>"
echo " <version>$VERSION</version>"
echo " </dependency>"
echo "[ALAN] "
echo "[ALAN] If the install was successful, then you can remove your jar file from: $JARPATH "
}


checkUserArgs
installFile
echo "[ALAN] Finished! (questions, comments, concerns - email "

mySQL versus Oracle data types





Shell script to use Maven2 to build jar libraries

Invoke this bldjar with:
sudo -u maven /home/maven/bldjar $1 $2 $3 $4
Don't forget to add your user to the sudoers file.

> cat bldjar



#!/bin/sh
# ===================================================================
# This script builds a maven2 jar project, commits the new jar to CVS
# and optionally registers the new jar as a reusable library in maven.
# Alan Lupsha
# ====================================================================

# environment variables
export JAVA_HOME=/opt/SDK/jdk
export CVSROOT=/maven/cvsroot

PROJECT=$1
REGISTER_JAR=$2
GROUP=$3
ARTIFACT=$4
MAVEN_DIR=/home/maven
LAST_UPDATE="2009.02.04"
OK_TO_REGISTER_JAR="no"

check_user_arguments()
{
if [ "$PROJECT" = "" ] ; then
echo "[ALAN] You must pass the project name as an argument! ex: sudo -u maven /home/maven/bldjar my-abc"
PROJECT="noProjectSpecified"
RETURN_CODE=1
OK_TO_REGISTER_JAR="no"
exit $RETURN_CODE
fi

if [ "$REGISTER_JAR" = "registerjar" ] ; then
if [ "$GROUP" = "" ] ; then
echo "[ALAN] Error: invalid group. You asked to register the jar in group ->$GROUP<-"
echo "[ALAN] Syntax: bldjar registerjar GROUP ARTIFACT"
RETURN_CODE=1
OK_TO_REGISTER_JAR="no"
exit $RETURN_CODE
else
echo "[ALAN] Registering jar: group is ok: $GROUP"
fi
if [ "$ARTIFACT" = "" ] ; then
echo "[ALAN] Error: invalid artifact. You asked to register the jar using artifact ->$ARTIFACT<-"
echo "[ALAN] Syntax: bldjar registerjar GROUP ARTIFACT"
RETURN_CODE=1
OK_TO_REGISTER_JAR="no"
exit $RETURN_CODE
else
echo "[ALAN] Registering jar: artifact is ok: $ARTIFACT"
OK_TO_REGISTER_JAR="yes"
fi
else
REGISTER_JAR="dontregisterjar"
fi
echo "[ALAN] Your saved arguments are: $PROJECT $REGISTER_JAR $GROUP $ARTIFACT"
}


set_up_directories()
{
# set up the directories, copy source
cd $MAVEN_DIR
mkdir $MAVEN_DIR/projects/
cd $MAVEN_DIR/projects
cvs checkout $PROJECT
cd $MAVEN_DIR/projects/$PROJECT/
mkdir TEMP
mv src/* TEMP/
mkdir src/main/
mkdir src/main/java
mv TEMP/* src/main/java
}


perform_build()
{
# perform the build
/maven/maven-2.0.6/bin/mvn --offline clean package > $MAVEN_DIR/projects/$PROJECT/build.log
cat $MAVEN_DIR/projects/$PROJECT/build.log
cvs add -m 'your build log' build.log
cvs commit -m 'your build log' build.log
}


commit_the_jar()
{
# go into the target dir, there may or may NOT be something in there
mkdir $MAVEN_DIR/projects/$PROJECT/target/
cd $MAVEN_DIR/projects/$PROJECT/target/
JAR_NAME=`ls *.jar`
echo "[ALAN] Your jar file name is $JAR_NAME"

# just in case this doesn't exist
mkdir $MAVEN_DIR/projects/$PROJECT/dist/

# if the jar already existed, commit it
if [ -f "$MAVEN_DIR/projects/$PROJECT/dist/$JAR_NAME" ] ; then
rm $MAVEN_DIR/projects/$PROJECT/dist/$JAR_NAME
cp $MAVEN_DIR/projects/$PROJECT/target/$JAR_NAME $MAVEN_DIR/projects/$PROJECT/dist/
cd $MAVEN_DIR/projects/$PROJECT/dist/
cvs commit -m 'newly built' $JAR_NAME

# if the jar is brand new, add it to CVS and commit it
else
echo "[ALAN] Adding new file to CVS - first time ever"
cp $MAVEN_DIR/projects/$PROJECT/target/$JAR_NAME $MAVEN_DIR/projects/$PROJECT/dist/

cd $MAVEN_DIR/projects/$PROJECT/dist/
cvs add -m 'newly added' $JAR_NAME
cvs commit -m 'newly-added now committed by bldjar script' $JAR_NAME
fi
}

perform_cleanup()
{
# clean up
echo "[ALAN] Now cleaning up, removing $MAVEN_DIR/projects/$PROJECT/"
rm -Rf $MAVEN_DIR/projects/$PROJECT/

echo "[ALAN] Script version was last updated on: $LAST_UPDATE"
echo "[ALAN] Any questions, comments, concerns? Email me at: "
}

register_jar_as_library()
{
# check if we need to register the jar
if [ "$OK_TO_REGISTER_JAR" = "yes" ] ; then
echo "[ALAN] Now registering your jar as a dependency in the maven lib directory structure..."
extract_rvl_from_jar_name
/maven/maven-2.0.6/bin/mvn install:install-file -DgroupId=$GROUP -DartifactId=$ARTIFACT -Dversion=$RVL -Dpackaging=jar -Dfile=$MAVEN_DIR/projects/$PROJECT/dist/$JAR_NAME
echo "[ALAN] If the above registration was successful, don't forget to add this to your pom.xml:"
echo " <dependency>"
echo " <groupId>$GROUP</groupId>"
echo " <artifactId>$ARTIFACT</artifactId>"
echo " <version>$RVL</version>"
echo " </dependency>"
echo " "
else
echo "[ALAN] I'm not registering your jar as a library. Syntax for that is: ./bldjar YOUR-PROJECT registerjar GROUP ARTIFACT"
fi
}


extract_rvl_from_jar_name()
{
STR=$JAR_NAME
len=${#STR}
REV=""
for (( i=$len ; i>0 ; i-- ))
do
REV=$REV""${STR:$i-1:$i}
STR=${STR%${STR:$i-1:$i}}
done
#echo "Reversed string $REV"
#ex: raj.3.2.1-reganamytiruces-ped

NAME=`echo $REV | cut -f1 -d'-'`
#echo "$NAME"
#ex: raj.3.2.1

STR=$NAME
len=${#STR}
REV=""
for (( i=$len ; i>0 ; i-- ))
do
REV=$REV""${STR:$i-1:$i}
STR=${STR%${STR:$i-1:$i}}
done
#echo "Reversed string $REV"
#ex: 1.2.3.jar

FULLLEN=${#REV}
ENDPOS=FULLLEN-4
RVL=${REV:0:ENDPOS}
}


check_user_arguments
set_up_directories
perform_build
commit_the_jar
register_jar_as_library
perform_cleanup



Thursday, January 29, 2009

How to fix the jsr173 missing artifact

How to fix the jsr173 missing artifact problem during a Maven build:

==========================================================
[ERROR] BUILD ERROR
[INFO] -------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) javax.xml:jsr173:jar:1.0

Try downloading the file manually from:
http://ftpna2.bea.com/pub/downloads/jsr173.jar
==========================================================


1. Go to /tmp
cd /tmp

2. Download the 14MB zip file:
http://cvs.apache.org/dist/incubator/beehive/v1.0-beta/bin/apache-beehive-incubating-beta.zip

wget http://cvs.apache.org/dist/incubator/beehive/v1.0-beta/bin/apache-beehive-incubating-beta.zip

3. Unzip the file
unzip apache-beehive-incubating-beta.zip

3. After unzipping, make sure that the jsr jar exists:
ls -la apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar

Example output:
-rw-r--r-- 1 maven maven 26396 Mar 25 2005 apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar

4. As user maven, install the file (use the right path to your mvn executable):
/maven/maven-2.0.6/bin/mvn install:install-file -DgroupId=javax.xml -DartifactId=jsr173 -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true -Dfile=/tmp/apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar

Example output:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install:install-file] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /tmp/apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar to /maven/lib/javax/xml/jsr173/1.0/jsr173-1.0.Jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Jan 29 09:56:38 EST 2009
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
[maven@myserver tmp]$

5. rebuild the project

cd /path/to/project-directory
/maven/maven-2.0.6/bin/mvn --offline

...
[INFO] BUILD SUCCESSFUL
...

Done.

Tuesday, January 27, 2009

Deny yourself

"To deny our own impulses, is to deny that very same thing that makes us human" - Mouse, the Matrix

How to parse Apache log files

How to parse Apache log files using the cat, grep and awk command, in order to see what a particular person was browsing

To view the Apache access log file:
cat /var/log/apache/access_log

Log lines look as follows:
74.6.72.36 - - [01/Nov/2006:02:10:33 -0500] "GET /~lupsha/artificialintelligence/artificialintelligence.htm HTTP/1.0" 200 116 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"

To only view log lines that contain "Nov/2006" and "lupsha" and Mary's ip of "141.213.178.207", and to save all the contents of the log in another file called mary.txt, use grep as follows:
cat /var/log/apache/access_log | grep Nov/2006 | grep lupsha | grep 141.213.178.207 > /tmp/lupsha/mary.txt

The contents of /tmp/lupsha/mary.txt are now:
141.213.178.207 - - [10/Nov/2006:22:47:13 -0500] "GET /~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg HTTP/1.1" 200 7996 "http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1)"
141.213.178.207 - - [10/Nov/2006:22:47:13 -0500] "GET /~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic-2.jpg HTTP/1.1" 200 5503 "http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1)"
... etc

Take a log line as the one above, for example:
141.213.178.207 - - [10/Nov/2006:22:47:13 -0500] "GET /~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg HTTP/1.1" 200 7996 "http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1)"

We wish to take the path
/~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg
and convert it to:
<a href ="http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg"> [10/Nov/2006:22:47:13 </a>
so that a user can click on the link with the date in order to see what files were browsed.

We use the awk command as follows:
awk '{print "<a href=\"http://socr.uwindsor.ca"$7"\">" $4 "</a>"}' mary.txt > mary.html
The awk command above takes argument 7 and 4 from the log line and concatenates it to a custom html string, creating a link for the user.

by Alan Lupsha

Monday, January 26, 2009

How to get an email when someone logs into a shell account

Add the following 2 lines at the bottom of the .bashrc file. Replace YOURUSERNAME with the shell login and replace YOUR@EMAIL.ADDRESS with a valid email address:


echo "Today is $(date) User is: `who | grep YOURUSERNAME | awk '{ print $6 }'`" > ~/lastuser.txt

mail -s 'user YOURUSERNAME logged into server XYZ' YOUR@EMAIL.ADDRESS < ~/lastuser.txt

Saturday, November 29, 2008

Numb nest

There is numbness in your head, fried neurons twitch in vain and you still smile. You're blind. The world around you is more real than your mind dictates it. You are the many, and I live amongst you.

Alan, November 2008

Wednesday, October 1, 2008

What to ask a complete stranger

- does your civilization you put a high price on life?
- is a live being respected as an individual?
- do you clone individuals?
- are your people treated equally?

- do you have a moral code?
- would you harm the innocent in order to achieve a higher purpose?
- would you harm the innocent in order to survive?
- is survival of the current population the most important priority?

- do some individuals ignore the rules of the community?
- what happens when rules are broken?
- is there punishment? If so, does it work, and what form of punishment takes place?
- are there community goals?
- is there personal gratification in the population?

Monday, May 19, 2008

High level minds, low level world, and the missing middle layer

The problem seems to arise from the fact that we don't live in the present. Our thoughts slide backwards and forwards in time, while we are actually in all of those times and in all of those locations at the same time.

The greatest disconnect between perception and reality occurs because of a missing middle layer between the high level human perception layer and the low level reality layer of the actual world. This middle layer is essential for realizing truth.

There are the few who manage to create thin and temporary connections between the perception layer and the reality layer (meditation?). However, like golden strands of gold connecting some circuitry between two extremes, these people can not fully interpret the stimuli of the physical world, and their brains become misguided by the received sensations.

If our duty is to understand the truth of the world, then we must create the middle layer between the mind and the world.

Thursday, June 22, 2006

Artificial Intelligence can save.

20060622: AI will save mankind. Built in man's image, with superhuman intelligence, strength, adaptation, coordination, AI will provide the necessary care for humans that will ensure their survival, the necessary work force for building interstellar homes, habitats and for providing resources. AI is only the beginning, the sky is the limit.

Tuesday, June 20, 2006

Techno Sapiens

20060620

We are a new species, techno homo sapiens sapiens (or techno sapiens, for short). Our understanding of the world is still in its infancy. The majority of the population has a minimal education, while the "educated" ones have spent at least one fifth of their lives in various schools, only to become specialized in only a couple of subjects. With a great lack of schooling, the rate of advancement is slow and the grasp on reality is weak. It is a time when the concept of non-earthly life is still mostly ridiculed and laughed at. It is a time when the world's governments are corrupt and thrive only for the enrichment of the few in charge. It is a time when the big picture of the universe is only studied by the few, unrewarded ones. It is a time we call "right now".

The techno sapiens of now is a species that relies heavily on technology. "Necessities" include imported foods, manufactured products, inefficient locomotion and inefficient and ecologically unfriendly sources of energy. The trend is for change to take place, for greener alternatives of energy generation to be implemented, and for more education to be distributed to the population, with hopes to lengthen the lifespan of various habitats on Earth. Many animal species are becoming extinct, the greatest forests are being cut down, pollution is causing the ice caps to melt, and most of the population is clueless. The media controls the people, the people believe what they're told, and a vast amount of time is being spent on inefficient labor, working for companies that only care for profit. The bulk of the population is easily entertained with sedentary activities such as watching television (sports, irrelevant shows), or eating beyond one's needs. Science programs are not very popular, while educators and research are paid very little.

Few understand the risks of nuclear war, space debris, dangerous viruses and other dangers that could annihilate the human species from the face of the Earth. If more people would become educated, more would invest their thinking to yield solutions to threats. Yet the system does not require such education for the population. The poor, uneducated are kept in the dark; their workforce is being exploited by their employers, they are fed unhealthy foods and information by the media and they are used as unknowing slaves as a force that propels the system that controls them. They are the bulk of society, the defense of the country, the suffering techno sapiens of today.

The Internet opened channels of communications. Ideas arise, are propagated and are built upon. The techno sapiens species may one day integrate machinery into itself, speeding the thought process, minimizing the years spent in school, and specializing itself on a variety of topics, thus saving itself from slavery to the system and from the dangers of extinction. Alternatively, non-earthly interventions may provide solutions to the problems, solving humans all the necessary work.

Chances that everything will change for the better, that the masses will become educated and that corporate greed will give in to preserving the species, are slim. It is more likely that the few will remain the few, searching to understand the world, searching for solutions to grave problems, forever hindered by the simplicity of the masses, which are forever kept in the dark about the risks at stake. Be part of the few, and you will help.

Alan

Monday, March 27, 2006

Conventional logic may lead to chaotic order

20060327:
Discrepancy of conventional logic is the critical ingredient of the chaos machine.

Tuesday, June 29, 2004

We need AI and space colonization

We need to explore our Solar System. We must create means of traveling safely and securely to other celestial bodies. Once we start exploring and inhabiting other places, such as planets' moons, we will have a secured and maintained thumbprint that identifies that humans ever existed.




The intelligence of artificial intelligence today, in 2004, is insufficient and it does not even come close to the intelligence of a common person. We are way behind schedule, the rate of advancements of A.I. have been slower than the promise of A.I. Technology and exploration are the runners in the turtle and the hare race. Right now, technology is the turtle, because it is the defining means of exploration, and it moves very slowly.




Artificial intelligence can aid in reaching univisited planets and the moons of those planets. Human bodies are not designed to withstand the requirements of space exploration. They are very demanding and very inefficient. Humans should build A.I. and use it to explore and create new worlds.




We need to replicate the human mind. We need to scan the brain, its functionality, and store it in a non-biological medium, a medium that is replicable, persistent and efficient. We need to scan people, and store their precious personnae, their mind, their thoughts, their personality. Then, we need to create space ships, controlled by A.I., which will travel to different planets, create habitats for people, and then build humans. After the humans are built, their personality needs to be transferred back into the biological bodies, for the continuation of our human species.

Thursday, June 10, 2004

Geographical simulation environment

Artificial intelligence, simulation, ant world, stock market (idea from 2003)

The World project is a model that is an abstraction of many other real models in the world.

The idea is simple: there is a world with defined locations, which can hold objects in them.
Instead of having the world control the objects, we allow the objects to interact with
each other. Thus, we don't have a world which needs to: check where every object is, check each
object's state, request a move, etc. The nodes in the world interact with each other, just
like objects in a nanotechnological world would interact with each other. The benefit to
having nodes do the work is that by using distributed computing, we can use multiple
processors do work instead of using one processor do all the work.

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

Where could this model be used?

1) The Brain - The idea came from building a neural net, with the neurons interacting
with each other in a model that tries to replicate the physical world of the neural nets
(i.e. a copy of a brain).

2) Simulation - Another application that comes to mind is simulation. Each node can
represent an object in the physical world, holding specific data (attributes and functions),
and having different states, or requests.

3) Ant world - I have always wanted to create a simple ant world, where ants meet each other,
carry food, physically interact with the world. The idea was to have a plain surface which
is marked with squares, and then place an ant on this grid. The movement of the ant is never
straight, because ants have a genetically built-in method to walk, probably to search for
food their whole lives. If this movement were to be straight -> left -> right -> straight,
or some very complex movement, videotaping this move for the ant could allow to determine
this movement. A series of matrices could be built, showing the tendency of the ant's move.
If these matrices were accurate, the model should in theory predict the movement of an
ant to the highest accuracy. Please note that building an abstract behaviour model for an
ant would be much more computationally cheaper than building a neural net which acts
as a copy of an ant's brain.

4) Stock market - A possibly controversial but exciting application of this world is to
let each node be a specific stock, with attributes, certain behaviour, and so on. The
nodes are either let loose on the board (the world), where they interact with each other,
or they are linked ahead of time, if one knows which stock affects which other stock.
For example, a strong pharmaceutical company's stock could affect smaller pharmaceutical
companies' stocks, but not the stocks of a mining company. Stocks that are bonded together
would eventually find a stable location on the market world, slightly shaking in their
physical location, but no longer wandering off on the board. One option is to set the
nodes off, let them stabilize in the market world, and then dump real world data into
each node, and observe if they stay stabilized. One could use a year's worth of data,
and watch the nodes move into a new place, until stabilized. The actual prediction for
a current stock's rise or fall would be obtained after having a stabilized stock world,
and after dumping real time data into the nodes that are bound to it.

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

Movement vector:

A node can also have a general movement vector, which is a weighted 3D vector which
generally tends to move into one direction. Even though the direction D=(x->, y->, z->)
has randomized values, these are added to a predefined static matrix, which makes
the direction more or less stable. The object crawls along the world, and when it reaches
an obstacle (i.e. end of the world, or another object), it acts according to the world
rules. It could bounce in an opposite direction, it could generate a new random movement
vector, it could act according to gravity.

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

Creating the world:

The world can be created, and nodes can be randomly dropped into this world, and set alive.
Each node would move around in its own direction pattern. Once each node reaches another
node, it could make a bond with that node, enforcing a proximity with it, or it could
reject it, bouncing off in a haste, trying to get away from that node.

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

A wrap-around world:

Instead of reaching the end of the world and bouncing off walls, a node could wrap around
the world, and when exiting on the right side, it would reappear on the left side. This
ensures that the physical world is just a container for the nodes, and that it would not
affect the behaviour of the nodes, which could be very sensible in nature.

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

Bound nodes:

If two nodes which are meant to be together meet in the world, they create a link to each
other, and they try to keep this link alive and not broken. If one node pulls into one
direction and the other node pulls in an opposite direction, they must calculate which is
the dominant node, and compute a mean value, moving in that direction. The computation
can be a sumation of vectors. Note that we should not violate our object-oriented model,
and each node must compute it's own decided movement. We cannot have the world extract
the intended move for each node, and then compute each node's individual enforced move.
If node A has an intended move in direction vector a->, and it is only bound to another
node B, (but node B is bound to many other nodes which affect its move drastically), then
node A should only talk to node B, ask for its current intended move, and act upon it.
If B happens to be processing its move, and it needs a lot of time, this should not be
relevant to node A, who needs the information immediately and doesn't want to wait.

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

How one moves:

Let A be a node that is not bound to any other node. Node A has a movement vector, which
tells it that it should pretty much move towards a predetermined direction. On each
iteration of the world (each "game move"), node A must do the following:

- talk to the world, give the world its current location, and ask if the next
physical location where it wants to move is available or not

- if the location is NOT available, probably because another node is currently
in the same spot, the world must give node A a link to the object which occupies
the location where node A wanted to move. This link is then used by node A to
decide whether the occupying node can interact with node A, or whether node A
should bounce away in a haste.

- if the location is available, the world must tell node A that the desired
location is available, and it must mark this spot as being occupied by node
A, and at the same time it must mark node A's previous position as being
free. Note that this move should be atomic, since we do not want node A
to exist in 2 places at once, and we also do not want two nodes to take
the same spot in the world.

- node A MUST then move to the new location.


Example of an atomic move. Semaphores must be used.

Node A's next intended move is to location N. Node B's next intended move is to location N.
Location N is vacant.

A -> World : "I want to move to location N. My position is X."
[World stores the request from node A in a queue]


B -> World : "I want to move to location N. My position is Y."
[World stores the request from node B in a queue]


World -> A : "Node A, checking location N... yes, it is avilable, ok, you can move
to location N. I have marked your current location X as being no longer
occupied. I will not talk with any other node (thereforer noone can
move to where you are, and step on you) until you have confirmed your
move. Waiting for your response..."


A -> World : "Ok, I have moved to location N. My new location is: N"


World -> A : "Thank you. Connection closed. Good bye."


World -> B : "Sorry for keeping you waiting, I am now available. Checking...
Sorry but location N is taken by ... checking ... node A. Here is
node A's reference, talk to it if you need to. Good bye."


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

Saturday, January 26, 2002

What is dreaming?

20020126 If a thought is an instance of a configuration of certain neural path ways, then when the being sleeps, a dream is the visual representation that the house-keeping function that administers the freshly produced thought (in the day previous to the dream) creates. Here we create a being that dreams.

Monday, January 1, 2001

We are making ourselves extinct - transhumanism

2001

One could accept the idea of human kind becoming extinct. The whole race could evolve into a collective consciousness of minds, interacting with one another and finding optimal solutions to all problems. The new race would engineer bodies and use them as tools that are needed to accomplish mobility tasks. The speeding thought process in this collection of minds would be an iterative process, a source of energy for new ideas. The conventional biological homo sapiens sapiens body would become a natural gateway between the dawn of intelligence and artificial new species, which would work towards the goal to be fit for eternal existence.

Alan Lupsha

A Christian fantasy becomes true

Hans Moravec, once said:

"All we have to do is get rid of these bodies and these brains. "I have faith in these computers," Hans Moravec said. "This is not some way of tricking you into being less than you are; you're going to be more than you are. You're going to be more intelligent, you'll be able to do much more, understand much more, go more places, not die - all those things. "It really is a sort of a Christian fantasy: this is how to become pure spirit." (source: http://slate.msn.com/id/111178/ )

----------

2001

One could accept the idea of human kind becoming extinct. The whole race could evolve into a collective consciousness of minds, interacting with one another and finding optimal solutions to all problems. The new race would engineer bodies and use them as tools that are needed to accomplish mobility tasks. The speeding thought process in this collection of minds would be an iterative process, a source of energy for new ideas. The conventional biological homo sapiens sapiens body would become a natural gateway between the dawn of intelligence and artificial new species, which would work towards the goal to be fit for eternal existence.

Alan Lupsha

Saturday, January 8, 2000

My world is a bubble

My world is a bubble,
I'm a tiny speck of dust,
I'm a builder of castles,
Out of the sand of the past.

I fly high with the wind,
Reaching out to the sky,
As my thoughts wander farther,
Even higher I fly.

With the truth I acquire,
Even more things I know,
On these steps of my journey,
Even taller I grow.

Alan Lupsha, August 2000