Scott Hanselman

The Weekly Source Code 11 - LOLCode DLR Edition

November 11, '07 Comments [11] Posted in ASP.NET | Learning .NET | Microsoft | Programming | Source Code | Speaking
Sponsored By

During my Friday Keynote at the PNPSummit I did a silly 30 minute PowerPoint that ended with some LOLCats and a few examples of LOLCode. If you're not familiar with LOLCats, they are basically silly pictures of cats that speak a l33tspeak-like language, like IM IN UR BASE KILLIN YUR D00DS.

This language has turned into a Programming Language called LOLCode for which there are already at least TWO .NET implementations. The first implementation of LOLCode.NET is up on Google Code and is by Nick Johnson.

During my talk, unbeknownst to me, literally that minute John Lam was uploading the DLR team's own implementation of LOLCode implemented from scratch on the DLR. The amazing Martin Maly of the DLR team implemented LOLCode on his plane ride to Spain for presentation at TechEd.

I invited John up on stage spontaneously to give a demo of LOLCode and he did...he showed a Fibonacci implementation.

This is great code to read for two reasons. It's two completely separate implementations of the same general idea - an LOLCode compiler. However, they are implemented completely differently. Of course, the DLR team images this as a Dynamic Language so their implementation is a great primer on how to make your own language on the DLR.

HAI

CAN HAS STDIO?
VISIBLE "HAI WORLD!"

I HAS A CODE ITZ "CRAZY"
VISIBLE CODE

I HAS A NUMBR
LOL NUMBR R 2
VISIBLE NUMBR TIEMZ 2

I HAS A FIB
I HAS A A ITZ 1
I HAS A B ITZ 0

VISIBLE "Fibonacci: "
GIMMEH FIB

IM IN YR
    VISIBLE B

    IZ FIB SMALR 1?
		YARLY
			GTFO
	KTHX

    I HAS A TEMP ITZ A UP B
    LOL A R B
    LOL B R TEMP

    NERFZ FIB!!
KTHX

CAN HAS System?

VISIBLE CurrentDirectory ON Environment ON System
NJU Hashtable ON Collections ON System
I HAS A HT ITZ IT

I HAS A DT
LOL DT R DateTime ON System
VISIBLE Now ON DT

COL Add ON HT WIT "LolCode" AN "Rulezz!!"
VISIBLE COL get_Item ON HT WIT "LolCode"

COL Concat ON String ON System WIT "LolCode " AN "Rulezz!!"
VISIBLE IT

KTHXBYE

In order to get the DLR Team's implementation running on your own machine, you need to do the following:

  1. Get the LOLCode sources
  2. Get IronPython 2.0 Alpha 6
  3. Get the Gardens Point Parser Generator (GPPG) 
  4. Get the Gardens Point Scanner Generator (GPLEX)
    These are kind of Lex and Yacc for C#. Open up the Parser.y and Scanner.l to see the language grammar details.
  5. Confirm the PostBuild steps point to the right locations and make sure the Microsoft.Scripting.dll reference points to the Microsoft.Scripting.dll from the IronPython download.

Enjoy! If you don't think this is fun, go play with the MVC Demo Source Code from DevConnections and the PNPSummit.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Baby Sign Language - Update at 2 years

November 11, '07 Comments [13] Posted in Musings | Parenting | Z
Sponsored By

UPDATE: Check out http://www.babysignlanguage.com for more info on Babies and Sign Language!

My son is nearly two years old. He's 23 months. I suspect we'll stop counting months after he's second birthday.

It's always fun to be recognized at a conference and have folks ask about technology, but more and more people want to talk to me about Baby Sign Language. Most often they're folks from outside the U.S., which I think is great. I blogged about Baby Sign twice previously:

Often parents concerns are that a baby who is taught sign language will speak later or will be developmentally slowed in some way due to "confusion." Are they supposed to talk or sign?

I have found this with my own child, my brother's child and all my signing friend's children to be totally false. If anything the child begins speaking with more sophisticated phrases than one would expect.

