domenica 18 aprile 2010

Opening Sopcast links from within Firefox on Ubuntu Karmic 9.10

I'd like to open sop:// protocol links automatically in Firefox. The most popular solution I found is:

 1. In Firefox, in the Location bar, type about:config and press Enter.
 2. Right-click anywhere in the grid, choose New, then String.
 3. In the Enter the preference name prompt, type in network.protocol-handler.app.sop and press OK.
 4. In the Enter string value prompt, type sopcast-player and press OK.
 5. Try to open sop:// link on your favorite website and you will be presented with dialog box where you can search location of sopcast player. Navigate to ~/usr/bin and point to sopcast-player and click OK.
 6. OK out of dialog box and now all sop:// links should open sopcast player automatically.

This solution doesn't work for me. When I try to to open sop:// link, I'm not presented with "Open with..." dialog box. I receive an error message like:

Firefox doesn't know how to open this address, because the protocol (sop) isn't associated with any program.

In my case Firefox 3 does not actually launch sopcast-player using the network.protocol-handler.app configuration option.
If I go to Edit -> Preferences -> Applications, the sop protocol is not listed and I cannot add it there.
So I tought to retrieve all needed parameters from Windows and add the protocol manually via config file. mimeTypes.rdf stores information about which action is to be performed when downloading certain types of files, such as opening the file in a specific program or saving it to disk. mimeTypes.rdf is stored on our hard drive in ~/.mozilla/firefox/xxxxxxxx.default/
1.  Quit Firefox
2. we can back up the profile directory: if something goes wrong we can restore original files.
3. Let's open up mimeTypes.rdf. We have to find the section and modify it in this way (adding the line <RDF:li RDF:resource="urn:scheme:sop"/>):

<RDF:Seq RDF:about="urn:schemes:root">
    <RDF:li RDF:resource="urn:scheme:mailto"/>
    <RDF:li RDF:resource="urn:scheme:irc"/>
    <RDF:li RDF:resource="urn:scheme:ircs"/>
    <RDF:li RDF:resource="urn:scheme:webcal"/>
    <RDF:li RDF:resource="urn:scheme:dlc"/>
    <RDF:li RDF:resource="urn:scheme:sop"/>
</RDF:Seq>

4. Now we have to add these parameters below the line </RDF:Seq>:

<RDF:Description RDF:about="urn:scheme:sop"
                              NC:value="sop">
   <NC:handlerProp RDF:resource="urn:scheme:handler:sop"/>
</RDF:Description>
<RDF:Description RDF:about="urn:scheme:handler:sop"
                              NC:alwaysAsk="true" />


Done! Now if we open sop:// protocol links in Firefox, we will be presented with "Open with..." dialog box. Or, once Firefox is loaded, we can go to to Edit -> Preferences -> Applications and set the location of sopcast-player.

EDIT (09/12/2010):
It may be necessary to modify the boolean value of network.protocol-handler.expose-all on Ubuntu 10.04:

 1. In Firefox, in the Location bar, type about:config and press Enter.
 2. Set the value of network.protocol-handler.expose-all to false .
 3. Try to open sop:// link on your favorite website and you will be presented with dialog box where you can search location of sopcast player. Navigate to ~/usr/bin and point to sopcast-player and click OK.
 4. OK out of dialog box and now all sop:// links should open sopcast player automatically
 5. We can restore the value of network.protocol-handler.expose-all to true.

Best regards.

venerdì 16 aprile 2010

CGPersia toolbar for Firefox

CGPersia is a great forum dedicated to 3D arts and related softwares. CGPersia has a lot of sections and sub-sections. Since I visit CGPersia every day, I created a toolbar extension for Firefox to speed up my navigation and to easily search threads and posts.


The very early version of the toolbar is available here.
It does not contain all of the features that are planned for the final version, but it works fine for me.
Probably I will add drop-down menus with dynamic links to hottest and most  viewed threads and a window for advanced search.
I'm releasing it because a 3d passionate could find it useful.

Best regards.

mercoledì 14 aprile 2010

Creating a 3D terrain from height measurements

Sometimes we architects have to create a digital representation of a ground surface topography (DEM) for 3D visualizations. I usually start with a .dwg file and a bunch of  height measurements. The image on the left is a typical case.
I invented an "original" way to crank out a digital elevation model.
I usually use AutoCAD Map and a couple of extra tools.
I export all measurements in a text file and then import it into AutoCAD Map. Exporting all measurements is quite simple: I use CAD2FILE, a free Lisp program that allows me to export all needed parameters into a text file.

We can select the file type to create (on the left) and the properties to send to the file. In my case I select Insertion Point and click  Okay.

The result is a text file with this structure:

Start X,Start Y,Start Z,Text Value,
2318050.04,4644289.52,0,12.4,
2318382.41,4643741.07,0,12.4,
2318385,4643737.46,0,12.4,
2318387.03,4643734.37,0,12.4,
...

Start X, Start Y,Start Z are the coordinates of the insertion point of the measurement. Value is the measurement.

