Nov 20, 2013
Technology###Using Wget to fetching the webpages
wget could be used to fetch the webpages from a specified website, using following command could fetch all of the wiki related 1st layer pages from “awesome Wiki”
$ wget -r -l 1 http://awesome.naquadah.org/wiki/Main_Page
After wget finished, you will found the 1st layer webpatges under your directory.
###Decide which you want for generating the book
There are some rubbish pages in downloaed pages, thus we have to write a script for fetching the valuable ones, my script is listed as following:
[Trusty@DashArch wget]$ pwd
/home/Trusty/wget
[Trusty@DashArch wget]$ cd awesome.naquadah.org/
[Trusty@DashArch awesome.naquadah.org]$ ls
doc download images index.html robots.txt wiki
[Trusty@DashArch awesome.naquadah.org]$ cd wiki
[Trusty@DashArch wiki]$ cat listitem.sh
#!/bin/sh
for file in `ls `
do
#echo $file
type=`file $file | awk {'print $2'}`
#echo $type
if [ "$type" = "HTML" ]
then
#echo $file
#echo $type
echo "<a href=\"$file\">$file</a><br/>"
fi
done
simply run listitem.sh, we will get the file list tables like following:
<a href="Automounting">Automounting</a><br/>
<a href="Autostart">Autostart</a><br/>
<a href="Autostart_with_consolekit">Autostart_with_consolekit</a><br/>
<a href="Autostop">Autostop</a><br/>
<a href="Awesome_3.0_to_3.1">Awesome_3.0_to_3.1</a><br/>
..........................................
Add them into the html like:
<html>
<body>
<h1>Table of Contents</h1>
<p style="text-indent:0pt">
<a href="Automounting">Automounting</a><br/>
<a href="Autostart">Autostart</a><br/>
......
<a href="XRandR_Screen_Table">XRandR_Screen_Table</a><br/>
<a href="Xscreensaver">Xscreensaver</a><br/>
</p>
</body>
</html>
###Generate the ebook
Use Calibre, click “Add Book”, navigate to your directory which contains “index.html”, choose it, and now you can do whatever you want to generate epub, mobi, or 6 inch pdf. Just enjoy your ebook!!!
[Trusty@DashArch Awesome (5)]$ ls -l -h
total 4.5M
-rw-r--r-- 1 Trusty root 887K Nov 20 21:07 Awesome - Dash.epub
-rw-r--r-- 1 Trusty root 511K Nov 20 21:19 Awesome - Dash.mobi
-rw-r--r-- 1 Trusty root 2.6M Nov 20 21:10 Awesome - Dash.pdf
-rw-r--r-- 1 Trusty root 560K Nov 20 21:06 Awesome - Dash.zip
-rw-r--r-- 1 Trusty root 1.1K Nov 20 21:18 metadata.opf
Depending on your settings, your generated ebook could be read on NOOK, Kindle, or other mobile equipment.
Nov 20, 2013
TechnologyImage1:
Image2:
Image3:
Image4:
Image5:
Nov 19, 2013
Technology###Partition the SD card
Insert the SD card and view the partitions via fdisk -l, then
[root@XXXyyy Trusty]# parted -s /dev/mmcblk0 mklabel msdos
[root@XXXyyy Trusty]# fdisk -l
Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0002d03c
Make partition 1, fat32, and its size if 16 “cyl” (cylinders)
[root@XXXyyy Trusty]# parted -s /dev/mmcblk0 unit cyl mkpart primary fat32 -- 0 16
Parameters
unit unit
Set unit as the unit to use when displaying locations and sizes, unit cyl means cylinders.
mkpart part-type [fs-type] start end
Make a part-type partition for filesystem fs-type (if
specified), beginning at start and ending at end (by
default in megabytes). part-type should be one of "pri‐
mary", "logical", or "extended".
Make the partition 1 bootable:
$ parted -s /dev/mmcblk0 set 1 boot on
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 258047 128000 c W95 FAT32 (LBA)
Make the second partition:
[root@XXXyyy Trusty]# parted -s /dev/mmcblk0 unit cyl mkpart primary ext2 -- 16 -2
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 258047 128000 c W95 FAT32 (LBA)
/dev/mmcblk0p2 258048 15491071 7616512 83 Linux
Now we can see the partitions:
[root@XXXyyy Trusty]# parted -s /dev/mmcblk0 print all
Model: SD SU08G (sd/mmc)
Disk /dev/mmcblk0: 7948MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 132MB 131MB primary boot, lba
2 132MB 7931MB 7799MB primary
###Make filesystems
Make dos file systems(FAT32) in the first partition:
[root@XXXyyy Trusty]# mkfs.vfat -n System /dev/mmcblk0p1
mkfs.fat 3.0.23 (2013-10-15)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
-n means the volumn name
Make ext4 filesystems in the second partition:
[root@XXXyyy Trusty]# mkfs.ext4 -L Storage /dev/mmcblk0p2
-L means the Label of the partition
###Copy to SD Card
Mount the card
[root@XXXyyy Trusty]# mount /dev/mmcblk0p1 /mnt
[root@XXXyyy Trusty]# mount /dev/mmcblk0p2 /mnt1
Copy
[root@XXXyyy bcm2835-bootloader-1100e2a]# pwd
/media/x/code/openELEC/OpenELEC.tv/build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-1100e2a
[root@XXXyyy bcm2835-bootloader-1100e2a]# cp start.elf /mnt/
[root@XXXyyy bcm2835-bootloader-1100e2a]# ls
bootcode.bin fixup_cd.dat fixup_x.dat start_cd.elf start_x.elf
COPYING.linux fixup.dat LICENCE.broadcom start.elf
[root@XXXyyy bcm2835-bootloader-1100e2a]# sync
[root@XXXyyy bcm2835-bootloader-1100e2a]# cp bootcode.bin /mnt/
[root@XXXyyy bcm2835-bootloader-1100e2a]# sync
Copy kernel and System
[root@XXXyyy target]# pwd
/media/x/code/openELEC/OpenELEC.tv/target
[root@XXXyyy target]# cp OpenELEC-RPi.arm-devel-20131119160254-r16396.kernel /mnt/kernel.img
[root@XXXyyy target]# sync
[root@XXXyyy target]# cp OpenELEC-RPi.arm-devel-20131119160254-r16396.system /mnt/SYSTEM
[root@XXXyyy target]# sync
Make the startup scripts:
[root@XXXyyy mnt]# echo "boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh quiet" | tee cmdline.txt
boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh quiet
[root@XXXyyy mnt]# ls
bootcode.bin cmdline.txt kernel.img start.elf SYSTEM
[root@XXXyyy mnt]# cat cmdline.txt
boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh quiet
###Startup
Now Insert the SD Card into your Raspberry Pi, and enjoy the XBMC.
Nov 19, 2013
Technology1. Awesome tips, for example, drop-down terminal.
2. Verify the XBMC on Raspberry Pi.
3. Using IRremote on XBMC and know its principle.
4. BeagleBone’s old kernel and the old style tutorial.
5. Device tree of kernel on BeagleBone.
6. MP3 Player in IRremote control on Arduino.
7. Awesome Book in mobi or epub and send it to Kindle.
8. How to enable the various display method on Arduino(12864, Nokia5110, etc?)
Nov 19, 2013
Technology###ssh command
Take following command for detailed example of using ssh:
alias mydaili='ssh -qTfnN -D '
-q Quite Mode
-T Disable pseudo-tty allocation
-f background the ssh
-n redirect the stdin from /dev/null
-N Don't execute a remote command
-D Bind address
###Using rsh
rsh could be used for executing the command remotely, thus in my family’s debian machine I could write following script:
cat /bin/remoteON
#!/bin/sh
rsh -l root localhost -p 4381 ssh -qTfnN -L 1XX.XXX.XXX.XXX:9004:1XX.XXX.XXX.XXX:8000 USERNAME@remoteserver.com &
chmod 777 /bin/remoteON
For killing the remote machines’s running ssh tunnel process, write another script:
!#/bin/sh
#Fetch the ssh id
sshid=`rsh -l root localhost -p 4381 ps | grep "ssh -qTfnN" | awk '{print $1}'`
#Kill the selected process
rsh -l root localhost -p 4381 kill $sshid
$ chmod 777 /bin/remoteOFF
###Write the local script
Local Scripts is for calling the remoteON and remoteOFF.
Script for starting the proxy
#!/bin/sh
#Start the openWRT Tunnel
rsh -l root 10.0.0.111 /bin/remoteON &
#Sleep 3 seconds
sleep 3
#Start the Debian Tunnel
rsh -l root 10.0.0.111 ssh -qTfnN -L 10.0.0.111:9001:1XX.XXX.XXX.XXX:9004 root@localhost -p 4381 &
Script for stopping the proxy
#!/bin/sh
# Stop the openWRT Tunnel:
rsh -l root 10.0.0.111 /bin/remoteOFF &
# Sleep 3 seconds
sleep 3
# Stop the Debian Tunnel
sshid=`rsh -l root 10.0.0.111 ps -ef | grep "ssh -qTfnN" | awk '{print $2}'`
rsh -l root 10.0.0.111 kill $sshid &
###How to use it?
If you want to use proxy, simply ./startproxy.sh.
After using the proxy, you can ./stopproxy.sh for totally release the connection and release the resources.