Archive for the ‘Uncategorized’ Category

HTML5 Carousel/Slideshow

Saturday, August 28th, 2010

This is my new script. An image carousel/slideshow made in Javascript (no frameworks, HTML5 browsers).
It uses the new figure, figcaption HTML5 tags, and css3 opacity, transition, text-shadow and border-radius.

Demo and Code
Documentation
GitHub Development Page

The script was tested in Chrome 5.0. Submit Bugs and comments to github page.

Qt + Boost Spirit Logo Interpreter

Friday, May 21st, 2010

This is a logo interpreter i have been working on:

http://code.google.com/p/qslogo/

It uses Boost.Spirit for parsing and Qt for the GUI.

Javascript Inheritance

Wednesday, October 14th, 2009

Inheritance in Javascript is pretty simple.


function Child(arg1, arg2)
{
    Parent.apply(this, arguments);
    // .. other methods
}

The apply function calls the Parent function with arguments and sets this to Child’s this object. The arguments variable contains all the arguments passed to Child. (Available since Javascript 1.2).

To create an instance of Child call:


    var instance = new Child(x, y);

Writing jQuery Widgets ( 1.7+ )

Wednesday, July 22nd, 2009

It is easy to create your own jQuery widgets. First make sure you include the jQuery and jQuery.ui libraries.

The next step is to define our widget using the $.widget helper method.


$.widget("ui.name", {
    _init: function() {
    },
    _privateMethod: function() {
    },
    method: function(arg1, arg2) {
    }
});

The _init function is the constructor of the widget. Methods that start with “_” are private and cannot be accessed. All other methods are public and accessible outside the object by calling:


    $("id").name("method_name", par1, par2); 

If the method returns a value you need to add it to the object “getter” declaration (See below).

To access the element used to build the widget inside the object use:


    this.element

To access the options passed to the widget use:


    this.options

To set default properties:


    $.extend($.ui.name, {
        defaults: {
           option: value
        }
    });

To define “getter” methods:


    $.extend($.ui.name, {
        getter: [ "method", "method2" ]
    });

Jquery Filtered Select Box

Thursday, July 2nd, 2009

This is a jQuery widget that transforms a select box to a nice looking double list box. See it in action and download it at:

http://hackerhosting.com/ph-jquery/demo/dualselect.html

ActionScript 3 – Z index function

Saturday, April 25th, 2009

This function lets you calculate the z-index or depth of an object in a flash movie based on its vertical position. The greater the y component the closer to the viewer the object is.


elements.sortOn("y", Array.NUMERIC);

var i:int = this.numChildren;
var a:int = elements.length;
while(a--){
i--;
setChildIndex(elements[a], i);
}

Include Javascript File in HTML Document

Sunday, March 29th, 2009

The best way to include a Javascript file into an HTML Document is by loading and evaluating it. To do this with jQuery you can use the $.getScript() function. This function will load the contents of the Javascript file through an AJAX request.

To learn more about this function click here.

Write Custom Spirit Iterators/Parsers

Tuesday, December 30th, 2008

The easiest way to write a Boost Spirit Parser is to define a functor_parser (boost/spirit/home/classic/utility/functor_parser.hpp).

To use it you have to define a functor(struct with a operator()):


struct function_functor
{
typedef nil_t result_t;

template
std::ptrdiff_t
operator() (ScannerT const& scan, result_t& result) const
{
// Return -1 if parsing was unsuccesful or number of characters parsed if successful.
}
};

result_t is the attribute type of the parser: int, float, etc. Default is nil_t. result will be passed to the action associated with the parser.

How to install Intel C Compiler (ICC) In Ubuntu 8.10

Tuesday, December 16th, 2008

To install icc in Ubuntu:

  1. Download icc from Intel website
  2. tar -zxvf the file.
  3. Run ‘install.sh’.
  4. Follow the installer instructions.
  5. When it is done add this line to your ~/.bashrc (or initialization script):
    source /opt/intel/Compiler/11.0/069/bin/iccvars.sh ia32
    Replace ia32 with your platform: (ia32, intel64, ia64)
  6. Log off and log in and that is it. You can test it with icc -v
  7. To use icc with a configure script use ./configure CC=icc

Ruby 1.9 C API Extension Guide

Tuesday, December 9th, 2008

I am writing a guide on the Ruby (SVN) C API. You can see it here: http://coaxialhost.com/tutorials/writing_ruby_extensions.html.

Expect more stuff to be added later.