Programming

Tips on Computer Programming Languages

Rename files and folders to lower case letters

Here's a simple bash script that will help in renaming files and folders with uppper-case to lower-case letters.

Make sure you have a backup and test it with a small batch. Also read the whole comments section below if you have spaces in your file names.

#!/bin/bash

#
# Filename: rename.sh
# Description: Renames files and folders to lowercase recursively
#              from the current directory
# Variables: Source = x
#            Destination = y

#
# Rename all directories. This will need to be done first.
#

# Process each directory’s contents before the directory  itself
for x in `find * -depth -type d`;
do

  # Translate Caps to Small letters
  y=$(echo $x | tr '[A-Z]' '[a-z]');

  # check if directory exits
  if [ ! -d $y ]; then
    mkdir -p $y;
  fi

  # check if the source and destination is the same
  if [ "$x" != "$y" ]; then

    # check if there are files in the directory
    # before moving it
    if [ $(ls "$x") ]; then
      mv $x/* $y;
    fi
    rmdir $x;

  fi

done

#
# Rename all files
#
for x in `find * -type f`;
do
  # Translate Caps to Small letters
  y=$(echo $x | tr '[A-Z]' '[a-z]');
  if [ "$x" != "$y" ]; then
    mv $x $y;
  fi
done

exit 0

Lightweight ASP.NET!!!

I am not much of a .net fan but, I always wanted to do some ASP.net for web programming just to get a taste of .net, but was always lazy to install the entire VS.net because its too huge and my Compaq Presario 900 notebook aint got much harddisk space left after i installed linux as the other OS.

But, Microsoft in conjunction with some other companies have come out with a light weight version of ASP.net and the best part is that its free!!!

Visit http://www.asp.net/ and download this thing called WebMatrix. It is actually a mini asp.net IDE and a mini IIS like webserver. Its small but it has almost all the features that the IDE in VS.net provide for ASP.net

Pkill.sh [Shell script to kill process by name]

In *nix the "kill" command needs to know the pid(process id) of the process to kill it. So i decided to code a bash script to kill a process by name :

#!/bin/bash

if [ $1 -eq ""]; then
echo "Usage : ./pkill.sh <process name>"
else
get_proc=`ps -e -o pid,command | grep $1`
echo $get_proc > get_it
get_pid=`gawk -F" " '{ print $1 }' get_it`
kill -9 $get_pid
fi

The script is quite messy and certainly needs more improvement.

Learning Tcl with Tcl Tutor

TclTutor is a Computer Aided Instruction package that teaches the basics of the Tcl programming language.

The 40+ lessons in this package can be completed in under 10 minutes each. You'll be ready to start simple programs after the first half dozen lessons.

Visual C++ Tutorial

Author: Brian Martin

Lesson 1: Behind the scenes, Handles and Messages

Though you think you want to dive right into the code, you really don't. Windows programming is overwhelming at first. Let's take a quick look at how Windows works. The backbone of all of your programming will be responding to and sending messages. What are messages? Messages are simply a 32bit number designating some event. Example: You move the mouse, a message (defined as WM_MOUSEMOVE) is 'posted' to the active window. You press a key, a message (WM_KEYDOWN) is 'posted' to the active window. You resize the window, a message (WM_SIZE) is 'posted' to the active window. Get the picture?

Syndicate content
Comment