My belief is this (remembering that I'm neither a doctor, nor a parenting expert, just a Signing Enthusiast and current father of one):

There is a window in a baby's development when they have needs, wants and feelings to express. This window might be from 6 months to 18 months or from 12 months to 2 years. It's usually at least a year long, and it's that time when your baby is "in there" but isn't able to express themselves verbally. Our goal with my son was to get involved in his head for that "missing year" and see what he had to say. For us, it prevented a lot of tantrums and early confusion about what he needed. Instead, he simply told us what was on his mind.

However, they haven't got the tools. If you listened carefully to their cries, posture and other thing I'm sure you'd find that the child was trying to get their need out, but it was either too subtle or unclear for us to see. Using Baby Signing - which is simply American Sign Language or ASL - is a way of formalizing this easily communication with your baby and letting he or she know that we're here, and we're listening.

When a child discovers that they are seen, that their opinion matters and that their parents understand them, I believe it enables and extends so many other interactions with our kids.

How To Start

A gentleman at the PNPSummit from Europe approached me to ask about Baby Signing for his 6 month old. This is the ideal time to start. The baby is just starting to get their bearings and realize that they are not alone and that there's a whole world to interact with.

Pick some basic signs, no more than 4 or 5, since you're going to be learning Sign Language as the child does. Plus, the baby's ability to learn signs will surpass your own very quickly.

To start with, we taught him: Milk, More, Eat, Dog, Mommy and Daddy. We did this from 6 months to about 9 months before we got anything. This is tip #1 - be patient. You'll do it for literally months before it'll POP one day. One day he or she will sign and they won't shut up until they move out of the house 20 years later.

He signed More one day, and the others quickly followed. The key was that we always signed while we spoke. This is important Tip #2 - teaching your child sign language doesn't mean you don't talk to them. Always talk and sign at the same time. Eventually the child will learn that talking is easier and abandon most signs. At two, my son rarely signs as he's not go the words for everything he had previously learned the sign for. However, the signs are still in his head if we need them someday.

You can buy an ASL Dictionary online, or get an inexpensive subscription to a site like HandSpeak.com that includes a video dictionary of over 2800 words. There are photo sites, but they don't quite capture the jist as the images are static. (There are also some free sites like the one at Michigan State University although it requires Quicktime and for you to click twice on the video to get it to play.)

There's also a great FREE "Signing Success Guide" here as a PDF on the Baby Signing Time site.

"Testimonials"

Many of my friends and family have taught their kids sign. For many, including all the non-American's, they were teased by family and friends - especially concerned mother's-in-law. But they stuck with it. My friend Daniel "Kzu" Cazzulino had a great experience with Baby Sign Language in Argentina:

"Just after a couple weeks signing 3 words to her (duck, drink and milk), she signed the duck! I was blown away by how fast she started with the first one, but it took another month for her to start picking up more and more signs. When she was exactly one year old (about a month after we started), I got a couple of books which tought me more techniques and approaches to signing to make it more effective. Three months later, she's able to sign: duck, drink, milk, cookie/cracker, eat, more, baby, take a bath, need heulp, hot, dog, cat, monkey, flower, shoes, hat, pain, water, sleep, silence (and clip, which Agustina uses at the kindergarten to also mean silence), dance (this one she made it up and we learned what she meant!). That's 22 words for a 15 months-old baby that can barely say Mom and Agus (her sister's nickname and the first thing she learnt to say :)). And there are many more that she understands but she's not signing yet.

Just like Scott felt, it's not just a matter of teaching her something to make her "smarter" early on. There's a new kind of connection that you can make with your baby. Aylen's face shines when she sees that we can listen to her needs and help her. She no longer cries when she's hungry or thirsty, or when she wants to take a bath. That's huge. "

Daniel as a native Spanish speaker also got an interesting sign benefit when we recommended Rachel's Baby Signing Time videos:

We bought a couple DVDs from the Baby Signing Time collection (awesome stuff) which both Aylen and Agustina love. It's playing on my TV almost every day for at least a couple hours. It teaches new signs through songs and showing other babies doing them, and it does so while pronouncing the words in english. That may sound obvious to you, but we live in Argentina, so english is not our primary language. However, both girls are now learning the words in both english and spanish at the same time! So my baby signs "baby" when you say the word in english AND spanish too! It's simply amazing.

Another good friend emailed last week when his daughter announced with sign that she needed to have her diaper changed:

"perhaps it's too soon to tell -- but we think we've had good consistent responses on the hand sign for "change me" today.
Great stuff!! [she's 9 months old now]"

Craig Andera is also huge Baby Signing Fan. He had to have patience early on though:

Just like Scott, it was initially like signing to a wall. She didn't seem to care, and she certainly didn't sign back. But I knew from my brother that it was just a matter of time, and sure enough, at about eight months, Ellen was able to mime the sign back to us. It's pretty amazing to get any communication whatsoever (other than smiling and crying) from an eight-month-old.

And Craig also sees Sign to be a good complement to an already bilingual education. ASL is recognized here by colleges as a legitimate foreign language:

It's funny for me to hear resistance to the idea. The one that really puzzles me is the "it'll slow down their speech" one. Not only is this contrary to clinical evidence (IIRC - we did the research but I no longer have the citation), but my personal experience has been the opposite. Ellen, like Z, is bilingual in verbal languages (Chinese and English), and despite that seems to have verbal capabilities comparable to her contemporaries.

Does Ellen still sign? Yes she does, but not to communicate. She communicates exclusively (and nearly endlessly :) ) verbally, but there are about five signs she still makes even when speaking. For example, she still signs "sorry" even as she says it - in English or in Chinese.

I'm really interested to hear in the comments from anyone else whose had success with teaching their infant Sign Language. It's worked great for us. We're going to teach Un-named Son #2 sign lanuage. He's due in less than two weeks!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Hanselminutes Podcast 88 - Writing FaceBook Applications with .NET - Interview with Mel Sampat, author of OutSync

November 10, '07 Comments [5] Posted in ASP.NET | Microsoft | Podcast | Programming | Speaking | Tools
Sponsored By

My eighty-eighth podcast is up. In this episode, I talk to Mel Sampat of the Windows Mobile team. He's written a desktop Facebook application called OutSync (link on Facebook) that brings your Facebook photos to Outlook and Windows Mobile. We also talk about how you can write your own Facebook apps with .NET and managed code. (This is the show that was almost lost but was rescued from the brink!)

Subscribe: Subscribe to Hanselminutes Subscribe to my Podcast in iTunes

If you have trouble downloading, or your download is slow, do try the torrent with Āµtorrent or another BitTorrent Downloader.

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is our sponsor for this show.

Check out their UI Suite of controls for ASP.NET. It's very hardcore stuff. One of the things I appreciate about Telerik is their commitment to completeness. For example, they have a page about their Right-to-Left support while some vendors have zero support, or don't bother testing. They also are committed to XHTML compliance and publish their roadmap. It's nice when your controls vendor is very transparent.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

DevConnections and PNPSummit MVC Demos Source Code

November 9, '07 Comments [23] Posted in ASP.NET | Source Code | Speaking
Sponsored By

110207_2058_AnnouncingT1 Folks are chomping champing at the bits to get their hands on the MVC bits. There will be a CTP very soon, so hang in there and be patient. Bits will come as soon as possible, truly.

Until then, I talked to BradA and got permission to share with you the source code of all the demos that Phil, Chris, myself and others worked on and showed at the two conferences minus all DLLs.

<disclaimer>
To be clear, these demos are demos. They were put together for the talks. You won't be able to compile or run them, and they don't represent anything other than interesting proofs of concept for the purpose of demo'ing. They are useless for anything other than reading. If they kill your flowers, it's no one's fault but your own. Read at your own risk and for your own edification. These demos don't represent the final product, nor do they even represent anything other than being an interesting curiosity. Everything can and will change and likely already has.
</disclaimer>

Here they are:

Enjoy. Also, as an aside, I encourage you to go get the new ".NET Framework 3.5 Commonly Used Types and Namespaces" poster and find a printer large enough to print it out.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

That Sinking Feeling and Repairing a Corrupt WAV File

November 9, '07 Comments [15] Posted in Podcast | Tools
Sponsored By

I've been up on campus talking at the PNPSummit and in my spare time recording podcasts with interesting people. A particularly cool show that'll be coming up very soon ran pretty long, and filled up my 1 gig CF Card. I had to transfer that now "part 1" off that disk and keep recording "part 2." My editor Lawrence will then stitch the two files together and make the transition sound natural.

I uploaded the two parts and went along with my day. However, I got a call from the guys saying that the file wouldn't open and that it might be corrupt. Yikes. This has happened before, but it's usually just a transmission error. I opened the original file and....crap!

Windows Media Player

It won't open. Hm. Well, I figured that some WAV file programs are more strict than others. Perhaps I could open it in another program.

Well, shoot. It's not opening in any programs. That's not cool. I tried WAV Saver and while I see on the net that lots of folks have had success with it, for me it crashed as I clicked repair. Apparently my file was messed up in a special way.

As I Googled around for answers and the program "GoldWave" kept coming up. It's apparently very well thought of.

When I dragged the corrupt file into GoldWave I got this friendly dialog:

File Format

This is cool because here I can get to the RAW PCM data. I just needed to tell the system what the original recording was in. Since we're on Intel, we're little endian. The recording was in stereo, at 44.1kHz and was 24-bit. Also, anything over 12-bit is usually signed. So, I'm feeling good at this point. However:

GoldWave - [mel sampat part 2 - ORIGINAL.wav]

...I ended up with a screen full of white noise. Bummer. At this point, I'm getting close to giving up. Then, on a whim, I remembered that you can click the tiny down arrow next to the Open button in the Visual Studio Open File Dialog.

image

I selected Binary Editor and got this:

mel sampat part 2 - ORIGINAL.wav - Microsoft Visual Studio

Now, I'm not an expert on the WAV file format, but I understand it's just a header and some RAW PCM data. It's supposed to be pretty simple, but ALL ZEROS is simpler than even I expected. :)

So, I opened up Part 1, the valid WAV file, and looked at its header. Then I selected it on a word boundary (guessing) and copied it to the clipboard. Then I flipped over to the broken WAV and pasted in the first 48 bytes of the header of the working file, up to and including the "data" chunk.

mel sampat part 1.wav - Microsoft Visual Studio (2)

Then, I saved the file with a new name and opened it in GoldWave.

GoldWave

Amazing, it worked! Notice the correct WAV format listed in the status bar. This trick worked, because I stole the WAV Header from a file that was encoded in the identical way. It wouldn't have worked with different files. There was a small warning from GoldWave that the header's length differed from reality, but this was fixed by File|Save As with a new filename.

Miracle of miracles. I thought the show was ruined. This technique was lucky because apparently only the header was missing and I had a header available with the same format. I hope this helps someone with the same problem.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.