Ana içeriğe atla

Kayıtlar

Sed grouping and paranthesis

I forgot how to group regex in sed and also using \ with paranthesis. Here is a summary 1-If you group a regex with () then \1,...,\10 is the way to call them. 2-You must put \'s before any paranthesis inside sed like this sed "s/\([0-9]\{1,3\}),\([0-9]\{1,3\}/\1.\2/g" This sed makes two groups [0-9]\{1,3\} representing the digits before and after ",". And makes the comma between them a point ".". And prints the result. This is the page which inspired me http://www.catonmat.net/blog/sed-one-liners-explained-part-one/

FreeNAS On Qemu

I have an openbsd on an old P2 computer. I use this box as a nfs and dns server for myself and some friends on my network. Because my friends have windows pcs I was in search of a way of sharing my music and files on this box. I found mt-daapd (now called firefly media server) as a solution. It works fine for sharing music with DAAP a protocol used by IPods. On windows there are programs Songbird(with an extesion), Itunes which are able to understand DAAP. For sharing files and many other things I knew FreeNAS is a nice solution but I didnt have chance to try. I thought it is time to try it and planned using it with QEMU. I compiled QEMU from the ports of my openbsd 4.1 without any problems.Then I created an image file for FreeNAS by this $ qemu-img create FreeNas.img 1GB Then I used FreeNas iso file downloaded from www.freenas.org and used it to install by this $ qemu -localtime -hda FreeNas.img -cdrom /path/FreeNas.iso -boot d After installing FreeNas as described in its manual, I cl...

VirtualBox Services on Guest

When you install on Virtualbox a guest operating system with NAT (connection between guest and host provided by nat) and you want to provide a service on guest, then you can make port forwarding to reach this service from outside. Host: 192.168.2.x on network 192.168.2.0 Guest: 10.0.2.15 on network 10.0.2.0 Lets say the service we want to provide on Guest is rdp. We need to make these commands VBoxManage setextradata "GuestVM"       "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP VBoxManage setextradata "GuestVM"       "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" portnumber(ie,3389) VBoxManage setextradata "GuestVM"       "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" portnumber(ie,say 3389 or anything other which is availabel on host)

An Awk feature

I was trying to use sub (or gsub) function in awk to delete an \r from the end of line. For that purpose I used dum=sub(/\r/,"",$0) and thought that the variable "dum" will be filled with the changed value of $0. But I realised that sub function only make the change and returns 0,1 accordingly. So I wrote like this sub(/r/,"") ; x=$0;

Sed wisdom

cat yop2.sql | sed -e "s/\([0-9]\),\([0-9]\)/\1.\2/g"  > yop3.sql To turn commas into dots on numbers like "343,123" I have the previuos sed statement. Thanks sed!

IE bugs makes life unbearable

CSS is a nice technology when everybody adapts it correctly. Unfortunately some browser(s) like IE doesnt follow W3Cs recommendations and standarts making our lives miserable. I have done an html page with CSS which seems perfect on Firefox,Opera etc. But when it comes to IE it fails to be sown correctly. After some search I learned that IE has also a bug about floats which is called "3px float bug" . To solve it for my case I changed a "width" attribute to a "max-width". Also I used  png images with a hope for  transparency. But I learned after searc again that IE 6.0 is not capable of png transparency which is added to IE7.0 version. This is IE and life of a web programmer.

Mambo change 2

A new problem with com_events and mysql 5.0 DB function failed with error number 1054 Unknown column 'a.checked_out' in 'on clause' SQL=SELECT a.*, cc.name AS category, u.name AS editor, g.name AS groupname FROM jos_events AS a, jos_categories AS cc LEFT JOIN jos_users AS u ON u.id = a.checked_out LEFT JOIN jos_groups AS g ON g.id = a.access WHERE a.catid=cc.id ORDER BY a.catid LIMIT 0,30 And the solution: This query is the one that fails, and appears around line 226. This is the fixed version and has had brackets added in line 227 in the FROM clause, like so- Code:    $database->setQuery( "SELECT a.*, cc.name AS category, u.name AS editor, g.name AS groupname"       . "\nFROM (#__events AS a, #__categories AS cc)"       . "\nLEFT JOIN #__users AS u ON u.id = a.checked_out"       . "\nLEFT JOIN #__groups AS g ON g.id = a.access"       . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "")...