Showing post in category: Random hacks
Background:
At work we are currently in the process of creating a general data hub which is easily expendable and configurable. It’s already in use exchanging EDI messages (EDIFACT) for a supplier on the danish electricity market.
For the configuration we settled on a GUI where you could drag different kinds of data manipulations into the data flow and this is all implemented in HTML with jQuery.
The problem:
Upon drop I had to use Ajax to ask the server if it was ok to drop the draggable. Since Ajax is asynchronous the drop event would return before the Ajax actually had finished. I decided that I didn’t want to force the request to the server to be synchronous instead I wanted the ajax success callback to be able to do the reverting.
Upon searching the net, the closest thing I came to a solution was defining a callback function for revert on the draggable, and this functionality isn’t even documented by the time of this writing.
The solution:
After playing a bit around I found an acceptable solution. I’ve created a small example reverting a drop using a confirm where you can test it (and see the code).
Tags: draggable, droppable, jquery, revert
I like my desktop to look good (cool effects not needed) and I’m a heavy Gnome-Do user so it has been annoying me for quite some time that when starting Pidgin it looks like this:

So I started searching Launchpad for a bugreport and actually found 2:
Thos bugs led me to a bug report in Pidgins own trac about the same issue. Which led me to download the source code and an usable svg file which I manually copied to my system:
sudo cp ./pidgin-2.5.5/pidgin/pixmaps/icons/hicolor/48x48/apps/scalable/pidgin.svg /usr/share/icons/hicolor/scalable/apps/
Long story short… now launching Piding from Gnome-Do looks like this:

YAY
Tags: bug, gnome-do
I found the first problem with running this Wordpress installation on multiple domains. The installation generates a .htaccess filen in the installation directory. This won’t work when the blogs are in differet directory levels.
What I did was adding the rewite rules to the virtual host instead… that way all my domains could have different rewrite settings.
I also tried to move the upload directory away from the central Wordpress installation and into the document roots for the different domains. But this seems to be impossible due to a bug in Wordpress MU.
The last issue I found with my solution to the multiple domains with Wordpress MU is that the site admin might not be able to see the blogs on the other domains but if you know the id of the blog you can just change that in the URL and gain edit access to the blog anyway.
Example:
The user domain1_admin is site admin for domain1.com. On the domain domain2.com the a blog with the id 3 is attached. So admin logs in on domain1.com and uses this url:
http://domain1.com/wp-admin/wpmu-blogs.php?action=editblog&id=3
The last few issues I can live with… so I wont be experimenting with Wordpress for a while I guess. Hope someone can use this.
Tags: wordpress
Ever since my guild in World of Warcraft first introduced a system for raid sign ups I wished that it was integrated into the forum so I wouldn’t have to login to the forum with one user and the raid sign up system with another (and into the dkp system with a third).
Anyway a little over a year ago I became responsible for the guild forum and looked for a mod for phpBB so raid sign ups would integrate well with the forum. I couldn’t find anything usable at the time so I decided to try write my own phpBB raid sign up mod.
Apart from being fun this little project kept my php skills from rusting totally and I also learned to use Bazaar (a version control system).
Just wanted to blog about it because I think it turned out quite good even though its small. Sure there is room for improvements but hey… the source is there for everybody – change it if you like
Tags: phpbb, world of warcraft
Alright… my blog is now officially migrated from Serendipity (s9y) to Wordpress. I created the new webdesign a while back and made a few small changes tonight just before the switch… let me know if you find any problems with it. The design was inspired by a Wordpress theme by webdemar.com.
A while back I found a s9y importer on Michael Tysons weblog which worked pretty well. Since my last visit a german guy had made a few small changes to it to import extended posts. I had a few of those so I grabbed his script. I had to make a small change to the import script in order to get drafts imported as drafts (and not published).
I also had to insert an extra newline before and after the more-tag (<!–more–>) in order to get my markdown working as intended.
To get Markdown support in my posts I installed the plugin ‘text-control’ (even though its fairly old). I had to get the newest markdown.php and replace the one provided by the plugin to make it work (to get rid of php errors).
I had a few posts which have been pretty popular, so I made sure that old links would still work by using “Wordpress Permalinks – Custom Structure”:
/archives/%post_id%-%postname%.html
I had to make a “last minute” change which affects my Wordpress installation in order to get it working. I will blog about that later in a “Hacking Wordpress MU 2.7 – Part 3″.
I hope you like the change
Tags: wordpress
This is my part 2 of my pursuit on howto host multiple Wordpress blogs spreading over multiple different domains (not only sub-domains) on the same Wordpress MU installation. You can read the first part here. It seems to be possible without using the Domain Mapping plugin which also creates the extra table to provide the functionality (which seems unnecessary).
So far my research shows that it possible using what’s already inside the Wordpress MU 2.7 release. There is no web interface for some of these things but with a few manual inserts into the database it seems to work like a charm.
After my last post I was able to create multiple blogs spread over mulitple domains. But before the blog was moved to its own domain you had to attach the users for the blog because the blog would disappear from the admin webinterface as soon as the site id changed (as soon as the blog was bound to another domain).
It was possible to login on the new domain with the admin user but the user would only serve as a blog admin and not as a site admin on that domain.
With the following I was able to make the admin user site admin for the new domain as well:
INSERT INTO `wp_sitemeta`
( `site_id` , `meta_key` , `meta_value` )
VALUES
('2', 'site_admins', 'a:1:{i:0;s:5:"admin";}');
The number two (2) refers to the site_id your domain got in the table wp_site. If you want another user than admin to be the site admin you’ll have to modify the strange string. Its not as hard as it might look. You can read about how to interpret the string on the Wordpress MU forum – capabilities explanation and the PHP function serialize
Alright… one of my good friends wanted a Wordpress blog… I’ve been thinking of migrating this blog (Jacob’s Weblog – Time is always against me) along with another blog on my webserver to Wordpress… that’s 1 2… 3 Wordpress installations.
I went to the Wordpress website and finds they recently released a new version (version 2.7). After downloading it and falling in love my good friend points me to Wordpress MU Why maintain 3 Wordpress installations when you can maintain a single probably 10x times as complex one?… I like a challenge.
The first part of the challenge was that Wordpress MU hasn’t been released in a 2.7 version yet. Well I fetched it right from trunk (revision 1616) and installed. Then created two blogs on two different domains and created users for the blogs on the different domains. Second part of the challenge was that users attached to the second domain couldn’t login and was just redirected back to the login screen.
I described my problem in detail on the Wordpress forum in the hope of some mighty Wordpress MU guru would serve me the solution on a silver platter… that wasn’t the case.
I can get stubborn sometimes and the last 2 months we had a php development project on work so I figured: “How hard can it be?”
After an a few hours (first spend googling for debugging Wordpress) I ended up using lots of echo, if and exit – there is no school like the old school
Now I think I found a solution and it wasn’t code changes. I needed som changes to the data in the database. You will find a table named wp_site where you will need to add your second domain (and third… etc.) Now browse the table wp_blogs and change the site_id so it matchs the site id for the domain in wp_site.
I still need to test this out but so far it looks good
The third challenge will be to make my domains work with www. prepended. But I’ll save that for another time.
After my server was restarted twice by my hosting center I decided to make sure Teamspeak would start automatically.
I read a few posts on how other people did it but in the end I decided that I created my own minimal script.
My two goals with this init script was:
- Run the Teamspeak server as an unprivileged user.
- Make sure the Teamspeak server starts up after reboot even though it wasn’t shut down properly
- A little bonus was that it reuses much of the init script that is bundled with the installation
Init script (/etc/init.d/teamspeak):
#!/bin/sh
TEAMSPEAK_DIR=/usr/local/teamspeak
TEAMSPEAK_USER=teamspeak
# Make sure that Teamspeak starts even though it wasn't closed nicely last time (ie. by a power cut)
if [ $(su - $TEAMSPEAK_USER -c "ps ux" |grep tsserver2.pid|grep -v grep|wc -l) -eq 0 ] && [ -f ${TEAMSPEAK_DIR}/tsserver2.pid ]
then
rm ${TEAMSPEAK_DIR}/tsserver2.pid
fi
cd ${TEAMSPEAK_DIR}
su - $TEAMSPEAK_USER -c "./teamspeak2-server_startscript $1"
cd -
I have been learning a bit of Mono over the last couple of months and yesterday I decided that I wanted my code in a verison control system. The choice fell on Bazaar for various reasons which is unimportant and uninteresting at this point. Right now I just wanna write down how I did
First off you tell Bazaar who you are with:
bzr whoami "Jacob Emcken "
To test it is set correct just type:
bzr whoami
Jacob Emcken
For the sake of it, lets imagine my project I want to version control is called Starfire.
Go to the directory with the project and initialze the directory as a Bazaar branch:
cd Projects/Starfire
bzr init
Within that directory a new directory called .bzr will be created:
ls -la
drwxr-xr-x 5 je je 4096 2007-09-01 23:56 .
drwxr-xr-x 3 je je 4096 2007-09-01 23:37 ..
drwxr-xr-x 6 je je 4096 2007-09-01 23:37 .bzr
drwxr-xr-x 2 je je 4096 2007-09-01 23:37 Glade
-rw-r--r-- 1 je je 5342 2007-09-01 23:37 Starfire.cs
-rw-r-xr-x 1 je je 5342 2007-09-01 23:40 Starfire.exe
Now tell Bazaar which files your branch consist of. In the following example we’ll tell Bazaar to ignore Starfire.exe because we dont need the compiled file within our version control:
bzr ignore Starfire.exe
bzr add .
added Glade
added Starfire.cs
added Glade/gui.glade
ignored 1 file(s).
If you wish to add some of these files, please add them by name.
Ignored files is found in the file .bzrignore, just try run ls -la if you wont take my word for it
And finally to actual save the code in the branch repository commit your files:
bzr commit -m "Initial revision"
added .bzrignore
added Glade
added Starfire.cs
added Glade/gui.glade
Committed revision 1.
By supplying commit with the parameter -m you avoid a text editor popping up asking you for a commit message.
Now you can just hack away and you can check changes with:
bzr diff
Whenever you want to save you changes to the branch, just do a commit again. In the following example I change a line in Starfire.cs:
bzr commit -m "Fixed small typo"
modified Starfire.cs
Committed revision 2.
Now if you want to make your code available on the another machine ie. a server on the internet you can push you code out there through ssh (and ftp). Place yourself in the root directory of your project. The following example will push the branch out to my server (emcken.dk) where I have a ssh key so I dont need to write a password when logging in:
bzr push sftp://emcken.dk/~/development/Starfire
Now a copy of my branch is available in my home directory on my server (/home/je/development/Starfire).
As a last thing I would like my server to be central for my development. From the root directory of my project I tell Bazaar that my current branch is a checkout of the branch on my server:
bzr bind sftp://emcken.dk/~/development/Starfire
Now whenever I commit changes they will be committed to the server as well so I don’t need to push the copy of the branch out there every time. You can test the settings with:
bzr info
My experience with version control systems are very limited to say the least which was why some of the above wasn’t obvious to me before I made a few tests and read the man pages. But the above was what I needed to get started and I hope that this might help someone else. You can find more inspiration here and here.
When I came home from work today I read Planet Gnome, I usually visit Planet Gnome several times a day so nothing new in that.
But this time I found the post “tsclient 0.150 – call for translators” post by Jonh Wendell.
I thought why not… even tough I always use the English language when ever I can get away with it.
I use tsclient a lot at work so I guess it was about time I payed something back to this great program.
I found an old Danish translation back from version 0.106 in the SVN repository, and started from there.
I used a Danish translation guide translation guide since this is the first time I’ve ever translated software.
This guide linked to a nice word list for Danish translations which helped me a few places where I was unsure about which Danish word I should choose. About 2 hours later I was finished and had submitted the translation in a bug report.
I hope someone will find this useful out there.