tag (ubuntu)

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

create/generate qr code with qrencode in ubuntu Oct
14
1
1

You can create qr codes easily in Ubuntu using qrencode. You can install it like so:

sudo apt-get install qrencode

and then create the qr code with the following command:

qrencode -o /path/to/qrcode.png -s 10 'http://example.com'

the `-s` option flag is the size of dot (pixel). The default is 3.

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

git-aware ps1 Nov
19
1
0

http://blog.bitfluent.com/post/27983389/git-utilities-you-cant-live-without

You'll need git-completion.bash working, but put the following line into your .bashrc or .bash_profile to display the current branch in your terminal.

PS1='$(__git_ps1 "(%s)")$ '

Which you can combine with whatever you already have setup. It can be something similar to one of the following:

PS1='\h:\W$(__git_ps1 "(%s)") \u\$ '
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\ $(__git_ps1 "(%s)")$ '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] $(__git_ps1 "(%s)")$ '

comments

installing a lamp stack on ubuntu Nov
17
1
0

If you're ever in the unfortunate position where you need to install a LAMP stack (Linux, Apache, MySQL, PHP) on an Ubuntu server, you can install the following modules to quickly get yourself up and running.

apache2 php5-mysql libapache2-mod-php5 mysql-server

sudo apt-get install apache2
sudo apt-get install php5-mysql
sudo apt-get install libapache2-mod-php5
sudo apt-get install mysql-server

Or, for the super lazy use tasksel:

sudo tasksel install lamp-server

Good luck and godspeed.

comments

install and remove .deb packages in ubuntu Aug
20
1
0

You can use the <dpkg> package manager to install downloaded .deb packages on Ubuntu and other debian-based systems.

To install a package pass in the -i flag:

sudo dpkg -i <package.deb>

You can list installed packages with the -l and an optional pattern:

dpkg -l <optional pattern>

This list can be quite long, so it might be helpful to redirect the output into a file.

dpkg -l > dpkg.txt

Use -r to remove a package.

sudo dpkg -r <package>

-r uninstalls the package, but it leaves any configuration files in place so if you ever install that package again it'll already be initialized.

To remove all associated files use -P to purge all the data for the desired package.

sudo dpkg -P <package>

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