PiCloud Simulation: OSError: [errno 13] permission denied

I tried running a PiCloud simulation on Ubuntu 10.04 on linode and got the following error:

OSError: [errno 13] permission denied

I found the solution here:

add the following line to your fstab and reboot:

none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0

If you don’t want to reboot, a temporary fix might be:

sudo chgrp $GROUP /dev/shm
sudo chmod g+w /dev/shm

That last part might not be the best way to do it, but it worked for me.

Passwordless login for SSH not working

I have not been able to login to my system with passwordless SSH for some time now and finally figured out the problem. I had to change the permissions of my home directory to disallow writing by everyone. I knew that ~/.ssh and the files in it required specific permissions to be set, but I hadn’t heard about the home directory having similar requirements.

Oyster Mushrooms

So I’ve been reading a book by Paul Stamets who has given one of the best TED talks I’ve ever seen, and I watched a lot of them. The book is fantasy meets scifi meets reality; I’m really enjoying it. I’m currently reading one of the chapters covering medicinal uses of mushrooms and am really amazed. One small study of 30 people found that oyster mushrooms could reduce LDL (bad) cholesterol by 30%. There are 37 results for ‘pleurotus ostreatus cholesterol’ on pubmed (sorry they don’t allow linking to searches). Many are on animals like rats and rabbits which seem to support the study sited by the book. It seems to be a fairly well researched phenomenon.

This begs the question: Is there a reason why doctors do not prescribe oyster mushrooms? Is there a reason why they don’t at least suggest them? You can even find them freeze-dried, powered and capsulized so you can get the placebo effect of eating pills if thats what you need. All of the information I was able to dig up as a layman was supportive of the idea that they helped lower LDL cholesterol.

So I talked to a friend of mine Elizabeth who knows a bit more about the medical industry than I do (she’s recieved grant money to do medical imaging research on mice). Her basic response was that no pharmeseutical corperation is going to fund this kind of research. Mostly since they couldn’t patent a mushroom as common as the oyster which doesn’t even need extracting or processing to become medically useful. I was hoping for a less synical response, but alas, it was the best one I could find. Anyone else have any ideas about this?

My next thought (a fairly predictable one if you know me at all) is how we could get around this limitation through distributed cooperation rather than concentrated power and money. What kind of experiments could we perform by having thousands of people assist from home with. Could they try eating oyster mushrooms and looking for a change in cholesterol level? What kind of procedures in a lab would be hard to reproduce and which would be easier? I understand that this kind of experiment or data mining, wouldn’t be of the same rigorous type as one performed by scientists in a lab, but could we not still learn a great deal about it? How would a system which allowed for these kinds of experiments operate? Does this already exist?

Obama spam

I keep getting emails asking to please visit this website and vote for Obama, or sign up to this Obama facebook group. I like Obama and I plan on voting for him, I really do. I like showing my support for him and letting anyone who is interested know what I think. However, I could spend every hour of the day joining Obama facebook groups and voting for him in various polls. This is not a productive use of my time. I want to publish the fact that I support Obama, and be done with it. Let this be the informal declaration. I hope to have a framework which would allow people to make declarations of this type, which could then be read and understood by computers, and then analyzed and viewed by anyone and everyone who is interested. There could even be a facebook/myspace app. sigh Say it once, have it published, and moveon.

Net Neutrality

Net Neutrality is not just about innovation, free speech and democracy, it is about keeping the newly forming synapses of our collective mind free from corruptible power structures.

god damn this is important.

MySQLdb: TypeError: %d format: a number is required, not str

I was getting this error message from MySQLdb:

TypeError: %d format: a number is required, not str

The error message was the result of this code:

1
2
3
4
5
6
7
8
9
10
11
assert type(gateway_id) == int
sql = """
SELECT meter_id

FROM mtus
WHERE gateway_id = %d
AND name = '%s' """
conn = mysql_connect()

cursor = conn.cursor()
cursor.execute(sql, (gateway_id, name))
ret = cursor.fetchone()
cursor.close()

It turns out, execute converts all the arguments to SQL literal values. reference All %Xs should be %s and there shouldn’t be any quotes around them. MySQLdb takes care of the string escaping too.

Other Causes:

For those of you arriving here from a search and are not having problems with MySQL, the reason for this error is that a string was passed into a format where a number was expected:

1
2
3
4
# throws the TypeError:
message = "%d seconds until done" % "three"
# works:
message = "%d seconds until done" % 3

MySQL Permission Errors After Moving Datadir

I wanted to make space on my root partition and so moved my mysql data dir to /home/mysql in /etc/mysql/my.conf and received the following errors:

dwiel@dwiel:~$ sudo mysqld
091111 20:39:16 [Warning] Can’t create test file /home/mysql/dwiel.lower-test
091111 20:39:16 [Warning] Can’t create test file /home/mysql/dwiel.lower-test
091111 20:39:16 [Note] Plugin ‘FEDERATED’ is disabled.
mysqld: Can’t find file: ‘./mysql/plugin.frm’ (errno: 13)
091111 20:39:16 [ERROR] Can’t open the mysql.plugin table. Please run mysql_upgrade to create it.
091111 20:39:16 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: ‘open’.
InnoDB: Cannot continue operation.

The problem was with apparmor. It was restricting mysql from reading and writing to /home/mysql. To correct this I edited the file /etc/apparmor.d/usr.sbin.mysqld and added:

/home/mysql r,
/home/mysql** rwk,

to the end of the file. Then restarted apparmor:

sudo /etc/init.d/apparmor restart

and then restarted apache with no problem

mongorestore: ERROR: root directory must be a dump of a single collection when specifying a collection name with --collection

mongorestore wants the specific collection’s filename rather than the entire database’s dump folder:

dwiel@dwiel$ mongodump -d db -c variables -o ../backups/1
connected to: 127.0.0.1
DATABASE: db to ../backups/1/db
db.variables to ../backups/1/db/variables.bson
3 objects
dwiel@dwiel$ mongorestore -d db -c variables –drop ../backups/1
ERROR: root directory must be a dump of a single collection
when specifying a collection name with –collection
usage: ……..
dwiel@dwiel$ mongorestore -d db -c variables –drop ../backups/1/db/variables.bson
connected to: 127.0.0.1
../backups/1/db/variables.bson
going into namespace [db.variables]
dropping
3 objects

JQuery + Greasemonkey

Had to look around to figure out how to include jquery in greasemonkey. Should have just guessed this first; Just use the @require, and your standard jquery document ready code. Heres my template anyway.

1
2
3
4
5
6
7
8
9
10
11
12
 
// ==UserScript==
// @name JQuery Template
// @author Zach Dwiel
// @description Provide a basic template for using jquery in greasemonkey
// @include *://*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

$(document).ready( function() {
// your jquery code here
}