tag (linux)

archive

continuously print lines of a file as they are added Jul
08
1
3

Use `-f` flag on `tail` to continuously output lines of a file as they are added in the terminal:

tail -f <file>

CTRL-C to stop the process.

comments

convert png to windows icon .ico file for favicon in ubuntu Dec
21
1
0

I've never had a great way of making windows icon files (.ico). I used to use the icon editor in Visual Studio in the past, but I haven't programmed in Windows for years and I don't have access to VS anymore. I've always felt there had to be a way to convert a png to ico file. Even Photoshop doesn't have this built in: for that you need a plugin.

It took me a while, but there's a way to do it using some of the packages from netpbm. If you're using Ubuntu you're in luck, as with most things it's just an apt-get away.

sudo apt-get install netpbm

Next, I'll start with a 16x16, 32x32 or 48x48 square pixel PNG. I tend to use the 32x32 size.

For this example I start with a 32x32 favicon.png, convert it to an intermediary pnm file, force the scaling to a ppm file, convert to 256 color space, and compile it into an ico file with the following set of commands.

pngtopnm -mix favicon.png > tmp_favicon.pnm

pnmscale -xsize=32 -ysize=32 tmp_favicon.pnm > tmp_favicon32.ppm
pnmscale -xsize=16 -ysize=16 tmp_favicon.pnm > tmp_favicon16.ppm

pnmquant 256 tmp_favicon32.ppm > tmp_favicon32x32.ppm
pnmquant 256 tmp_favicon16.ppm > tmp_favicon16x16.ppm

ppmtowinicon -output favicon.ico tmp_favicon16x16.ppm tmp_favicon32x32.ppm
rm -f tmp_favicon*

This method gave me what I needed: an ico file that I could use for a favicon and include as a windows icon for a binary executable.

comments

delete old files in linux Mar
16
1
0

Edited: 4.15.2010 - fixed typo

You can use the [find] command in linux to remove old files through the command line. Pass in [-mmin +/-num] to specify minutes, and [-mtime +/-num] for days. Use [+] to get items older than the specified times, and [-] for younger.  Filter file/directory names through [-name], and run a command through [-exec].

# remove all files older than 7 days
find /path/to/directory* -mtime +7 -exec rm {} \;

# remove all *.py files younger than 30 minutes
find /path/to/directory* -name '*.py' -mmin -30 -exec rm {} \;

This is tested on Ubuntu.

comments