New Stupid Minds website

Author: lucian

I have decided to migrate the website to WordPress, leaving behind the good old Joomla, as it was far too much for what I actually needed (and I got kind of behind on keeping it updated).

In due time all past content will be migrated here, but in the meanwhile, the (trusty) old Joomla version can still be accessed at http://old.stupizii.ro/. About 75% of the content has been migrated here, so the old website has been disabled.

All other items are still available at their permanent locations:

The downloads section is still incomplete, but hopefully I’ll get the time to rebuild it soon.

Setting your hostname, IP address, netmask, gateway, DNS server via files

It is sometimes helpful to know what is going on behind the scenes or if you want to modify the network configuration via changing files.

For example, assume you want to modify the network configuration by modifying files with the following:

hostname: server
domainname: demo.eu
Static IP address: 10.0.1.23
Netmask: 255.255.255.0
Gateway: 10.0.1.254
Primary DNS server: 10.0.1.1
Secondary DNS server: 10.0.1.253

    Networking is set up in these files:

    /etc/sysconfig/network
    /etc/sysconfig/network-scripts/ifcfg-eth0
    /etc/resolv.conf

    First, add your host to the /etc/hosts file:

    # The next line "127.0.0.1" is needed. Do not remove it.
    127.0.0.1       localhost.localdomain localhost
    10.0.1.23       server
    

    Your /etc/sysconfig/network file would be:

    NETWORKING=yes
    HOSTNAME=server
    GATEWAY=10.0.1.23

    Your /etc/sysconfig/network-scripts/ifcfg-eth0:

    DEVICE=eth0
    BOOTPROTO=static
    BROADCAST=10.0.1.255
    IPADDR=10.0.1.23
    NETMASK=255.255.255.0
    NETWORK=10.0.1.0
    ONBOOT=yes

    DNS servers are set in: /etc/resolv.conf. An example:

    domain demo.eu
    search demo.eu
    nameserver 10.0.1.1
    nameserver 10.0.1.253

    Using ifconfig and route

    You normally would not need to use ifconfig or route unless you want to change your IP address, disable the Ethernet interface, etc. change your gateway, etc. This is sometimes helpful, so the information is here. To set an ip address:

    ifconfig eth0 10.0.1.23 netmask 255.255.255.0 up
    

    To set a default route or gateway (“gw” = “gateway”):

    route add default gw 10.0.1.254 eth0
    

    Troubleshooting

    If your system is saying there is no Ethernet card found, make sure the card is in the kernel.

    Type:

    modprobe eth0
    dmesg | less
        Look for any info about eth0 to help track down the problem.
        
    cat /etc/modules.conf
        Look for a line line this:
        alias eth0 driver-name-like-wdi or 3c503
    

    Source: http://www.linuxmigration.com/quickref/install/network.html

    The dd utility can be successfully used to create a backup of a filesystem (in lack of more specialised backup utilites).

    dd if=/dev/sdaX | gzip > /backup/sdaX.gz

    where sdaX is the partition you want to backup, and the /backup folder is located on a different disk/partition than the one you’re backing up..

    Only note that dd does not care whether a sector is used or not, it will copy it to the image file nonetheless. Zeroing out all free space before backup up is a good way to keep wasted backup space to a minimum (since the backup will be compressed)

    Zero out free disk space

    Author: lucian

    This function comes in handy when you want to make a compressed sector-by-sector backup of the filesystem and you don’t want to include/waste space with the unused sector (which still have information on them)

    Running

    nice cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

    before the actual backup will make sure all unused sectors contain zero (so they will not waste any space in the archives).

    If you ever need to count the occurences of a character in all (or some) files, this next series of commands would come in handy:

    for f in `ls`; do cat $f; done | awk ‘{ for ( i=1; i<=length; i++ ) arr[substr($0, i, 1)]++ }END{ for ( i in arr ) { print i, arr[i] } }’ | grep X

    Replace X with the character in question. The command is all in one line. “ls” can be replaced with a more specific list (eg: “ls *.c“)

    Merry New Year!

    Author: lucian

    Two days ago I’ve just bought myself a new UPS, which comes with a nice little handy app that displays useful technical data. The UPS is an Alberex Vesta Pro 1500, and the monitoring software is named Emily2 (alternative download v2.01, v2.031).

     

    The good thing about it is that it stores all data in its log, a MS Access database file named Data.mdb.  So I thought it’s a nice ideea to include all this data as graphs in my already-running System Network Monitor page.

    So I write this nice little module that reads data from the log and includes it in SNM.

    The only pre-requisite is that you’ll have to install mdbtools on your Linux (for the module to be able to export the necessary table out of the database to a text file)

    To use, include it in your graphs.xml as a

    cntUps::sensor( 'sensor_id', 'mdb log file' [,'table name'] );

    where sensor_id can be one of

    involt, outvolt, load, freq, bat, temp

    and “mdb log file” is the full path of the Data.mdb file (this file can also be accessed through network shares)

    ‘table name’ is optional, and is needed only if you renamed the default Machine0 field in Emily2′s configuration to something else.

    The perl file can be viewed/downloaded here.

    Now my SNM displays two more nice graphs :)

    You know how when you select an item in explorer, the color of the text for the highlighted item is white on dark-blue.

    When you have an item selected in explorer and you switch to another program (but can see the explorer selected text still due to window overlap arrangement), you see that the selected item color changes to black on very-light-grey. This is very close to black on white (like all of the unselected items).

    Any bad light conditions at all make this selection really difficult to see but I can’t find a Display properties color change selection for this.

    This color is read from the HKEY_CURRENT_USER\Control Panel\Colors\ButtonFace registry key (as a Red Green Blue set), and changing it requires a restart for the setting to take effect.

    Merry Christmas!

    Author: lucian

    Merry Christmas everyone ;)

    If you’ve ever needed to expand and restore multiple files from the Windows Xp CD (and don’t want to run expand for each file by hand), the following batch file might come in handy:

    @echo off
    setlocal
    set List=X:\path\*.ex_
    for /f “delims=” %%a in (‘dir /b “%List%”‘) do expand %%a %%~na.exe

    You’ll need to change “X:\path\” into the right path (where the source files are located. You should copy the files in question from the Xp CD to a folder on the hard disk).

    Then replace *.ex_ (in that same line) with the right file type (for example *.dl_ – you can only expand one filetype at a time, since “expand” expects you to manually specify the output filename).

    Finally, replace the %%~na.exe with the right output extension, for example %%~na.dll.

    Enjoy.

    own-potf