Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Aug 28, 2009

Print Images Across Multiple Pages in Ubuntu

Ubuntu, which I use as my primary desktop OS is sweet, but it always has these little issues, when things you're used to in Windows are either hard or impossible to achieve. Well, there's nothing impossible when it comes to Linux, it just depends whether it'd take two minutes or five years to achieve whatever it is you want.

Today I had to print a large image across multiple pages and couldn't find an easy way to do this. Apparently, this is a known issue.

One messy way to do this (assuming you have the time and resources to get the right size) is this:

$ lp -d hp -o scaling=200 -o media=a4 filename.png


Where hp is the name of the printer and 200 is the size of the original image in percents.

Sadly enough, this only works for bitmap images. I had to export my original .svg file to .png, otherwise I was getting just a part of my svg which was cut to fit the A4 sheet.

Jan 9, 2009

Pidgin's “New IM” Tray Icon

I think Pidgin is really one of the best-designed applications for GNOME. It almost looks like its interface was done by Google: nothing extra, just what you need to send and recieve messages. No bluish colours though.

However, I was a bit surprised once, when changing DPI resolution of the system also changed the Pidgin's tray icon for new instant message from original to a smiley: . I actually connected those two events later, when I've found out that Pidgin uses four different sets of tray icons to suit the height of the tray panel.

Those are stored in /usr/share/pixmaps/pidgin/tray in four different folders related to the size of the icons. Turns out, the tray-new-im.png icon in 22x22 folder is different from icons in three other folders. There's actually a confirmed bug for that. But wait, it goes further.

Not only the 22x22 icon has a smiley instead of an orange dialogue-box, also «speech box part of tray-message.png is white, instead of having a bluish gradient like the others in 22”. That'd probably be okay with me if it was about an icon in some messy has-version-for-every-os java application like Azureus, but since we're talking about spotless purity of GNOME native app, that's truly an outrage.

Luckily for everyone, Linux has a very simple way to fix this. Just save an icon from the bug page (or you can use the one from the above, they are identical), and replace the one in /usr/share/pixmaps/pidgin/tray/22x22 with it.

Now you're good to go (well, except for the tray-message.png).

Aug 18, 2008

Jackrabbit on JBoss with JNDI & RMI

We recently decided to use JCR, specifically, it's Apache implementation, JackRabbit. What's already done, is a web application running on Tomcat servlet container. One of the most obvious ways to tie those two, is to deploy JackRabbit on JBoss and expose it via JNDI.

Configuring JBoss Server


First, you need to download JBoss Application Server. Its installation in Ubuntu is as easy as extracting the downloaded jar/zip to the directory where you want JBoss to sit, and setting the JBOSS_HOME variable to that directory in ~/.bashrc.

To deploy JackRabbit, you need to obtain jackrabbit-jca.rar and jackrabbit-rmi.jar from JackRabbit downloads page and jcr-1.0.jar.

Note: The .rar archive contains all JackRabbit dependencies, including concurrent.jar.

You will also need to download the jcr-ds.xml. Edit the file so the <rar-name>jackrabbit-jca.rar</rar-name> property would contain the actual name of the rar you've downloaded (I had jackrabbit-jca-1.4.rar) and the homeDir property would point to the directory where you want JackRabbit to store its stuff.

To complete deployment, you now need to put jackrabbit-jca.rar, jackrabbit-rmi.jar and jcr-ds.xml files to $JBOSS_HOME/server/default/deploy and jcr-1.0.jar to $JBOSS_HOME/server/default/lib.

Note: Apparently, you should be careful about renaming the jcr-ds.xml file. I tried to name it “jcr-ds-1.4.xml” and kept getting JackRabbit deployed incompletely. Once I renamed it back to “jcr-ds.xml”, everything went smoothly.

To start JBoss, do $JBOSS_HOME/bin/run.sh.

Configuring Client


Now you might wanna check your JCR repository. You will need to create a simple function I found in the mail archive:

