Al Sweigart's tumblr

Short blog posts on my random ideas and thoughts.

Jun 29

Software idea: PygScratch

I’d like to create a Python module that uses Pygame to implement a Scratch-like API for intermediate programmers who want to jump from Scratch to Python. For example, this Scratch project would look like the following in Python

import pygscratch

class Cat(pygscratch.Cat1):
    def __init__(self, name):
        self.whenGreenFlagClicked(self.greenFlag)
        super(Cat, self).__init__(name)

    def greenFlag(self):
        while True:
            if pygscratch.keyPressed(‘up’):
                self.changeY(10)
            if pygscratch.keyPressed(‘down’):
                self.changeY(-10)
            if pygscratch.keyPressed(‘left’):
                self.changeX(-10)
            if pygscratch.keyPressed(‘right’):
                self.changeX(10)

c = Cat(‘Cat’)
pygscratch.greenFlag()

I’m weighing the advantages and disadvantages of this approach.

ADVANTAGES:

Provides a familiar way of moving on from Scratch to a real programming language like Python.

You can use all of Python’s other modules, such as things that could add multiplayer or save to files.

PygScratch could extend certain features, such as having camera objects instead of a single stage.

DISADVANTAGES:

It is new, and therefore doesn’t have a large community supporting it like Scratch has.

You lose the easy sharing of code the Scratch website has.

The programs would be desktop applications, which are becoming more irrelevant, and would not be mobile or web apps.

In addition, with Pygame you could use other desktop UI toolkits like QT or WxWidgets.

If the programmer has to start learning all the new things about PygScratch that make it different from Scratch (including the Python language itself), they might as well just learn Python in general and maybe use Unity or something more established.

So far, it’s looking like this project might not be worth the effort.


Jun 26

Laser Pointer Projector Whiteboard

Software idea: For when you need a whiteboard but only have a projector surface, a system that uses a web cam that identifies when a laser pointer is on the screen and draws a mark on that position. Handles various angles and calibrates itself automatically. Makes it easy to draw on top of screen shots, zoom in, and have multiple virtual boards to swap between. Waits a split second after the laser pointer appears so that the drawer can adjust it to the correct position first.


Apr 30

Website Idea: I18N Translation Snippets for Software

Most open source projects don’t focus on internationalization (I18N) and providing translations into other languages for their software. I’d like to lower the bar to do this with a new website.

The aim of this website is to provide software-specific and idiomatically correct translations for individuals and small organizations to translate their open source projects.

I suggest a website that would host common terms in programming like “File” or “Print” or ”Download to your computer” and then instantly offer the translated terms (“Herunterladen auf deinen Computer”, “Télécharger dans votre ordinateur”). I’d like the lookup of terms to be as easy as, say, thenounproject.com.

Users would be able to request new terms to translate, or suggest improvements to existing translations. Translations would be downloadable in common string table formats. They would not have to manually go through Google Translate for common terms and can be assured that the translations make sense in the context of software.

(Does anything like this already exist? I can’t seem to find anything like it.)


Jan 29

Game idea: “Bicameral”, a bot-programming Ingress-like game.

Ingress is an AR game where, using your smartphone’s GPS, you visit IRL landmarks which are “portals” in the in-game universe. You then “hack” or “access” these portals to receive items, which you can then deploy to other portals to claim them for your team. Once a portal has enough items deployed, they can be linked together. Three linked portals form a triangular area. The point of the game is to have the most claimed area.

There are other items too: defenses you can set up for your portal, bombs to attack other team’s portals’ items so you can then claim them, etc. You can strategically create links to block off potential links for your opponents.

I had an idea for a bot-programming game that is like Ingress. Instead of humans playing an AR game, you program bots to move around the game world and access landmarks and link them. Bots can be as simple or sophisticated as you want. They can coordinated with each other, or use simple algorithms and rely on emergent behavior (like ants or other colony insects).

I originally had an idea for a theme of Neanderthal-like humans wandering areas. The human player acts as the cognitive part of their bicameral mind, programming them what to do. Instead of portals, you have sacred sites. Instead of deploying resonator items, they build alters. You then want to link alters and also destroy the alters of the other team.

This could be implemented as a HTTP game with a REST API for issuing commands for your bots. The bot-controlling program could then come from anywhere, or even just be a human-controlled player (though humans have jobs and need to sleep).

This would also be a perfect information game, with the positions and statuses of the sacred sites and bots in the game world known to all.

The bots would have to handle several interesting programming problems:

  • Finding new targets, and prioritizing targets.
  • Calculating efficient travel paths to target sacred sites.
  • Knowing when to attack and when to reinforce alters.
  • Various traveling-salesmen type problems.
  • Coordinating with several different bots, including bots on the same team but controlled by other programmers.

Dec 19

