Installing Arch Linux on Raspberry PI 1 or 2

In order to do this for Raspberry PI 2 (since February 2015), use this url: http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz Download size is about 200-300 MB.

Replace sdX in the following instructions with the device name for the SD card as it appears on your computer.

  1. Find what sdX is, using
    fdisk -l | grep “Disk /dev/”`
  2. Start fdisk to partition the SD card:
    fdisk /dev/sdX
  3. At the fdisk prompt, delete old partitions and create a new one:
    1. Type o. This will clear out any partitions on the drive.
    2. Type p to list partitions. There should be no partitions left.
    3. Type n, then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +100M for the last sector.
    4. Type t, then c to set the first partition to type W95 FAT32 (LBA).
    5. Type n, then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.
    6. Write the partition table and exit by typing w.
  4. Create and mount the FAT filesystem:
    mkfs.vfat /dev/sdX1 mkdir boot mount /dev/sdX1 boot
  5. Create and mount the ext4 filesystem:
    mkfs.ext4 /dev/sdX2 mkdir root mount /dev/sdX2 root
  6. Download and extract the root filesystem (as root, not via sudo):
    wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
    bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
    sync
  7. Move boot files to the first partition:
    mv root/boot/* boot
  8. Unmount the two partitions:
    umount boot root
  9. Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power.
  10. To find the IP-address of the Raspberry PI, use:
    ip addr or ifconfig to find your own IP-address (aaa.bbb.ccc.xxx)
    nmap -sP aaa.bbb.ccc.0/24 | grep report
    (… which takes a short while because it scans brute force) or simply use:
    arp -a
  11. Use the serial console or SSH to the IP address given to the board by your router. The default root password is ‘root’.

Source: http://archlinuxarm.org/platforms/armv6/raspberry-pi

Advertisements

Animate object using jQuery without hiding overflow

If you animate an object in HTML using Javascript and specifically the jQuery library, then jQuery will by default set the CSS `overflow` value to `hidden`. This is to prevent unwanted behaviour.
However, if you do wish to keep overflow on a specific value, for example `visible`, then you need to use the step function:

var obj = $('#object')
    .animate({width: '0px'}, {duration: 1000, step: function()
    {
        obj.css({overflow: 'visible'});
    }});

You could also change the library’s source code, but this is not recommended, since this feature is kind of useful and you do not want to get any unwanted behavior elsewhere. I did not notice any performance issues using the step-function like this.

Get external IP-Address of Linux server

The following script will get your external IP address as defined in /etc/hosts, you can always define it yourself in that file if is nonexistent.

#!/bin/bash
cat /etc/hosts | grep $(hostname) | sed "s: .*::"

This bash script will return your IP address, you could also use it directly in the command-line of course.

Give permission to all files of a certain user in their own home directory in Linux

This code will give permission to all files of a certain user in their own home directory in Linux. Take for example user ‘Yeti’, with a home directory /home/yeti”.

chown -R yeti /home/yeti
chmod -R u+rwX /home/yeti

Chown sets the owner, and chmod changes permissions. A more detailed description of what is happening here, is down below.

‘-R’ in chown and chmod means that it should apply recursively through directories and files.

‘u’ in chmod means to make it apply to the owning user only, alternatively you could use ‘g’ (group), ‘o’ (others), or ‘a’ (all, equals ‘ugo’).

‘+’ means to add the following permissions. Alternatively you could use ‘-‘ to remove permissions, or ‘=’ to set all permissions exactly.

The parameters ‘rwX’ indicate respectively read, write, and special execution permissions. Note that a capital is used for execution permissions, this means that only files which were already able to execute will get execution permission.

Change default target ‘File explorer’ of to ‘My Computer’ in Windows

Select any shortcut named ‘File explorer’, bring up the context menu, then choose ‘Properties’. In the tab ‘Shortcut’ set the text field labelled ‘Target’ to one of the following values:

My Computer: %windir%\explorer.exe ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

Some other options:

My Documents: %windir%\explorer.exe ::{450D8FBA-AD25-11D0-98A8-0800361B1103}
My Network: %windir%\explorer.exe ::{208D2C60-3AEA-1069-A2D7-08002B30309D}
Homegroup: %windir%\explorer.exe ::{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}
Libraries: %windir%\explorer.exe ::{031E4825-7B94-4dc3-B131-E946B44C8DD5}

Why is using My Computer the best option? Well, it gives you a hierarchical view of all files from all disks. From here you can go anywhere without going a level up, or using shortcuts. Also you can instantly check your drives (and their space usage) and externally connected drives and network locations. But how about those nice libraries? Well, shortcuts belong in a separate bar, you can find them by default in the left navigation bar.

Naturally, you can also set a real path (e.g. C:\MyShortcutsFolder).

List of useful meta-tags in HTML

Set the default charset of the HTML-page. If the document is displaying characters of a specific charset, you will want the browser to use the same charset, or unintended and weird symbols may appear.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Prevent Microsoft Internet Explorer (MSIE) to use compatibility-mode, since this may introduce unintended and weird bugs. In order to get in compatibility-mode, the user will have to explicitly tell the browser to use another mode.
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Some of these meta-tags may also be set server-side, which may be preferred over meta-tags for several reasons. First, it is neat, no messy HTML-code for configurations of interpretation of the HTML-document. Second, it is maintainable, because otherwise several meta-tags will be spread across multiple documents. Third, it is most-likely faster.

Get IP-address in Linux bash by hostname in local network

Solution: extract parenthesized IP-address from first line of the ping-command using regular expression.

ping AnyPCName | head -n 1 | sed 's/^.*(\(\([0-9]\{1\,3\}\.\)\+[0-9]\{1\,3\}\)).*$/\1/'

Output sample:

> ping AnyPCName | head -n 1
PING AnyPCName (192.168.0.100) 56(84) bytes of data.
> ping AnyPCName | head -n 1 | sed 's/^.*(\(\([0-9]\{1\,3\}\.\)\+[0-9]\{1\,3\}\)).*$/\1/'
192.168.0.100