Add Scroogle to your search area in Firefox 2.0 Install the 'Scroogle Scraper' search plugin.

Uncategorized


mcbride-lies.jpgWe all know that SCO sucks. By extension, the people who work for that deplorable company also suck and because now SCO isn’t doing so well financially, SCO is laying off a bunch of employees. These people took the bet that SCO would win and now that SCO is losing, they’ll expect to pretend that nothing ever happened and jump to another job. Of course, they stood to gain a lot if SCO’s attempt to extort money out of the Linux world would have worked. Fortunately SCO’s plan has failed miserably. Sorry SCO employees, You can’t eat your cake and have it too (as the saying originally went) — no jobs for you!

and no, I’m not talking about the Utah Summer Games Arm Wrestling competition.

I’m talking about Python, the programming language. And to encourage adoption of that language some clever people created a little Python programming game (back in 2005.) You’re presented with a riddle of sorts and you’re supposed to code up a python script to solve it. Only, I don’t like people telling me what to do, so I intentionally did NOT code up python to solve them. I used PHP mostly. Here are my notes:

QUESTION 1: what’s 2^38?
ANSWER: I asked google: http://www.google.com/search?hl=en&q=2%5E38&btnG=Google+Search
and then I used the answer to get to the next step: 274877906944.html

QUESTION 2: given: K->M, O->Q, E->G, decode: g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr’q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
ANSWER: I used an online cryptogram solver (though i could have written a simple script to shift up two letters…)
“map” then, shifts to “ocr”, which leads to http://www.pythonchallenge.com/pc/def/ocr.html

QUESTION 3: Find rare characters in the mess below (mess omitted)
ANSWER: php:

$challenge=file_get_contents(‘phychall2.txt’);
echo(ereg_replace("[^a-z]","",$challenge));

which produces: http://www.pythonchallenge.com/pc/def/equality.html

QUESTION 4: “One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.”
ANSWER: I used textpad’s regex ([a-z][A-Z][A-Z][A-Z][a-z][A-Z][A-Z][A-Z][a-z]) and found “linkedlist”, which means: http://www.pythonchallenge.com/pc/def/linkedlist.html

QUESTION 5: “urllib may help. DON’T TRY ALL NOTHINGS, since it will never end. 400 times is more than enough”
ANSWER:

$linked="12345";
for($x=0;$x<400;$x++)
{
$page=file_get_contents("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=$linked");
echo($page."n");
 $previouslinked=$linked;
 $linked=‘’;
list($blank,$linked)=@split(‘and the next nothing is ‘,$page);
 $pos = strpos($page, "Divide");
if ($pos === false)
{
  if ($linked==‘’) die();
}
 else
{
   $linked=$previouslinked/2;
   echo("divide found!!");
 }
echo($linked."n");
}

which produces: http://www.pythonchallenge.com/pc/def/peak.html

QUESTION 6: peak hell
ANSWER:
arghh. have to use python…need to load the pickle dump:

import pickle
unpicklefile = open(‘banner.p’, ‘r’)
unpickledlist = pickle.load(unpicklefile)
unpicklefile.close()
for item in unpickledlist:
        print item
 
python unpickle.py > nextstep.txt

