Skip navigation

Tag Archives: Geek

I’ve had networking issues on and off. The severity ranges from having my network manager disabled or having it drop out an be unable to connect randomly. I have a Dell XPS M1330, running Ubuntu 10.04.1 LTS with networking card:
Intel Corporation PRO/Wireless 4965 AG or AGN [Kedron] Network Connection (rev 61).

These are the things I have checked and or run when I’ve had networking issues and one of them has usually resolved the problem:

When your wired/wireless networking manager says it’s disabled:
The file “/var/lib/NetworkManager/NetworkManager.state” contains:


(make sure all these values are true)

you can edit it with simply:

sudo gedit /var/lib/NetworkManager/NetworkManager.state

then do:

sudo restart network-manager

Also check /etc/network/interfaces to verify an entry similar to:

auto eth1
iface eth1 inet dhcp

Sometimes this gets deleted.
I’ve even deleted this entire file, and restarted my computer and the networking issued fixed itself.

If the above steps aren’t working or your card has been dropping connections randomly it may be another issue with your driver or driver packages. If you know that restarting your computer will make it work for a little while longer then the fixes suggested below should help you out:

Use lspci to find your “Network Controller”

$ lspci
00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub (rev 0c)
00:02.0 VGA compatible controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (rev 0c)
00:02.1 Display controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (rev 0c)
00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 02)
00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 02)
00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 02)
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 02)
00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 02)
00:1c.3 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 4 (rev 02)
00:1c.5 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 6 (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f2)
00:1f.0 ISA bridge: Intel Corporation 82801HEM (ICH8M) LPC Interface Controller (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller (rev 02)
00:1f.2 SATA controller: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 02)
03:01.0 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 IEEE 1394 Controller (rev 05)
03:01.1 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 22)
03:01.2 System peripheral: Ricoh Co Ltd R5C592 Memory Stick Bus Host Adapter (rev 12)
03:01.3 System peripheral: Ricoh Co Ltd xD-Picture Card Controller (rev 12)
09:00.0 Ethernet controller: Broadcom Corporation NetLink BCM5906M Fast Ethernet PCI Express (rev 02)
0c:00.0 Network controller: Intel Corporation PRO/Wireless 4965 AG or AGN [Kedron] Network Connection (rev 61)

and lsmod to find what drivers your network card uses (or you can google them if your internet is working):

$ lsmod
Module Size Used by
nls_iso8859_1 3249 2
nls_cp437 4919 2
vfat 8933 2
fat 47767 1 vfat
usb_storage 39425 2
iwl3945 68727 0
iwlagn 105694 0
iwlcore 105922 2 iwl3945,iwlagn
aes_i586 7268 2
aes_generic 26863 1 aes_i586
snd_hda_codec_intelhdmi 11622 1
snd_hda_codec_idt 51978 1
snd_hda_intel 21941 4
arc4 1153 2
snd_hda_codec 74201 3 snd_hda_codec_intelhdmi,snd_hda_codec_idt,snd_hda_intel
snd_hwdep 5412 1 snd_hda_codec
max6650 8042 0
snd_pcm_oss 35308 0
snd_mixer_oss 13746 1 snd_pcm_oss
psmouse 63245 0
snd_pcm 70662 4 snd_hda_intel,snd_hda_codec,snd_pcm_oss
coretemp 4289 0
snd_seq_dummy 1338 0
mac80211 205146 3 iwl3945,iwlagn,iwlcore
snd_seq_oss 26726 0
cfg80211 126517 4 iwl3945,iwlagn,iwlcore,mac80211
snd_seq_midi 4557 0
sdhci_pci 5470 0
sdhci 15462 1 sdhci_pci
snd_rawmidi 19056 1 snd_seq_midi
snd_seq_midi_event 6003 2 snd_seq_oss,snd_seq_midi
dell_wmi 1793 0
snd_seq 47263 6 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
dell_laptop 6856 0
uvcvideo 56990 0
snd_timer 19098 2 snd_pcm,snd_seq
snd_seq_device 5700 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
videodev 34361 1 uvcvideo
v4l1_compat 13251 2 uvcvideo,videodev
serio_raw 3978 0
snd 54148 20 snd_hda_codec_intelhdmi,snd_hda_codec_idt,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
led_class 2864 3 iwl3945,iwlcore,sdhci
soundcore 6620 1 snd
snd_page_alloc 7076 2 snd_hda_intel,snd_pcm
joydev 8708 0
dcdbas 5422 1 dell_laptop
lp 7028 0
parport 32635 1 lp
fbcon 35102 71
tileblit 2031 1 fbcon
font 7557 1 fbcon
bitblit 4707 1 fbcon
softcursor 1189 1 bitblit
vga16fb 11385 0
vgastate 8961 1 vga16fb
usbhid 36110 0
hid 67032 1 usbhid
i915 285076 3
drm_kms_helper 29297 1 i915
drm 162409 4 i915,drm_kms_helper
ohci1394 26950 0
intel_agp 24119 2 i915
tg3 109324 0
ieee1394 81181 1 ohci1394
ahci 32200 1
i2c_algo_bit 5028 1 i915
video 17375 1 i915
output 1871 1 video
agpgart 31724 2 drm,intel_agp

