Facing new challenges everyday

Writing MacOSX System Services with RubyCocoa

September 7th, 2009

Today I started my study about RubyCocoa and how it works, my first project was a simple system service for MacOSX Leopard where the user can type a portuguese text, select it and translate to english, the user can also type the text in english and execute the system service to translate it back to portuguese.

Here’s what I did:
(more…)

Post to Twitter

Playing with AppleScript

August 22nd, 2009

ApplesScript is a very interesting scripting language that allows the user to write scripts to automate computer tasks, it differs from the other script languages because of its syntax that is pretty closer to natural language.

I spent few hours this morning trying to understand how to write AppleScript scripts, It’s very simple, please read the AppleScript Language Guide to learn more about how to use AppleScript with your favorite applications.

The scripts below give to us an idea about how we can use AppleScript to change the behaviour of 4 most popular applications for MacOSX: iChat, Growl, Adium and Skype.

iChatStatus

1
2
3
tell application "iChat"
    set the status message to "New iChat status message"
end tell

iChatStatus can be used to change status message of the user on iChat. The first line starts with “tell” statement, we use this statement to specify the target of all commands on this script, in the second line we are using the “set” command to change a the value of “status message” property value on application to “New iChat status message”, the third line finishes the “tell” statement.

(more…)

Post to Twitter

Handling server responses with WinHttpRequest object

August 14th, 2009

Yesterday I spent few hours trying to understand why my application was crashing after receive a big responses from server, in the end it was a question of how to use WinHttpRequest object.

WinHttpRequest is a COM object that can be used to send and receive data from server via HTTP protocol, I use it a lot in my search application because I need send user queries to search server and then process the responses in xml format.

Look this piece of code that I used to send HTTP requests to my search server:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Dim objXMLHTTP
Set objXMLHTTP = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
objXMLHTTP.Open "GET" , "/bigfile.xml" , false
objXMLHTTP.setRequestHeader "Content-Type", "text/html; charset=utf-8"
objXMLHTTP.Send
       
Dim objXML
Set objXML = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
objXML.validateOnParse = false
objXML.resolveExternals = false
objXML.preserveWhiteSpace = false
objXML.async = false
       
objXML.LoadXML( objXMLHTTP.ResponseText  )

(more…)

Post to Twitter

MongoDB and the rest of NoSQL solutions

August 8th, 2009

In the last weeks I have been evaluating two NoSQL solutions available in the market, MongoDB and CouchDB, each solution has very interesting features, but besides of its features we must consider how much easy to use each one is, right?

Let’s talk a little about CouchDB first, CouchDB is a document-oriented solution written in Erlang language, with CouchDB you can easily persist documents in JSON format it also has a very powerful RESTful interface from where you can retrieve database information and persist/query documents.

But how to perform basic operations on CouchDB like persist or query data? It’s simple, you just need to know how to use its RESTful interface, the example below shows how much easy is persist data in CouchDB with help of curl tool:

1
curl -X PUT -d '{"name": "Rogerio Araujo", "address": "Estrada dos Bandeirantes", "city": "Rio de Janeiro", "state": "RJ", "country": "Brazil" }' "http://127.0.0.1:5984/contacts/user3"

The command above will create the following JSON document on database:

1
{ "_id": "user3", "_rev": "3771096703", "name": "Rogerio Araujo", "address": "Estrada dos Bandeirantes", "city": "Rio de Janeiro", "state": "RJ", "country": "Brazil" }

Once we have few documents stored on CouchDB we need to create a view used to help on query data, to do it, you must write the following javascript function and store it as a document on database:

1
2
3
4
function(doc) {
  if(doc.name)
     emit(doc.name, doc);
}

(more…)

Post to Twitter

ByteBuffer implementation for dotNET

August 2nd, 2009

Today I created a dotNET version of ByteBuffer class, with this class you can easily read and write data into byte array. You can get the source file here.

Here’s an example about how to use ByteBuffer class:

Program.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestCode
{
    class Program
    {
        static void Main(string[] args)
        {
            ByteBuffer buffer = new ByteBuffer(20);

            buffer.AddInt(10);
            buffer.AddString("Test");
            buffer.AddLong(10000);
            buffer.AddInt(350);
            buffer.AddChar('c');
            buffer.AddDouble(10000.325);

            Console.WriteLine(buffer.ReadInt());
            Console.WriteLine(buffer.ReadString());
            Console.WriteLine(buffer.ReadLong());
            Console.WriteLine(buffer.ReadInt());
            Console.WriteLine(buffer.ReadChar());
            Console.WriteLine(buffer.ReadDouble());

            Console.ReadLine();
        }
    }
}

My implementation doesn’t contains all features found on Java version of the same class, but can help on most cases.

Post to Twitter

« Previous PageNext Page »

Visitors Around the World

Polls

How Is My Site?

View Results

Loading ... Loading ...

Categories

Meta

Links

hosted by easy2use.net