Notes on Java, Solaris, PHP, LDAP…

August 20, 2008

Searching for RPM packages?

Filed under: Java — negev @ 1:09 pm
Tags:

Searching for RPM packages? Just type package name at rpmseek.com and it lists them by Linux distributions.

June 27, 2008

Virtual hosts on SUSE

Filed under: Java — negev @ 7:45 pm
Tags: ,

When enabling the second vhosts in Apache2 <virtualHost *:80> on a SUSE server, apache restart gave me the following error:

“_default_ VirtualHost overlap on port 80, the first has precedence”

Solution: in /etc/apache2/listen.conf add or uncomment following line:
NameVirtualHost *:80

June 20, 2008

Notes on Capistrano

Filed under: Java — negev @ 6:53 pm
Tags: ,

How to use capistrano to invoke a command remotely:
cap -f deploy.rbĀ  invoke COMMAND=ls

Since Capistrano 2 it kind of required ‘Capfile’ in the folder where I run capistrano. deploy.rb can be under ‘deploy’ folder but not in the same folder as Capfile. Capfile then contains:
load ‘deploy’ if respond_to?(:namespace) # cap2 differentiator
load ‘deploy/deploy’

How to make capistrano deploy a chosen revision (thanks to Jamis Buck):
cap -S revision=1234 deploy

Capistrano on Suse SLES 10: Latest version of Ruby for SLES 10 is version 1.8.4 – from
http://demeter.uni-regensburg.de/SLES10-SDK-x86/suse/i586/ But the newest capistrano (2.4.0) doesn’t deploy correctly in ruby 1.8.4 – it deploys older revision (24) from Subversion rather the newest revision (HEAD).

Concatenating strings and variables in shell

Filed under: Java — negev @ 5:44 pm
Tags:

I had a variable and I wanted to concatenate its value with a string – in a Unix shell script (run by sh or bash). It turns out that quotation marks work well. Apostrophes don’t work all the time. An example:

echo Go “$HOME” — “$HOME”

Private/public SSH keys between different logins (usernames)

Filed under: Java — negev @ 5:40 pm
Tags:

Today I’ve set up a private and public SSH key on one server, and I copied the public key to our CVS server. However, my login names were different on those machines, and the keys didn’t help.

Then my colleague advised to create a file under ~/.ssh called config, with an entry like this:
Host happycvs.happycompany.com
User peterk

And suddenly SSH connected fine!

May 13, 2008

Filtering via Perl on commandline to extract values

Filed under: Java — negev @ 3:16 pm
Tags: , , ,

My superb admin showed me two tricks. He invokes perl and passes it the regular expression from the shell. Perl processes standard input and writes to standard output.

The first one collects all user emails and then it gets their unique email domains. The second one collects values of LDAP attribute companyDomains and again gets their unique values.

mysql -h mysql-server -u user -ppassword db-name -e ‘SELECT email FROM users’ | perl -nle ‘/.*@(.*)/;print $1;’ | sort -u | wc

ldapsearch -x -h ldap-server -D “cn=readonly,o=services” -w password -b o= users “(objectClass=organizationalUnit)” companyDomains | grep -P ^companyDomains: | perl -ple ‘s/^companyDomains: //;’ | grep -Pv ‘^\d’ | sort -u

January 31, 2008

Searching for dash ‘-‘ using grep

Filed under: Java — negev @ 6:52 pm
Tags:

Using grep to search for text containing dash –
grep –exclude ‘*.svn*’ -r “\\- Details” *

December 4, 2007

Single-user boot and fdisk in OpenBSD

Filed under: Uncategorized — negev @ 10:14 pm
Tags:

I needed to test something in OpenBSD. So I’ve installed it on a separate partition on my AMD-based laptop. What a surprise – when I wanted to boot up the other system (Solaris), it turned out to be quite difficult.

In OpenBSD, if you want to choose (switch) the active (bootable) partition, you can’t do it on a hard-drive you’ve normally mounted from (read/write mount). You need the hard-drive to be mounted read-only. For that you need to start in a single-user mode. Right after you turn on/reset your computer, when the OpenBSD boot screen shows up, type boot -s. Then it asks you for terminal type and it doesn’t give you any default or common choice(s). It looks that vt100 is a good one. Then you boot up in a single-user mode.

You can run fdisk and it just prints the partition table and exits. Now let’s go change things: run fdisk -e wd0 where -e stands for interactive mode. You can type manual to show the commands at any time. If you want to change the active partition, type flag numer-of-partition. To commit the changes type write.

November 21, 2007

File uploads with Apache/PHP and Flex; TCP dump

Filed under: Uncategorized — negev @ 6:44 pm
Tags: , ,

File upload with Apache/PHP
– if your HTML form has a hidden input MAX_FILE_SIZE and you submit a file bigger than that, you won’t get any warning by the browser, and the file won’t be submitted to the server!

File upload in Flex using FileReference
– the file size must be above 0!

TCP dump filtering
sudo tcpdump -i en0 -s 0 -w csv_processing_tcpdump.dmp
-s 0 => print whole packets

tcpdump -s 0 -n -e -A -vvv -r DumpFile.dmp host ip-of-the-target-host
-A => prints packet in ASCII

November 17, 2007

Various

Filed under: Uncategorized — negev @ 9:33 pm
Tags: , , ,

4 July 07

Unix/CRON output redirection
my-command >/my_log_dir/my_file 2>&1

LDAP search expressions
– need to have parenthesis both outside & inside operator-based expressions:
(&(myAttrib=value)(anotherAttrib=value)..)

Subversion on Novell SLES 10
– subversion.tigris.org
— don’t use David Summer’s summersoft.fay.ar.us – it complained about libraries even when they were up to date (for SVN 1.4.0)
– use CollabNet commandline client

Subversion on Mac OS X
– subversion.tigris.org
— use DMG from Metissian 1.3.1 or newer

Grep filtering of Java/C multi-line comments
pcregrep -r -M -f ~/comments.regex Hashtable.java
– comments.regex is:
\/\*\*([^*]|\*[^/])*\*\/
– don’t use \w – that doesn’t include new line in pcregrep
– \n doesn’t represent new line
options:
-l = Instead of printing lines from the files, just print the names of the files
-c = Do not print individual lines; instead just print a count of the number of lines
-n = Precede each line by its line number in the file

Backslash problems when connecting via rdesktop from a Linux box to Windows VM:
Set Windows (VM) to use US keyboard

PortableApps – packaging/’virtualization’ of MS Windows applications – it makes a package you can run from USB; open-source
Thinstall – same but commercial

MySQL on Mac OS X 10.4 Intel
– install DMG from Mysql site and also follow http://www.entropy.ch/software/macosx/mysql

Cross-platform presentational SW: http://www.debugmode.com/wink/
– generates Flash
– audio+screenshots

JavaOne 2007 – Open Source mobile OS:
Freedom also means that you have to let other people be free to make choices that you might not…

Test Units – abstract of Tapestry testing @JavaOne 2007
– it helps if there a single class that has responsibility for all task of a given process
– test-driven dev = change detection (regression tests) + more
– tests
— isolated, thorough
— easy to debug, frequently run (i.e. fast) => out-of-server, or out-of-container
— test the ‘hard stuff’
— tests document design decisions – expectations/requirements

Next Page »

Blog at WordPress.com.