python, perl, pygtk, gtk, c, php

C: implementing str_replace to replace all occurrences of substring

Last time, I showed how to replace PHP's str_replace in C.

The previous code was only replacing one occurrence of substr which might be sufficient in most cases... but will not do the job when the pattern appears more than once within the original string.

This new piece of code will replace ALL occurrences of substring by the replacement pattern.

C GTK+ : Copying an image over another one

GTK+ offers a nice toolkit through the GDK library to make image manipulation quite easy.

This page will go through the process of modifying an image but putting another on on top as an overlay. In this example, we will be copying an MSN icon on top of a "busy" icon.
Another use case could be to watermark images.

C: implementing str_replace

And example on how to implement str_replace in C.

This implementation will only replace the value once. If the substring to replace is not found, a copy of the original string is returned.

If you are looking for a version that replace all occurrences of substring, please have a look at str_replace all matching pattern.

PHP: How to calculate the SSHA value of a string

This bit of code allow one to generate SSHA password as accepted by 'ldapmodify' userPassword entry.
unlike SHA, SSHA is using a random seed, increasing the security of your passwords.

C GTK+ : Text Completion on a GtkEntry with GtkEntryCompletion

Text completion is quite a nifty feature to have on an interactive software, saves you loads of typing, helps you remember the exact spelling on one's email, lost urls (thanks firefox 3 for the regex based search :-) )....

Gtk+ offers this ability through the use of GtkEntryCompletion that we will hook to the GtkEntry.

This tutorial will explain through a code sample how to set it up.

C: Handling large files (>2G) with standard c

Once upon a time, file size was capped to 2G because of 2^31 - 1 = 2G. Has such, open will fail on files bigger than 2G.

this tutorial will show how to get standard C to handle large file.

C: Linux Socket Programming, TCP, a simple HTTP client

Linux provide a high level socket API that will allow programmer to easily connect to any TCP or UDP services.

In this tutorial, we will see how this works by implementing a simple HTTP client which will get request a web page given the hostname and the page name, then read the server answer and output the HTML content of the reply.

Python GTK: How to customize the size of a button in a notebook tab label

In the previous post, I showed how to customize your gtk.Notebook Tab Label by adding a close button to the tab.
Depending on the theme used by the user, the tab might get pretty big once a gtk.Button is added.

In this tutorial I will explain how to override the theme behaviour by creating a custom style for our widget.

Python GTK: How to set up gtk.Notebook tab with custom widget

gtk.Notebook is a great feature as it help keep your application footprint on the desktop occupation low. I personnally would not even think of using a web brower without a tab feature as it would take me a help of a time to go from one application to another.

A gtk.Notebook page is composed of a child widget and a label gtk.Widget. From there on, we can fit anything we like in a tab label such as an icon on the side representing the content, a title and a handy close button on the right side a bit like firefox's tabs.

This tutorial will detail how to customize the content of a Notebook tab label but really is a kickstart to any plausible gui arrangement.

Python GTK: Treeview with rows of different colors

With a simple example, I am going to illustrated how to build a ListStore TreeView in pygtk (python's gtk binding).

Building a standard ListStore in pygtk is pretty straightforward, however, it can get a bit more difficult to set up a custom TreeView where the rows and columns that are displayed can have different colors.

This tutorial will show how-to create and set up a TreeView, its TreeViewColumn and finally, the CellRenderer.

Syndicate content