Thursday, February 28, 2013

WCF Tracing

This link explains the most of trace levels: WCF Tracing FAQ

Add the following sections to server config


And corresponding params to system.serviceModel as well.
All the explanatory notes on params may easily be found in MSDN.


Wednesday, February 27, 2013

Using map() in Python 3


A: python 2.6:
>>> map(chr,[66,53,0,94])
['B', '5', '\x00', '^']
However, on 3.1, the above returns a map object.
B: python 3.1:
>>> map(chr,[66,53,0,94])
<map object at 0x00AF5570>
To return a list in Python 3 the following should be used:


list(map(chr,[66,53,0,94]))

Thursday, February 21, 2013

Accessing class from another module in Ruby on Rails

Modules in Ruby on Rails are not autoloadable in Ruby on Rails application.

Some hints on how to use a class from another module.

1. To make a module autoloadable the corresponding line should be commented out in application.rb

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

2. Just use "::" before the class
3. Include the module in a code where the class is supposed to be used.


Certificate errors when using RVM to install Ruby

Fixing $PATH:
http://www.troubleshooters.com/linux/prepostpath.htm

Curl Certificate Error when Using RVM to install Ruby 1.9.3

From here:

More on this:
DigiCert Trusted Root Authority Certificates: https://www.digicert.com/digicert-root-certificates.htm
https://github.com/mxcl/homebrew/issues/6103

Tryng to installing RVM on Mac OS (Leopard):

bash << (curl https://raw.github.com/ajiwo/rvm/targtar/binscripts/rvm-installer) 
bash << (curl -s https://rvm.beginrescueend.com/install/rvm)
bash << (curl -s raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
curl -L get.rvm.io | bash -s stable

Got this message:

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

Message might as well be:

Downloading RVM from wayneeseguin branch stable

Could not download 'https://github.com/wayneeseguin/rvm/tarball/stable'.
  Make sure your certificates are up to date as described above.
  To continue in insecure mode run 'echo insecure >> ~/.curlrc'.

Certification fix # 1:

You need to download the ca certificate from http://curl.haxx.se/ca/cacert.pem and add them to your curl-ca-bundle-new.crt file.
To find the location of this file use:
   $ curl-config --ca

   /usr/share/curl/curl-ca-bundle.crt
Backup your curl-ca-bundle.crt file:
$ cp /usr/share/curl/curl-ca-bundle.crt /usr/share/curl/curl-ca-bundle.crt.old
Then you want to concatenate the two file using:
$ cat cacert.pem /usr/share/curl/curl-ca-bundle.crt >> curl-ca-bundle-new.crt

Certification fix # 2:

If do not want to change the script AND you do not want to add a cert "for ever" to the cert bundle. There is a very nice and quick solution:
#to download the cert
wget http://curl.haxx.se/ca/cacert.pem
#to let curl use it for the next calls
export CURL_CA_BUNDLE=~/cacert.pem
Then run your script. To reset the environment variable (for subsequent script calls that should not use this cert) re-login to your system or unset the environment variable:
export CURL_CA_BUNDLE=

Certification fix # 3

Explanation
The version of libcurl provided with Mac OS X Leopard has outdated
SSL certificates.

This can cause problems when running commands that use Git to fetch over HTTPS.

You can force Git to ignore these errors by setting GIT_SSL_NO_VERIFY.

export GIT_SSL_NO_VERIFY=1

Quick and dirty, what have work out for me before the Certification fix:

Option 1
Execute
echo insecure >> ~/.curlrc
if the above mentioned errors occurs in any of the installation steps.

Option 2:
$ curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer > foo.sh
$ chmod 755 foo.sh

Add -k to the curl command as in this:

if curl -Lk https://github.com/${_repo}/rvm/tarball/${_branch} -o ${rvm_archives_path}/${_repo}-rvm-${_branch}.tgz
Then run the script:

$ ./foo.sh --branch stable

Powered by Blogger.