Tag Archives: Linux

Fix yum error TypeError: can’t multiply sequence by non-int of type ‘float’

I ran into this bug which prevented me to update yum packages, and after a quick search, this helped to fix it:

# vim /usr/lib/python2.7/site-packages/urlgrabber/grabber.py

Go to line 1539, with vim you can use :1539

Replace the line with this:

if cur > (float(max_size)*1.10):

 

Fix bug: Fedora 17 does not shutdown. Kernel Panic.

If you upgraded from Fedora 16 to Fedora 17, you may get an error when shutting down the system.

This happens because the kernel is the same, and grub2.cfg does not get the Fedora 17 kernel, but it is installed, although not recognized.

To fix this just run the following command:

# grub2-mkconfig > /etc/grub2.cfg && grub2-install /dev/sda

Notice that you should change /dev/sda for your partition

This will generate a new grub2.cfg with the new Fedora 17 kernel.

Convert m4a files to mp3 with this script.

Some of my library was in m4a files, which I have problems to play, furthermore I prefer having everything in mp3 format.

So I wrote the following script:

echo "Dependencies: mplayer and lame"
if [ $# -lt 1 ]; then
	echo "Usage: sh m4a2mp3.sh '/path/to/files'"
else 
	echo "This could take sometime. Converting to 320kbps MP3 files..."
	sleep 1
	cd "$1"
	for i in *.m4a; do mplayer -ao pcm "$i" -ao pcm:file="$i.wav"; done
	for i in *.wav; do lame -h -b 320 "$i" "$i.mp3"; done
	echo "Cleaning the house..."
	rm -rf *.m4a
	rm -rf *.wav
fi
echo "All files converted. Thank you."

Usage is pretty straightforward:

sh m4a2mp3.sh /path/to/your/songs

The only dependencies, as you can see also in the script are mplayer and lame

You can install them with the following command:

# Yum based (Fedora, CentOS, SuSE)
yum install mplayer lame
# Apt based (Debian, Ubuntu, Mint) (NOT TESTED)
apt-get install mplayer lame

As always, you also can find the script on my Github.

Reset NICs by unloading / loading network drivers

This script is specially useful when you clone VMs, but can be used in any other kind of situation where you have problems with network cards, say, duplicated cards for X reason.

Try to run this script I wrote:

if [ $UID -ne 0 ] 
then
	echo "Sorry, you have to run this script as root"
else
	cat /etc/udev/rules.d/70-persistent-net.rules | grep PCI | cut -d' ' -f5 | cut -b 2-6 | uniq > /tmp/drivers
	for driver in $(cat /tmp/drivers); do
		rm -rf /etc/udev/rules.d/70-persistent-net.rules && echo "Removing 70-persistent-net.rules"
		rmmod $driver && echo "Removing $driver"
		modprobe $driver && echo "Loading $driver"
	done
	echo "Done."
	rm -rf /tmp/drivers
fi

Tested under Debian and Fedora, but should work fine on other distributions.

The code is also on my github