Talk is over, Slide and source code can be found on my develer tech blog http://mbertozzi.develer.com
Slide PDF is also available here PythonFuse.pdf, and examples git respository here: Python FUSE Examples Web Git Repository.
Saturday, May 8, 2010
Sunday, April 18, 2010
Qt Animation Framework Example
Today I've finally written my first example with the Qt Animation Framework (Qt 4.6).
The animation framework aims to provide an easy way for creating animated and smooth GUI's. By animating Qt properties, the framework provides great freedom for animating widgets and other QObjects.
The examples is really simple, few lines of code. And the Qt Animation Framework does all the magic under the hood. Just assign the Start and the End Value for the specified property and the interpolator does the rest.
YouTube video is available here: Qt Animation Example Video and you can find the Source Code here: Example Source Code.
Sunday, March 28, 2010
Cocoa: Draw your Shelf!
Back a bit to play with cocoa, new file-systems need new metaphor for desktop, Shelves? Below you can find a simple draw code, that you can port easily in qt or other library that have a good painter.
The code is really simple, just draw a rectangle and a path to give a perspective effect.
The code is really simple, just draw a rectangle and a path to give a perspective effect.
- (void)drawRect:(NSRect)frameRect {
NSGradient *gradient;
NSColor *startColor;
NSColor *endColor;
NSBezierPath *path;
[NSGraphicsContext saveGraphicsState];
CGFloat height = frameRect.size.height - 1.0f;
CGFloat width = frameRect.size.width - 1.0f;
CGFloat pcp = 10.0f;
CGFloat sh = 10.0f; /* shelf Height */
path = [NSBezierPath bezierPath];
[path setLineJoinStyle:NSRoundLineJoinStyle];
[path moveToPoint:NSMakePoint(0.0f, sh)];
[path lineToPoint:NSMakePoint(width, sh)];
[path lineToPoint:NSMakePoint(width - pcp, height)];
[path lineToPoint:NSMakePoint(pcp, height)];
[path fill];
startColor = [NSColor colorWithCalibratedRed:0.85f
green:0.66f blue:0.45f alpha:1.0f];
endColor = [NSColor colorWithCalibratedRed:0.78f
green:0.61f blue:0.42f alpha:1.0f];
gradient = [[NSGradient alloc] initWithStartingColor:startColor
endingColor:endColor];
[gradient drawInBezierPath:path angle:90.0f];
[gradient release];
path = [NSBezierPath bezierPathWithRect:NSMakeRect(0.0f, 0.0f, width, sh)];
startColor = [NSColor colorWithCalibratedRed:0.29f
green:0.16f blue:0.04f alpha:1.0f];
endColor = [NSColor colorWithCalibratedRed:0.48f
green:0.30f blue:0.16f alpha:1.0f];
gradient = [[NSGradient alloc] initWithStartingColor:startColor
endingColor:endColor];
[gradient drawInBezierPath:path angle:90.0f];
[gradient release];
[NSGraphicsContext restoreGraphicsState];
}
Saturday, January 30, 2010
PyQt4 Schema Script
I've received a couple of emails asking me what I use to draw various graphs and schema that I post on this blog. And the obviously answer is QPainter! I've a small PyQt script that does the easy things but the more difficult one is coded every time...
The script is really simple, it take an xml input and just draw the few items that can recognize. You can use RGBA colors and you can draw linee-paths, like in the image above. The XML looks like this one:
I know that it's a stupid thing and making xml seems to be a long job, but this is what I need at the moment, maybe in the future this script will get a WYSIWYG ui but at this time is just a simple script that generate an image :)
The source code with the above example is available here: PyQt4 Schema Script.
The script is really simple, it take an xml input and just draw the few items that can recognize. You can use RGBA colors and you can draw linee-paths, like in the image above. The XML looks like this one:
<!-- Green Rect -->
<item type='rectangle'
x='130' y='140' width='140' height='60'
border='1/0x98b954'
color='0xf4ffe4/0xdbfdab' />
<text x='130' y='140' width='140' height='60'
color='0x000000' font='Arial'
size='12' bold='false' italic='true'>
I'm just a Test!
</text>
<!-- Links Line -->
<line path='70,120;70,170;130,170' />
I know that it's a stupid thing and making xml seems to be a long job, but this is what I need at the moment, maybe in the future this script will get a WYSIWYG ui but at this time is just a simple script that generate an image :)
The source code with the above example is available here: PyQt4 Schema Script.
Directories and File-System, RaleighFS Way!
When you talk about a new file-system to someone, one of the first question that you will hear is "It will suffer from directory unbalancing" or "How performs with larger directories".
Ext3 seems to have spread the fear of large directory, but What is a directory? and what large directories mean?
When you design a File-System you've to decide what is your target/end-user. Don't try to design your file-system for everyone, but just for one.
So, what's your focus? Be the fastest file-system for continuous 'ls' (Directory traversing)?
My idea and RaleighFS idea, is that File-System is just a "Big Hashtable" with some useful information, where you ask for an item 'x' and you'll receive it's data, and metadata. Following this idea, what is a directory? It's just a name-container that allows user to keep track of his items. At this point, what is the best way to represent Directory?
Directory is just another item in the FS, like your mp3, c source file, and all the other stuff.
When you're a high-level developer, sometimes you forget how the low-level works, in this case the File-System. The FS has blocks when you remove something from the begin/mid of a file you shift back all the rest and you rewrite the entire file to avoid this you can intelligently pack your data based on the "block-data size" of the file system. (Block data size is not the block size, maybe the file-system add its own block header to your data).
The above picture shows the RaleighFS Directory Block data structure. There's a small block header that say how much of space are free in this block and there're directory items that are simply 2-field struct, 1 byte name size and N chars for the name.
In a few blocks you can handle large amount of files, and the remove operation are really quick. Just find your item, move back just your "block" friends and decrease the Directory Header free space. In this way you don't have to rewrite all the item but just one or few blocks of it.
Remember, in RaleighFS, directory is just a name-container that allows user to keep track of his items (ls /home/) and on disk directory is just a file there's no unbalance. Every item is looked-up in a O(1) Time, like traditional Hashtables.
Ext3 seems to have spread the fear of large directory, but What is a directory? and what large directories mean?
When you design a File-System you've to decide what is your target/end-user. Don't try to design your file-system for everyone, but just for one.
So, what's your focus? Be the fastest file-system for continuous 'ls' (Directory traversing)?
My idea and RaleighFS idea, is that File-System is just a "Big Hashtable" with some useful information, where you ask for an item 'x' and you'll receive it's data, and metadata. Following this idea, what is a directory? It's just a name-container that allows user to keep track of his items. At this point, what is the best way to represent Directory?
Directory is just another item in the FS, like your mp3, c source file, and all the other stuff.
When you're a high-level developer, sometimes you forget how the low-level works, in this case the File-System. The FS has blocks when you remove something from the begin/mid of a file you shift back all the rest and you rewrite the entire file to avoid this you can intelligently pack your data based on the "block-data size" of the file system. (Block data size is not the block size, maybe the file-system add its own block header to your data).
The above picture shows the RaleighFS Directory Block data structure. There's a small block header that say how much of space are free in this block and there're directory items that are simply 2-field struct, 1 byte name size and N chars for the name.
block_size = 8192 byte block_head = 12 byte dir_head = 2 byte avg_dir_item_size = 1byte + 15 byte (avg name size) (block_size - block_head - dir_head) / avg_dir_item_size = 511 entries in one block
In a few blocks you can handle large amount of files, and the remove operation are really quick. Just find your item, move back just your "block" friends and decrease the Directory Header free space. In this way you don't have to rewrite all the item but just one or few blocks of it.
Remember, in RaleighFS, directory is just a name-container that allows user to keep track of his items (ls /home/) and on disk directory is just a file there's no unbalance. Every item is looked-up in a O(1) Time, like traditional Hashtables.
Saturday, January 16, 2010
Qt4 Image Crop Item
Just a quick break from Math, File-System and Data Structure (I'm overly busy). The example below is a simple QGraphicsItem, that allow the user to select an area on the screen, like the "crop tool" that you can see in every Image Editor. The source code is very simple, just paint() and moveEvent() handlers.
The source code is available here: Qt4 Image Crop Item Source Code.
The source code is available here: Qt4 Image Crop Item Source Code.
Saturday, January 9, 2010
Base Raleigh Library is out
In these days I've rewritten parts of my Raleigh Library, that I use for my work-in-progress file-system (RaleighFS). The Library provides the basic Abstraction mechanism for read/write data from devices, client-server communication, threading and various data structures like Hashtable, Sets, In-Memory Stream (Chunk), Red-Black Tree, B*Tree and other things.
I've published the base source code, with BSD license, at google code (http://code.google.com/p/raleigh). You can download it using Mercurial.
I've published the base source code, with BSD license, at google code (http://code.google.com/p/raleigh). You can download it using Mercurial.
hg clone https://raleigh.googlecode.com/hg/ raleigh
The usage is very simple, and the source code contains Test Cases and Examples that shows how to use all the "classes". For more information feel free to send me a mail.
Subscribe to:
Posts (Atom)





