All of the interesting technological, artistic or just plain fun subjects I'd investigate if I had an infinite number of lifetimes. In other words, a dumping ground...

Friday, 11 July 2008

C++ unicode library

What is ICU?

ICU is a mature, widely used set of C/C++ and Java libraries providing Unicode and Globalization support for software applications. ICU is widely portable and gives applications the same results on all platforms and between C/C++ and Java software.

ICU is released under a nonrestrictive open source license that is suitable for use with both commercial software and with other open source or free software.

Here are a few highlights of the services provided by ICU:

  • Code Page Conversion: Convert text data to or from Unicode and nearly any other character set or encoding. ICU's conversion tables are based on charset data collected by IBM over the course of many decades, and is the most complete available anywhere.

  • Collation: Compare strings according to the conventions and standards of a particular language, region or country. ICU's collation is based on the Unicode Collation Algorithm plus locale-specific comparison rules from the Common Locale Data Repository, a comprehensive source for this type of data.

  • Formatting: Format numbers, dates, times and currency amounts according the conventions of a chosen locale. This includes translating month and day names into the selected language, choosing appropriate abbreviations, ordering fields correctly, etc. This data also comes from the Common Locale Data Repository.

  • Time Calculations: Multiple types of calendars are provided beyond the traditional Gregorian calendar. A thorough set of timezone calculation APIs are provided.

  • Unicode Support: ICU closely tracks the Unicode standard, providing easy access to all of the many Unicode character properties, Unicode Normalization, Case Folding and other fundamental operations as specified by the Unicode Standard.

  • Regular Expression: ICU's regular expressions fully support Unicode while providing very competitive performance.

  • Bidi: support for handling text containing a mixture of left to right (English) and right to left (Arabic or Hebrew) data.

  • Text Boundaries: Locate the positions of words, sentences, paragraphs within a range of text, or identify locations that would be suitable for line wrapping when displaying the text.

And much more. Refer to the ICU User Guide for details.

Wednesday, 9 July 2008

grep for two (2) strings at the same time

 egrep "CTAU4070425|GCEU7711584" ecs.log.08070816*

Friday, 4 July 2008

Common programming on Linux tools and tips

A friend from work has started writing down good programming, compiling and editing practices for Linux.

Thursday, 3 July 2008

Copy constructor and copy assignment test C++

#include <iostream>
#include <list>
#include <pthread.h>

/*
 * test copy constructors and copy assignment
 * g++ -Wall copyctor.cc -o copyctor
 * ./copyctor
 * valgrind -v --leak-check=full --show-reachable=yes ./copyctor
 */


using namespace std;

class CopyCtor {
    private:
        pthread_mutex_t pMutex;
        int * passed_in;
        int * created_1;
        int * created_2;
        list<int> functions;
   
   
    public:
        CopyCtor();
        CopyCtor(int * passedin);
        CopyCtor(const CopyCtor &cc);                     // copy constructor
        CopyCtor& operator=(const CopyCtor &cc); // copy assignment
        ~CopyCtor();
}; 
   
CopyCtor::CopyCtor(): passed_in(NULL), created_1(NULL), created_2(NULL) {}
   
// Ctor
CopyCtor::CopyCtor(int * passedin): passed_in(passedin) {
   
    pthread_mutex_init(&pMutex, NULL);
    created_1 = new int(1);
    created_2 = new int(2);
    cout << "CopyCtor::ctor: passed_in " << *passed_in << "," << passed_in << ", created_1: " << *created_1
         << "," << created_1 << ", created_2: " << *created_2 << "," << created_2 <<  endl;
}  
   
   
// copy constructor
CopyCtor::CopyCtor(const CopyCtor & cc) {
    // want to get a new lock
    pthread_mutex_init(&pMutex, NULL);
    pthread_mutex_lock(&pMutex);
    //if (passed_in)
    //    delete(passed_in);
    passed_in = cc.passed_in;
    /*if (created_1)
        delete created_1;
    if (created_2)
        delete created_2;*/
    created_1 = new int(*cc.created_1);
    created_2 = new int(*cc.created_2);
    cout << "CopyCtor::copy ctor: passed_in " << *passed_in << "," << passed_in << ", created_1: " << *created_1
         << "," << created_1 << ", created_2: " << *created_2 << "," << created_2 <<  endl;
    pthread_mutex_unlock(&pMutex);
}

// copy assignment operator
CopyCtor & CopyCtor::operator=(const CopyCtor& cc)
{
    if (this != &cc) {
        // want to get a new lock
        pthread_mutex_init(&pMutex, NULL);
        pthread_mutex_lock(&pMutex);
        //if (passed_in)
        //    delete(passed_in);
        passed_in = cc.passed_in;
        if (created_1)
            delete created_1;
        if (created_2)
            delete created_2;
        created_1 = new int(*cc.created_1);
        created_2 = new int(*cc.created_2);
        cout << "CopyCtor::operator=: passed_in " << *passed_in << "," << passed_in << ", created_1: " << *created_1
             << "," << created_1 << ", created_2: " << *created_2 << "," << created_2 <<  endl;
        pthread_mutex_unlock(&pMutex);
    } else {
        pthread_mutex_lock(&pMutex);
        cout << "CopyCtor::operator=: this == &cc: passed_in " << *passed_in << "," << passed_in
             << ", created_1: " << *created_1
             << "," << created_1 << ", created_2: " << *created_2 << "," << created_2 <<  endl;
        pthread_mutex_unlock(&pMutex);
    }
    return *this;
}

CopyCtor::~CopyCtor()
{
    cout << "~CopyCtor" << endl;
    delete created_1;
    delete created_2;
}

int main()
{
    int first = -1;
    int second = -2;
    CopyCtor *cc = new CopyCtor(&first);
    CopyCtor *cd = new CopyCtor(&second);
    *cd = *cc;
    CopyCtor *ce;
    ce = new CopyCtor(*cd);
    CopyCtor cf = *ce;
    cf = cf;
    delete(ce);
    delete(cc);
    delete(cd);
}

Tuesday, 1 July 2008

C++ multi thread optimisations & off file system & clipperz passowrd storer & mozilla C++ networking code & Google style guide

Optimizations That Aren't (In a Multithreaded World)

This article appeared in C/C++ Users Journal, 17(6), June 1999.

Google C++ Style Guide

How Clipperz works

Clipperz lets you submit confidential information into your browser, but your data are locally encrypted by the browser itself before being uploaded. The key for the encryption processes is a passphrase that never gets sent or saved to the server! Therefore no one except you can access your data.

Clipperz is simply in charge of delivering the Ajax code to your browser and then storing your data in an encrypted form on its servers. All encryption and decryption operations take place inside your browser.

The OFFSystem

What is OFF?

The Owner-Free Filesystem (or OFF) is a distributed filesystem in which everything is stored in reference to randomized data blocks, as opposed to a 1:1 copy of the original data being inserted. The creators of the Owner-Free Filesystem have coined a new term to define the network: A brightnet. Nobody shares any copyrighted files, and therefore nobody needs to hide away.

Mozilla C++ networking bug - upload progress bar

Javascript code prettifier

A Javascript module and CSS file that allows syntax highlighting of source code snippets in an html page.
Look at the test page to see if it works in your browser.

tim's shared items

Add to Google Reader or Homepage