Use either the Internet while it is working to find the main driver module for your network card or a driver name (or names) that looks like your cards name and do the following commands to stop and restart your driver:
(In my case my driver is iwlagn)

sudo service network-manager stop
sudo rmmod iwlgan
sudo rmmod iwl3945
sudo rmmod iwlcore
sudo modprobe iwlgan
sudo modprobe iwl3945
sudo modprobe iwlcore
sudo service network-manager start

Basically, rmmod pulls your dymanically linked driver and stops it and modprobe restarts it.

Sometimes that still doesn’t work. I found a bug fix posted by Brian Wu in this thread that fixed my problems recently. The method is outlined below:

$ sudo apt-get install --reinstall linux-backports-modules-wireless-lucid-generic
$ sudo apt-get install --reinstall linux-backports-modules-headers-lucid-generic

I did both, I wasn’t sure which would work. Note: replace ‘lucid’ with whatever distro/version of linux/ubuntu you are running, jaunty, karmic, gusty…etc.

If all else fails, try using live cds of various versions to verify that it isn’t a hardware failure.


Python loggers are a good mechanism for printing to console or a log file when running any python file or especially useful when logging information from a server. Some of the useful things you can do are, logging to console and files at the same time, logging from different python packages, set logging filters to include timestamps and/or logging levels and/or handler information, and logging at different message levels weather an error is debug, information, a warning, an error, or critical level.

To create a logger:

import logging
LOG_FILENAME = 'mylog.log'
logging.debug('This message should go to the log file') #This is how to would print using the logger

or you can create a logger using:

LOG_FILENAME = 'mylog.log'

#Creating a logger
my_logger = logging.getLogger('MyLogger')

#Create handler - in this case a file handler
handler = logging.FileHandler(
LOG_FILENAME, mode='a')

#Set the format you want to log in
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')

#add format to the logging handler

#add logging handler to logger

Note the mode=’a’ line means that this logging handler is going to append to the file. The mode ‘w’ means it will create a new file each time.

To add a console logger to our previous example so that we can see output on the console we would add the following code:

# create console handler and set level to debug
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.DEBUG) #sets default default level to debug

# create formatter -- this is format only prints the level of the debug message
formatter = logging.Formatter("%(levelname)s - %(message)s")

# add formatter to console_handler

# add console_handler to logger

Now we have a console logger. Whenever we call:

my_logger.debug("this is a debug level message")

This will be printed to the console, and the log file at the debug level, each in different formats. Note that in this example, we changed the format from the original File Handler so that it only prints the logging level to the console handler.

This example from shows the debug level:

import logging
import logging.config


# create logger
logger = logging.getLogger("simpleExample")

# "application" code
logger.debug("debug message")"info message")
logger.warn("warn message")
logger.error("error message")
logger.critical("critical message")

And this one is how to handle each logging in each package:

import logging


logger1 = logging.getLogger('package1.module1')
logger2 = logging.getLogger('package2.module2')

logger1.warning('This message comes from one module')
logger2.warning('And this message comes from another module')


Type selectors:

em {color: blue;}

This rule will select any <em> element on the page and color it blue anywhere in the document

Class selectors:
if you have:

<p class="big">This is some <em>text</em></p>

then the rule:

.big { font-size: 110%; font-weight: bold; }

will select that line because it selects every class=”big”.

To be more specific we can combine class and type selectors:

div.big { color: blue;}

this would select only class big objects with type <div>

You can also assign and element multiple classes:
<p class="big indent">
.big { font-weight: bold; }
.indent { padding-left: 2em; }

both these rules apply to the html line above.

Try to style all elements in a <div> the same way instead of abusing the class selector

ID selectors:
You can also select html objects by ID, eg:

<p id="navigation"> navigation stuff </p>
#navigation { width: 12em; color: #333; }

Descendant selectors:

p em {color: blue; }

this would select all em elements that are descendent’s of p even if they are grandchildren of p and not direct descendants.

Child selectors:

div.em { color: blue; }

only select the children of div that are em…

Universal selectors:

* {color: blue;}

these select all elements regaurdless of their position in the document tree

Adjacent siblings selectors:

These have applications if you have a series of headers that you want to use multiple times together. If you have <h2> and <h3> elements in the same section then you create a style using:

h2 + h3 {margin: 1em;}

This targets any h3 that follows and h2.

Attribute selectors:

img[src="icon.gif"] { border: 1px solid #000; }

Targets all images with the source “icon.gif”.


I will be using this blog to update my learnings in the world of the web, courses, and simple hack I’ve come to learn. Currently, I am running Ubuntu 10.04 on a Dell XPS M1330. This summer I am researching with professor Valeria Betacco, working on the FunSAT research project through the SURE program at U of M. The following posts are my learnings.