jeudi 17 avril 2008

Disabling Samba and Portmap on EeePC

Today I joined the EeePC frenzy. After playing a while with it I found that there are too many opened ports on this little thing, and I HATE having opened ports when I don't use the given service:
  • netstat -tul

My suspicions were right - after searching a while on the net I found that the version of Samba shipped with the EeePC has some security flaws (see here for a quick fix). 

After fixing the flaw I wanted to stop Samba and Portmap, but it turned out to be a tricky business. No matter what I tried, they always came up after a reboot (removed all scripts from /etc/rc*d from both the system and the user partitions, etc.). Finally I was really pissed of from the damned things showing up, so I did a quick:
  • sudo chmod a-x /etc/init.d/samba
  • sudo chmod a-x /etc/init.d/portmap
  • sudo chmod a-x /sbin/portmap
  • Reboot
and the problems went away (note that stopping the inet.d/portmap script alone did not prevent portmap from running). Now I can start and stop the service only when I need it with:
  • sudo sh /etc/init.d/samba start
and
  • sudo sh /etc/init.d/samba stop

I don't understand who and why starts the services (possibly because I've never actually used Xandros) so I'd really appreciate it if someone could give a better solution to this problem.

dimanche 2 décembre 2007

Disappointed from Mac OS X Leopard (for now)

I am a Mac convert. For an year now. The first month it was really painful, but when I got the "right" mental model it became a real pleasure. I guess people get so inflamable on the Mac vs. Win issue because of the one month of sufferings.

The one thing that made me really appreciate Mac was that it *just worked*. Having worked on Windows and Linux beforehand, it was really amazing to see that many things done intuitively.

And I installed Leopard. Big Mistake. Sure, there are many improvements, but apart the Time Machine there's nothing really new. Of course, there are many little improvements - over 300 according to Apple. And that's the biggest problem - this would be a nice evolution of the OS (something like the Service Packs under Windows, which by the way are FREE) if it didn't cause me so much problems.

Before installing Leopard my Mac was pretty stable. Everything worked perfectly well, no hangups.. pure pleasure. After the upgrade the system became more instable.
- Before the 10.5.1 fix I couldn't connect to the Wi-Fi network at work because WPA was broken. So, one week or so I was using a 10m long cable to connect to the network.
- After the 10.5.1 WPA works again (yess!) but my Ethernet card is acting weird. When I plug the cable in, it is shown as "connected" and after one second it becomes "disconnected". Tried with all kinds of cables. You have to retry 5-6 times and hope that it will realise that the cable is still there.
- On three occasions KeyNote (from iWorks'08) restarted the computer. You press "Start the presentation" button and you get the nice little "booting up" screen. Great thing to get in the middle of a presentation. Or just after adding several complex animations (which you might loose even if you've pressed "save" beforehand).
- For two days now the clipboard is working like crap. Some applications just ignore the text copied from certain other applications. I can't copy the URL of a web page from Safary and paste it in Mail. WTF?
- Safari and Preview are buggy. Sometimes doing a simple copy of a text makes them hang up. Great when you have 7-8 tabs or documents opened and you HAVE to restart the application. Long gone are the old days of Safari 2 when I really didn't worry that the browser might hang and I'd have to look up the same information AGAIN.
- Mail crashed several times. Afterwards several e-mails were messed up - the senders were exchanged. I almost replied to the NS2 mailing list that I didn't want to participate in a Photoshop study course.

Even with all these problems, I still feel better with Mac than with Windows. However, Apple wants us to believe that Macs are inherently better than PCs. But, in order to achieve this, they must produce rock-solid products EVERY time. Which they don't. So, yes.. they're just humans.

To put it simply - OS X 10.5.2 will be the thing that 10.5.0 should have been (at least I hope so) - an evolution of the OS that should make the life more pleasant and most importantly - care-free.

vendredi 13 juillet 2007

Mac OS X converting A4 to US letter (or vice versa) when saving PDF file

Today I had to generate a PDF version of a Word document. Fortunately enough, Mac OS X has great integration with PDF documents, so it's possible to export a PDF document directly from the "Print" dialog of any application.

There was a little problem, however - the source Word document came in "US Letter" format and the PDF document had to remain in the same format. It turned out that the "Save as PDF" action converted the page to the local A4 format. After searching a little bit on the net I found some solutions (like this one) which seemed a little too complicated for such a simple thing.

I was thinking that I should try opening the document in OpenOffice to export it directly from there, but I decided to try out some of the options in the System Preferences before jumping in the hell of fixing the layout.

I tried switching to "American" measurement units (found under System Preferences -> International -> Formats) and it worked! After exporting the document in the correct "US Letter" format I switched back to "Metric" system and the system started generating PDFs in the plain old A4 format. Youpee!

That's it for now - I hope that you found it useful!

C ya!
Alex


PS. I'm using Mac OS X 10.4.10, so this procedure may not work in the older releases

mercredi 20 juin 2007

Counting the number of files in all subdirectories with a one-line Bash script

As I usually forget the scripts I'm using from time to time, I decided to backup them to a place where they'll be easily accessible and could eventually be used by someone needing the same thing.

Enough talking already. This time I needed to find the number of PDF files in all my directories (listed directory by directory). Currently I'm working under Linux, so a one-line bash script seemed the ideal solution. Here's what I came up with:

for x in `ls -d */ . | tr ' ' '*' ` ; do x=`echo "$x" | tr '*' ' '` ; find "$x" | grep -i "\.pdf$" | wc -l | xargs -i/// echo /// files in $x ; done



Here is a sample output of the execution:
1069 files in .
4 files in App Help/
1 files in Books/
73 files in Lectures/
12 files in Personal/
979 files in Work/


Some explanations:
ls -d */ - lists all subdirectories of your current directory. If you want to list all hidden directories add ".*/" (as found in the comments of this post).

tr ' ' '*' - replaces all spaces with * so that the "for" loop does not break directory names containing spaces. The name is restored with another "tr". I used the symbol * as it is very rare that someone would put it in the name of a directory, but who knows.

find "$x" - outputs all files of the given subdirectory to the standard output, which in this case is:

grep -i "\.pdf$" - which filters out only the files ending with .pdf (case insensitive).

wc -l - counts the number of lines (ie. the number of files) and the output is passed to xargs, which is used to format the output.

xargs -i/// echo /// files in $x - the "-i" option specifies the string that will be replaced with the text read from the standard input (ie. the number of files). I'm using a string that is impossible to put in a filename, so that we have a nicely formatted output.


Ok, that's it for now. I hope that someone might find this one useful.

Alex

mardi 15 mai 2007

Hi everyone !

Hello everyone !
Here I join the blogging madness.. only time will show if everything's going to be ok ;)