Notes on Java, Solaris, PHP, LDAP…

November 27, 2007

Notes on Mercurial SCM, compared to Subversion and GIT

Filed under: Uncategorized — negev @ 5:55 pm
Tags:

Mercurial – Source Control

Mercurial (hg) is a distributed versioning system. I’ve installed it and tried just a little. Following are my notes based on http://hgbook.red-bean.com/hgbook.pdf and my experience.

Mercurial and GIT are both free distributed versioning systems. Main differences – GIT possibly a little faster, but it requires maintenance (repacking the repositories). There’s no user manual for GIT, only docs for the invdividual commands.

hg uses language very similar to Subversion, although some terms have different meaning. It introduces some more terminology specific to merging and branches, and it sounds confusing to me as a SVN user. Probably it clears out with practice.

In overall Mercurial looks more ‘human friendly’. It’s focused more on how we people think of history of documents and parallel changes (branches). It takes responsibility for book-keeping branches/merges, while in Subversion you need to keep track or identify start and end revisions in the branch you’re merging from. In SVN you need to find those start/end revisions by date, or by ‘svn log –stop-on-copy’ command. hg takes care of all that. Those were the ‘high level’ hg branches and merges. ‘Low level’ branches and merges occur all the time when pulling from other team members.

SVN has a URL for each subfolder/file in the repository – which covers all branches, tags, everything. hg has URLs but only for the main, public branch (tip or head?).

Niceties of Mercurial:

  • easy reverting of all subfolders and their files – ‘hg revert .’

  • easy pullback

  • little merges – everything you do is in your local repository. Then you merge it with changes of other people. Because merging is the daily bread, hg makes it as simple as possible

  • simple installation and administration. It only stores repository on file system, while SVN can use DB and FS.

  • history search by programmable filters via ‘hg bisect’ (logarithmic rather than sequential search)

The positives of being distributed

  • 0 day start

    • once you install locally, you can commit locally

    • works over SSH without setting any deamon/DB on the server, once you install hg on it

  • local searches over whole history – very quick

Drawbacks/complications:

  • update, merge are separate tasks. ‘hg update’ updates your local repository, but it doesn’t update your working directory – use ‘hg merge’ for that.

  • The simplest way to have ‘high-level’ branches is to have one repository for a branch. That’s OK locally, but if you want the branches to be stored on a server then developers need rights to create them and it gives extra work. hg supports several branches in same repository but it’s when the usage gets more advanced/complicated. But, it looks nicer/easier than keeping track of SVN branches (within same repository).

November 23, 2007

Filed under: Uncategorized — negev @ 3:57 pm
Tags: ,

I’ve learned how to configure SSL for Apache 1.3 on Mac OS X: http://www.macosxhints.com/article.php?story=20041129143420344
I’ve found two errors in Flex/Flash:

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 18, 2007

Notes on MySQL, Novell eDirectory LDAP ACLs, XSLT, Mailtrap

Filed under: Uncategorized — negev @ 12:12 pm
Tags: ,

9 Aug 07
MySQL Select & GROUP records with minimum value of a chosen column
SELECT offices.id, disposition, count(positions.id) num_positions FROM offices, positions WHERE condition-on-office AND offices.id=positions.office_id GROUP BY offices.id ORDER BY num_positions ASC LIMIT 8;

Novell eDirectory
– schema and attribute names
http://developer.novell.com/documentation/ndslib/index.html?page=/documentation/ndslib/schm_enu/data/sdk738.html#sdk738
– how to change [ROOT] permissions to more specific permissions:
— When replacing [ROOT] by a specific DN, then remove [] brackets
— so instead of “2#entry#[ROOT]#member” you use “2#entry#o=MyCompanyName#member”

XSLT to concatenate strings
– use concat( first, second…) rather than operator +. + works only for numbers
– don’t concatenate values/expressions with in-XML constants, because it will add spaces etc:
<xsl:value-of select=”$logoName” />.gif

Using JEdit with files that are hard-linked at multiple locations
– then in JEdit’s opetions unset: jEdit > General > Two-stage save (safer but resets file owner on Unix)

novell eDirectory weird ACLs – couldn’t modify LDAP ‘mail’ attribute
– that was because I had ACLs in ConsoleOne to EMail Address, not to ‘Internet EMail Address’ – and the second is NDS attribute respective to LDAP attribute ‘mail’
– so you need to set ACLs to ‘Internet EMail Address’ rather than ‘EMail Address’
– see NDS-LDAP attribute mappings in Console One > tree > Resources > Servers > LDAP Group – my server > Attribute Mappings

