JennPhoenix.ca – in Brief

I spent about 40 minutes earlier this week designing and deploying JennPhoenix.ca for my sister, who does piano lessons.

JennPhoenix.ca Screenshot

Jenn's New Piano website

Probably the things that are most of interest to highlight: I used some free icon packs, which I will be attributing in the next version of this website, which I found via Smashing Magazine. I found the repeating background image using AVA7 Patterns which I will also be attributing (they also do not require attribution, but I like attribution when it makes sense). I've got a contact form ready to go using Jquery Contactable but I was trying not to do any PHP for this site, so I haven't actually made it happen yet. I guess I could replace the PHP with something else. For the font in the header, I use a Google Web Font, which is awesome.

The breakdown on time spent is as follows:

  • Write the html and content. ~10 min
  • Come up with design. ~15min
  • Find icons / fonts / resources. ~10 min
  • Write the css. ~5 min

Altogether, I'm happy with how this microsite turned out

Posted in Confluence | Comments Off

How Project Euler got me to Infringe Almost Every Copyright

That's a bit of a sensationalist title, but it's also not too far off of true.

I was recently working on a problem for Project Euler that starts off like so:

An irrational decimal fraction is created by concatenating the positive integers:

0.123456789101112131415161718192021...

The constructed number is made in such a way that you count from n to infinity, and add whichever number you are on to the decimal expansion. This fraction has several interesting properties. It is normally distributed, but not random. It is a transcendental number, like pi or e. It can be constructed in other bases (2, 3, 16) and holds the same properties in those bases. While each of these is mindboggling enough (if you think on them) the thing that drove me to title my post in this way is pretty simple: since this string of numbers contains within it's infinitude every single number that could ever be, and because anything that we have transcribed or copyrighted can be expressed as a sequence of numbers, then every single copyrighted piece of information in the world is merely a subsection of this string of numbers.

As an example, let's look at something pretty safe. Here's the first paragraph of the preamble of the GPL:

The GNU General Public License is a free, copyleft license for software and other kinds of works.

Using a binary encoder, we can see that this text is represented in binary as:

01010100 01101000 01100101 00100000 01000111 01001110 01010101 00100000 01000111 01100101 01101110 01100101 01110010 01100001 01101100 00100000 01010000 01110101 01100010 01101100 01101001 01100011 00100000 01001100 01101001 01100011 01100101 01101110 01110011 01100101 00100000 01101001 01110011 00100000 01100001 00100000 01100110 01110010 01100101 01100101 00101100 00100000 01100011 01101111 01110000 01111001 01101100 01100101 01100110 01110100 00100000 01101100 01101001 01100011 01100101 01101110 01110011 01100101 00100000 01100110 01101111 01110010 00100000 01110011 01101111 01100110 01110100 01110111 01100001 01110010 01100101 00100000 01100001 01101110 01100100 00100000 01101111 01110100 01101000 01100101 01110010 00100000 01101011 01101001 01101110 01100100 01110011 00100000 01101111 01100110 00100000 01110111 01101111 01110010 01101011 01110011 00101110

Since this is just a number, it will occur quite naturally somewhere within the string of this constructed decimal. What's even better is it will occur an infinite amount of times. This is just a loose and fast example - you could convert this encoding to decimal, and see it again, also an infinite amount of times.

So, if you write a function to express this number, you are, in effect, breaking every restrictive copyright an infinite amount of times. Really, just thinking about this number probably makes a lot of companies gnash their teeth.

By the way, I was not the first to find this or think it interesting. By doing a bit of research, I found out that this number was something called the Champernowne constant.

Edit: Also a note: I said "Almost Every Copyright" in my title, because I am neither a Copyright Lawyer or Mathematician.

Posted in Confluence | Comments Off

Guelph Coffee and Code + Project Euler

I'm talking about Project Euler at tonight's Guelph Coffee and Code. My talk is going to be short, but here's the main talking points.

Lenhard Euler: Mathematician

Euler (pronounced "Canada's Worst Hockey Team that's not The Senators") was a Mathematician in the 1700s. He was a genius, and he helped shape the world of mathematics that we know and love today. Check out Euler on Wikipedia for more in depth info about the fellow.

What's this all about?

Project Euler is gets you to combine mathematical insights with computer programming in an effort to find answers to a series of over 300 problems. It's not tied to a particular language, though there are some languages that will serve you better than others. It's all about finding the answer in an elegant fashion.

Why should I care?

