Viewing Category : programming

Post thumbnail of The most useful and complete sed tutorial
9 August 2010
Continue reading The most useful and complete sed tutorial

The most useful and complete sed tutorial

Everything you ever wanted to know about the stream editor sed. Pattern matching, delimiters, deletion, ranges, grouping, all explained.

Post thumbnail of Bash integer counter just like in C
6 August 2010
Continue reading Bash integer counter just like in C

Bash integer counter just like in C

In almost all high level languages you can do something similar to x++ to increment an integer counter. Bash doesn’t have an incrementer, but you can still make your own integer counter using back-ticks and expr.

Post thumbnail of Automate rpmbuilds from spec files including name-version-build info automatically
28 June 2010
Continue reading Automate rpmbuilds from spec files including name-version-build info automatically

Automate rpmbuilds from spec files including name-version-build info automatically

Start the spec file with %define statements at the top. Continue the spec file as you would normally, using the variables you just defined in place of the real name, version, build. Create an rpmbuild script that replaces the template variables with current information. Make an rpm target in your Makefile that calls the rpmbuild script.

Post thumbnail of Two ways to change case lowercase to uppercase using sed
22 June 2010
Continue reading Two ways to change case lowercase to uppercase using sed

Two ways to change case lowercase to uppercase using sed

Change lowercase to uppercase or vice versa using sed the brute force easy way and the smart way. One use of this would be finding the hardware address of an interface and converting it to all uppercase.

Post thumbnail of Bash One-liner to get IP address for each network interface
15 June 2010
Continue reading Bash One-liner to get IP address for each network interface

Bash One-liner to get IP address for each network interface

This one should be pretty bulletproof. Use a single sed command to dump the list of all ip addresses from interfaces showing in ifconfig.

Post thumbnail of Use awk to figure out your ip address from ifconfig for a bash script
3 June 2010
Continue reading Use awk to figure out your ip address from ifconfig for a bash script

Use awk to figure out your ip address from ifconfig for a bash script

99% of the time you can just use the local address to talk to yourself. This is just an example to show you how wrangle the ip address using awk. Rewrite the hosts file so the host itself can use it’s external address by name. Write out the basic stuff in hosts that doesn’t change then write out the current IP address.

Post thumbnail of Force gui updates during long callbacks or internal operations in pygtk or gtk
28 May 2010
Continue reading Force gui updates during long callbacks or internal operations in pygtk or gtk

Force gui updates during long callbacks or internal operations in pygtk or gtk

This faq is the most useful pygtk resource you will find. The full documentation is great for looking up which methods to use or what’s available in one class or another, but it’s the little nooks and crannies that are always left out by most pygtk resource sites that I …

Post thumbnail of Rotate and change the font size of a GTK Label object
30 April 2010
Continue reading Rotate and change the font size of a GTK Label object

Rotate and change the font size of a GTK Label object

Although the PyGTK Reference Manual is extremely helpful in figuring out how to use gtk objects, there’s not a whole lot of information about setting properties on gtk.Label objects readily available. Some hard-to-find yet simple tasks are setting the font size of a label and rotating the text. Pango is your friend, so don’t forget to include him.

Post thumbnail of Generate python code from Glade XML files
22 April 2010
Continue reading Generate python code from Glade XML files

Generate python code from Glade XML files

Why can’t I find a code generator that works? Tepache is a code sketcher for python that uses pygtk and glade, but it is broken and it looks like it hasn’t been updated since July 2005 anyway. Gladex was broken out of the box. Autocode does not like my glade and the documentation is limited.

Post thumbnail of How to reverse a list or string in Python
14 April 2010
Continue reading How to reverse a list or string in Python

How to reverse a list or string in Python

So easy, and it works with lists too. Won’t work with dictionaries but it should work with any hash-able type.

 Page 1 of 5  1  2  3  4  5 »
Powered by Wordpress   |   Lunated designed by ZenVerse