Subscribe

  • Subscribe via XML
  • Subscribe via Bloglines
  • Subscribe via NewsGator
  • Subscribe via MyYahoo
  • Subscribe via Google
  • Subscribe via MyMSN
  • Add this blog to my Technorati Favorites!

How To Write a PHP Quine

May 25th, 2005 by Patrick Schneider

A Quine is a piece of self-reproducing code. There are plenty of resources out there to explain the theoretical side of this, about Quine himself, examples in other languages, etc. I don’t want to reproduce that information, but I’d like to walk you through the step-by-step way to making your own quine in PHP.

If you want more background information on quines, here are some places to start:

http://en.wikipedia.org/wiki/Quine
http://www.nyx.net/~gthompso/quine.htm
http://www.philosophypages.com/ph/quin.htm

So, on with the PHP example.

You will need two PHP scripts to accomplish the task at hand. My examples will be run from the command line, though you could just as easily run these from a browser.

First, create the ‘quine’ script:

#!/usr/local/bin/php
<?php
$dna = '*';
echo str_replace(chr(42), $dna, base64_decode($dna));
?<

Second, create the ‘generator’ script:

#!/usr/local/bin/php
<?php
echo base64_encode(file_get_contents('./quine'))."n";
?>

Now, run the generator:

$ ./generator

Provided the files are exactly as mine, you will get a long string of characters, like “IyEvdXNyL2xvY2FsL2Jpbi9waHAKPD9 …”. Replace the asterisk in the ‘quine’ script with this long string of characters, like so:

#!/usr/local/bin/php
<?php
$dna = 'IyEvdXNyL2xvY2FsL2 ... ';
echo str_replace(chr(42), $dna, base64_decode($dna));
?>

Note that I have not included the full string of characters here; I’ve put an elipses where the rest of the string should be. Including it would have caused it to run way off to the right of the screen.

Now, run the ‘quine’ script:

$ ./quine

Pretty!

Notes: To follow this example exactly, you’ll need to have PHP-CLI enable (so that you can run PHP scripts from the command line). Also, your scripts will need to have the executable bits set:

$ chmod +x generator
$ chmod +x quine

The idea for this was stolen from Sam Barnum at 360works. His original program is here. There’s no step-by-step method of how he made his program, though, which I thought needed to be mentioned. Thanks Sam for the idea!

San Antonio Gets Biodiesel

May 24th, 2005 by Patrick Schneider

Renewable Energy Access reports that San Antonio’s AGE Refining company will be offering B20 biodiesel straight off of their rack. This fuel is definitely gaining ground, and I will absolutely be buying diesel next time around (unless, of course, something even more awesome becomes widespread).

IKEA Kitchen Installation - Updates Coming Soon

May 18th, 2005 by Patrick Schneider

Today I browsed some of the pictures I have up here from the IKEA kitchen that I put in over a year ago. It’s finished now — the main page for it states that I’m still in the demolition phase. This is incorrect :)

So, what I would like to do is get a real web page for each individual picture and have text on each. Perhaps also I will create a little “Questions/Comments” segment on each picture where I can post/answer things that people ask…

If you have any other good ideas (and/or have an IKEA kitchen question right now) let me know.

Biodiesel is Now, Redux

May 12th, 2005 by Patrick Schneider

I’m enamoured with biodiesel. And there seem to be more and more sites popping up with biodiesel information. Perhaps, actually, they’ve been there for some time, and I’m just now stumbling across them.

For those of you in Houston, here’s a great site I came across: Houston Biodiesel. Among some good information, I found out that MINI makes a diesel (it’s called the MINI One D and MINI One TD). Naturally, it’s only available in Europe… but can you imagine? This thing gets 58.85 MPG combined city/highway! And what if you ran it on biofuel — biodiesel or straight vegetable oil (SVO)?!? Unreal.

Rudolf Diesel was quite an amazing individual. Ahead of his time: Fattywaggons.com.

Oh — and Willie Nelson has taken quite an interest in biodiesel as well. So much so, that he started his own company, BioWillie. While I wasn’t able to find a website for BioWillie biodiesel, I was able to find a ridiculous blogger that is sticking-it-to-the-Rebuplicans with her (?) awesomely bad, feminist-and-biodiesel-but-not-Republican promoting agenda: The Goddess. Well, Goddess, I’m glad that we can at least agree on the fact that Willie Nelson is very progressive in adopting biofuels. But why do we have to hate Republicans also? I’m not too fond of the policies of any of the crack-heads up in DC. So can’t we just agree that, regardless of political affiliation, biofuels are a *good* thing? I would hope so.

