Wednesday, 23 October 2013

Comments: (0)

Vi Tip: Search and Replace Text

There are times when you would like to change text within a specific range:
First show the line numbers using;

:set nu

Then do the search and replace task like so:


Modifying multiple files in one stroke 

The other day, I was working on code and felt that I had to change the date creation function and make use of SQLAlchemy's server_default = text("sysdate") from a rather bizare default =

so I run this;

sed -e 's/default = = text("sysdate")/g' -i models/*.py

and all python files were updated

How to install RapidSMS in Ubuntu 12.10

RapidSMS is a free and open-source framework for dynamic data collection, logistics coordination and communication, leveraging basic short message service (SMS) mobile phone technology (according to RapidSMS is a python program built on top of django. This is a quick "how to" to have rapidsms quickly set up on an Ubuntu machine. It is seven step process.

How to view bios info

There exist a myriad of ways of retrieving hardware details of a host machine in Linux (as is case with Linux).
To extract information such as bios date, bios vendor, your board vendor and the like, you can use the virtual file system sysfs. That information is stored in the /sys directory.The precise directory is: /sys/devices/virtual/dmi/id So typing $head /sys/devices/virtual/dmi/id should display all the necessary details for you. You may also want to use sudo or su for elevated privileges to view some restricted files.An alternative method to retrieving info on your BIOS and even other hardware information from dmi is dmidecode. This usually requires root privileges to execute.
dmidecode is actually a dmi decoder what decodes readings from the dmi table.

Bash: List of commands (Executing Commands Sequentially)

The bash shell has an interesting feature where one is able to execute a list of commands sequentially. A list refers to a sequence of one or more commands that are separated by the following operators; '&', '&&', '||', ';', or the new line character.

Bash Tips: Command History

There are several ways of working with command line history in a bash shell. The history command helps you check what commands have been typed previously. The bash command line history is usually stored in the file .bash_history in a user's home directory (that is; if you use bash as your user shell-which is true for Linux (I run the kernel). You can check which shell is your default from the /etc/passwd file. It is usually the last value after the last colon on your username line e.g:
user_name:x:1000:1000:FirstName LastName,,,:/home/my_user_name:/bin/bash
The command line history is controlled by HISTSIZE and HISTFILE environment variables...

Vi Tip: Prepending Text to multiple lines

There are cases when you want (for many reasons), to add same text to the beginning of multiple lines. This may happen when you are coding (say python) and then you realise that you need to enclose your function within a class. So you add the class definition at the start of the module file. You then need to indent the function, as python requires. To indent you need to add four spaces (or your preferred number). In vi, you do this like so;

Limiting the number of simultaneous user logins

When a user is created, the user generally has an unlimited number of simultaneous logins. This, I think, is generally not a good idea. There should be a limit to the number of virtual terminals that a user can open simultaneously. Those users who just cannot resist opening many terminals should seriously consider installing screen. Read on...

VirtualBox: Managing Virtual Machines In Headless Mode

Virtual Box is a virtualization software that allows many operating systems (guests) to run simultaneously on a host operating system. In the concept of cloud computing, virtualization has become the "in-thing". It is increasingly common for applications to be run on different virtual machines running on one physical machine/server. The guest operating systems (Virtual Machines) can be run in either headed or headless modes. The difference is that in "Headed" mode, the guest displays an interface similar to that displayed when the monitor is connected to the system. More...

Kismet: Ultimate Access Point Discovery Tool

Kismet is an absolutely incredible piece of software for Linux boxes to discover any wireless access points (AP) in your neighborhood. Even if the AP does not broadcast anything and is pretending to hide, kismet will bust it. Mac users have kismac.Kismet is one of the ultra modern wireless sniffers. It can and should be used in together with others such as aircrack-ng, airodump, airdecap, airreplay and others. I view these applications as complementary rather than competing.  Just read on

Remove files or directories in Linux

This is a comprehensive way to remove/ delete files/ directories from konsole, or Terminal (whatever you call your command line). `rm' removes each given FILE. By default, it does not remove directories. rm short form of remove deletes directories and files from your disk.

What is Intelligence - Isaac Asimov

What is intelligence, anyway? When I was in the army, I received the kind of aptitude test that all soldiers took and, against a normal of 100, scored 160. No one at the base had ever seen a figure like that, and for two hours they made a big fuss over me. (It didn't mean anything. The next day I was still a buck private with KP - kitchen police - as my highest duty.) Read More

Working with Microsoft Ofice Excel Files

Want to use HSSF and XSSF read and write spreadsheets in a hurry? This guide is for you. If you're after more in-depth coverage of the HSSF and XSSF user-APIs, please consult the HOWTO guide.  Read More...