The Bad Roommates Situation

I think this is a metaphor that could apply to a lot of social/economic dynamics:

You have a clean roommate and a messy roommate who live together. The messy roommate doesn’t mind a messy apartment or a clean apartment. The clean roommate doesn’t mind cleaning their own messes but does mind messy apartments and cleaning other people’s messes. The messy roommate does mind cleaning and hearing the clean roommate complain.

It takes effort for the clean roommate to clean the messes the messy roommate makes. One person pays the cost of cleaning, but both benefit from the clean apartment. However, the messy roommate doesn’t see this as a “benefit” (they don’t mind a mess) but they do see the “cost” of cleaning.

This isn’t quite the Tragedy of the Commons: the messy roommate honestly doesn’t mind messes and couldn’t care if clean roommate cleaned or not.

Each roommate considers the other to be a “bad roommate”. Aside from getting separate apartments, what is the “fair” agreement that should be reached? Should one accommodate the other? (The messy roommate by sharing in the cleaning, the clean roommate by not complaining about cleaning the other roommate’s messes.) UPDATE: Assume that hiring a cleaner and splitting the cost is just as odious to the messy roommate as sharing in cleaning duties.

UPDATE: Some more thoughts. This situation easily applies itself to software developer “code reviews”. You may have one developer who thinks code reviews are effective ways to prevent bugs, but one who thinks they’re a waste of time. The pro-review developer needs the other one to do the review, while the anti-review developer hates taking time to do something they think is ineffective.

I think one of the things that makes this situation so insidious is that it cannot be solved with the Golden Rule. Clean roommates would like the messy roommate to do unto them and clean their share, while the messy roommate would rather they both not complain about messes.


Oct 25

Hardware & software idea: InstaCRT-type photo setup for online chess games.

TL;DR: A robotic system for setting up chess boards with arbitrary configurations and take photos of it. Use these images for online chess games.

A CNC-like device that can move magnetic chess pieces around a board into new positions. Whenever people online make a chess move, instead of drawing a computer-generated image of a board, it shows the actual photo of the chess board. We can’t pre-photo every possible combination board beforehand (between 6 pieces for each player and 1 empty space, iti s 13^64 or 1.96 x 10^71 possible photos. Times 8 if we want to have multiple perspectives of the board.)

Instead download a large quantity of chess games and photo each of those positions and save them to a database. We can then have common photos taken for most cases, and then move the chess board in real time and take a photo in other cases.

The system would need to be able to move pieces on and off the board as they are captured, and handle knight jumping, and also have duplicate pieces when pawns are promoted.


Oct 16

Idea for Homelessness Awareness publicity stunt

Requires five or six people. One dressed in a costume head-to-toe made up of cardboard signs that say, “Homeless. Please help.” Two dressed as scientists with clipboards and white lab coats that say “Invisibility Cloak Test Engineer” on the back. They are on either side of the first guy, backs turned so that pedestrian traffic can read it from both directions. One photographer (though a scientist can double for this job). Two people handing out fliers and interacting with the public and soliciting donations with Square readers on their smartphones.

Got the idea from http://www.smbc-comics.com/?id=2381


Oct 8

Mobile/Web App Ideas List

This is my personal app ideas list when I finally get around to learning Android programming. I’ll be updating this list on occasion.

  • 7 Wonders player scoring app (that doesn’t suck)
  • Dice Rolling app (that doesn’t suck)
  • "Tetris for Idiots" (joke game)
  • Regex teaching game
  • Alien currency exchange game
  • Rock-paper-scissors siege game
  • Clicker counter (that is highly configurable and doesn’t suck)
  • BeatCount, multiple color circles with patterns of “beats”. You need to keep count of how many times they beat. It is a concentration game.
  • "Set" Training Game
  • Flash cards that don’t suck, work offline, only need JS file.
  • Percolate game
  • Snip - gardening game where you create art by cutting out the pixels you don’t want.

Sep 18

"Once upon a generically timeless time…"

Once upon a generically timeless time there was a boy or a girl or a set of siblings who were bored with their mundane lives. This boredom was a constant in their adolescent world, punctuated with the occasional frustration, social humiliation, or outright abuse.

The protagonist was different. In fact, another character comes and reveals that the protagonist has magical powers or is of secret-royalty or has some other quality that is both special and effortlessly innate. This quality is initially weak but will strengthen as the plot does.

His or her parents are absent, if not permanently than temporarily for the season. If there are any adults at all, they are a careless uncle, a cruel aunt, a wrathful headmaster or some other person unfit to be a loving and responsible guardian.

On an otherwise ordinary day, something curious happened. When he/she/they examined the something closer, it did not seem to be just the thing its ordinary appearance made it seem to be. While investigating further, they accidentally stumbled upon a different world where extraordinary things were an ordinary fact of life for its inhabitants, and disbelief was well-suspended.