23 Oct 2007
Mailtrap – fake SMTP server that traps all emails and saves them to a file
http://matt.blogs.it/entries/00002655.html
– it uses Ruby

Universal USB Webcam driver for Mac OS X
http://webcam-osx.sourceforge.net

November 17, 2007

PHP and LDAP, PHP debuggers

Filed under: Uncategorized — negev @ 11:24 pm
Tags: ,

26 Sep 07
Delete all values of an LDAP attribute in PHP
ldap_mod_del( $connection, $dn, array( 'attrib-name' => array() ) );

Copy a directory recursively and keep the symlinks- use cp -R
- not cp -r

Relative inclusion of files using include/require in PHP
from comments on http://www.php.net: When I'm dealing with a package that uses relative includes of its own, rather than modify all of their includes, I found it was easier to change PHP's working directory before and after the include, like so:

<?
$wd_was = getcwd();
chdir(“/path/to/included/app”);
include(“mainfile.php”);
chdir($wd_was);
?>

This way neither my includes nor theirs are affected; they all work as expected. Or:
ini_set(‘include_path’, (ini_get(‘include_path’).’;’.$SITEROOT_PATH));

PHP ldap_mod_del()
– it requires attribute values to be indexed by consecutive int keys starting at 0!

PHP debuggers
http://uk3.php.net/debug_backtrace
http://uk.php.net/manual/en/function.class-exists.php

http://www.ibm.com/developerworks/library/os-debug/
http://pecl.php.net/package/apd

http://xdebug.org
— installs OK on Mac OS X 10.4
— if you activate it in php.ini, then commandline PHP stops working!
— error traces refer to PHP sources with lines starting at 0, not starting at 1!

http://gubed.mccabe.nu/?/article/articleview/Download&Gubed=f06cc6837ecb7ab00b0cb1791ad8274e&themex=public

When updating/creating an LDAP object in PHP and you get a funny attribute value
– if the attribute schema is a DN to (any) object
– and if the attrib value shows up as [Root] in ConsoleOne of Novell eDirectory
– and if the attrib values shows as null/empty string in PHP ldap_search and commandline ldapserch
– then you saved/created the object passing PHP null as the value of that attribute to PHP ldap_mod_add()
– solution: remove PHP null values when creating a new LDAP object. If updating an existing LDAP object, remove any existing values of that attribute by ldap_mod_del()

Java Clustering, Multicore, Profiling, Exceptions

Filed under: Java — negev @ 9:56 pm
Tags: ,

Java notes

Clustering
– in Java
— www-sop.inria.fr/oasis/ProActive
— OpenMOSIX – Message Passing Interface
http://www.cs.wics.edu/condor/downloads

Multi-thread development: Where can you go wrong? (from Java Platform Performance on Multicore: Better Performance or Bigger Headache? )
Profiling Pitfalls
• Profiling just once
• Iterative process
• Investigate one issue at a time
Cache access
Synchronization
• Investigating only user-written code
• Issues can be in libraries
• Rewrite code to use different library methods

Testing JavaTM Code: Beyond the IDE
— Developers can spend up to 50% of their time understanding code before they can fix it…

FindBugs – it tries to detect bugs in Java source

Don’t swallow Exceptionshttp://www.javalobby.org/java/forums/t91338.html

Bug Fixing, Java 7: http://java.sun.com/developer/technicalArticles/Interviews/community/harry_qa.html
* The book I’d recommend is Code Complete. It’s convinced me of the limitations of unit tests
** http://cc2e.com/
* superpackages and method references at the language level.
* invokedynamic
* a limited form of multiple inheritance will exist

Java community
JUG – Java User Group – http://www.javalobby.org
Free Sun course – creating Web tier apps – http://developers.sun.com/offers/

Java news
– unstructured http://www.planetjava.org
– structured RSS feeds http://www.javarss.com/

Sun Studio Performance Analyzer – useful to profile Java apps – both interpreted & hotspot stacks
http://developers.sun.com/solaris/articles/java_on_solaris.html

Firefox, Javascript, Tiny MCE tips

Filed under: Uncategorized — negev @ 9:55 pm
Tags:

Details configuration of Firefox:
about:config
— any changed values get highlighted

Escape HTTP Parameters in URL
– to find out the escape sequence, run e.g. javascript:alert( escape(‘=’) )

Customizing Tiny MCE wysiwyg

Tiny MCE now works in Safari. Upee!

Customizing it and debugging in Firefox? When using default ‘advanced’ theme, edit tiny_mce/themes/advanced/css/editor_content.css and then re-load it in Firefox. Otherwise Firefox caches old version of editor_content.css

See http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=20422#p20422

