Netbeans and Scala

I'm taking a look at Netbeans 6.0 with the new Scala plugin (http://blogtrader.org/page/dcaoyuan/entry/first_experimental_scala_supporting_for).  When I tried to build a HelloScala app, I received the error "Could not load definitions from resource scala/tools/ant/antlib.xml."

Setting SCALA_HOME in my environment variables appears to not work with Windows Netbeans 6.0 final and the Scala plugin.

I've got SCALA_HOME=C:\scala in my environment (which is where my Scala lives). I've confirmed it by starting a Command prompt and typing "set". Yet I still get the scala/tools/ant/antlib.xml error.

However, adding -J-Dscala.home=C:\scala to the end of the netbeans_default_options string in C:\Program Files\NetBeans 6.0\etc\netbeans.conf resolves the problem.

I don't speak ant, but I'm betting that the following snippet from build-impl.xml doesn't behave as expected in some cases:

<condition property="scala.home" value="$">
<isset property="env.SCALA_HOME"/>
</condition>


Having solved the Ant problem, I thought I’d build a simple HelloScala app.

  1. Start Netbeans
  2. Click the New Project icon on the toolbar
  3. Select Scala
  4. Press Next 
  5. Project name = ScalaApplication1
  6. Location = K:\Code (giving Project Folder = K:\Code\ScalaApplication1)
  7. Create main class = ScalaApplication1.Main
  8. Press Finish
  9. Press Shift-F6 to build and run.
  10. Error message: java.lang.NoClassDefFoundError: ScalaApplication1/Main
  11. Change "package __PACKAGE_NAME__" to "package ScalaApplication1"
  12. Change "object __CLASS_NAME__" to"object Mail"
  13. Press Shift-F6 to build and run.
  14. Success!

Reinitialize a Deki Wiki