private static Session getJackrabbitSession() throws RepositoryException {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

try {
InitialContext ctx = new InitialContext(env);
ClientAdapterFactory adapter = new ClientAdapterFactory();
RemoteRepository rr;
rr = (RemoteRepository) ctx.lookup("jnp://localhost:1099/jcrServer");
Repository repository = adapter.getRepository(rr);
Credentials credJBoss = new SimpleCredentials("username", "password".toCharArray());
return repository.login(credJBoss);
} catch (NamingException ex) {
ex.printStackTrace();
}

return null;
}


For that code to work, you will need jcr-1.0.jar, jackrabbit-jcr-rmi.jar, jnp-client.jar and jboss-common.jar libraries in your classpath. The latter two can be found in $JBOSS_HOME/client and $JBOSS_HOME/lib respectively.

If you've done everything correct, and are lucky enough, the “first hops” from Jackrabbit introduction should work fine, with appropriate changes to obtaining Session object done.

Jul 29, 2008

Deploying Django Project on Ubuntu Server

I've recently had to deploy a pretty simple Django application on Ubuntu server, and here're a few tips for myself in the future doing this once again.

For starters, there's a Jeff Baier's tutorial which covers most steps. There're, however, a couple of things I had to learn the hard way.

First, if you wish to use a stable version of Django, instead of dealing with subversion and compilation, just install it from repositories:

$ sudo apt-get install python-django

If you do so, your admin media will be in the following directory:

/usr/share/python-support/python-django/django/contrib/admin/media

Second, in your .py files don't use relative imports. If you have a project named “project_one” and two applications, “app_one” and “app_two” applications, this will work on local django server, but won't work in production:

import app_one.Something

Instead, you must always do

import project_one.app_one.Something

Third, mind the paths to your media files. It's better to adjust them before deployment so they look the same on your development localhost and production server, otherwise you might have problems during deployment.

I'm mentioning this here because django's default recommended media/admin-media url configuration is somewhat doesn't makes this easier.

Finally, keep in mind that out-of-the-box MySQL databases are not UTF-8 which is not very good if you have any language in db besides English. Unless you won't unicode-enable your MySQL server before you create your tables structure, you will have to change encoding of all the tables after.

Pretty much that is it, which actually seems really smooth deployment process to me, so another score for Django.

Jun 3, 2008

MSSQL + PHP in Ubuntu 8.04

Following comments to this post, I got MS SQL working with PHP.

$ apt-get install freetds-dev tdsodbc php5-sybase
$ nano /etc/odbcinst.ini
[FreeTDS]
Description = FreeTDS 0.61-5 Deb
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
FileUsage = 1
CPTimeout = 5
CPReuse = 5


$ nano /etc/odbc.ini
[Products]
Description = Products on The MSSQL Server
Driver = FreeTDS
Servername = FSData
Database = Products
Port = 1433

May 1, 2008

Ubuntu 8.04 Wireless

I googled out the wireless/ndiswrapper problem. The solution, quoting Ankur Srivastava's blog post, is as simple as this:

$ nano /etc/rc.local
then put
rmmod ssb
modprobe ndiswrapper

before exit 0...
...then
$ shutdown -r now

And your wireless is there.

Update: Apparently, these actions aren't needed if you're using kernel 2.6.24-17. After update from 8.04 original 2.6.24-16, wireless had not worked until I removed those lines from rc.local.

Apr 7, 2008

Firefox Memory Management Mystery

Firefox's appetite for memory is a well-known problem, especially in the latest 2.0.x versions. However, I never experienced it while I was using it on Windows. The browser never ate more than one and a half hundred megabytes.

I started to suffer from it only when I switched to Ubuntu a couple years ago. In fact, latest version with all the plugins (TMP+Firebug+Webdeveloper+DownThemAll) enabled, consumed up to four hundred megabytes of RAM so I even had to switch to Epiphany to be able to keep other greedy processes running.

But now, on the HP laptop with the same Ubuntu 7.10 the same Firefox 2.0.0.13 acts as it did in the Windows days — one and a half hundred megs no matter how many pages are opened.

I guess, this mystery will never be unriddled.