Saturday, January 29, 2011

"They"

As an undergrad, I hear the term "they" a lot. What "they" want "you" do to. The work that "they" want "you" to show when doing a Calc II "problem". I honestly think this is a very bad way to go about wording things when teaching to students of any age. When you, the instructor, use these pronouns, you make the education of your students revolve around "them". The people who write "the tests", the people who have written "the tests" and will be writing more tests. The point of teaching any form of calculus (passed the superfluous Calc I, from which I have seen questions such as "what is the graph of |y|=1?", at least at SUNY Binghamton) or any theoretical (or even practical) study is to build a foundation of thinking for higher practice. Calculus is the foundation for some higher math and most higher physics. If you are teaching a convention, it is not because of the rules; the rules are, hopefully, incidental of the convention's strength.

So forget about what "they" might want. When you're discussing standards or showing work, and a student asks how they "should" do something, style-wise or otherwise, say not "this is the way they want" but "this is the way that makes the most sense".

Unless it doesn't make sense. Then mention "them" by name and insult them appropriately.

Tuesday, January 25, 2011

An Anagram Solving Bot In Python

This article will detail how I made a bot in Python that can solve web-based anagram games. I wrote it for people with at least a beginner's grasp of Python and programming languages. I originally wrote it for a joint blog my friend and I were starting but it never got started. It is half a tutorial, half a 'look what I did!' post.

Any experienced developer knows that before you can run a program with an interface of bells and whistles, it is best to write a command-line version; reduce the problem to a command, and it becomes an algorithm. Therefore, before I made the bot itself, I wanted to make a method that solves anagrams, as many times as I wanted, whenever I wanted.

Saturday, January 1, 2011

heart.py: String macros in Linux with Python

Here's something I made after discovering the Python module virtkey: a way to bind macros that type out strings for you to keyboard shortcuts in Ubuntu (and most likely other Linux platforms):


import virtkey
import time
import sys
time.sleep(0.5)
v = virtkey.virtkey()
if len(sys.argv) > 1:
    str = sys.argv[1]
    strords = [ord(c) for c in list(str)]
else:
    strords = [9829] #heart!
for i in strords:
    v.press_unicode(i)
    v.release_unicode(i)


The fourth line (time.sleep(0.5)) is a necessary hack: When you bind the keyboard shortcut, you will likely bind it to Windows + a letter key or Ctrl + Alt + a letter key. The delay gives you time to release those held mod keys before virtkey starts typing the argument, or if there is no argument, a heart (♥). It would be run as:

python ~/heart.py "hello, world!"

And one could keybind it with the Keyboard Shortcuts dialog in Ubuntu, or a similar tool in other Linux distros. The original script can be downloaded here. It's also in my code scraps on Google Code

The idea is, for developers or other people who have strings that they use a lot and would like to keep on a permanent clipboard, to bind oft-used strings to Windows + 1, Windows + 2, ... , Windows + 0, for quicker access. This has probably been done with multiple-clipboard applications, but this was still fun to make.

Followers