lines look like: [(’ ‘, 14), (’#', 5), (’ ‘, 70), (’#', 5), (’ ‘, 1)]

parse them with:

$problem=file("nextstep.txt");
$parseout=array(‘(’,‘]’,‘)’,‘[’,"’");
function printit($value,$times)
{
  for($loop=0;$loop<$times;$loop++)
    echo($value);
}
foreach($problem as $line)
{
  $tuples=split(‘),’,$line);
  foreach($tuples as $tuple)
    {
      list($first,$second)=split(‘,’,$tuple);
      $first=trim(str_replace($parseout,‘’,$first));
      if ($first==‘’) $first=‘ ‘;
      $second=trim(str_replace($parseout,‘’,$second));
      printit($first, $second);
    }
  echo("n");
}

which produces a nifty ascii art version of: http://www.pythonchallenge.com/pc/def/channel.html

QUESTION 7: : now there are pairs (in http://www.pythonchallenge.com/pc/def/channel.zip)
ANSWER:

$linked="90052";
for($x=0;$x<909;$x++)
{
  $bigArray[]=system("zipinfo -v channel.zip {$linked}.txt|tail -3|head -1",$retval);
  $page=file_get_contents("{$linked}.txt");
  $previouslinked=$linked;
  $linked=‘’;
  list($blank,$linked)=@split(‘Next nothing is ‘,$page);
  $pos = strpos($page, "Collect");
  if ($pos === false);
  else
    {
      $x=10000;
    }
}
$counter=2;
foreach($bigArray as $dot)
{
  if ($dot==‘’) $dot=‘ ‘;
  echo($dot);
  if ($counter++%65==1) echo("n");
 }

Which produces more ASCII art and leads to: http://www.pythonchallenge.com/pc/def/oxygen.html

QUESTION 8: the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]
ANSWER:

$im = imagecreatefrompng("oxygen.png");
for($x=3;$x<629;$x+=7)
{
$rgb = imagecolorat($im, $x, 46);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
 echo(chr($r));
}

more code:

$thelist=array(105, 110, 116, 101, 103, 114, 105, 116, 121);
foreach($thelist as $entry)
{
  echo(chr($entry));
}

http://www.pythonchallenge.com/pc/def/integrity.html

QUESTION 9:
un: ‘BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw: 'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'
ANSWER: missing link : bee
use commandline python, arghh…

s = "BZh91AY&SYAxafx82rx00x00x01x01x80x02xc0x02x00 x00!x9ah3Mx07<]xc9x14xe1BAx06xbex084"
import bz2
bz2.decompress(s)
‘huge’
t = "BZh91AY&SYx94$|x0ex00x00x00x81x00x03$ x00!x9ah3Mx13<]xc9x14xe1BBPx91xf08"
bz2.decompress(t)
‘file’
<code></p>
<p><strong>QUESTION 10: </strong>first+second=?<br>
<strong>ANSWER: </strong>
connect the dots
<code>[php]
$image = imagecreatefromjpeg("good.jpg");
$col_poly = imagecolorallocate($image, 255, 0, 0);
$firstArray=array(146,399,163,…);
$secondArray=array(156,141,165,…);
imagepolygon($image, $firstArray,count($firstArray)/2, $col_poly);
imagepolygon($image,$secondArray,count($secondArray)/2,$colpoly);
header("Content-Type: image/jpeg");
imagejpeg($image);

http://www.pythonchallenge.com/pc/return/cow.html
http://www.pythonchallenge.com/pc/return/bull.html

QUESTION 10: a = [1, 11, 21, 1211, 111221, len(a[30]) = ?
ANSWER:
googled for code:

#!/usr/bin/perl
$str="1"; for (1 .. shift(@ARGV)) { print($str, ", "); @a = split(//, $str); $str=""; $nd=shift(@a); while (defined($nd)) { $d=$nd; $cnt=0; while (defined($nd) && ($nd eq $d)) { $cnt++; $nd = shift(@a); } $str .= $cnt.$d; } } print($str);

paste into textpad for character count
http://www.pythonchallenge.com/pc/return/5808.html

QUESTION 11: odd even
ANSWER:
PBM (Portable BitMap) file (PBM stores single bit pixel image as a series of ascii “0″ or “1″’s. The magic identifier for PBM is “P1″.)

32 0s and 1s (separated by spaces) on 20 rows makes 640
then switch to 1s and 0s and do this 240 times


print "P1\n", "640 480\n";
my $odd = ( "0 1 " x 16 . "\n" ) x 20;
my $even = ( "1 0 " x 16 . "\n" ) x 20;
for ( 1 .. 240 ) { print $odd, $even }

gimp:
load image
load mask.txt as a layer
select that layer
layer->color to alpha
white->alpha

produces: evil

Maybe you, too, are forced to use a web app that doesn’t support Firefox? At my work, we use Salesnet.com. Says salesnet.com’s login help screen “The application supports Internet Explorer 5.0, 5.5, 6.x, and 7.x. You cannot login with any other browser.”

That’s pretty inconvenient, particularly because it doesn’t even do a very good job in IE 7.0. It keeps complaining about the pop-up blocker being on, when the pop-up blocker is clearly off. Annoying.

Enough of this silliness! I installed the User Agent Switcher Firefox extension, restarted firefox, instructed the extension to identify my browser as IE 6.0 and HUZZAH! I could log into salesnet.com and do my work.

Nice job dumb Salesnet.com people.

The other day Beau Scott accused me of neglecting my tech blog, so I thought I’d better post something here. Yes, I know, it’s just a repost from my regular blog. Sorry. :(

Just about every week I get an email/text/IM/comment from someone who stumbles across my blog and then finds my talking robot. Many describe the feature as one of the best on the site. If you haven’t yet discovered the talking bot, (or if you want to have some more fun) now is as good a time as any to click on over and begin your chats. If the conversation is particularly funny, post it here in the comments for us all to enjoy. Happy Talking!

Did I write the bot myself? No, it’s just an AliceBot PHP app. When i get some time, I’ll modify it. I think that AIML has promise. Do you? Discuss.

In my other blog I recently wrote about the Problem with Google. I mentioned a site called Scroogle which strips out the Google tracking cookies, so you can surf in peace. An anonymous writer just emailed me the XML OpenSearch description file to allow you to use Scroogle in your toolbar if you’re running Firefox 2.0. I just installed it. It works swimmingly.

So, you can go ahead and add scroogle by click the button at the top of this blog, or you can add scroogle to your toolbar here

Thanks DS!

Maybe you want to print to PDF. maybe you’ve used programs like: http://www.pdf995.com/
WARNING: THIS DOESN’T YET WORK WITH VISTA!
FYI, a lot of the Windows PDF printers are simply generic PS printers which are connected to ghostscript (which has PS-PDF conversion functionality). http://www.cs.wisc.edu/~ghost/

In fact, you can make your own windows PDF printer by downloading ghostscript and redmon
http://www.cs.wisc.edu/~ghost/redmon/index.htm

“The RedMon port monitor redirects a special printer port to a program. … RedMon can be used with any program that accepts data on standard input.Using RedMon you create redirected printer ports. If you connect a Windows printer driver to the redirected printer port, all data sent to the redirected port will be forwarded by RedMon to the standard input of a program. This program is then responsible for processing the data and producing new output.”

I’ve done this and it’s easy to do.

Here are two step-by-step tutorials to creating a free PDFWriter using Ghostscript:
http://www.stat.tamu.edu/~henrik/GSWriter/GSWriter.html
http://kenchiro.tripod.com/howtoPDF.html

if you’re into ajax, you’ve no doubt used the Scriptaculous Javascript library and the Prototype Javascript framework

on the scriptaculous demo site, they have a sortable demo

I modified that script ever-so-slightly and wrote a
small php script
to go along with it and posted an invention quiz to my ryanbyrd dot net blog

$answer = "42351";
$guess = implode('',$_REQUEST['list']);
 
if ($answer==$guess)
{
echo("correct!");
?>
<ol>
<li><a href="http://inventors.about.com/library/inventors/bltelegraph.htm" target="_blank">telegraph 1838</a></li>
<li><a href="http://inventors.about.com/od/bstartinventors/a/fax_machine.htm" target="_blank">fax machine 1843</a></li>
<li><a href="http://inventors.about.com/library/inventors/bltelephone.htm" target="_blank">telephone 1876</a></li>
<li><a href="http://inventors.about.com/od/rstartinventions/a/radio.htm" target="_blank">radio 1901</a></li>
<li><a href="http://inventors.about.com/library/inventors/bltelevision.htm" target="_blank">television 1929 (cathode ray tube) </a></li>
</ol>
 
<?
}
else
{
echo("Keep trying!");
}
die();

Let’s say a friend of mine was interested in employment with a company called Zamazon. Let’s further pretend that he recently had a phone interview with Zamazon. Continuing this thought game, let’s imagine Zamazon asked this friend the following question:

You are given a word list/dictionary with several thousand words. You are then provided two words, a start word and an end word. For example

Start: corn
End: barn

Your task is to use the dictionary to provide the shortest path (from the dictionary words) from the start word to the end word in single character-changing iterations. For our example, the answer might be: corn -> cord -> card -> bard -> barn

(where cord, card and bard appear in the dictionary.)

Who’s up for the challenge?

Beau Scott, a man with a soul patch, coded up an elegant php solution in just an hour or two. Strong work, Beau!

When I started my first blog, Ryan Byrd’s Ramblings, I had no idea how extraordinarily popular it would be. Each week, practically dozens of people visit the site. My vast server farm has struggled to stay up with the load. In the hundred odd entries I’ve authored, I’ve posted a few that are somewhat technical in nature. Still, I’ve stayed away from the severe details and arcane tech topics because my readership is general in nature. The time has now come, however, for an additional blog that addresses the needs of the worldwide body of discerning scientists, engineers and technologists. I present to you, Ryan Byrd’s Tech Ramblings. Enjoy.

Send to a friend * Print this page * Join the club * Talk with my robot * Advertise here * Search this Site * Donate * Link to me


Web hosting by Utah Hub *  Powered by CreativeTap *  In association with Segomo
Unless otherwise noted, Copyright 2004-2006, Ryan Byrd. All Rights Reserved.
Ryan Byrd dot net -- probably the coolest site in Utah