Thursday, September 4, 2008

Using SyntaxHighlighter with Blogger or Blogspot

I added Syntax Highlighting capabilities to this blog and here it is how i did it. You might need another server where to put your files:

  1. Download SyntaxHighlighter from http://code.google.com/p/syntaxhighlighter/downloads/list.

  2. Add this to your Edit HTML code in Layout:

  3. <script language='javascript' src='http://www.url.com/Scripts/shCore.js'></script>
    <script language='javascript'>
    window.onload = function() {
    dp.SyntaxHighlighter.ClipboardSwf = 'http://www.url.com/Scripts/clipboard.swf';
    dp.SyntaxHighlighter.BloggerMode();
    dp.SyntaxHighlighter.HighlightAll('code');
    }
    </script>
    <link href='http://www.url.com/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>

  4. Put the code you want to highlight inside a <pre> tag like this:

  5. <pre name='code' class='language'>
    code;
    </pre>

  6. Make sure you replace the url and also '<' with &lt; if you are using HTML code

  7. Add this to the top of your post:

  8. <script language='javascript' src='http://www.url.com/Scripts/shBrushXml.js'></script>

  9. Replace the script name with the one used for your language.



For more information and language list visit http://code.google.com/p/syntaxhighlighter/w/list.

Wednesday, September 3, 2008

CSS Sprites



What a wonderful idea, simple and easy. A great way to reduce HTTP GET's.

How to use it in your application:


  1. Find/Buy a good icon set (like tango), try to find a transparent one.

  2. Place a div where the icon would be located and set its onclick event to whatever you want it to do.

  3. create a css class for the icon:


  4. .icon-name {
    display: block; height: 32px; width: 32px;
    background: transparent url(icon.png) -(x)px -(y)px no-repeat;
    cursor: pointer;
    }

  5. Change height, width and (x) and (y) position with the respective values.

  6. assign the class to your div.


Pretty easy.

Ruby on V8



What a great idea, someone put together a hacked version of ruby for the v8 engine based on hotruby.js. It is not a real compiler but it works.

Now, Who is going to make a real port of Ruby to the v8 engine? Sounds like an interesting project. Just what we need, another ruby virtual machine/interpreter!!

Tuesday, September 2, 2008

Chrome


Chrome is fast. Even though I had problems installing it on my laptop win xp sp3, I managed to get a copy of the exe file from http://cache.googlevideo.com/chrome/install/149.27/chrome_installer.exe. I run it and it installed fine. Not sure what the problem was because other people with sp3 could install it just fine. It was probably a disabled service.

Cool things to try in the address bar:

about:network - Network Tools
about:stats - Shhh! This page is secret!
about:cache - Cache.
about:histograms - Data about chrome features.
about:plugins - Installed Plug-ins.
about:dns - DNS records.
about:version - Google Chrome browser version.
https://gmail.com - This one is pretty bad actually... No one is perfect.

To access google's task manager: right click in the blue space at the top and click Task Manager.

Bad news: still doesn't work on linux(nor wine) or macs.

Friday, August 29, 2008

Understanding a Crazy Programmer



Found this on the net. If you have any problems with a programmer in your team, this article/blog might help.

Learning Lisp - Do you know any programmers that exhibit these personality traits?

Tuesday, August 5, 2008

Catching Ctrl+C in Ruby 1.9

Ctrl+C sends a SIGINT signal to the kernel.
To catch it and execute code we use:
Kernel.trap('INT') { code }
Remember to call Kernel.exit if you want to terminate the execution of your ruby script. Kernel.trap can also catch other signals. For more information visit: Kernel.trap

Saturday, August 2, 2008

Storing Passwords securely


The best way to store a password: Salt it then Hash it.

To salt it add random characters to the password entered by the user. Remember we are going to need those random characters later so save them somewhere you can retrieve them later. I would say insert them in fixed locations in the hash. To hash it use the md5 or sha1 function. You can find these functions in the encode ruby extension.

To authenticate the user, you will need to pull the hash associated with the username, retrieve the salt characters, apply them to the password entered by the user, hash it and compare.

Is there a better way?