Archive for November, 2013

YouTube popularity of my IDE videos

Nov 29 2013 Published by under Life

The recent video I made for Python Fiddle didn’t prove to be a hit with on 60 views so far, but the one for the JavaScript IDE has been on the top or second place in referrals for Fiddle Salad. One explanation would be YouTube’s video ranking algorithm takes into account community factors such as subscribed channels and the videos in your channel.
The number of visitors to my site for Wijmo Books is also disappointing but almost to be expected. At least the site was a lot of fun to build and still looks spiff.

No responses yet

Course Planner Prerequisite Parsing Fixes

Nov 24 2013 Published by under CourseTree,Programming

One of the bugs still in the Waterloo Course Planner is the handling of prerequisite sentences that end with “* students only.”. The fix I made was rather simple. Though converting existing test cases to unit tests did not help because none of the older grammar rules were changed and therefore the tests were not broken, it did help in the development of new grammar rules. Python unit tests does a nice job of pinpointing the exact place where the expected results differ from running the code.

Failure
Traceback (most recent call last):
  File "N:\Projects\ply\prereqyacc.py", line 182, in testQuirks
    self.assertEqual(results, map(parser.parse, prereqs))
AssertionError: Lists differ: ['MATH 127/MATH 128/MATH 137/M... != ['MATH 127/MATH 128/MATH 137/M...

First differing element 1:
MATH 115/MATH 119
MATH 115, MATH 119

- ['MATH 127/MATH 128/MATH 137/MATH 147', 'MATH 115/MATH 119']
?                                                  ^

+ ['MATH 127/MATH 128/MATH 137/MATH 147', 'MATH 115, MATH 119']
?                                                  ^^

“* students only.” appearing in a string results in the tokenizer printing out a list of invalid tokens. There are two ways of ignoring strings in PLY:

  1.  t_ignore_ in the tokenizer
  2. change t_ignore_ to a token and add a new rule that returns an empty string in the parser

I used the second method this time, since the semicolon preceding “* students only.” would also need to be ignored. Semicolons are treated as a signal for an “and” clause otherwise. The new rule looks like the following:

def p_restriction(p):
    'semi_restriction : SEMI STUDENTS_ONLY'
    p[0] = ''

No responses yet

How to Clone a Gentoo Workstation

Nov 22 2013 Published by under Linux

Installing Gentoo Linux across all Pentium 4 machines for DataMill was an easy process. I copied an existing installation across hard drives. While installing Gentoo on the source machine, I had -march=pentium4 in make.conf while I would recommend i686 or x86_64 for a generic install that can be copied over a large number of machines. I follow the same steps as http://www.gentoo-wiki.info/HOWTO_Clone_a_Gentoo_Server_or_Workstation, with slight modifications.
DataMill benchmark cluster
On the source machine, I boot up the System Rescue CD and resize the last partition of the install to fit the hard drive size. I also have netcat compiled and uploaded to my site. I run

ifconfig -a

to find out its ip address. Before I start the cloning process, I also change the hostname.

mount /dev/sda3 /mnt/gentoo #sda4 is the partition for /
vim /mnt/gentoo/etc/conf.d/hostname
umount /mnt/gentoo
dd if=/dev/sda conv=sync,noerror bs=1024 count=30000000 | ./nc -l 0 -p 5000

On the destination machine, I boot the Gentoo Live CD, download netcat, and listen to port 5000.

net-setup eth0 #your network interface may vary
wget http://yourdomain.com/linux/nc
chmod +x nc
./nc 10.10.10.16 5000 | dd of=/dev/sda bs=1024

Replace the IP address with the one you obtained from the source machine.
Resize partition with System Rescue CD

No responses yet

Coding in Python in the Browser

Nov 20 2013 Published by under Python Fiddle

I made this video in the summer and Python Fiddle back in 2010. It is still the best Python IDE on the web running in a browser. So here is a demo if you’re new to Python:

No responses yet

Course Planner Book Links and Share Bar

Nov 17 2013 Published by under CourseTree

First up on the list is the bad news: the old share bar is permanently gone as Google has shut it down. That’s right! Google has shut down a competitor’s service after buying it. At least the meebo team is honest and left us a message:

Meebo was acquired by Google on June 4, 2012.

Our team is now working just a few miles down the road with the Google+ team, where we continue to focus on creating delightful experiences for our users, developers, and publishers.

Meebo’s products are no longer available, but you can find all the latest and greatest things that we’re working on at https://developers.google.com/+/.

Thanks,
The Meebo Team

Elsewhere on the internet, you can find news reports about the shutdown. That gives credence to the “Google is Evil” motto.

On the course explorer side, there has recently been a change to Amazon’s Ecommerce API, breaking code for getting book titles and URLs that I wrote several years ago. Basically, most of the responses returned changed from single item ones to

<?xml version="1.0"?>
<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<OperationRequest>
    <RequestId>cd6bd87d-046c-4a07-a99e-16fc600ebe31</RequestId>
    <Arguments>
        <Argument Name="Operation" Value="ItemLookup"/>
        <Argument Name="Service" Value="AWSECommerceService"/>
        <Argument Name="AssociateTag" Value="yuguzhan-20"/>
        <Argument Name="SearchIndex" Value="Books"/>
        <Argument Name="Signature" Value="a6ZCkXLOYFw8xTYH8gaBl/K5YGeTlQdGxtDKwY2YuaU="/>
        <Argument Name="ItemId" Value="9780470392164"/>
        <Argument Name="IdType" Value="ISBN"/>
        <Argument Name="AWSAccessKeyId" Value="AKIAIZLBWTLA3LJJZ2MA"/>
        <Argument Name="Timestamp" Value="2013-11-17T19:21:08.000Z"/>
    </Arguments>
    <RequestProcessingTime>0.0220990000000000</RequestProcessingTime>
</OperationRequest>
<Items>
    <Request>
        <IsValid>True</IsValid>
        <ItemLookupRequest>
            <IdType>ISBN</IdType>
            <ItemId>9780470392164</ItemId>
            <ResponseGroup>Small</ResponseGroup>
            <SearchIndex>Books</SearchIndex>
            <VariationPage>All</VariationPage>
        </ItemLookupRequest>
    </Request>
    <Item>
        <ASIN>0470392169</ASIN>
        <DetailPageURL>http://www.amazon.ca/How-Read-Proofs-Introduction-Mathematical/dp/0470392169%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0470392169</DetailPageURL>
        <ItemLinks>
            <ItemLink>
                <Description>Add To Wishlist</Description>
                <URL>http://www.amazon.ca/gp/registry/wishlist/add-item.html%3Fasin.0%3D0470392169%26SubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0470392169</URL>
            </ItemLink>
            <ItemLink>
                <Description>Tell A Friend</Description>
                <URL>http://www.amazon.ca/gp/pdp/taf/0470392169%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0470392169</URL>
            </ItemLink>
            <ItemLink>
                <Description>All Customer Reviews</Description>
                <URL>http://www.amazon.ca/review/product/0470392169%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0470392169</URL>
            </ItemLink>
            <ItemLink>
                <Description>All Offers</Description>
                <URL>http://www.amazon.ca/gp/offer-listing/0470392169%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0470392169</URL>
            </ItemLink>
        </ItemLinks>
        <ItemAttributes>
            <Author>Daniel Solow</Author>
            <Manufacturer>Wiley</Manufacturer>
            <ProductGroup>Book</ProductGroup>
            <Title>How to Read and Do Proofs: An Introduction to Mathematical Thought Processes</Title>
        </ItemAttributes>
    </Item>
</Items>
</ItemLookupResponse>

to multiple item ones

<?xml version="1.0"?>
<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<OperationRequest>
    <RequestId>cc114a2f-75e9-419a-81a4-fc7e98f6df13</RequestId>
    <Arguments>
        <Argument Name="Service" Value="AWSECommerceService"/>
        <Argument Name="Operation" Value="ItemLookup"/>
        <Argument Name="Signature" Value="cfstltrmlmtQHrzz5s9t130uhLWZFG3Y7It9EqBQ/pA="/>
        <Argument Name="AssociateTag" Value="yuguzhan-20"/>
        <Argument Name="ItemId" Value="9780201350883"/>
        <Argument Name="IdType" Value="ISBN"/>
        <Argument Name="AWSAccessKeyId" Value="AKIAIZLBWTLA3LJJZ2MA"/>
        <Argument Name="Timestamp" Value="2013-11-17T19:19:46.000Z"/>
        <Argument Name="SearchIndex" Value="Books"/>
    </Arguments>
    <RequestProcessingTime>0.0407320000000000</RequestProcessingTime>
</OperationRequest>
<Items>
    <Request>
        <IsValid>True</IsValid>
        <ItemLookupRequest>
            <IdType>ISBN</IdType>
            <ItemId>9780201350883</ItemId>
            <ResponseGroup>Small</ResponseGroup>
            <SearchIndex>Books</SearchIndex>
            <VariationPage>All</VariationPage>
        </ItemLookupRequest>
    </Request>
    <Item>
        <ASIN>0201350882</ASIN>
        <DetailPageURL>http://www.amazon.ca/Algorithms-Parts-1-4-Fundamentals-Structure/dp/0201350882%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0201350882</DetailPageURL>
        <ItemLinks>
            <ItemLink>
                <Description>Add To Wishlist</Description>
                <URL>http://www.amazon.ca/gp/registry/wishlist/add-item.html%3Fasin.0%3D0201350882%26SubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0201350882</URL>
            </ItemLink>
            <ItemLink>
                <Description>Tell A Friend</Description>
                <URL>http://www.amazon.ca/gp/pdp/taf/0201350882%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0201350882</URL>
            </ItemLink>
            <ItemLink>
                <Description>All Customer Reviews</Description>
                <URL>http://www.amazon.ca/review/product/0201350882%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0201350882</URL>
            </ItemLink>
            <ItemLink>
                <Description>All Offers</Description>
                <URL>http://www.amazon.ca/gp/offer-listing/0201350882%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3D0201350882</URL>
            </ItemLink>
        </ItemLinks>
        <ItemAttributes>
            <Author>Robert Sedgewick</Author>
            <Manufacturer>Addison-Wesley Professional</Manufacturer>
            <ProductGroup>Book</ProductGroup>
            <Title>Algorithms in C++, Parts 1-4: Fundamentals, Data Structure, Sorting, Searching (3rd Edition)</Title>
        </ItemAttributes>
    </Item>
    <Item>
        <ASIN>B001FWIJFA</ASIN>
        <DetailPageURL>http://www.amazon.ca/Algorithms-Parts-1-4-Fundamentals-Structure-ebook/dp/B001FWIJFA%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001FWIJFA</DetailPageURL>
        <ItemLinks>
            <ItemLink>
                <Description>Add To Wishlist</Description>
                <URL>http://www.amazon.ca/gp/registry/wishlist/add-item.html%3Fasin.0%3DB001FWIJFA%26SubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3DB001FWIJFA</URL>
            </ItemLink>
            <ItemLink>
                <Description>Tell A Friend</Description>
                <URL>http://www.amazon.ca/gp/pdp/taf/B001FWIJFA%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3DB001FWIJFA</URL>
            </ItemLink>
            <ItemLink>
                <Description>All Customer Reviews</Description>
                <URL>http://www.amazon.ca/review/product/B001FWIJFA%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3DB001FWIJFA</URL>
            </ItemLink>
            <ItemLink>
                <Description>All Offers</Description>
                <URL>http://www.amazon.ca/gp/offer-listing/B001FWIJFA%3FSubscriptionId%3DAKIAIZLBWTLA3LJJZ2MA%26tag%3Dyuguzhan-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386005%26creativeASIN%3DB001FWIJFA</URL>
            </ItemLink>
        </ItemLinks>
        <ItemAttributes>
            <Author>Robert Sedgewick</Author>
            <Manufacturer>Addison-Wesley Professional</Manufacturer>
            <ProductGroup>eBooks</ProductGroup>
            <Title>Algorithms in C++, Parts 1-4: Fundamentals, Data Structure, Sorting, Searching (3rd Edition)</Title>
        </ItemAttributes>
    </Item>
</Items>
</ItemLookupResponse>

As with many of these bugs, they are easy to fix once cause of the problem is found. If you know XML, an exercise for you is to spot the difference between the top one and the bottom one.

No responses yet

Wijmo UI Book – the Right Timing

Nov 04 2013 Published by under Coincidences

Finally with help and support from my hosting service setting up a newer version of Django to run with a newer version of Python, Building UIs with Wijmo’s official site has been launched. It is just in time for the lucky winners of free copies of the book to join in the party. I spent the last Saturday writing the site and the ideas over the last month just came together.
Building UIs with Wijmo site

No responses yet