Author Archives: Rene

Run asp.net on ubuntu 12.10 linux

Thanks to mono we can run asp.net on our linux machines (i have to test some asp.net code), to do that we will use XSP, here the description took it from mono website.

XSP is a standalone web server written in C# that can be used to run your ASP.NET applications with minimal effort. XSP works under both the Mono and Microsoft runtimes. The code is available from our download page (look for XSP web server) or from the Anonymous SVN repository (module name: xsp).

To nstall it:

  1.  

Once installed, just start XSP from the directory where your code is located, after that you can browse to http://localhost:8080 to see your web pages

  1.  

Crypting data using 3des on c#

Today i have to use c# to crypt some data using 3des, so here is a pretty basic example to do it, i test it using mono.

  1.  
  2. using System;
  3. using System.Security.Cryptography; // used for TripleDESCryptoServiceProvider
  4. using System.Text; // used for Encoding.ASCII.GetBytes
  5. // i create the 3des object
  6.                 byte[] key = Encoding.ASCII.GetBytes("123456781234567812345678"); // the key should be 24 chars long
  7. "Here goes the data to encrypt";
  8.                 des.Mode = CipherMode.CBC; // We’ll use CBC
  9.                 des.Key = key; // I set the key
  10.                 byte[] iv = des.IV; // I store the randomly generated IV since i will need for decrypt
  11. // i will print as readble data

Edit less files using Jedit

When you try to edit a less file on jedit, by default there is no color scheme at all, that makes editing css files extremely hard.

To change the way jedit color code the actual file go to “Utilities > Buffer Options” and on “Edit mode” select the color scheme to css.

If you don’t want to do these each time you edit a less file, lets tell jedit to treat *.less files as css files, to do this, “Utilities>Options” and then choose “Editing” on “Change settings for mode” select css, then uncheck “use defaul settings” and chane “File name glob” to “*.{css,less}”.

Block spammers by IP

If your website is being attacked by spammers, you may want to block those users from your website. first thing we will do is to see how many connection by IP we have in our server, we will do this using netstat.

  1.  
  2. netstat -ntu | awk ‘ $5 ~ /^[0-9]/ {print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
  3.  

Once we have the IP address to block, we will use .htaccess to block those ip address like:

  1.  
  2. order allow,deny
  3. deny from 127.0.0.1
  4. deny from 127.0.0.2
  5. deny from 127.0.0.3
  6. allow from all
  7.  

Use google docs to embed PDF documents and PowerPoint presentations on your site

If you want to embed a PDF file or a Powerpoint presentation on your site, a pretty easy way to do it, is just go to https://docs.google.com/viewer, introduce the pdf url, click on “Generate Link” and you will get a url to share with your users, where they can see the pdf file on the web or get the html code to embed on your web site

If you want to create the html code on you own is pretty easy just insert an iframe that points to http://docs.google.com/viewer and pass two parameters url=http://yousite.com/pdfile and embed=true and that’s it now you have a pdf embeded on your site

  1.  
  2. "http://docs.google.com/viewer?url=http%3A%2F%2Fwww.mywebexperiences.com%2Fwp-content%2Fuploads%2F2010%2F04%2Fphp-cheat-sheet-v2.pdf&embedded=true""600""780""border: none;"
  3.  

PHP Cheat Sheet (V2) Creative Commons License (Attribution, Non-Commercial, Share Alike).

Via : Embeddable Google Document Viewer

Google Maps Operation aborted on IE

If you are getting an annoying message like this

“Internet Explorer cannot open the Internet site”
“Operation aborted”

When trying to see a web page that contains a google map.
And right after the message pop ups Internet Explorer shows an empty page here are some tips to help you fixing this issue

First thing you’ll have to do. Is to move all the code used to generate the map to a function and call it once the page is loaded

  1. span class=”co1″>// JS code to create your map

If you are using prototype you can use

  1. span class=”st0″>"dom:loaded"

Or you can add an onload attribute to your body tag

  1.  
  2. "loadMap()"
  3.  

If you are using polylines you should add vml namespace to your header and should look like this

  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. "http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"
  5.  
  6. "text/css"
  7. v\:* {
  8. behavior:url(#default#VML);
  9. }
  10.  
  11.  

Loading the javascript needed to generate the map as an external file , and adding defer attribute so internet explorer will wait until it loads the page before executing the Javascript. It has the same effect than moving your JS code to the bottom of the page.

  1.  
  2. "maps.js""text/javascript""defer"
  3.  

It can be also a problem with a base tag messing wiht IE more info on
http://www.shauninman.com/archive/2007/04/13/operation_aborted