Sunday, October 24, 2010

Saturday, January 30, 2010

Zend Frame work in wamp -------

I was suck with zend famework
finally got it working

1. copy library zend folder to project library folder
2. do some settings on wamp - httpd.conf file
un comment
LoadModule rewrite_module modules/mod_rewrite.so
only then .htacces file works properly
and set allowoveride none to allow override all

Tuesday, September 29, 2009

sh^M: bad interpreter: No such file or directory


$ ./configure
bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory

Problem is that we r trying to run script saved in dos format at some point.
Convert this to unix by using dos2unix

dos2unix is contained in package tofrodos

sudo apt-get install tofrodos
dos2unix configure

It will (attempt) to convert this/these files properly to a use-able format

Monday, September 7, 2009

How To Enable Adobe's Flash Player In Google Chrome (Ubuntu 9.04)

If the Flash plugin is already installed for Firefox, we have to find out where it is located:

sudo updatedb
sudo locate libflashplayer.so

If it is installed, output should be similar to this one...

falko@falko-desktop:~$ sudo locate libflashplayer.so
/opt/Adobe AIR/Versions/1.0/Resources/libflashplayer.so
/usr/lib/flashplugin-installer/libflashplayer.so
falko@falko-desktop:~$

... which means the Flash plugin is located in /usr/lib/flashplugin-installer/libflashplayer.so. If there's no output, this means that the Flash plugin isn't installed - you can then install it as follows:

sudo aptitude install flashplugin-installer

Now we create a plugins directory for Google Chrome...

sudo mkdir /opt/google/chrome/plugins

... and copy the Flash plugin to it:

sudo cp /usr/lib/flashplugin-installer/libflashplayer.so /opt/google/chrome/plugins

Finally we have to tell the Google Chrome launcher that it should look out for plugins. To do this, we right-click on Applications and select Edit Menus:




In the Menu Editor, go to Internet > Google Chrome and click on the Properties button:




In the Launcher Properties window, replace the contents of the Command field with this line...

/opt/google/chrome/google-chrome --enable-plugins %U

... and click on Close:

Then leave the Menu Editor.

That's it! We can now launch Google Chrome (Applications > Internet > Google Chrome):





Tuesday, August 25, 2009

Seting-Up a HTTP Proxy Server with Authentication and Filtering