Javascript errors within/between iFrames in MS IE is a very bad situation. Standard MS IE reports these errors very vaguely. It says line number but it doesn’t tell which actual file it is – either outer/inner HTML or one of possibly many JS files.

An excellent way to debug JS errors in MS IE 6 is described here. Follow the installation/activation instructions literally. In order to get ‘Script Debugger’ entry in ‘View’ menu of MS IE you need to install Microsoft Script Editor (called ‘HTML Source Editing’ in MS Office XP Pro) *and* enable script debugging in MS IE settings.

When using ‘HTML Source Editing’ which comes with Microsoft Office XP Pro you need – in Microsoft Office XP Pro Setup do custom install, specify features of each app to be installed: Microsoft Office > Office Tools > HTML Source Editing – set it to be ‘Run from my computer’.

Aptana -a free Ajax IDE

MS IE7
– window.open
( url, title….) requires title not to have a space in it; otherwise it complains of a bad argument
Source: http://forums.invisionpower.com/lofiversion/index.php/t228859.html
myIframeObject.contentDocument doesn’t work anymore (e.g. myIframeObject.contentDocument.location.href).
— therefore test whether myIframeObject.contentDocument is set; otherwise use myIframeObject.contentWindow.document

Javascript boolean type
– ‘0’, ‘false’ is same as boolean true

Javascript escaping and ASCII codes
quotation mark = ASCII 39 (decimal) = ASCII 27 (hex) = %27 in query string
equal operator ‘=’ is %3D in query string

Javascript weird on MS IE 6
– element id=”..” and JS variable names must be different

PHP and LDAP, regex and sessions

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

8 Aug 07
PHP ldap_search and its search base parameter:
– If you pass null LDAP base to PHP’s ldap_search, then it searches the whole tree – that is, all containers.

PHP and regex – regular expressions
– Perl-like pcre functions are faster than Posix ereg functions
– use str-replace if you don’t need regex

Clearing PHP sessions
<?
session_start();
session_destroy();
echo “Session destroyed OK.”;
/*
The following doesn’t clear the session – don’t use session_id() to test whether there
is any out-of-date data in the session. You need to call session_start() first.

if( session_id() ) {
session_destroy();
echo “Session destroyed OK.”;
}
else {
echo “There was no previous session or it timed out already.”;
}
*/
?>

PHP LDAP search by groupMembership or attributes of ‘Distinguished Name’ syntax
There are situations when you want to have a DN in the search *filter* – e.g. when you search by groupMembership attribute or by an attribute whose syntax is Distinguished Name. Then you need to escape all occurrences of ‘=’ in that attribute’s value by a backslash and its hexadecimal code – i.e. ‘\3D’.

Example: Following works with unix/Mac OS ldap_search command – you use apostrophes to separate the DN part of the filter:

ldap_search -x -h my-server -D ‘cn=my-user,ou=my-container,o=users’ -w my-password -b ou=my-search-container,o=users groupMembership=’cn=my-admin-group,ou=MyApplication,ou=Applications,o=services’

But if you need a similar search in PHP, then you need to pass the following filter to ldap_seach() and its alternatives:

<? ‘groupMembership=cn\3Dmy-admin-group,ou\3DMyApplication,ou\3DApplications,o\3Dservices’
?>

MySQL MAMP

Filed under: Uncategorized — negev @ 9:37 pm
Tags:

17 July 07
MAMP (AMP for Mac OS X) and graphics library error: Symbol not found: __cg_jpeg_resync_to_restart
– follow http://forum.mamp.info/viewtopic.php?p=4213
— comment out both lines in /Applications/MAMP/Library/bin/envvars

MySQL counting of associations grouped by the number of occurrences
SELECT count(*), agency_id FROM positions WHERE active_flag=1 GROUP BY agency_id;

– be careful though: following 2 queries give different results:
SELECT count(*), agency_id FROM positions WHERE active_flag=1 AND agency_id IN (SELECT id FROM agencies WHERE disposition=’live’) GROUP BY agency_id;
–> a lot of small sum results
SELECT count(*), agency_id FROM positions WHERE active_flag=1 GROUP BY agency_id AND agency_id IN (SELECT id FROM agencies WHERE disposition=’live’);
–> a few big cumulated results

MySQL dump when you don’t have lock rights to the tables:
mysqldump –lock-tables=FALSE

Setting old-style MySQL passwords:
GRANT SELECT , SHOW DATABASES ON * . * TO ‘readonly’@’%’
IDENTIFIED BY ‘readonly’
WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;

SET PASSWORD FOR ‘readonly’@’%’= OLD_PASSWORD(‘readonly’);

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.