Cool! What I wanna do now is fix this file because AutoCAD Map can import a series of x, y and z coordinates only, without other parameters.
To do this I wrote a simple Java program named Virgola:




// Author: Stefano Bolli
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;

public class Virgola {

public static void main(String[] args) {
Virgola virgola = new Virgola();
}

public Virgola() {

// Text directory
File textDir = new File(".");
// Filter for text files
TextFilter tfilter = new TextFilter();
// Text files
String[] textList = textDir.list(tfilter);

if (textList.length == 1 ) {
System.out.println("I found the file:" + "\n");
System.out.println(textList[0] + "\n");
System.out.println("I'm fixing the file...");
readFile(textList[0]);
}
else if (textList.length > 0) {
System.out.println("\nFound multiple files. Indicate the file you wanna fix:");
System.out.println("\n");

for (int i = 0; i < textList.length; i++)
System.out.println(i + ") " + textList[i]);
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String fileChoosen = in.readLine();
int x = Integer.parseInt(fileChoosen);
readFile(textList[x]);
} catch (IOException e) { }
}
else
System.out.println("No text file found");
}

public void readFile(String fileToRead) {
try {
BufferedReader br = new BufferedReader(new FileReader(new File(fileToRead)));
String line;
Vector vector = new Vector();
while ((line = br.readLine()) != null) {
// Store the row in the vector.
vector.addElement(line);
}
br.close();
SaveFile(vector, changeNameToFile(fileToRead));
}
catch (IOException e) { } }
public String changeNameToFile(String name) {
String newName = name.substring(0, name.lastIndexOf(".")) + "_fixed_by_Virgola.txt";
return newName;
}
public void SaveFile(Vector v, String fileToSave) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(fileToSave));
for (int i = 0; i < v.size(); i++) {
String s = (String)v.elementAt(i);
if (!s.startsWith("Start")) {
out.write(cleanLine(s) + "\n");
}
}
out.flush();
out.close();
} catch (IOException e) {
}
}
public String cleanLine(String line) {
String oldLine = line.substring(0, line.lastIndexOf(","));
String newLine = oldLine.substring(0, oldLine.indexOf(",0,")) + oldLine.substring(oldLine.lastIndexOf(","));
return newLine;
}
/** * Filter for text files. */
class TextFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
boolean acceptFile = false;
if (name.endsWith(".txt"))
acceptFile = true;
return acceptFile;
}
}
}


If someone needs this program, I can compile it and send as .exe file.


Ok, now we can import the text file into AutoCAD Map and create the terrain.
The final mesh is a triangular irregular network and can be imported into 3d softwares like Maya o 3DS Max: as you can see, I was working on a level land with a river. There are a few errors I can fix quickly before smoothing the mesh.

Best regards.

JDownloader Click'N'Load on Ubuntu Karmic

JDownloader is a terrific Java software to simplify downloading files from One-Click-Hosters like Rapidshare.com or Megaupload.com. These sites allow us to upload any kind of file that can be downloaded by other users. If the file size exceeds the allowed limit, the data are splitted into a lot of parts, zipped and uploaded to the hosters. If we don't have a Premium Account, we have to download one part at time. Click'N'Load is a JDownloader's built-in technology to downloading a container file that lists the different parts. Installing Click'N'Load on Windows is pretty simple. On Ubuntu we have to install it by ourself:

Download the Linux/Mac Installer/Starter, open it and change the path to the Installation folder, make it executable with the terminal command:

 stefano@SERVER:~$ chmod +x jd.sh

and run it. This file will download the latest Jdownloader.
Now, what we wanna do is add some protocols to Firefox to handle Click'N'Load.
On Linux/MAC, some needed protocols are not controlled by the OS. If you are using Firefox, you may add the protocols by ourself:
  1. Open Firefox advanced configs by typing “about:config” in the address bar.
  2. Right click –>new: create the following entries for each protocol:
    1. Replace PATH_TO_SCRIPT with the path to jd.sh. First Line is String
    2. Second Line is Boolean
  3.  Restart JDownloader
 network.protocol-handler.app.jd = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.jd=true
 network.protocol-handler.app.jdlist = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.jdlist=true
 network.protocol-handler.app.ccf = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.ccf=true
 network.protocol-handler.app.rsdf = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.rsdf=true
 network.protocol-handler.app.dlc = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.dlc=true

martedì 6 aprile 2010

Funky gallo

My brother Massimo manages a team of players in an Italian fantasy soccer league named Hattrick. The team is named Alligallya, a play of words from an old Italian song . He asked me for a logo for his team and I was very happy to sketch a funky cock (on the left... I'll buy a pen tablet as soon as possible, I think I need it :) ) and trace it in Photoshop. No special effects, I used transparent gradients for reflections and soft shadows to fake depth. This kind of works remembers me how lazy I'm: the head is good, the torso and everything else are not exceptional. But I need a rest after a couple of hours. Probably I'll fix the torso tomorrow. I like to help my brother, his team is quite scanty (lol, it's a joke, Max) :)
Best regards