‘ Operating systems ’ category archive

Pictures partially displayed, tinyMCE problem, lightbox2 problem because of sendfile

July 25, 08 by the programmer

I had this problem a long time, I found a post I wrote from 2007-10-27.

The symptoms are

  1. Pictures displayed from the web server are not complete, only the top part of the picture is displayed, and the rest of the picture is black. This usually happens if the picture is very big (high resolution)
  2. Weird javascript problems. Problems occur only if the Javascript is served by the apache web server. The problem can gennerally occur with every static file.

This is the configuration I have:

Apache 2.0.54 on Windows XP Professional SP2
PHP 4.4.4
MySQL 4.1.12

I noticed the problem once when I was making a picture upload. I noticed that when I try to view the uploaded picture I could see only a part of the image, only the top part and never the full image.

This was pretty weird for me at the time, so I tried to see if the same is going to happen on the production server, because that was on my local server. Everything was ok on the production server so I did not bothered to fix the problem because it did not make any difference for me.


After a while I tried to install TinyMCE, a free HTML WYSIWYG editor, version 2.1.2. I run the examples from the desktop folder before uploading them to the local web server, and they were working great. After I saw that the examples were working I wanted to put them in my project and I copied all the files to the htdocs folder on the apache web server.

After I uploaded the files I tried to run the same example scripts but I noticed that they are not working, and that there was an error in firebug.

This is what the error was:

tinyMCE is not defined
tinyMCE.init({

example_advanced…. (line 8 )

missing : after case label
function TinyMCE_Engine(){var ua;this.majorVersion=”2″;this.minorVersion=”1.2″;t…

At that time I made a post to the tinyMCE support forum. This is the post. Nobody new why this error was appearing because nobody responded to my post.

So I tried to find a solution of the problem on the net, but none was available, at least I could not find it.
I also tried to upload the scritpts to my production server and supprisingly everything worked great there, so the scripts were ok, and I tried to be suspicious of my PHP, Apache confuguration. I thought that this might be some security issue or something similar.

I could not fix the problem so I decided not to use tinyMCE and I worked without a HTML WYSIWYG editor.


2 Days ago I a friend asked me to make him a web page with picture gallery I and I decided to use the lightbox2 javascript picture gallery (version v2.04 Released 3/09/08). It is very nice. It looks great. I downloaded the javascript files on my desktop.
I run the example files from my desktop and they were working great.
Again I copied the same files in the htdocs folder and after I run the examples I got an error in the firebug console.
This is what the error was:

syntax error
if (parent == do

prototype.js (line 4417)

uncaught exception: script.aculo.us requires the Prototype JavaScript framework >= 1.6.0

Object.extend is not a function
}, window.LightboxOptions || {});


lightbox.js (line 63)



I remembered that I had problems with tinyMCE, with the pictures display and now with lightbox2 and I somehow new that all those problems must be related.
I aslo noticed that the problem happens only i the files are static, like .js files of .jpg files, and if the files are big. Both the tinyMCE and lightbox have a lot of lines of javascript code.


At that moment I went to the tinyMCE Web site and downloaded the latest version (v 3_1_0_1_2). I wanted to see if the same problem will appear with the new version again. It did. I After I run the example files from the htdocs folder I got a javascript error in the firebug console.
This was the error:

missing ) in parenthetical
var tinymce={majorVersion:’3′,minorVersion:’1.0.1′,releaseDate:’2008-06-18′,_ini…

tiny_mce.js (line 1)

tinyMCE is not defined
tinyMCE.init({

skins.html (line 10)

Displaying pictures from http
Dispaying half images


I had a filling that the poblem must be in the php, apache configuration. Maybe something with the encodings, or the file size limitation or something similar. But it had to be with some confuration. So I decided that I have to solve this problem. I started to search the net for any similar cases and I found a post that is not very related to this problem but I decided to try.

I found this post: CSS and Javascript files not showing up when running Apache under Ubuntu on a flash drive? Read on. (Many thanks to the writer for writing the solution)

This guy had some similar problem, not displaying images, javascript files problem, so I thought I would give it a try.

As I found out later from the post apache by default uses a system command from the operating system called sendfile.

This command tries to deliver the static files to the browser, but because I am using Windows XP and it is “Windows operating system”, there must be some problem with it.

So I found out that Apache by default checks if the operating system supports sendfile syscall, and if it does then it uses it from the operating system, and if not it uses his own implementation of the functionality. Aslo I found out that there is a configuration property called EnableSendfile in the http.conf file, the Apache configuration file, which by default is on, which means use operating system function.

I set this configuration property to off, restarted Apache and BINGOOOOOOOOOOOOOO.

Everythig worked.

The pictures were showing up, both versions of the tinyMCE editor were working and the lightbox2 script was working. Finally after more that 9 months the problem is resolved :)

So if you have similar problems open httpd.conf, find “EnableSendfile” and set it to off like this:
EnableSendfile off


Dont forget to restart Apache after changing the configuration file

The symptoms as I mentioned before are

  1. Pictures displayed from the web server are not complete, only the top part of the picture is displayed, and the rest of the picture is black. This usually happens if the picture is very big (high resolution)
  2. Weird javascript problems. Problems occur only if the JavaScript is served by the apache web server.



More about EnableSendfile can be found here:

http://wiki.apache.org/httpd/SendfileNotImplemented

http://httpd.apache.org/docs/2.0/mod/core.html#enablesendfile


I hope this post will be useful to somebody with similar problems

Thank you



How to disable autoplay on Windows?

June 18, 08 by the programmer
Whenever you put a USB memory in the USB port or you insert a CD or DVD the Windows attempts to start the content on the medium.
This is a big security hole that some of the viruses use to spread themselves.
This is especially true if it is a USB memory because the viruses can copy themselves on the drive from the infected computer and after that with the autoplay option they can transfer themselves on the other (uninfected) machine, and by doing that they are spreading around
So in order to stop them from spreading around you can disable the autoplay option.
You can do that by following the bellow steps:

  1. Click Start ->Run
  2. Type “gpedit.msc” in the run text field
  3. Open “Computer Configuration -> Administrative Templates -> System “
  4. Find “Turn off AutoPlay”and double click it
  5. Click on the “enabled” radio button
  6. Select all drives from the drop down list bellow
  7. Click “Apply” to apply the changes
  8. That’s it, you are done

What is GNU?

June 13, 08 by the programmer

The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system.

GNU’s kernel wasn’t finished, so GNU is used with the kernel Linux. The combination of GNU and Linux is the GNU/Linux operating system, now used by millions. (Sometimes this combination is incorrectly called Linux.)

There are many variants or “distributions” of GNU/Linux. We recommend the GNU/Linux distributions that are 100% free software; in other words, entirely freedom-respecting.

The name “GNU” is a recursive acronym for “GNU’s Not Unix”; it is pronounced g-noo, as one syllable with no vowel sound between the g and the n.

The above text is quoted from the GNU official site.

So , what is GNU?

GNU is a free Unix-like operating system. They started making the operating system in January 1984. You can read the initial announcement at http://www.gnu.org/gnu/initial-announcement.html.

The Free Software Foundation was founded in October 1985, initially to raise funds to help develop GNU.

By 1990 they managed to finish most of the parts of the operating system except for the kernel. In that time a Unix-like kernel, was developed by Linus Torvalds in 1991 and made free software in 1992. Combining Linux with the almost-complete GNU system resulted in a complete operating system: the GNU/Linux system.

Estimates are that tens of millions of people now use GNU/Linux systems, typically via distributions such as Slackware, Debian, Red Hat, and others.

The GNU General Public License (GPL), the GNU Lesser General Public License (LGPL), and the GNU Free Documentation License (GFDL) were written for GNU, but are also used by many unrelated projects.

To learn more about the GNU and the complete history of development, visit the GNU official site at http://www.gnu.org and you can visit the free software foundation site at http://www.fsf.org/

You can even buy a GNU shirt or adopt a Gnu. :) http://shop.fsf.org/

Whois command in UNIX

June 02, 08 by the programmer

If you want to find out some informations about a domain name and you are running unix than you should use the whois command.

Usage: whois [OPTIONS] [QUERY]

Bellow is the list of the options

–version display version number and patch level
–help display this help
-v, –verbose verbose debug output
-c FILE, –config=FILE use FILE as configuration file
-h HOST, –host=HOST explicitly query HOST
n, –no-redirect - disable content redirection
-s, –no-whoisservers disable whois-servers.net service support
-a, –raw disable reformatting of the query
-i, –display-redirections display all redirects instead of hiding them
-p PORT, –port=PORT use port number PORT (in conjunction with HOST)
-r, –rwhois force an rwhois query to be made
–rwhois-display=DISPLAY sets the display option in rwhois queries
–rwhois-limit=LIMIT sets the maximum number of matches to return

Example: whois google.com

This will return all the available information about the domain google.com

* Note that there are many versions of the whois command so before you use it consult the man page

Display a calendar in UNIX

May 28, 08 by the programmer

If you want to see a calendar in UNIX all you have to do is write the cal command in the terminal.

This is how it’s used:

cal [-options] [[month] year]

DESCRIPTION
Cal displays a simple calendar. If arguments are not specified, the current month is displayed. The options are as follows:

-1 Display single month output. (This is the default.)
-3 Display prev/current/next month output.
-s Display Sunday as the first day of the week. (This is the default.)
-m Display Monday as the first day of the week.
-j Display Julian dates (days one-based, numbered from January 1).
-y Display a calendar for the current year.

A single parameter specifies the year (1 - 9999) to be displayed; note the year must be fully specified

Two parameters denote the month (1 - 12) and year. If no parameters are specified, the current month is calendar is displayed.
A year starts on Jan 1.
The cal command first appeared in Version 6 AT&T UNIX.

How can I disable / enable the internal PC speaker in Windows?

May 25, 08 by the programmer

If you’re running Microsoft Windows you can enable the Internal Speaker or PC speaker by following the below steps.

  1. Open Device Manager
  2. In Device Manager click View and click “Show hidden devices”
  3. This should make “Non-Plug and Play Drivers” visible in Device Manager.
  4. Expand Non-Plug and Play Drivers by clicking the plus and double-click Beep.
  5. Within the “Beep properties” window click the Driver tab.
  6. Under the driver tab if you wish to temporarily enable this device click the Start button. If you wish to permanently enable this device under the Startup Type select System.

Rename file or folder in Unix

May 20, 08 by the programmer

You want to rename a file or folder in Unix and you can`t find the command, hmmmm

That happened to me too :)

Unix does not have a command specifically for renaming files, instead, the mv command is used for renaming and moving files and folders.

To change the name of a file in Unix, use the following command syntax

mv old_file.php new_file.php

To change the name of a folder in Unix, use the same syntax as for changing files except that the parameters are folder names.

mv old_folder_name new_folder_name

That’s it,

Lazy Unix programmers :)

Synchronizing folders in Unix with rsync

May 18, 08 by the programmer

Very important think when you are a programmer is to have the ablility and tools to synchronize your code on multiple locations.

For example you can have a development version a test version and a production version of the code, and you will want all of these versions to be synchronized.

One way of doing that in Unix operating systems is by using the rsync command.

Rsync is a free open source project.

In order to use this command you have to install it first. This article will not go into the installation procedure. You will have to download rsync from the official site (http://samba.anu.edu.au/rsync/) and install it on your unix operating system.

Usage examples

Rsync is a very efficient command because it uses a special protocol (rsync remote-update protocol) to synchronize files. It only synchronizes the differences between files, not the all files, which makes it very fast.

The command can be used to synchronize files/folders on a local computer and between remote computers.

The command has the following syntax:

rsync [options] src dest

  • options - see available options bellow
  • src - This is the source path. It can be a local or remote location. This is where the files that your are going to synchronize are located.
  • dest - This is the local or remote destination that you want to be synchronized with the source destination. All the files from the source destination will be copied here, and the source and destination folders will be the same.

You must specify a source and a destination, one of which may be remote.

Perhaps the best way to explain the syntax is with some examples:

rsync *.php foo:src/

this would transfer all files matching the pattern *.php from the current directory to the directory src on the machine foo.

rsync -avz foo:src/my_web_site /data/tmp

this would recursively transfer all files from the directory src/my_web_site on the machine foo into the /data/tmp/my_web_site directory on the local machine. The files are transferred in “archive” mode, which ensures that symbolic links, devices, attributes, permissions, ownerships etc are preserved in the transfer. Additionally, compression will be used to reduce the size of data portions of the transfer.

rsync -avz foo:src/my_web_site/ /data/tmp

a trailing slash on the source changes this behavior to transfer all files from the directory src/my_web_site on the machine foo into the /data/tmp/. A trailing / on a source name means “copy the contents of this directory”. Without a trailing slash it means “copy the directory”. This difference becomes particularly important when using the –delete option.

You can also use rsync in local-only mode.

rsync -avz *.php /home/dev/src/

The above line means synchronize all the php files from the current local directory to the “/home/dev/src/” local directory, and preserve all file/folder attributes.

The most interesting option that rsync has is the ability to use the command only to see what the diffrences are between two destinations. You can do that by sing the -n option.

rsync -navz *.php /home/dev/src/

The above line will only display the differences between the current folder and the “/home/dev/src/” folder, but it will not make any changes. This is very useful if you want to see what files you have worked on or which files were changed.

Available options

There are all the available options in rsync.

 -v, --verbose               increase verbosity
-q, --quiet                 decrease verbosity
-c, --checksum              always checksum
-a, --archive               archive mode
-r, --recursive             recurse into directories
-R, --relative              use relative path names
-b, --backup                make backups (default ~ suffix)
--backup-dir            make backups into this directory
--suffix=SUFFIX         override backup suffix
-u, --update                update only (don't overwrite newer files)
-l, --links                 copy symlinks as symlinks
-L, --copy-links            copy the referent of symlinks
--copy-unsafe-links     copy links outside the source tree
--safe-links            ignore links outside the destination tree
-H, --hard-links            preserve hard links
-p, --perms                 preserve permissions
-o, --owner                 preserve owner (root only)
-g, --group                 preserve group
-D, --devices               preserve devices (root only)
-t, --times                 preserve times
-S, --sparse                handle sparse files efficiently
-n, --dry-run               show what would have been transferred
-W, --whole-file            copy whole files, no incremental checks
--no-whole-file         turn off --whole-file
-x, --one-file-system       don't cross filesystem boundaries
-B, --block-size=SIZE       checksum blocking size (default 700)
-e, --rsh=COMMAND           specify rsh replacement
--rsync-path=PATH       specify path to rsync on the remote machine
-C, --cvs-exclude           auto ignore files in the same way CVS does
--existing              only update files that already exist
--ignore-existing       ignore files that already exist on the receiving side
--delete                delete files that don't exist on the sending side
--delete-excluded       also delete excluded files on the receiving side
--delete-after          delete after transferring, not before
--ignore-errors         delete even if there are IO errors
--max-delete=NUM        don't delete more than NUM files
--partial               keep partially transferred files
--force                 force deletion of directories even if not empty
--numeric-ids           don't map uid/gid values by user/group name
--timeout=TIME          set IO timeout in seconds
-I, --ignore-times          don't exclude files that match length and time
--size-only             only use file size when determining if a file should be transferred
--modify-window=NUM     Timestamp window (seconds) for file match (default=0)
-T  --temp-dir=DIR          create temporary files in directory DIR
--compare-dest=DIR      also compare destination files relative to DIR
-P                          equivalent to --partial --progress
-z, --compress              compress file data
--exclude=PATTERN       exclude files matching PATTERN
--exclude-from=FILE     exclude patterns listed in FILE
--include=PATTERN       don't exclude files matching PATTERN
--include-from=FILE     don't exclude patterns listed in FILE
--version               print version number
--daemon                run as a rsync daemon
--no-detach             do not detach from the parent
--address=ADDRESS       bind to the specified address
--config=FILE           specify alternate rsyncd.conf file
--port=PORT             specify alternate rsyncd port number
--blocking-io           use blocking IO for the remote shell
--no-blocking-io        turn off --blocking-io
--stats                 give some file transfer stats
--progress              show progress during transfer
--log-format=FORMAT     log file transfers using specified format
--password-file=FILE    get password from FILE
--bwlimit=KBPS          limit I/O bandwidth, KBytes per second
--read-batch=PREFIX     read batch fileset starting with PREFIX
--write-batch=PREFIX    write batch fileset starting with PREFIX
-h, --help                  show this help screen

What is the nslookup command?

May 18, 08 by the programmer

NSLOOKUP (Name Server Lookup)

is a command that it is used to query DNS (Domain Name System) servers and is embedded in Windows and Unix operating systems. Although nslookup exists in both UNIX and Windows, there are some differences in the way that it behaves in the two operating systems.

This command can be found in the BIND (Berkeley Internet Name Domain) package, the most commonly used DNS server on the Internet, especially on Unix operating systems.

The nslookup can be used to find various details relating to DNS including IP addresses of a particular computer, MX records for a domain or the NS servers of a domain - all using DNS lookups

The following examples are done on Windows platform.

NSLOOKUP common usage

You can use nslookup command by

  • calling it directly or
  • entering the nslookup shell

Direct usage of nslookup

In this example I will try to find out the IP address of my domain using the nslookup directly without entering its shell.

In order to do that I will write the following :

C:\>nslookup minanov.com
Server: locac dns server domain name
Address:
locac dns server IP Address

Non-authoritative answer:
Name: minanov.com
Address: 64.72.119.195

The first two rows in the command colored with light blue are showing the local network DNS server. This information is not correct.

However the other text bellow non-authoritative answer shows the name of the domain and the IP address of the server.

Using nslookup from it’s shell

Note that nslookup is a command that has a lot of possibilities. By entering in the shell all of this possibilities are available.

To enter the nslookup shell all you have to do is write “nslookup on the command prompt. If you want to find out more about all the possibilities just write “?” in the shell and hit enter. All of the available options will be displayed.

C:\>nslookup
>

Note that there is a more modern version of the nslookup command.

The command that will probably replace nslookup is the “dig” program, also embedded in the BIND package. However the dig command is not embedded in Windows operating systems yet. At least not in Windows XP.

Simple folder hiding in windows

May 11, 08 by the programmer

Have you ever wanted to hide some of your folders in Windows XP.

If you did and you does’t know how this is a pretty easy way of hiding a folder that most of the basic computer users wont be able to find and see. It is very simple, all you have to do is change the attributes of the folder that you want to hide. You have to make the folder to be hidden and you have to make it to be a system folder. That way the windows will not show it.

Let’s say that we want to hide the folder c:\my_folder

Open the command prompt and write

attrib +h +s c:\my_folder

This means make this folder to be hidden and system folder, and because by default the windows doesn’t show hidden system folders your folder will disappear immediately .

If you want to restore the folder you need to write

attrib -h -s c:\my_folder

and the folder will show.

That’s it.

HINT

If you want Windows to show the hidden system folders by default you have to go to

Folder Options, select the View tab and unselect the “Hide protected operating system files” checkbox.

After you do that you will be able to see all the hidden system files including our hidden folder.

Note that by default this option is disabled.