Lua Cheat Sheet for Programmers

November 1st, 2010

If you don’t know Lua, the popular programming language often used as a embedded scripting language, but you do know how to program, here’s a cheat sheet that covers the basics of the language’s syntax.

The cheat sheet itself is an executable program. You can download the file here: lua_cheat_sheet.lua

For quick viewing, here it is on Pastebin

For printing, here it is as a PNG:
Lua Cheat Sheet

Pyperclip – A cross-platform clipboard module for Python

October 9th, 2010

I got tired of not having a good cross-platform module for accessing the clipboard in Python, so I put this together. It is a module that loads a getcb() and setcb() function depending on what your operating system (or window manager) is.

It has the following requirements:

  • Windows - No requirements. You don’t need the win32 module installed.
  • Mac - Requires the pbcopy and pbpaste, which come with OS X.
  • Linux - Requires the xclip command, which possibly comes with the os. If not, run sudo apt-get install xclip. Or have the gtk or PyQt4 modules installed.
  • Pyperclip runs on both Python 2 and Python 3.

Usage is simple:

import pyperclip
pyperclip.setcb('The text to be copied to the clipboard.')
spam = pyperclip.getcb()

UPDATE: (9/13/2011) I’ve fixed a small TypeError that some people were coming across that Gustav pointed out below.

UPDATE: Kenneth Reitz pointed out that he’s coded a similar module called Xerox. I missed it in my prior art search. http://github.com/kennethreitz/xerox It seems to have a fairly similar implementation as Pyperclip, except requires the win32 Python module to work on Windows.

I’m busy trying to figure out X11 programming so I can get rid of the xclip dependency.

Well, I guess there not.

September 5th, 2010

I was walking past 16th & Mission St when I saw this car. First time I’ve had to take out my new phone and take a photo in a hurry, but managed to get a good snap shot. I guess this guy thought he was being clever:

'There not straight' car

'There not straight' car

Living in hippie San Francisco, I keep forgetting that there really are people like this out there. And they really are that dim.

Attitudes on Programming for Kids: “They Need Blood Exploding Onto Their Faces Just to Keep Them From Yawning”

June 21st, 2010

I wrote a book titled “Invent Your Own Computer Games with Python” (free online under Creative Commons at http://inventwithpython.com) to teach kids (and adult beginners) how to write computer programs by making simple games. The book adopts a different teaching style from most programming books. Rather than tediously list out the programming concepts I instead present the source code to several games and introduce the concepts as I explain the code line by line. The programs themselves start off simple and text-based (“Guess the Number”, Tic Tac Toe, Hangman, etc.) and then progress in complexity.

The decision to use text-based games was done on purpose. Text is easy to present in a book and to be understood by the reader. There are no 3D models, sprites, or textures to download. By typing in the text themselves instead of using pre-made models and artwork, the reader makes the program their own rather than the product of third party content.

But from people on the Internet (who are my main audience) the most common criticism is that a programming book for kids must have fancy graphics and animation or else the kids will get bored. I receive a fair share of emails where readers and parents disagree, but we have the idea, deserved or not, that all kids live in fast-paced, ADD world of blinking lights, fiery explosions, and flashing images that we hypocritically deride and yet cater to. And if you want to teach programming, you’re going to need sophisticated toolkits with animated models, particle effects, and huge sandbox worlds that are creatable at the click of a button. I call this the “blood exploding onto their faces just to keep them from yawning” mentality. Actually typing out code is seen as dull, tedious, and an effort kids are not willing to make.
(more…)

“Invent with Python” Available in Print on Amazon

May 10th, 2010

Invent Your Own Computer Games with Python, 2nd Edition, is now available in print on Amazon.com:

Buy “Invent Your Own Computer Games with Python” on Amazon.com

Of course, the book will still be available online, in full, for free under a Creative Commons license. If you like the book, but don’t/can’t buy the print version, go to Amazon and put in a review. The book is $25 (and qualifies for Amazon’s free shipping.)

I’m very excited about this. Thanks to all the readers and people who have emailed me. Thanks!

« Previous PageNext Page »

Powered by WordPress