Archive for August, 2008

Some conditional REBOL parse examples

Sunday, August 24th, 2008

I am still improving my webcrawler, so I thought I would post some code to show you some more of REBOL’s parse functionality. I needed to parse somthing with this pattern:

Name » Janko
City » Sevnica

<div>Name &raquo; Janko<br/> City &raquo; Sevnica<br/></div>

I assigned it to s-ok and parsed it with this code at first:

NAME: CITY: ""
parse s-ok [
	to "Name" thru "&raquo;" copy NAME to "<br/>"
	to "City" thru "&raquo;" copy CITY to "<br/>"
]
print NAME print CITY
;and got printed
 Janko
Sevnica

So it works, but sometimes the page I parse includes only City and with code above we fail to get the City out:

<div>City &raquo; Sevnica<br/></div>

OPT (optional) in code below will take care of this. But the HTML is also slopy written so I have seen these variations of it:

s-ok: "<div>Name &raquo; Janko<br/> City &raquo; Sevnica<br/></div>"
s-1: "<div>Name &raquo; Janko<br/></div>"
s-2: "<div>City &raquo; Sevnica<br/></div>"
s-br: "<div>Name &raquo; Janko<br/> City &raquo; Sevnica</div>"
s-2brr: "<div>City &raquo;&raquo; Sevnica</div>"

We modify our code to parse this all and we put it into a function :

do-parse-all: func [ s ] [
	NAME: CITY: ""
	parse s [
		OPT [ to "Name" thru "&raquo;" copy NAME to "<br/>" ]
		OPT [ to "City" SOME [ thru "&raquo;" ] copy CITY [ to "<br/>" | to "</div>" ] ]
	]
	print NAME print CITY
]

Now we go to console and we extract info out of all variants:

>> do-parse-all s-ok
 Janko
Sevnica
>> do-parse-all s-1
 Janko

>> do-parse-all s-2

Sevnica
>> do-parse-all s-br
 Janko
Sevnica
>> do-parse-all s-2brr

Sevnica
>>

BTW: The original parse would correctly parse s-ok and s-1.

Bureaucracy I love you (again)!

Thursday, August 21st, 2008

I finished one of web-services I am preparing. We decided that we will be using an affiliate system to help it kick in. So I had to make a affiliate system also, you know register, login, check earnings, request payment, see past payments… But when I made it I started figuring out that there is another wall in front. A wall made of bureaucracy bricks…

So after exploring how can we legally pay the affiliates that don’t have companies or anything (which would probably be the big part of them) we figured out it would mean so much paper work per affiliate/payment, so much taxes that the money that we give to affiliate will be probably minor compared to the cost of that.

So, we dumped the affiliate thing… anyone needs an well preserved, never used affiliate system?

Bureaucracy is really the enabler in our country? I hope I will never want to make something like an international affiliate system because then I could probably just go mad by finding out what all I have to do to do it “right”.

Reblog this post [with Zemanta]

Few vacation pics

Saturday, August 16th, 2008

vacations

Dove ? Dove ? (Camp Eden, Lago di Garda - IT)

-

vacations

Biker in the shadow ( Camp Šobec, Lesce - SLO )

-

vacations

Kolpa safari ( Camp Podzemelj, Črnomelj - SLO )

-

vacations

View at Kolpa ( Camp Podzemelj, Črnomelj - SLO )

-

vacations

I might need a bigger bucket… ( Camp Zelena Laguna, Poreč - CRO )

-

vacations

Master Yoda: At Soča, heaven, there is… (Kamp Soča, Bovec - SLO )

-

vacations

.. and a tree, nice view, it has. (Kamp Soča, Bovec - SLO )

-

vacations

Follow my lead ! (little lake Jasna, Kranjska gora - SLO )

vacations

Who woke the psycho ninja beast ?!? ( Vršič pass, 1611m - SLO )

Reblog this post [with Zemanta]