tisdag 24 januari 2012

How to get User's IP adress using Perl


In a server environment there several servers are involved in an architecture with load balancer for example the user's IP-address are retrieved using  HTTP_X_FORWARDED_FOR environment parameter in PERL:

my @ip_address = split(/,/, $ENV{'HTTP_X_FORWARDED_FOR'});
print   $ip_address[0] ;

In all other language you should be able to access to  HTTP_X_FORWARDED_FOR:
Ruby:
@remote_ip = request.env["HTTP_X_FORWARDED_FOR"]



onsdag 18 januari 2012

Using Emacs instead of Eclipse

One of the selling points in using Eclipse or other IDE is code completion, but this can be as well in Emacs.
With Emacs you can be more effective using only keyborads as all is textbased.
As a developer you will be more effective. I would recommend that you begin using Emacs instead of IDE for scripting languages like Scala. Here is an excellent instruction how to use Emacs on Scala:
http://www.scala-lang.org/node/354

The server principal "user" is not able to access the database "Database" under the current security context.

If you get the following error message in MS SQL 2008:
The server principal "yourUser" is not able to access the database "yourDB" under the current security context

This issue arise due to cross ownership chaining restriction that comes after SQL 2000 SP3.
If cross database ownership chaining is required for your application to work, you must enable it.

How you see if this uis enabled ?
exec sp_dboption ' yourDB ', 'db chaining'

You should get:
OptionName   CurrentSetting
db chaining      OFF

If you are using views to see data in tables owned by different users SQL server check the permissions on the table.




Resources:
Using Ownership Chainshttp://msdn.microsoft.com/en-us/library/aa905173%28SQL.80%29.aspx

Solution
http://blogs.technet.com/b/mdegre/archive/2010/08/29/the-server-principal-quot-sqlloginname-quot-is-not-able-to-access-the-database-quot-mydatabasename-quot-under-the-current-security-context.aspx

Troubleshooting Orphaned Users
http://msdn.microsoft.com/en-us/library/ms175475.aspx

PRB: "Troubleshooting Orphaned Users" Topic in Books Online is Incomplete
http://support.microsoft.com/kb/274188/

sp_addlogin (Transact-SQL)
http://msdn.microsoft.com/en-us/library/ms173768.aspx