-
mongorestore: ERROR: root directory must be a dump of a single collection when specifying a collection name with –collection
Posted on April 21st, 2010 No commentsmongorestore 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 objectsquite obvious in retrospect given the error message, but the internet didn't know the answer yet and there isn't much documentation about mongorestore.
-
Introducing Quiqi
Posted on February 16th, 2010 No commentsQuiqi is a greasemonkey script and firefox plugin which shows you quick answers to your search queries inline and unobtrusively in Google searches. Quick answers are provided by users, editable by anyone.
Some example answers (so far mostly answers to programming questions):
ruby string to int -> str.to_i
apt-get ab -> apt-get install apache2-utils
jquery checkbox status -> .is(\':checked\')
js string to int -> parseInt(str)
usb 2 speed -> 480Mbps
javascript array copy -> new_copy = original.slice()
php referrer -> $_SERVER['HTTP_REFERER']
water couscous -> 1 1/2:1 water to couscous
when to plant thyme -> outside: 2 weeks after average last frost or when soil is ≥ 70° inside: 8 weeks before last frost
error: ‘memcpy’ was not declared in this scope -> #include </cstring>
And an example screen shot. Notice how the answer isn't provided in the excerpted content.

-
Howto Replace a Screen Invertor on a Dell Inspiron 1520
Posted on December 19th, 2009 13 commentsI have a Dell Inspiron 1520 which started to get a whining noise right under the DELL logo below the screen right in the middle. It would change pitch depending on how bright the screen was set at. I replaced the inverter which cost me $15 on ebay. The process was fairly simple but I took more things apart and made things generally more difficult on myself than I needed. Here is the most simple way to repair your inverter on a Dell 1520 Inspiron laptop.
- Remove the plate covering the power button and numlock/capslock keys. This can be done by twisting a screwdriver under the little slot on the top right hand side of the cover.
- Remove the frame around the screen. Do this by removing the 6 little pads and and stickers covering the screws to remove the frame from the screen. There is one in each of the corners and two near the center/top. Unscrew these screws. To remove the screen cover frame you will need to twist and pry a little bit near the hinges. Don't be afraid it does require some force.
Once it is removed it should look like this:
- With the frame off, remove the screws holding the screen to the lid. There are some that screw down from the top and other that screw into the side of the screen, just look around. Next, remove a couple screws holding the microphone/webcam board above the very top of the screen. This will allow you to safely move the entire screen and get to the inverter. Once you have done this, you can open your laptop lid all of the way so it is almost flat and move the screen and webcam board so they are flat on the keyboard. It should look like this:
- Replace the Inverter. At this point you should be able to easily get to the inverter which is between the hinges below the screen. There are two cables to unplug. One has a blue ribbon to pull on and the other a white connector to pull out.
- Once you've switched them out, put everything back together and you're done.
It took me a long time to realize that if I removed the screws to the microphone/webcam board it would move with the screen which led to lots of problems trying to get to the inverter while the screen was still attached to the lid. That is really the only trick.
Good luck!
-
MySQL Permission Errors After Moving Datadir
Posted on November 11th, 2009 No commentsI 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
-
Build tolua++ files with makefile
Posted on July 31st, 2009 No commentsHere is how you can have your makefile build your tolua++ .cpp and .h files for you. It should work for plain tolua also.
TOLUA = tolua++5.1 tolua_%.cpp tolua_%.h : %.pkg $(TOLUA) -o $(@:%.h=%.cpp) -H $(@:%.cpp=%.h) $<
this will generate tolua_file.cpp and tolua_file.h files from corresponding file.pkg files anytime they the .cpp or .h file is depended on somewhere else in the file. In my case I just added tolua_file.o to my list of objects. Here is the full makefile for the project which required this - for reference:
# LINUX LIBLUA=lua5.1 # MAC OSX #LIBLUA=lua # LDFLAGS=-arch x86_64 OBJS = swarm.o group.o scene.o vmath.o tolua_group.o tolua_swarm.o tolua_vmath.o CXX = g++ CXXFLAGS = -Wall -c -O2 `sdl-config --cflags` LDFLAGS = -Wall `sdl-config --libs` INCLUDES = -I./include -I/usr/include/lua5.1 -I/opt/local/include LIBS = -L./lib -lANN -lGL -lGLU -llo -ltolua++5.1 -l$(LIBLUA) TOLUA = tolua++5.1 tolua_%.cpp tolua_%.h : %.pkg $(TOLUA) -o $(@:%.h=%.cpp) -H $(@:%.cpp=%.h) $< %.o: %.cpp $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $@ # the executable swarm: $(OBJS) $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
-
Swarms
Posted on April 17th, 2009 No commentsSo I've been experimenting with generating swarms and was able to get some basic code working pretty quickly thanks to some Particle Systems example code on NeHe. Here are some of my first steps:
I think the next step is going to be to get multiple swarms each operating on different rules in the same space interacting.
-
example of MQL/freebase in Python
Posted on March 30th, 2009 No commentsfirst, easy_install freebase
from freebase.api import HTTPMetawebSession, MetawebError mss = HTTPMetawebSession('www.freebase.com') bob = mss.mqlread([{ 'type':'/music/album', 'artist':'Bob Dylan', 'name':None }]) for album in bob: print album['name']
Or with, metaweb.py which for some reason doesn't seem to be available via easy_install, but does seem to be a bit more advanced and less code (example from MQL Reference):
import metaweb bob = metaweb.read([{ 'type':'/music/album', 'artist':'Bob Dylan', 'name':None }]) for album in bob: print album['name']
-
Howto install pyclutter 0.8.2 on Ubuntu
Posted on February 26th, 2009 No commentsUbuntu 8.04 has pyclutter 0.6.2 in the repositories while the current stable version is 0.8.2. Here is how I installed pyclutter 0.8.2 with all of the extra available libraries (gtk, gst, cairo):
download:
also make sure you have python-cairo-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev installed. There may be more required, but these were the only ones I didn't already have installed.
For some reason I had to configure all of these libraries with --prefix /usr to get pycluster to see all of them.
Also, configure pycluster with --enable-docs if you want any documentation.
have fun!
-
Search terms as initial delicious bookmark tags
Posted on February 19th, 2009 2 commentsI've patched my copy of the delicious firefox extension so that when you bookmark a page which you got to from a google/yahoo search, those search terms are automatically included as the first set of tags for the post. This only happens if the search is in your recent history (must be able to get back to the search page with no more than 2 back button clicks from the page you are bookmarking).
I've posted that patch to the extension's yahoo group, so it will hopefully end up in the official extension (as a non-default option). In the meantime, here is the patch and the modified extension (original version 2.1.018). Note that I didn't change the name of modified extension so that it overwrites your old delicious plugin. However, this also means that this version will be overwritten by any new official versions released. I'll figure out a more clean solution if the patch doesn't get accepted.
NOTE: This feature must now be enabled via preferences
-
Single Instance Application with command line interface
Posted on February 17th, 2009 No commentsI wanted a python gtk application to open a new window on its first execution and then have subsequent executions send their command line arguments to the initial application rather than starting a new one. Here is the template which provides that functionality:
download singleinstanceapp.py
""" This will only spawn one gtk application at a time. If this command is executed while an instance is already running, the command line arguments are sent to the already running application. """ import sys import pygtk pygtk.require('2.0') import gtk import socket import threading import SocketServer class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) cur_thread = threading.currentThread() # do something with the request: self.server.app.label.set_label(data) # could instead of the length of the input, could return error codes, more # information (if the request was a query), etc. Using a length function # as a simple example response = 'string length: %d' % len(data) print 'responding to',data,'with',response self.request.send(response) class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): stopped = False allow_reuse_address = True def serve_forever(self): while not self.stopped: self.handle_request() def force_stop(self): self.server_close() self.stopped = True self.create_dummy_request() def create_dummy_request(self): client(self.server_address[0], self.server_address[1], 'last message for you') def client(ip, port, message): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((ip, port)) sock.send(message) response = sock.recv(1024) print "Received: %s" % response sock.close() def start_server(host, port): server = ThreadedTCPServer((host, port), ThreadedTCPRequestHandler) ip, port = server.server_address # Start a thread with the server -- that thread will then start one # more thread for each request server_thread = threading.Thread(target=server.serve_forever) # Exit the server thread when the main thread terminates server_thread.setDaemon(True) server_thread.start() return server class SingleInstanceApp: def destroy(self, widget, data=None): self.server.force_stop() gtk.main_quit() #exit(1) # I'm sorry but mozembed is making a huge pain in my ass def __init__(self, server): self.server = server # create a new window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_default_size(300,30) self.window.connect("destroy", self.destroy) self.label = gtk.Label("hello world") self.window.add(self.label) self.window.show_all() # and the window self.window.show() def main(self): gtk.gdk.threads_init() gtk.main() if __name__ == "__main__": # pick some high port number here. Should probably put this into a file # somewhere. HOST, PORT = "localhost", 50010 server = None try : client(HOST, PORT, ' '.join(sys.argv)) print 'an insance was already open' except socket.error : exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() if exceptionValue[0] == 111 : print 'this is the first instance' server = start_server(HOST, PORT) else : # don't actually know what happened ... raise app = SingleInstanceApp(server) server.app = app app.main()
The first execution of this script starts an asynchronous server on a predetermined port. This port is checked each time the script is run to see if another instance has already been started. If it has, the command line arguments are sent to the existing instance which can react to them however you want.
download singleinstanceapp.py