Project Euler will help you to identify areas of interest for you, and to make you a better all around programmer (and mathematician). There's a ton of different subjects that are covered, and it's an opportunity to push your self in new directions.

Let's do an example!

Sure thing! Look at Question #1.

Add all the natural numbers below one thousand that are multiples of 3 or 5.

Not hard right? Make a loop that goes from 1 to 1000, and for each number check if it's divisible by 3 or divisible by 5. If it is, add it to a running sum. Pseudocode looks something like this:

x=1
sum=0
while x is under 1001
    if x is a multiple of 3 then sum = sum + x
    if x is a multiple of 5 then sum = sum + x

And at the end return sum. Does that give the right answer? Are we forgetting something?

Of course, if x is a multiple of both 3 and 5, then we've counted it twice. We can fix that in a few ways, like subtracting off x one time if it's a multiple of 3 and 5.

if x is a multiple of 3 and 5 then sum = sum - x

Or we could just solve it with an else

if x is a multiple of 3 then sum = sum + x
else if x is a multiple of 3 then sum = sum + x

Now a lot of people will understand that the "trick" is not really tricky in this case. Remember not to count multiples of 3 and 5 twice is pretty simple. But the curve is pretty steep - after 20 or 30 questions, it's much more hidden.

And that's the gist of what I'm saying tonight.

By the way, here's that pseudocode in python:

f=0
x=1
while x < 1000:
  if x%3==0:
    f=f+x
  elif x%5==0:
    f=f+x
  x=x+1
print f
Posted in Techgnostics, The Proof | 2 Comments

Deregistering Parent Theme Widgets in WordPress

I had a "fun" time figuring out how to deregister parent theme widgets in WordPress the other day so I went through the codex and learned a lot about how functions are called in function.php. I learned about something I didn't know - you can specify the order of priority that something has within a hook!

This made deregistering widget areas pretty easy. In twentyten (something I child theme from a fair bit), the widgets are added on line 373 with code that looks like this:

function twentyten_widgets_init() {
  // Area 1, located at the top of the sidebar.
    register_sidebar( array(
    'name' => __( 'Primary Widget Area', 'twentyten' ),
    'id' => 'primary-widget-area',
   // and so on
 

So, you write an unregister function in your child theme's functions.php that looks something like this:

function my_unregister_sidebars() {
    unregister_sidebar('primary-widget-area');
    unregister_sidebar('secondary-widget-area');
    unregister_sidebar('first-footer-widget-area');
    unregister_sidebar('second-footer-widget-area');
    unregister_sidebar('third-footer-widget-area');
    unregister_sidebar('fourth-footer-widget-area');
}

Then you just call that in the widgets init hook, but give it a later priority:

  add_action( 'widgets_init', 'my_unregister_sidebars', 11);
  add_action( 'widgets_init', 'my_widgets_init',12);

Google wasn't super helpful for me until after I had figured out the solution to the problem. So, if you need to unregister widgets in a child theme, this is how to do it.

(Feel free to tell me if I have typoed anywhere.)

Posted in Left Brain, Techgnostics | 4 Comments

Sunday Stranding – Update

In my last post, I talked about a problem I experienced in the The City of Guelph, where a local even stranded my neighbourhood so that we weren't able to leave. As it was happening, I tweeted about it. @CityOfGuelph was kind enough to tweet back with an email for me to get in touch with someone about the problem.

So I emailed the operations department for the city. Within what I would call "one business hour" (I sent the email one evening, and got it returned the next morning by 8 am), I got an email back telling me that they'd read my email and sent it on to the specific person for whom this was pertinent. I was pleasantly surprised that they'd made the effort to get back to me so quickly.

About an hour and a half later, I got a second, very polite, email addressing my concerns, apologizing, and saying they would take it up with the organizer of the event. I was again pleasantly surprised that they would make the effort to get back in touch so quickly. They addressed each of my concerns, and told me that local access was a priority during events like this. I figured that this was probably the end of my contact with the city over this issue, so I thanked them (because I was 75% satisfied) and forgot about it.

About an hour later, that same person got back to me, telling me that they'd checked up with the organizer of the event, and heard that there had been other complaints similar to mine, and that they would address the issue in a variety of ways before the next event happened. They also again thanked me for my feedback.

I'm so happy to live in the City of Guelph, where a complaint (even a fairly minor one like mine) gets heard and addressed within a day. What a great city!

Posted in Confluence, In Review, Right Brain | 2 Comments