“I wish that you, oh exalted one, would not be angry with me,” said the
young man. “I have not spoken to you like this to argue with you, to
argue about words. You are truly right, there is little to opinions.
But let me say this one more thing: I have not doubted in you for a
single moment. I have not doubted for a single moment that you are
Buddha, that you have reached the goal, the highest goal towards which
so many thousands of Brahmans and sons of Brahmans are on their way.
You have found salvation from death. It has come to you in the course
of your own search, on your own path, through thoughts, through
meditation, through realizations, through enlightenment. It has not
come to you by means of teachings! And–thus is my thought, oh exalted
one,–nobody will obtain salvation by means of teachings! You will not
be able to convey and say to anybody, oh venerable one, in words and
through teachings what has happened to you in the hour of enlightenment!
The teachings of the enlightened Buddha contain much, it teaches many to
live righteously, to avoid evil. But there is one thing which these so
clear, these so venerable teachings do not contain: they do not contain
the mystery of what the exalted one has experienced for himself, he
alone among hundreds of thousands. This is what I have thought and
realized, when I have heard the teachings. This is why I am continuing
my travels–not to seek other, better teachings, for I know there are
none, but to depart from all teachings and all teachers and to reach my
goal by myself or to die. But often, I’ll think of this day, oh exalted
one, and of this hour, when my eyes beheld a holy man.”
Author Archives: matt
pitz has a CLI
I’ve exposed lots and lots of pitz functionality as command-line scripts. Here’s the list so far:
$ pitz-help
pitz-abandon-task Abandon a task
pitz-add-task Walks through the setup of a new Task.
pitz-components All components in the project
pitz-estimates All estimates in the project
pitz-everything No description
pitz-finish-task Finish a task
pitz-milestones No description
pitz-my-tasks List my tasks
pitz-people All people in the project
pitz-prioritize-above Put one task in front of another task
pitz-prioritize-below Put one task behind another task
pitz-recent-activity 10 recent activities
pitz-setup No description
pitz-shell Start an ipython session after loading in a ...
pitz-show Show detailed view of one entity
pitz-start-task Begin a task
pitz-statuses All statuses in the project
pitz-tasks All tasks in the project
pitz-todo List every unstarted and started task in the...
pitz-unassign-task Take this task off somebody's list of stuff ...
A few iPhone or android app ideas
Just like my post with some web app ideas, feel free to steal any of these.
A fake lottery game
This has already been done several times. You would start with some money (fake money) then buy some tickets and scratch them off. Some would win (more money) and most would lose. Maybe I would hide silly messages in the tickets. The gimmick would be the activity of scratching off the tickets, or maybe spending money on other side treats. Like cigarettes. While smoking, maybe the screen would be hazy. Or maybe you could buy crystal meth, too, and you could scratch tickets really really fast.
And so forth. On to idea number two!
Pick a scab
If you want high-brow, go somewhere else. So, the idea here is obvious, right? The screen shows an ugly scab. You can pick at it. Then it bleeds. Then maybe it heals, and the cycle starts again. Probably been done before.
AWESOME RIGHT?
Pop the pimple
Yeah, so apparently this has already been done too, damnit. But what if the pimples could be superimposed on top of the photos in your album?
Help me rewrite some repetitive scripts
I have about a dozen functions (that are run as scripts) that have very similar sections interleaved with specialized code. I copied two of the scripts below. Here’s the first:
def pitz_estimate_task():
p = optparse.OptionParser()
p.add_option('--version', action='store_true',
help='Print the version and exit')
# This script requires these arguments.
p.set_usage("%prog task [estimate]")
options, args = p.parse_args()
if options.version:
print_version()
return
# This is unique to this script.
if not args:
p.print_usage()
return
# And now we're back to boring generic stuff.
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
# This section is specific to this script.
t = proj[args[0]]
if len(args) == 2:
est = proj[args[1]]
else:
est = Estimate.choose_from_already_instantiated()
t['estimate'] = est
# That was the last thing that was specific to just this script.
# Save the project (generic).
proj.save_entities_to_yaml_files()
That script does some “generic” stuff to build an object p, then adds on some extra tweaks to p, and uses p to build an options object and an args object.
Then the script does some generic stuff to build a proj object based on the data in the options.pitzdir object, and does some various method calls on the proj object.
And here’s another script:
def pitz_attach_file():
p = optparse.OptionParser()
p.add_option('--version', action='store_true',
help='Print the version and exit')
# Notice this line is different than the one in pitz_estimate_task.
p.set_usage("%prog entity file-to-attach")
options, args = p.parse_args()
if options.version:
print_version()
return
# This section is different too.
if len(args) != 2:
p.print_usage()
return
# Back to the generic code to build the project.
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
# Some interesting stuff that is specific just for this script.
e, filepath = proj[args[0]], args[1]
e.save_attachment(filepath)
# Save the project. (Generic).
proj.save_entities_to_yaml_files()
So, the pattern in every script is: generic code, specific code, generic code, specific code, generic code. And each step depends on the previous step.
I know I could do stuff like wrap all the generic stuff into functions, but I’m not really a fan of that approach. I’m looking for an interesting way to reduce all repetition, but keep the legibility. I’m thinking some nested context managers or decorators might be the way to go. I like to hear ideas from other people, so, please, let me hear them.
By the way, all this code is from the command-line module of pitz, available here. That’s where you can see all the different variations on the same theme.
Unauthorized Trader Joes commercial
Thanks for the link Niels!
Two @#$@#ING commas
Why I’m hooked on parameters
I have this need to make everything into a parameter. Here’s some code I wrote recently:
import subprocess, tempfile
def edit_with_editor(s=None):
"""
Returns the text typed in the editor, after running strip().
"""
with tempfile.NamedTemporaryFile() as t:
if s:
t.write(str(s))
t.seek(0)
subprocess.call([os.environ.get('EDITOR', 'vi'), t.name])
return t.read().strip()
There’s a voice in my head that says I shouldn’t be importing the subprocess and tempfile modules outside my function and then referring to them from within. And, the voice goes on, it wouldn’t be OK to move the import within my function either. Instead, if my function needs to use NamedTemporaryFile
, I should pass that function in as a parameter.
I think it all starts with the fact that I studied economics in college. I had a lot of lectures that started with a professor drawing something like this on the chalk board:
labor supply = f(...)
And then during the lecture, she would slowly replace the ellipses with parameters. By the end of class, the function might look like:
labor supply = f(income, wealth)
Then I’d also have a few pages of notes explaining the nature of the relationship between how hard somebody is willing to work, the wage they can earn, and the wealth they already have. The thing that sunk in deep is the idea that parameters (and only parameters) are what drives the dependent variable on the left hand site. Anything that drives labor supply is listed as a parameter. If it ain’t on the right hand side, then it is not relevant.
By the way, the war between the wealth effect and the income effect is one of the areas of economics that really does explain our behavior pretty dang well, and there’s neat charts involved, so go read about it.
Open letter to all candidates for Cleveland Heights City Council
I just sent the email below to lots of the candidates running for city council in my little burb. I’m hoping a few will reply.
Hi,
I’m your neighbor; I live at XXXXXXX. Anyhow, I’m emailing as many city council candidates as I can, looking for their thoughts on a few topics.
I would like to copy and paste anything you send me in my blog. I get very little traffic from locals; most of my posts deal with fairly obscure computer science issues.
So, here’s the topics:
- Cleveland has red-light cameras. Should Cleveland Heights (CH) have red-light cameras?
- Cleveland now allows people to keep chickens in their backyards. Should CH?
- Should we ban or regulate gas leaf blowers?
- If you couldn’t vote for yourself, what other candidate would you pick?
And here’s my opinions on those topics:
- I have nothing against red-light cameras in theory. But when I lived in DC, the city put them at intersections where lights were poorly timed and traffic flows were confusing. So it turned into a way for the city skim huge amounts of cash from drivers that believed they were following the law.
I wouldn’t mind cameras as long as we clearly pointed them out way in advance of intersections. Also I believe we should be generous and give some number of warnings for each driver before the tickets count for anything.
- Yup. More generally, the city should do anything it can to encourage backyard and community vegetable gardens.
- On nice days when I work from home with all my windows open, everything is great until some landscaping crews show up. I don’t like banning things, but I would like to create incentives for landscaping firms to explore less noisy options.
- No opinions here. I just started doing research.
Thanks for your time, and good luck!
Matt
How to download photos from phone over bluetooth with ubuntu
I have a samsung sync phone. It is about two years old now. It isn’t fancy, but it has a camera and a bluetooth device.
I wrote a python script to copy photos from my phone to my laptop. Any time I take a bunch of pictures, I just run
$ getpics.py
and if my phone is anywhere nearby, my computer will pull all the photos off my phone.
Bluetooth is a great little tool and I’m surprised it hasn’t caught on more with people like us. I’ve been able to access my phone from my laptop when I’m on the second floor and the phone is across the house and downstairs, still in my work bag. And bluetooth USB dongles are cheap (like around $9). There’s no need for carrying around USB keys or plugging in iPods. Everything should use bluetooth.
The getpics.py script requires that the phone and the laptop have already been bonded with each other. That’s not much work. Put your phone in to discoverable mode, then search for devices with your computer. When you find your phone, punch the same 4-digit PIN into the phone and your computer.
Anyway, here’s the script. I hope it helps somebody out.
#! /usr/bin/env python
# W. Matthew Wilson
# it into the public domain.
# vim: set expandtab ts=4 sw=4 filetype=python:
"""
Pull all the images off my phone.
"""
import commands, logging, os
from xml.etree import ElementTree
from xml.parsers.expat import ExpatError
logging.basicConfig(level=logging.DEBUG)
def get_list_of_pictures():
"""
Yield a list of strings, where each string is the file name of a
picture.
"""
# You'll need to change the 00:1D... stuff to your phone's
# MAC address.
# You might need to change /Graphics/ to where your phone
# stores its photos.
status, output = commands.getstatusoutput(
"obexftp -b 00:1D:F6:55:7E:D9 -l /Graphics/")
logging.debug("status of obexftp: %s" % status)
logging.info("Finished running obexftp...")
# Unfortunately, the output from obexftp includes some goofy status
# crap and then some XML data. So I parse each line separately,
# and skip the lines where parsing fails.
for line in output.split('\n'):
logging.debug("About to parse line %s." % line.strip())
try:
x = ElementTree.XML(line)
# Skip lines without a name attribute.
if 'name' not in x.keys(): continue
# Extract and yield the name
photofilename = x.get('name')
logging.debug("About to yield %s." % photofilename)
yield photofilename
logging.debug("Finished yielding %s." % photofilename)
except ExpatError:
logging.debug("This line is not valid XML: %s."
% line.strip())
def grab_pic(photofilename):
"""
Pull the photo named photofilename and save it locally.
"""
# You probably want to change this.
os.chdir("/home/matt/Documents/Photos/phonepics")
status, output = commands.getstatusoutput(
"obexftp -b 00:1D:F6:55:7E:D9 -g /Graphics/%s" % photofilename)
logging.info("Finished storing %s locally." % photofilename)
if __name__ == "__main__":
logging.info("Starting...")
for photo in get_list_of_pictures():
grab_pic(photo)
logging.info("All done!")
A few web app ideas
I read somewhere that having a good idea for a business is like finding your sneakers before running a marathon. I’m convinced that focusing on coming up with an awesome business idea is a waste of time. In other words, it isn’t the quality of the idea that separates successful entrepeneurs from all the failures out there. If you can learn to program, you’re smart enough to come up with an idea for a web application that is good enough. The hard part is building the prototype, selling it, training your customers, adding new employees, etc.
Anyhow, since I don’t believe ideas are all that precious, I’m sharing a few side projects I’m thinking about. Feel free to take them. In fact, I’d be flattered.
Just to be clear, these ideas are released into the public domain. When I have some free time I may do a few of these.
Idea 1: make something that helps teachers keep track of grades over the semester
I don’t mean some elaborate tool like blackboard. I mean something that tracks attendance and grades. And maybe a few other things, but not much more. I’ve been teaching for about four semesters now, and it’s a big hassle to keep track of this mundane stuff.
Idea 2: Graphical cash flow / burn rate projection tool
At work, I have to deal with scenarios like paying an extra 10% for some outsourcers to finish a product release that then might lead to increased sales. I want to be able quickly see effects of lots different possible rates of return.
At home, I wonder about stuff like paying an extra $100 toward the mortgage versus putting the same money to the car note.
I want to be able to enter in stuff like recurring payments, starting balances, interest rates, etc, and then see some pretty charts that show the results.
Last idea: workout tracker
I have a hard time remembering workouts. I know I could carry around a notebook, but that’s no fun. I would prefer that after each set, or when I want to take a break, I could send in a text from my phone to some shortcode. The message would have some details of part of my workout, maybe using some shorthand like:
dbp 12 120
meaning that I did twelve reps of dumbbell bench presses with one hundred and twenty pounds.
Then, at the next workout session, I could send in a text message and the system would figure out what I should do.
The system might adjust up weights by 3% for example, or make sure I vary exercises.
There could very easily be some facebook extension that brags to my friends with the details of my workout.