sudo apt-get install squid
Configure Squid by opening /etc/squid/squid.conf using your favorite text editor. In the configuration file, search for the following directives and modify (or add, if they don't exist) as it follows:

http_port 3128 - The port Squid will listen for connections. If your system has two or more interfaces, you can specify which IP address to use. Eg: http_port 192.168.0.1:3128

http_access deny all - Search for it in the config file, uncomment it (remove the # in front), and replace deny with allow so it becomes http_access allow all.

Restart the Squid proxy with:
CODE
$ sudo /etc/init.d/squid restart

Now you should have a fully functional HTTP proxy. To try it out, open a browser, open its preferences dialog and go to proxy settings. Here, enter the IP address of the machine running Squid and the port set in squid.conf. Now load a webpage.

SETTING UP SQUID AUTHENTICATION AND WEB FILTERING

This section will allow you to set up a web site filter for kids. The first time an address is entered in the browser's address bar, an authentication dialog will pop-up, prompting for a username and password. We will set-up two usernames, one with full and another with restricted access.

First, open the /etc/squid/squid.conf and add the following line in the auth_param section:

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

Now create the user accounts using htpasswd (use -c only for the first user):
CODE
$ sudo htpasswd -c /etc/squid/passwd dad
Enter a password for user 'dad':
Again:

$ sudo htpasswd /etc/squid/passwd kid
Another password:
Again:

Create the ACLs by adding the following lines in the ACCESS CONTROLS (acl) sections in Squid.conf:
CODE
acl dadUser proxy_auth dad
acl kidUser proxy_auth kid
acl whitelist dstdomain "/etc/squid/whitelist"
http_access allow dadUser
http_access allow kidUser whitelist

Create the whitelist by opening a text editor, adding allowed domains like this:
.google.com
.kids-play.com
.yahoo.com
.msn.com


and save it as /etc/squid/whitelist.

Finally, search for http_access allow all in the Squid config file and modify it so it looks like this:
http_access deny all

This is how my Squid config sections look like:
CODE
# NETWORK OPTIONS
# Squid normally listens to port 3128
http_port 192.168.0.1:3128

# TAG: auth_param
#Recommended minimum configuration per scheme:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

# ACCESS CONTROLS
# TAG: acl
acl dadUser proxy_auth dad
acl kidUser proxy_auth kid
acl whitelist dstdomain "/etc/squid/whitelist"
http_access allow dadUser
http_access allow kidUser whitelist

# TAG: http_access
# And finally deny all other access to this proxy
http_access deny all

Use deny all for squid with authentication and allow all for basic squid configuration.

create a shared and a static library with gcc


The code for the library

This is the code that goes into the library. It exhibits one single function that takes two doubles and calculates their mean value and returns it.
calc_mean.c
//#include   double mean(double a, double b) {   return (a+b) / 2; } 

The header file

Of course, we need a header file.
calc_mean.h
double mean(double, double); 

Creating the static library

A static library is basically a set of object files that were copied into a single file. This single file is the static library. The static file is created with the archiver (ar).
First, calc_mean.c is turned into an object file:
gcc -c calc_mean.c -o calc_mean.o 
Then, the archiver (ar) is invoked to produce a static library (named libmean.a) out of the object file calc_mean.o.
ar  rcs libmean.a      calc_mean.o 
Note: the library must start with the three letters lib and have the suffix .a.

Creating the shared library

As with static libraries, an object file is created. The -fPIC option tells gcc to create position independant code which is necessary for shared libraries. Note also, that the object file created for the static library will be overwritten. That's not bad, however, because we have a static library that already contains the needed object file.
gcc -c -fPIC calc_mean.c -o calc_mean.o     
For some reason, gcc says:
cc1: warning: -fPIC ignored for target (all code is position independent) 
It looks like -fPIC is not necessary on x86, but all manuals say, it's needed, so I use it too.
Now, the shared library is created
gcc -shared -Wl,-soname,libmean.so.1 -o libmean.so.1.0.1  calc_mean.o 
Note: the library must start with the three letter lib.

The programm using the library

This is the program that uses the calc_mean library. Once, we will link it against the static library and once against the shared library.
main.c
#include  #include "calc_mean.h"  int main(int argc, char* argv[]) {    double v1, v2, m;   v1 = 5.2;   v2 = 7.9;    m  = mean(v1, v2);    printf("The mean of %3.2f and %3.2f is %3.2f\n", v1, v2, m);    return 0; } 

Linking against static library

gcc -static main.c -L. -lmean -o statically_linked 
Note: the first three letters (the lib) must not be specified, as well as the suffix (.a)

Linking against shared library

gcc main.c -o dynamically_linked -L. -lmean 
Note: the first three letters (the lib) must not be specified, as well as the suffix (.so)

Executing the dynamically linked programm

LD_LIBRARY_PATH=. ./dynamically_linked 

Creating a library with the GNU archiver

Creating a library with the GNU archiver

The GNU archiver ar combines a collection of object files into a single archive file, also known as a library. An archive file is simply a convenient way of distributing a large number of related object files together

To demonstrate the use of the GNU archiver we will create a small library ‘libhello.a’ containing two functions hello and bye.

The first object file will be generated from the source code for the hello function, in the file ‘hello_fn.c’ seen earlier:

#include  #include "hello.h"  void  hello (const char * name) {   printf ("Hello, %s!\n", name); } 

The second object file will be generated from the source file ‘bye_fn.c’, which contains the new function bye:

#include  #include "hello.h"  void  bye (void) {   printf ("Goodbye!\n"); } 

Both functions use the header file ‘hello.h’, now with a prototype for the function bye():

void hello (const char * name); void bye (void); 

The source code can be compiled to the object files ‘hello_fn.o’ and ‘bye_fn.o’ using the commands:

$ gcc -Wall -c hello_fn.c $ gcc -Wall -c bye_fn.c 

These object files can be combined into a static library using the following command line:

$ ar cr libhello.a hello_fn.o bye_fn.o 

The option cr stands for "create and replace".(33) If the library does not exist, it is first created. If the library already exists, any original files in it with the same names are replaced by the new files specified on the command line. The first argument ‘libhello.a’ is the name of the library. The remaining arguments are the names of the object files to be copied into the library.

The archiver ar also provides a "table of contents" option t to list the object files in an existing library:

$ ar t libhello.a hello_fn.o bye_fn.o 

Note that when a library is distributed, the header files for the public functions and variables it provides should also be made available, so that the end-user can include them and obtain the correct prototypes.

We can now write a program using the functions in the newly created library:

#include "hello.h"  int main (void) {   hello ("everyone");   bye ();   return 0; } 

This file can be compiled with the following command line, as described in section 2.7 Linking with external libraries, assuming the library ‘libhello.a’ is stored in the current directory:

$ gcc -Wall main.c libhello.a -o hello 

The main program is linked against the object files found in the library file ‘libhello.a’ to produce the final executable.

The short-cut library linking option -l can also be used to link the program, without needing to specify the full filename of the library explicitly:

$ gcc -Wall -L. main.c -lhello -o hello 

The option -L. is needed to add the current directory to the library search path. The resulting executable can be run as usual:

$ ./hello Hello, everyone! Goodbye! 

It displays the output from both the hello and bye functions defined in the library.