For those of you in Austin, check out Austin Biofuels, LLC.

Biodiesel Redux III

May 12th, 2005 by Patrick Schneider

Here’s the link for BioWillie:

http://www.wnbiodiesel.com/

And another fantastic article on biodiesel/SVO:

http://moneycentral.msn.com/content/Savinganddebt/Saveonacar/P115218.asp

Speaker Scam

May 12th, 2005 by Patrick Schneider

Y’all heard of this?

Some guy approaches you, typically in a white van, pressuring you to buy really “high-end” speakers off of him because he works for an “audio company” and they “messed up and gave him extra”… so naturally, he wants to pass the savings on to you.

I was at the ATM today when a guy drove up next to me and gave me this spiel. I looked at him funny and he drove off. My first thought was that he was trying to get my ATM PIN, so I walked into the bank when I finished my ATM business and immediately changed my PIN. I mean… who knows how long he was next to me in his car?

This guy was actually in a beige SUV, not a white van. I imagine, though, the scam was the same. “I work at an audio company.” Really? I eat cows and like it. By the way, do you have any speakers you can sell me?

Anyway, don’t buy speakers in parking lots from people that are trying to pawn them off on you.

2005 Kona Sutra / Bianchi Volpe Comparison

May 10th, 2005 by Patrick Schneider

I’ve recently (for the past year) been in the market for a heavy-duty road bike/touring bicycle. There are a good number of them out there, but a lot of them are made by specialty companies and run in the range of several thousands of dollars. What’s more, local bike shops tend not to stock even the most basic touring bike, such at the Trek 520.

Anyway, Kona and Bianchi both have some interesting options that I asked my friend (who is a bicycle mechanic) to compare. He did a very awesome and very in-depth in his comparison of the ‘05 Sutra and the ‘05 Volpe, so I thought I’d post his thoughts for anyone else that’s interested. The two bikes I’m talking about are available here:

2005 Bianchi Volpe

2005 Kona Sutra

Those two bikes appear to be an interesting comparison.  You've
got a more classical design versus a more modern design.  So right
off the bat we've got a nice rift between the two.  

The first thing I see with both bikes is that the Kona has disc
brakes, and no options for other brakes.  I don't see any
cantilever posts, and the fork has the word "disc" in the name, so
I don't expect to find threads to insert any posts if you ever
want to use regular brakes.  Disc brakes in my opinion are more of
a headache than they're worth.  Plus these particular brakes are
cable drawn, which manufacturers began doing so that disc brakes
would begin to appear on lesser costing bikes.  You're not even
getting the full benefit with hydraulics.  Now the Bianchi has
cantilever brakes.  Nice and strong, they will allow wider tires
than road caliper brakes, and you're left with WHEEL OPTIONS.  You
won't be limited to disc-specific hubs.  You can build a
superlight wheelset for rallies, or you can run daily beaters
which it comes with.  You could even throw some linear pull brakes
on there for more power over the canti's, and even continue using
your standard pull STI brake levers with minimum modification.  As
for which is more reliable, disc or rim, I'm not sure.  I'd bet
though that there's as much chance of breaking a rim brake arm as
there is braking a disc pad caliper.  If you're running for three
weeks across a few states, either carry a few extra brake pads or
a spare rotor.  If I were running disc brakes on a touring bike,
they would have to be cable drawn, because bleeding brakes on the
side of the road is just stupid.  And a cable drawn disc brake is
stupid.  So my personal choice is to stick with rim brakes.

Next I see the differences in the two frame designs.  The
Bianchi's geometry is certainly relaxed from a racing bike, but
not quite as upright as the Kona.  The Kona has an extrememly
sloping top tube, and the cranks appear to be kicked a little
further out.  That's all good and fine for comfort, but I would
think it gives you less control.  I would wager that the Bianchi
probably rides more like a road bike, the Kona more like a
mountain bike.  In a perfect world there's a shop in Austin
carrying both Bianchi and Kona.  If so, go ride them both, one for
as long as they'll let you, and then the other for as long as
they'll let you.  See how they both feel, but try not to just
coast at five miles per hour doing quick turns in the parking
lot.  Although that may be your only option.