I’ve been messing around with a Deki wiki, and now I’m ready to start using it for real.  Here’s how I set it back to its newly created state.




  1. cd /path/to/your/deki/wiki/root
  2. cd ./attachments
  3. rm -rf *
  4. mysql -u root -p
    1. use db-catalog-name-from-mindtouch.deki.startup.xml;
      1. Mine is deki-kleinfelter
    2. DELETE FROM pages WHERE page_title!='' and page_namespace=0;
    3. DELETE FROM attachments;
    4. DELETE FROM comments;
    5. select user_id, user_name, user_role_id from users;
    6. You may want to delete some users rows.  Do not delete your admin ID or the 'Anonymous' user.   Me -- I didn't follow this advice. So here's the recovery:
      1. service dekihost stop
      2. mysqladmin -p drop database-name-here
      3. Delete everything from /path/to/deki/wiki/root
      4. cd to ~/Deki_Wiki_1.8.1a_Hayes_source
      5. cp -r web/*  /path/to/deki/wiki/root
      6. chown -R apache /path/to/deki/wiki/root
      7. service httpd restart
      8. Browse to http://www.example.com/config/index.php
      9. Complete and submit the form.
      10. cd to the config directory under your DocumentRoot (e.g. cd /usr/local/wikis/example.com/config)
      11. cp LocalSettings.php to your DocumentRoot (e.g. cp LocalSettings.php /usr/local/wikis/example.com/) 
      12. cp AdminSettings.php to your DocumentRoot (e.g. cp AdminSettings.php /usr/local/wikis/example.com/) 
      13. cp mindtouch.host.sh ../bin/
      14. service dekihost start
    1. If I missed something, please let me know!

    Importing a MoinMoin Wiki into a Deki Wiki

    I’m contemplating switching my wikis from MoinMoin to Deki.  In order to be able to do this, I need to import MoinMoin pages and attachments into Deki.



    What my scripts will do:


    • Import MoinMoin pages into Deki.
    • Import MoinMoin attachments into Deki.
    • Import MoinMoin users into Deki.
    • Create a mail-new-pw shell script you can run to notify all users of their user-ID and password on the new wiki.

    Known limitations:


    • All page text is imported, but it may look a little different in Deki than in Moin.
    • All attachments and embedded images will be moved to the end of their respective pages, and the embedded references to them will be changed to a message directing the user to the attachments at the end of the page.
    • Embedded URLs will not be rewritten.  This means that if your wiki is hosted at wiki.example.com, an url such as http://wiki.example.com/SomePage/Attached.file will NOT be adjusted to reference the relocated attachment.
    • Users will be imported, but passwords will not.  The Deki password 'recovery' process is available to users to gain access to their migrated account, as well as the email-password script generated by this upgrade process.

    Prerequisites:


    • A Deki wiki (can be empty).
    • A MoinMoin wiki.
    • A Windows PC with
      • Python 2.5
      • MoinMoin 1.5.8
      • Cygwin
    • The instructions below assume that you have a MoinMoin wiki at www.example.com, that you've been evaluating Deki at wiki.example.com, and that you want your new wiki to be available at www.example.com.
    • Patience!

    It does all the Deki I/O via curl, so you can use it for samples of the curl commands for:


    • Authorization (login)
    • Page creation
    • Subpage creation
    • User creation
    • Attachments

    Please note: I prefer to keep these instructions on my site, and that people download the scripts via this page.  That way, there is a slight chance that I’ll pick up some extra cents from the ads.

    Step-by-step instructions:

    </strong>

    1. Download my scripts to a Windows PC, and unzip them into a directory.
    2. Download the MoinMoin data directory to a Windows PC.
    3. Shut down your MoinMoin wiki and bring up your new Deki wiki at the old URL.
      1. Edit your httpd.conf:
        1. Comment out your MoinMoin VirtualHost at www.example.com.
        2. Locate your entry for wiki.example.com, and change its server name to use www instead of wiki.
      2. Restart Apache 
      3. Make sure your (possibly empty) Deki wiki works at the new URL.
    4. Edit myoptions.py to contain values relevant to your Deki wiki.
      1. Note: You may wish to create a special wiki user ID named something like "imported-from-old-wiki".
    5. From a CMD prompt, run: python builder.py C:\path\to\your\wiki\data-directory
      1. You now have a 'listfiles' subdirectory, containing content that is ready for importing into Deki, plus a 'load2deki.sh' shell script.
    6. From a Cygwin prompt, run: bash load2deki.sh
      1. Your pages have been loaded into your Deki wiki.  Note that it is safe to re-run this script, if needed.  It will overwrite any previous editions of the pages.
    7. From a CMD prompt, run: python builder2.py C:\path\to\your\wiki\data-directory
    8. From a Cygwin prompt, run: bash load2deki2.sh
      1. Your attachments have been loaded into your Deki wiki.
    9. From a CMD prompt, run: python builder3.py C:\path\to\your\wiki\data-directory
    10. From a Cygwin prompt, run: bash load2deki3.sh
      1. Your users have been loaded into your Deki Wiki.
    11. Optional: Run mail-new-pw.sh on a server that supports the Unix/Linux 'mail' command.  This will send email to each of your users, with their new ID/password.


    Notes on Using Dekiwiki

    Building from source hangs on a really big gmcs (C-sharp version of cc).  I edited the Makefile in src/Dekiservices to remove excess trailing whitespace on lines ending with backslash.
    <hr />

    "My passwords" is not on the User Preferences screen for non-admin users.

    Work-around: From your wiki root directory, edit includes/SpecialPreferences.php. At (or about) line 312, you'll see:

    //todo: was using isLocal(), but that doesn't work
    if ($wgUser->GetService()->GetSID() == WebService::SIDAUTHLOCAL) {


    Change the "if" line to read:
    if (true) {

    and you will begin getting the "My password" fields.

    QUESTION: What have I just done by removing the test for SIDAUTHLOCAL? Have I opened up a security hole?

    UPDATE: This is not enough to get password updates to actually work.
    1. Update includes/User.php and change this:
    • function isLocalAccount() { return $this->getService()->isLocal(); }
    to this:
    • function isLocalAccount() { return true;}
    2. Also edit includes/Title.php and change function isLocal to always return true
    3. Note: I think that changing just 2 should do it, but it doesn't, so do both.

    <hr />
    If attachments give error messages about not being able to create directories or set permissions on files, but your permissions are correct, adding "LD_LIBRARY_PATH=/opt/mono-1.2.5.1/lib:" to the environment in which dekihost runs resolved the problem.



    <hr />Timezone appears to be broken. To fix it:


    • vi languages/Language.php
    • find  function userAdjust
    • right after $tz gets set, add
      • $tz = '-5:00';   # KPK KEVIN changed to force EST, because saving the timezone preference is broken. 

    •  vi includes/SpecialPreferences.php
    • Around line 301, comment out the 2 (not 3) lines that send the timezone control.


    <hr />The part of changing your password that checks your old password appears to be broken, because all attempts in the code to fetch the password fail.  Hack the code to allow ANY old password:


    • vi includes/User.php
    • Change function checkPassword to always return true.  This does not break login, because login uses a different method to check the password. 


    <hr />The "Forgot password" feature is broken.  To work around:


    • cd ~kevin/Deki_Wiki_1.8.1d_Hayes_source/src
    • vi src/services/Deki/Entities/UserBE.cs
    • Locate "public XDoc ToXml"
    • Inside this function, ensure that "showPrivateInfo = false" gets changed to "showPrivateInfo = true"
    • cd src
    • make root_dir=`pwd` PREFIX=`pwd`/bin
      • (Those are back-ticks above.)
    • e

    Creating a Second Instance of Dekiwiki (Better Method)

    Here’s a better method (better than my first method) for running a multiple wiki dekiwiki farm.  My first instance was wiki.kleinfelter.org (with DocumentRoot /usr/local/wikis/deki-wiki-hayes-kleinfelter.org) and my second will be wiki.kleinfelter.com (with DocumentRoot /usr/local/wikis/deki-wiki-hayes-kleinfelter.com).



    My wikis run on the same physical host, but with different domain names.  Here’s how I created my second instance.



    Before you start this procedure, you must have at least one instance of the "Hayes" release of Dekiwiki running on your Unix/Linux server.



    1. cd ~ /Deki_Wiki_1.8.1a_Hayes_source
      1. Decide where you are going to put your DocumentRoot.  (I'm using /usr/local/wikis/deki-wiki-hayes-kleinfelter.com.) 
      2. mkdir /usr/local/wikis/deki-wiki-hayes-kleinfelter.com
      3. cp -r web/*  /usr/local/wikis/deki-wiki-hayes-kleinfelter.com
      4. chown -R apache /usr/local/wikis/deki-wiki-hayes-kleinfelter.com
    2. Edit your httpd.conf file (Mine is /usr/local/apache/conf/httpd.conf).
      1. Copy the entire "<VirtualHost *:80>" section for your first instance and paste it below your existing instance.
      2. In the newly pasted copy:
        1. Change ServerName to the dns name of your new instance.  (e.g. wiki.kleinfelter.com) 
        2. Change DocumentRoot to your new instance's DocumentRoot. (e.g. DocumentRoot "/usr/local/wikis/deki-wiki-hayes-kleinfelter.com")
    3. edit /etc/init.d/dekihost.  What you do here will be different, depending on whether you are starting with the dekihost file provided with dekiwiki, or you already have a multi-instance deki wiki running.
      1. If you are going from one wiki to two wikis, you'll want a dekihost file that looks something like this one.  Note that your apikey must match your dekihost's apikey.
      2. If you are simply adding another instance to a multi-instance setup, just create another 'config id=xxxx' section.
    4. Restart apache (e.g. service httpd restart)
    5. Restart dekihost (e.g. service dekihost restart)
    6. Open a browser to httpd://your-site-example.com/config/index.php.  (Use your site's URL.) 
    7. Fill in the blanks and submit the form.  Be sure to use a different Site Name, Database Name, and DB username than your other instances!
    8. cd to the config directory under your DocumentRoot (e.g. cd /usr/local/wikis/example.com/config)
    9. cp LocalSettings.php to your DocumentRoot (e.g. cp LocalSettings.php /usr/local/wikis/example.com/) 
    10. cp AdminSettings.php to your DocumentRoot (e.g. cp AdminSettings.php /usr/local/wikis/example.com/) 

    UPDATE: Well shoot!  That didn’t work so well. The problem is that the code is still immature, and I decided that I really need complete independence of my two Deki wikis.  This will let me upgrade them independently.  I also ran into trouble with lucene when I re-indexed both wikis at the same time (Find/Search started giving error messages).

    1. Create /etc/init.d/dekihost and /etc/init.d/dekihost2
    2. Create /etc/dekiwiki/mindtouch.deki.startup.xml and /etc/dekiwiki/mindtouch.deki2.startup.xml
      1. Do NOT change deki to deki2 in "<path>deki</path>"
      2. Point this to each wiki in the two flavors: <deki-path>/usr/local/wikis/deki-wiki-hayes-kleinfelter.org</deki-path>
      3. Update  <config id="www.kleinfelter.org">  for each of your wikis
      4. Ensure that the following is unique per wiki  <path.store>/usr/local/var/luceneindex</path.store> and  <path.store>/usr/local/var/luceneindex2</path.store>
      5. Point the filter paths at each wiki's code base.
    3. Create a file in vhosts.d for your wiki
      1. In the second wiki, set both proxy rows to use 8082
    4. /usr/local/apache/htdocs/kleinfelter-org/lbin/mindtouch.host.sh:  set HTTP_PORT="8082"


    SendTo Printer

    From ghacks:

    It is possible to add any printer to the Send To menu. To do this we have to open the SendTo folder which is located in Documents and Settings / userprofile / if you are using Windows XP and in the AppDate \ Roaming \ Microsoft \ Windows folder if you are using Windows Vista.

    Create a new folder in the SendTo folder and name it Printers.{2227A280-3AEA-1069-A2DE-08002B30309D}. The icon will change to the printers icon and you can double-click it to access all of the known printers. Drag and Drop the printer(s) into the SendTo menu which makes them available in the right-click menu.


    Customizing a Dekiwiki Instance

    1. Change the site title (and the title of the home page) via Tools/Control Panel (log-in as the site administrator)
    2. If you imported from a MoinMoin wiki, you'll want to copy (and clean-up) your Front Page into the site default page.
    3. Replace the Mindtouch logo in the upper-left corner. Select Tools/Control Panel/Visual Appearance
    4. Remove the Mindtouch logo in the lower-left corner. On the server, vi includes/Skin.php and search for function getPoweredBy.  Change the function to return the empty string.
    5. You can edit the help URL by adding to LocalSettings.php. a line resembling: $wgHelpUrl = 'http://www.kleinfelter.org/Help_on_Using_the_Wiki';

    Creating a Second Instance of Dekiwiki

    I’m evaluating Dekiwiki.  Since I run multiple wikis, if I convert one to Deki, I want to convert them all.  My wikis run on the same physical host, but with different domainnames.  Here’s how I created my second instance.  (To create a 3rd instance, substitute "3" for the "2" in the appropriate lines.)



    Before you start this procedure, you must have at least one instance of the "Hayes" release of Dekiwiki running on your Unix/Linux server.



    1. When you installed your first instance, you un-tarred the source somewhere.  (I put mine in ~ /Deki_Wiki_1.8.1a_Hayes_source.)  cd into that directory. (e.g. cd ~ /Deki_Wiki_1.8.1a_Hayes_source)
      1. Decide where you are going to put your second instance.  This will be your DocumentRoot.  I'm using /usr/local/wikis/example.com.Substitute your DocumenRoot in the below commands:
      2. mkdir /usr/local/wikis/example.com
        cp -r web/*  /usr/local/wikis/example.com
        chown -R apache /usr/local/wikis/example.com
    2. Edit your httpd.conf file (often found in /usr/local/apache/conf or /etc/httpf/conf).
      1. Copy the entire "<VirtualHost *:80>" section for your first instance and paste it below your existing instance.
      2. In the newly pasted copy:
        1. Change ServerName to the dns name of your new instance.  For example, www.example.com.
        2. Change DocumentRoot to the DocumentRoot you selected above. (e.g. DocumentRoot "/usr/local/wikis/example.com")
        3. Change the port number on ProxyPass and ProxyPassReverse to an unused number.  I like using the last digit as my instance number. (e.g. My second wiki is on 8082).  For the rest of this procedure, '8082' means whatever port you used here.
    3. edit /etc/init.d/dekihost:
      1. Make a copy of the DEKI_PATH and the DEKI_SERVERNAME rows, changing the values to suit your new wiki, and adding a single digit (e.g. 2) after PATH and SERVERNAME (e.g. DEKI_PATH2 and DEKI_SERVERNAME2)
      2. Duplicate the first “su apache” line in both the start and the stop functions
      3. Make your copied lines reference the names you created above (e.g. DEKI_PATH2 and DEKI_SERVERNAME2, respectively).
      4. Inside the testDream function, copy and paste the original 7 lines, changing the copy to use the names you created above (e.g. DEKI_PATH2 and DEKI_SERVERNAME2, respectively).  Optional: Also change the echo –n “Dream…” to be something like echo –n “Dream2…”.
    4. Restart apache (e.g. service httpd restart)
    5. Restart dekihost (e.g. service dekihost restart)
    6. Open a browser to httpd://your-site-example.com/config/index.php.  (Use your site's URL.)
    7. Fill in the blanks and submit the form.  Be sure to use a different Site Name, Database Name, and DB username than your other instances!
    8. cd to the config directory under your DocumentRoot (e.g. cd /usr/local/wikis/example.com/config)
    9. cp mindtouch.deki.startup.xml /etc/dekiwiki/mindtouch.deki2.startup.xml (substitute your instance number for 2).
    10. cp LocalSettings.php to your DocumentRoot (e.g. cp LocalSettings.php /usr/local/wikis/example.com/)
    11. cp AdminSettings.php to your DocumentRoot (e.g. cp AdminSettings.php /usr/local/wikis/example.com/)
    12. Edit mindtouch.host.sh:
      1. change SCRIPT= to reference mindtouch.deki2.startup.xml (substitute your instance number).
      2. Change the HTTP_PORT to match the port number you used in your httpd.conf (above)
      3. Change the LOGFILE to a unique name (e.g. add a 2)
      4. Change the PIDFILE to a unique name (e.g. add a 2)
    13. touch /var/log/deki2-api.log (substitute the LOGFILE value you used above)
    14. chown apache /var/log/deki2-api.log (substitute the LOGFILE value you used above)
    15. cp mindtouch.host.sh /usr/local/wikis/example.com/bin/ (substitute the DocumentRoot portion of the name to match your DocumentRoot)


    My Take on Google IMAP With Thunderbird 2

    1. Make sure IMAP is enabled in your GMail account settings (on mail.google.com)
    2. File/New/Account/Email_Account and click Nexw
    3. Identity: Enter your firstname and lastname, plus youremail@yourdomain.com and click Next
    4. Server Information:
      • Server type = IMAP
      • Incoming server: imap.gmail.com
      • Outgoing server: smtp.gmail.com
      • ...and click Next
    5. User Names
      • Incoming user name: youremail@gmail.com
      • Outgoing user name: youremail@gmail.com
      • ...and click Next
      • Click Next until the wizard completes
    6. Rename the account to Account Name = gmail.youremail@yourdomain.imap
    7. Take TB offline without downloading email (I'm behind a firewall)
    8. Further TB setup
      1. Tools/Account Settings
      2. Select gmail.youremail@yourdomain.imap
      3. Server Settings:
        1. Port = 993
        2. Use secure connection = SSL
        3. Check for messages at startup = true
        4. Check for new messages every 55 minutes
        5. When I delete a message: Remove it immediately (Paradoxically, this will retain the email in your "All Mail" folder.  The one thing that Google IMAP uses to trigger deleting an email from All Mail is when a message gets moved to Trash.)
      4. Select Outgoing Server (SMTP)
        • Select smtp.gmail.com and click Edit
        • Enter smtp.gmail.com as the Server Name and set the Port to 587
        • Username = youremail@gmail.com
        • Use secure connection = TLS
        • Note: If you just can't get it to connect for SMTP, it may be that your employer has blocked access to port 587 via the corporate edition of McAfee.  Employers used to just block port 587 via their firewalls.  However, when people took their company-owned laptops home, they were then able to connect in GMail.  So some have taken to configuring the corporate edition of McAfee to prevent all processes on your PC from connecting to port 587 on ANY server.
          • To see if this is the case:
            • Set up Portable Thunderbird and get SMTP working from another PC that you know does not block port 587.
            • Copy that Portable Thunderbird to your laptop.
            • See if it now fails.  If it does, you know that your laptop has port 587 blocked.
          • If you need to use SMTP anyhow:
            • Configure Thunderbird to use a proxy: SOCKS, localhost, 8080 (via Tools/Options/Advanced/Network & Disk Space/Connection)
            • Set up an ssh SOCKS proxy on port 8080.
    9. Click Get Mail in TB
      • If it asks to go online, tell it OK.
      • Take it offline afterward. (Click the light-bulb in the status bar.) Tell it do download messages for offline use.
    10. Change the default location for Sent and Drafts to [Gmail]/Sent Mail and [Gmail]/Drafts respectively by doing:
      • Tools/Account Settings/Copies & Folders
        • When sending messages, automatically place a copy in
          • Other
          • gmail.youremail.imap/Gmail/Sent Mail
        • Keep message drafts in: "Drafts" Folder on Local Folders
        • Keep message templates in: "Templates" Folder on Local Folders
    11. More Config
      1. Check (right-click on, select Properties/Offline)  Enable offline access for Inbox, Sent Mail, Trash, All Mail, Spam.
        • I don't enable it for Drafts, because this can lead to a bunch of copies of the message when using Tbird with Google IMAP.
        • I do perform the following Trash folder alignment exercise from Lifehacker.  I like the behavior that deleting a message deletes all copies of it (even those you said to 'copy' to another Tbird folder).  Note that if you really want to keep the other copy, you can move it to your "Local Folders" message store.
          • Tools/Options/Advanced/General
          • Hit the "Config Editor" button next to the "Advanced Configuration" label.
          • Using the filter entry box at the top, type in mail.server.server and you will see a list of keys and values. One of those keys will be mail.server.serverX.name, where X is a number and the value is the name of your Gmail IMAP account. Remember X.
          • Right-click somewhere in the box and select New->String.
          • A dialog box will pop up asking for the name of your new key. Put in mail.server.serverX.trash_folder_name, where X is the number you remember from above. (For example, mine is mail.server.server2.trash_folder_name.)
          • A new box will come up asking for the value of your new key. Put in [Gmail]/Trash
          • Go to Gmail's web interface and delete the label [Imap]/Trash.
          • Restart Thunderbird. 
    12. Open each of your folders in Thunderbird, and let it download all message headers. (Slow.)
    13. Go offline.