At first, this new world promised lots of exciting new possibilities. The world is very richly textured, with their own cultural customs, dress, holidays, colloquialisms, currency, given names and surnames, history, eating utensils and other details the author plagiarized from non-Western cultures.

Animals are sentient and can hold conversation, but that doesn’t seem to influence anyone to vegetarianism.

But not all was well in this land. There is an authoritarian and selfish antagonist who wields some degree of political and military power whose influence slowly encroaches on the initial place the protagonist entered the mystical world.

The antagonist is an adult.

Driven from the village or home-like domain that first welcomed them, the protagonist was forced to flee elsewhere in this new world. The other inhabitants view them as an outsider, or even hunt them outright as their presence is decreed to be a foreign contamination of their magical universe. At this point the boy or girl or group of children cannot easily make it back home.

But the protagonist makes friends who were willing to show them the ropes of navigating this new world. He or she comes into possession of an artifact that could be used to combat the antagonist or antagonists. If the artifact is a literal weapon, it is not a firearm.

Two of these characters, while both friends with the protagonist, constantly bicker with each other. But in times of danger, they prove to be loyal and courageous. They kiss. Then they pretend like they didn’t kiss. Then they kiss again and admit to their love for each other.

Secrets are hinted at, pursued, and revealed. Mysteries are presented, pursued, and solved. This involves a lot of sneaking around and cleverness rather than direct physical combat.

Many of the antagonist’s henchmen are pursuing the artifact, because it is the both the key to the antagonist’s downfall and the key to advancing the plot. One character who initially seems shifty is suspected of imminent betrayal, but in the end sacrifices themselves for the protagonist. This one act of generosity after a lifetime of deceptive behavior, snarky insults, and occasional theft shows he really did have a heart of gold after all.

Meanwhile, an ostensibly honest ally betrays the protagonist, showing that it can be completely unpredictable of who turns out to be trustworthy or not.

After their journey, the antagonist is either killed (to teach that violence solves problems) or it turns out to be all a big misunderstanding and the antagonist becomes good. But usually the antagonist is killed.

The child finds a way home, although the friends must stay behind in the magical world for some bogus reason the protagonist doesn’t question. He or she has learned a lot of important lessons about life, friendship, sacrifice, but mostly to stop being such an immature whining kid and start acting more like the adults who wrote, published, advertised, sold, and bought this book for the reader.

The End. Except with the possibility of eight or nine sequels.


Aug 15

Book Idea: “Automate the Boring Stuff: A Guide to Python Programming for Non-Experts”

I’m writing a a Python programming book for complete beginners that teaches just enough programming to be able to automate tasks on your computer. I’m thinking about what repetitive task that office workers or students do that a computer program could do for them. Tentative title would be: ”Automate the Boring Stuff: A Guide to Python Programming for Non-Experts”

4/10/2014 UPDATE: I’m working on this book now to be published with No Starch Press. Hopefully it’ll be done by the end of summer 2014. The first part of the book covers basic programming concepts, and the rest of the book has chapters around using Python modules to do interesting stuff. The chapters look like they’ll be:

Chapter 0: Introduction - Installing Python, What is Programming? etc.

Chapter 1: Python Basics - Interactive shell and basic programming concepts.

Chapter 2: Flow Control - if/else, loops, etc.

Chapter 3: Functions - Writing your own functions

Chapter 4: Lists - All about the list data type.

Chapter 5: Dictionaries - All about the dictionary data type.

Chapter 6: Manipulating Strings - String methods and advanced string stuff.

Chapter 7: Pattern Matching with Regular Expressions

Chapter 8: Reading and Writing Files - file i/o concepts and using the shelve module to store Python data

Chapter 9: Working with FIles - Using Python to copy/move/rename/delete files, and also working with zip files.

Chapter 10: Debugging - Debugging and other techniques to find and fix bugs in your program.

Chapter 11: Web Scraping - Downloading websites and automating web browser tasks.

Chapter 12: Working with Excel Files - Programmatically updating Excel spreadhseets.

Chapter 13: Working with Word, PDF Documents

Chapter 14: Working with JSON and CSV Data

Chapter 15: Time. Scheduling, and Launching Programs - The time and schedule module, cron jobs & scheduled tasks, and how to run other programs from a Python script.

Chapter 16: Sending Email and Text Messages - Using the Twilio API to send texts and also send out notification emails.

Chapter 17: Image Manipulation - Using the pillow module to programmatically manipulate images.

Chapter 18: Keyboard and Mouse Macros - Programmatically controlling the keyboard and mouse.

Any thoughts or suggestions? I’m looking for tasks that the typical office worker might have to perform as part of their job.


Page 1 of 2