Those are the two most obvious concerns that stand out to me.
Frame design, because that determins what kind of bike you have,
and how it will handle undernieth you.  Then brakes.  Not becuase
brakes are so important, but because they affect the wheels.  And
wheels are EXTREMELY IMPORTANT.  Plus the ease of regular
maintenance, and more critcally, roadside-friendly repairs.  

Aside from that I'd sum up the rest of the two bikes as the Kona
utilizing the most modern components, the Bianchi sticking to
classic work horse components.  That GXP crank on the Kona is
Truvativ's answer to Shimano's external bottom bracket setup.
Notice that it's hollow, you can see straight through it.  It
pushes the crank arms further away from the frame, which will
increase stability (great for off-road), but it's main goal is to
be lightweight.  Plus the design is brand new.  It has yet to
become a standard, or to flop.  The Bianchi has lower gearing on
the crank, and a very wide range cassette.  It is certainly more
cargo and touring friendly, and without bling-factor.  The only
thing I could set next to the bling category on the Bianchi would
be that suspension seat post.  I would trade it out for a regular
seat post.  The Kona has 105 shifters, the Bianchi has Tiagra.
Honestly, the Tiagra shifters are keeping the cost of the Bianchi
down.  The 105's are better, but you'll still get years out of
those Tiagras.  Maybe not as many as the 105's, but certainly your
money's worth.  And if you have a "new rider wreck" that will
graduate you into "experienced rider" (doesn't happen to many
people, but we see it with road bikes often enough), and you total
your shifters, you're breaking less, and possibly replacing it
with more.  Also, the Bianchi comes with clipless pedals, the Kona
does not.  They appear to be SPD style mountain pedals, but that's
okay.  Trade them out for some road pedals, or throw them on your
mountain bike.  

If I had to choose one of these two bikes, based on package only,
no money concerns, you can probably deduce from my comparison
which it would be.  If not, good.  That means my personal opionion
won't be contributing in any way to your method of balancing what
you think about the two versus what I think about the two.  

Oh yeah, I forgot to mention wheelbase.  I couldn't find a
geometry chart for the Kona that included wheelbase, if you do
email me a link.  The Bianchi does give wheelbase, and yes, it's
nice and long.  The Kona probably builds its long wheelbase with
that sloping top tube.  You'd ride a bigger number frame for the
Kona than you would the Bianchi, because the standover is so short
on the Kona.  You might ride the 55cm Bianchi, but a 58cm Kona.
Both will probably have a wheelbase about the same.  Unless Kona
is crazy and puts a short wheelbase on that bike.

Austin Passes the Smoking Ban - 52/48

May 9th, 2005 by Patrick Schneider

So the smoking ban in Austin passed. It basically means you can’t smoke anywhere inside in Austin, period. Including bars. There is an exception, however. Bingo parlours.

How do you get such an odd “public health” policy passed?

My thought: old people go to bingo parlours. Old people vote. Some old people also smoke. Old people that smoke are not going to change their ways. (Old, stubborn, old & stubborn, crotchety, etc… did I mention old?) So, make an exception for them, and let them decide how the young ‘uns should live their nightlives.

I voted against the ban. Early. Personally, I don’t smoke. And I’m selfishly glad that I can now go out and come home without smelling like smoke. But a bingo exception? Seems a bit odd… does the Austin City Council value old peoples’ lives less? If the law is in the name of “public health”, it would appear so.

SXSW Day 3, part 1

May 9th, 2005 by Patrick Schneider

This is a long time overdue; however, the story is worth telling.

Even after having a great Day 2, I was still a bit miffed that we had missed Ratatat. After all, they were most of the whole reason I purchased a wristband. Luckily we stumbled across a little gem on the web: http://showlistaustin.com/. What a find! Ratatat was playing a free day show at The Victory Grill. So I immediately took the rest of the day off, headed over there, drank free beer, and even had enough time to watch the ridiculously awful opening act (called something like Cheeseburger?).

The second act was M.I.A., which was an unbelievably pleasant surprise. Definitely worth checking out.

Ratatat took the stage last… well, maybe not last, but we left after they finished. They were very loud. And very awesome.

Biodiesel is now.

May 3rd, 2005 by Patrick Schneider

Wave of the future. This is the most exciting thing I’ve heard about in years.

If you haven’t heard of biodiesel, first, check out www.biodiesel.org. Afterwards, run out and purchase a Volkswagen Golf, and go driving.

www.greasecar.com also is a fascinating site.

So, America, it seems like our energy “problems” are not really problems at all. Simply an opportunity for some fantastic alternatives to further develop.