20 Juni 2010
specification pattern
16 Juni 2010
some useful daily scripts
Last update: 13 Feb 2011
I wrote several simple scripts to manipulate the content of files. Most of them are written in bash, but due to my lack of expertise sometimes I mixed bash with make, and perl. It will be very practical.. almost no explanation, but I'll try to gradually improve this article. Here are they:
- Find the files with specific content
find . -type f -name "*.bash" -print0|xargs -0 grep -ne "keyword"
- Change certain content of files in batch manner. Just copy these script into a command.bash, and change the permission then run it (command filenamepattern old new)
./command.bash "tt*" tir ti
The script:#!/bin/bash TMPDIR=/tmp fname=${1} old=${2} new=${3} tmpfile=${TMPDIR}/$$.tmp #echo "ls ${fname}" for mydataset in `ls ${fname}`; do echo "${mydataset}" cat ${mydataset} | sed -e "s/${old}/${new}/g" > ${tmpfile} mv ${tmpfile} ${mydataset} done
- Delete a bunch of file
If you have thousand of files, rm * will not work, therefore here is an alternative. Create a makefile with the following entry and call make clean.clean: find . -name "*.log" -print -exec rm {} \;
- Creating tags for emacs
find . -name "*.[chCH]" -print | etags -
In case you have only few filesetags file1 file2 ...
- Removing Hijriah calendar from islamicfinder.com praying timetable :). Often the hijriah date make me confuse and pick a wrong time. I do it in vi using this search and replace command.
:%s/[0-9]*\/[0-9]*\t//g
- Cleaning carriage return/line feed (crlf) but left double crlf. I use this for formatting my latex style text file (which uses crlf extensively) before I upload it into blogger.
cat fileinput |sed -n 'H;${g;s/\n/crlf/g;p}'| sed -n 'H;${g;s/crlfcrlf/\n\n/g;p}'| sed -n 'H;${g;s/crlf/ /g;p}' > file output
- Resize pictures/images, 1024 is the width
mogrify -resize 1024 *.jpg
- Montage/combine/collate pictures into one
montage *.jpg -tile 1x2 -geometry 1024 combine.jpg
- Convert images into pdf
mogrify -format pdf *.jpg
- Download Al-Quran ayats.
#usage: # want to download albaqarah ayat 1 to 10 # to download other ayat you must change this script accordingly # just to list the download commands #$ bash dlayat.sh 1 10 # actually download #$ bash dlayat.sh 1 10 download i="${1}" j="${2}" download=0 if [ "${3}" == "download" ] then download=1 echo download fi while [ $i -le $j ] do padd="" if [ $i -lt 100 ] then padd="0" fi if [ $i -lt 10 ] then padd="00" fi if [ $download -eq 1 ] then wget http://www.everyayah.com/data/Ghamadi_40kbps/002${padd}${i}.mp3 else echo wget http://www.everyayah.com/data/Ghamadi_40kbps/002${padd}${i}.mp3 fi i=$[$i+1] done
- Converting raw images into jpg in batch manner
#change the raw file extension accordingly thepath=${1} for file in `ls ${thepath}*.CR2`; do ufraw-batch --out-type=jpg ${file} done
- To be continued..
Label: komputer
06 Juni 2010
service bagus telkom speedy
Hari itu pas hari minggu, hujan deras. Pas mau magrib internet gak jalan.
Telpon ke customer service telkom disuruh restart dsb, tapi tetap
saja tidak jalan. Akhirnya dijanjikan akan dicek ke rumah.
Sekitar jam 7 malam, beneran ada petugas yang datang, ngecek koneksi dsb.
Eh ternyata memang koneksi ADSL nya yang lepas di central stationnya.
Mas petugasnya nelpon temannya yg bagian jaringan dan akhirnya dibenerin
di centralnya.
Salut.. hari minggu malam2 hujan deras pula. Salut telkom speedy.
Sejauh ini hanya itu saja masalah yg terjadi, speed ke lokal baik2
selalu, sekitar 300kbps. Begitu ngakses di luar IIX.. mampus deh..
tapi masih acceptable. berikut screen shotsnya:
04 Juni 2010
laptop baru
Memang bukan "baru laptop", cuman axioo pico.
Diinstali linux ubuntu kemarin, trus hari ini ngurusin wirelessnya, mengikuti petunjuk di sini.
Wah ternyata wifi cardnya bukan intel, cuma Realtek, sama dengan LAN cardnya.
Ada masalah waktu perintah:
make install
ada error berkaitan dengan bounds.c. Untuk mengkompilenya diperlukan source linux, bukan hanya headernya saja. linux-source bisa diinstall lewat synaptics saja, boleh juga pake apt.
Extract file source linux tersebut, kemudian jalankan make install.
Ada sedikit "unsolved mystery" tidak bisa dijalankan dengan sudo make install. Tapi masuk
konsole root (bisa menggunakan sudo su) kemudian jalankan make install.
boca a lupo!
[catatan tambahan: ditulis dengan laptop baru ini]
- wireless jalan, tapi harap hati2 kalau ingin beli, di manualnya ada seri dimana wifi adalah piranti optional
- key panah terlalu kecil sering kepencet sampingnya, untung cuma tombol ctrl
- tombol fn di pojok, cukup bermasalah buat yg suka pake ctrl di kiri. oooh emacs!
- webcam jalan juga.. tanpa instalasi apapun
- prosesornya support hyperthreading
- suaranya kecil banget. semoga baik2 saja kalo pake headphone
- tombol left & right click keras banget, kurang nyaman.
Label: komputer
Langganan:
Postingan (Atom)