After my week with Emacs I’m still struggling along. One of my main annoyances is the default way some of the modes indent the code. I think the worst offender of this is the default CSS-mode. After frustration when, yet again, I hit the tab key and the cursor rockets about 80 places to the right I decided to Google for a fix.
The internet is great! Clearly it wasn’t just me having a problem, Guido Stevens was also suffering and posted a fix, which he himself found on another blog post by Chris Miller, which Chris in turn found on StokeBloke.com which had been found originally on a now dead post.
Not bad! Four people all having problems with the same thing and posting a fix for others to share. So I thought I’d join the chain, and write this blog post.
As promised in my last post, I have spent a whole week using Emacs. Apart from the odd foray with Nano and Mousepad I haven’t touched Eclipse or Netbeans or any other IDE and managed to stick to Emacs for the full week.
How did it go?
To start off it was slow. Emacs has a notoriously high learning curve, and I pretty much started at the bottom. One of the reasons for doing this was so I could move away from the mouse and it turns out that the mouse is an extremely hard habit to break. So to are the keyboard arrow keys. I kept on finding my hands would instinctively jump off the keyboard and try to double click on something, or try to navigate around the page with the arrows. This is clearly not the way it is done in Emacs!
The next thing I found is that Emacs doesn’t let you indent code files as you want. It seems to have a preferred method and forces it on you. This is very annoying and being a n00b I still haven’t found a way around this.
However, after a couple of days I began to get the hang of it. Still painfully slow, but navigating around the page, buffers and windows was becoming gradually quicker. I began to enjoy using Emacs, even though my right hand kept on unceremoniously lurching to the right from time to time.
By a complete coincidence, on Wednesday I was invited to C-Base here in Berlin for a beginners’ introduction to Emacs. Even though it was all in German, and my Deutsch ist nicht so gut I was blown away by not only the speed but also the huge amount of functionality within Emacs. To see someone who actually knew Emacs inside out was a revelation. I made a huge amount of notes (within Emacs before you ask!) ready to test out for myself. This insight into the “how the pros use Emacs” has really been an eye-opener and I am determined to learn just a fraction of what was on display at the tutorial.
Summing up my week with Emacs.
It was hard work, there was much and is even more left to learn. It is a vast landscape to negotiate, with many nooks and crannies. But once it is mastered I have no doubt that my productivity will be greatly increased.
In a current database driven project that has multiple developers the single biggest issue we have is version control for the database.
For us at ibrow, the number one practise that we engage in is Version Control/Revision Control. I personally use version control for almost everything and not using it when having multiple developers working on a project sends shivers down my spine.We currently use Subversion, however I’m thinking of moving over to Git, but there is also Bazaar and Mercurial plus many, many others.
Whilst there is this vast array of version control system for code, there doesn’t seem to be the focus on version control for database schemes. Jeff Atwood has a couple of posts espousing the virtues of version control for databases. There is Rail’s Migrations which seems to be the most advanced version control for databases to date and there is a project to make a PHP version of Migrations. However, Migrations still has it’s flaws, which are discussed in Adam Wiggins’s blog post about this very subject. Adam offers some good insights into the problem and has a brain storm about possible solutions. But I think I’m coming to the problem from a slightly different angle to him.
As most of our projects are in constant development we do not, as such, have versions, but instead revisions. This is a key difference here. If we check in a database change to the version control, we don’t yet know it’s revision, especially if we have multiple developers working on the same project and possibly changing the scheme of the database at the same time.
The ideal solution would use the following steps:
Developer finishes their chunk of code with any database changes, and are ready to commit. The database changes include UP and DOWN changes.
Developer commits their code changes, a revision number is assigned
Based on this revision number, the database changes are committed.
Obviously the developer should update their working copy before committing, just to see if there are any conflicts and to make sure they have the latest copy of the code.
On the updating side, the following steps should occur when the developer updates their code:
The update process makes a note of their current revision number
Downloads all code changes via the SVN update command
Downloads all the database changes since their last revision
Update process applies all database changes to developer’s local database
This process can be reversed for reverting or merging backwards.
Currently I can’t find anything out there that does this – which probably means one of 2 things:
My Google-fu isn’t up to scratch
It is actually a lot harder than I think!
I really need to get this right, as this is possibly the most important thing to get right for us at the moment. It would be great to hear any possible solutions or existing implementations out there.
Maybe this will be an interesting sub project for me over the next few weeks?
(And obviously I haven’t even considered trying to keep the data up to date – but I guess that will be for another day.)
About a month ago I decided to get very geeky and installed a command line emailing program: Sup. I started off by moving my main work account over to test it out and after a month of heavy testing I have now just moved my other accounts across.
So why?
Well, let me first state that Sup is no where near perfect. Crazy people out there still send me HTML email which obviously doesn’t display too well in a command line interface, but I can open those up in my browser. I still haven’t found a way to easily search and add multiple names from the address book to an email I’m composing. And there is that irritating thing that means if I’m writing an email, I can go back and view my inbox (note: this is probably my fault, I’m using a popup window’d emacs).
But the thing is these are all fixable. It is open source, so if these things really pissed me off then I should learn Ruby and have a crack at fixing them myself. And the thing is I like Sup so much I just might.
Also Sup is being actively developed. If you have a look on the Gitorius page you can see that Sup’s maintainer William Morgan seems to spend every weekend hacking away! Plus there is a large list of active developers.
Yet I didn’t move all my mail accounts over to Sup just because I can fix things and if I can’t then hopefully someone else will!
No, I moved them all over because Sup appears to be slowly, email by email, saving my life.
I currently have 1893 emails index, but of these 1893 email, only 12 of them are in my inbox. For me this is unheard of.
Sup has provided me with such an easy system of filing and organising my mail that I can deal with it pretty much instantly, clearing my inbox. And over the last month I have found that keeping a clean inbox keeps my head pretty focused. I’m not worrying about all the emails I have to deal with. I am finding I can handle more stuff, get more stuff done and still have a tidy head.
This is great news!
Having this confidence of being able to handle more stuff, I’m wanting to handle more stuff. I want to do more things, I want to push projects forward. I am now no longer wallowing in an unorganised mess! So thank you William and thank you Sup – you are saving my life
Sometimes I really love the Linux world. Sometimes it all fits so neatly together and lets you just get stuff done. Sure it might take a bit of digging around, but when it all comes together it really is beautiful!
I’m waxing lyrical today because I have just managed to fit all the pieces together for a certain aspect of a large project we’re working here at ibrow towers. This particular problem was a three parter:
Users can FTP into a server into their own directory.
These users should be created automatically (i.e. sign up on site, get details, ftp) and have the same login credentials as the rest of the site
Uploads to the FTP server should be monitored and each file processed
To solve this three part problem, I utilised the following:
VSFTPD FTP Server using MySQL as the credentials database
I’ve been working on a Wordpress site for a client with one of our developers Tom Hartnell. The design of this particular site was that some pages would need content displayed over multiple columns. This content had to be updatable by the client, as such it could not be hard coded into the template files.
We had a look around and we found a potential solution on this blog post.
We played around with this for a while but found that, whilst it was a good solution, it wasn’t quite suitable for our needs. What we needed was a solution which allowed us to have any number of columns and for each column to contain completely different content. The solution in the post demanded that each column start with the same HTML tag (H2 in the example). We decided to rewrite the function described above, based on the same principals, but updated and improved so it would fit our needs.
To see what the end result is, you can see a demo page.
I’ve just committed a new very basic web installer for Timesheet Next Gen which is the Timesheet and job tracking open source web app that I’m trying to contribute to when I have a spare moment.
Only in the SVN repository at the moment, but if you have a chance you can get check it out anonymously from SourceForge using your favourite SVN app here:
In my “real life” I manage a number of blogs for both clients and friends, mostly Wordpress. One of the blogs had a requirement that was to completely password protect the entire site – i.e. only registered users could view any page/post.
For this I initially set up .htaccess password protection – quick and simple.
However, we found out that this prevented the Wordpress iPhone App from login in and doing it’s stuff. So we had to look for another solution.
After doing some Googling I found a post all about password protecting wordpress on the Cre8d Design blog. This pointed me to the “Registered Only” plugin. Whilst it is quite old (4 years since last commit) it should have been just what I was looking for, so I downloaded it, installed and activated (taking care to follow the readme and remove the RSS feeds)
When testing it out it displayed the login box on first visit to the site – prefect. However, I logged in, but it still showed the login box. I assumed I typed in the wrong password, so I tried again. Same result.
Argh, a bug!
Probably because it was meant for a much older version of Wordpress (this blog was using 2.6.3 – now upgraded to2.7)
There was only one thing for it, I had to view the source! Which turned out to be relatively simple:
function carthik_bouncer(){if(substr($_SERVER['SCRIPT_NAME'],-12)!="wp-login.php"){
auth_redirect();
}}
add_action('init','carthik_bouncer');
The problem was clearly the auth_redirect() function. After some searching, I found this threadin the Wordpress Support forums, after which I dutifully modified the code to this:
function carthik_bouncer(){if(substr($_SERVER['SCRIPT_NAME'],-12)!="wp-login.php"){if(!is_user_logged_in()){ auth_redirect(); }}}
add_action('init','carthik_bouncer');
Success! It works prefectly.
If you need to know, here is a patch:
--- registered-only-old.php 2008-12-1214:00:09.000000000 +0100
+++ registered-only-new.php 2008-12-1214:01:21.000000000 +0100@@ -26,7 +26,7 @@
function carthik_bouncer(){
if (substr($_SERVER['SCRIPT_NAME'], -12) != "wp-login.php"){- auth_redirect();+ if (!is_user_logged_in()){ auth_redirect(); }}}