haslo.ch – Guido’s Blog

We believe that people with passion can change the world for the better.

I’ll Be Back

Posted on | January 18, 2010 | 10:30 | 4 comments

This blog here was quiet for quite some time now. I plan to write again, now that my diploma thesis is finished – it’s with the Professor now. I will most probably publish it here, too. Examns are incoming in March, finally, after way more than enough time studying. And, we’re getting a baby, yay :D

I am not certain whether I will keep the Politblog. Maybe one of the reasons why I didn’t feel like posting anymore was that it started feeling too much like work. What do you think? Should I keep it?

So, this was one of my first “dear diary” blog posts in this blog. Back to more interesting more random subjects again soon :)

SetProperty and GetProperty with C# Reflection

Posted on | September 12, 2009 | 13:32 | 7 comments

I’ll make a post soon, comparing Ruby on Rails to C# with ASP.NET MVC, but this here is atomic and might be of help for one or two readers.

If you want to set and get properties in C# in a type-agnostic way, these are the functions you want to put into a library class somewhere (or, as I did, into the class that uses them):

private object getProperty(object containingObject, string propertyName)
{
    return containingObject.GetType().InvokeMember(propertyName, BindingFlags.GetProperty, null, containingObject, null);
}
 
private void setProperty(object containingObject, string propertyName, object newValue)
{
    containingObject.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, containingObject, new object[] { newValue });
}

That’s all I will say on this subject.

New Commenting Policy?

Posted on | July 31, 2009 | 9:12 | 2 comments

In the recent weeks, I have gotten quite a bit of not-quite-but-nearly-totally-spam-that-duisguises-really-well. As a result, I removed my DoFollow plugin.

But I don’t really like that solution.

I think I might change my approach and make a new commenting policy rule. A quite simple one at that: Every comment that uses some kind of product name as their “name” will be deleted (also those who were made before today), no questions asked, and I re-establish the DoFollow plugin.

I can always delete the links that lead to sites I don’t want to support afterwards, although I’d of course need to introduce an explicit disclaimer for that as well. (Luckily, my current disclaimer reads “I reserve the right to delete spam as I see fit, even if it’s handcrafted”, so I won’t break any promises if I delete things that are spammier than I like retroactively).

On the other hand, I really love your contributions, and I really don’t want to make contributing with comments harder than it apparently already is…

What do you think? How do you handle that kind of thing in your own blog(s)?

Creating my own little Portal Site

Posted on | July 22, 2009 | 12:43 | 4 comments

As you may or may not have noticed, I now have a second blog: haslos Politblog. I decided I’d want to blog about Swiss politics from time to time as well, and with this blog being English only and having a global rather than Swiss target audience, these subjects didn’t really fit in here.

Politblog

Politblog

So I went and started a second blog. Finding a theme and installing WordPress was one thing, but how do you tie those things together? And while we’re at it, why not add stuff like the Twitter feed or Delicious bookmarks? And why not make a mini-tutorial out of it? (That idea actually wasn’t mine, thanks @knowLED!)

When looking at easy ways to create such a mashup for a portal site, I stumbled upon the Google AJAX Feed API, and was amazed. Essentially, it does everything we need, in a format that’s incredibly easy to style with CSS. The higher-level FeedControl class is easy to use, and does exactly what I need: display a collection of feeds in <div> elements.
Read more

WordPress Themes have to be GPL (Thesis etc.)

Posted on | July 19, 2009 | 14:57 | 18 comments

Well, my comment at the Thesis blog is “awaiting moderation” for over 2 weeks, so I guess it won’t happen anymore. Unsurprisingly so, I might add. The folks at Thesis are apparently, essentially, doing illegal things. The only reason why they can do it is because nobody sues them.

First things first: WordPress themes are GPL, they have to be redistributable under the GNU General Public License. Necessarily, the PHP code (although not the CSS or image elements of a theme) has to be, since it is based on WordPress’ GPL code, GPL. Legal wording:

The PHP elements, taken together, are clearly derivative of WordPress code. The template is loaded via the include() function. Its contents are combined with the WordPress code in memory to be processed by PHP along with (and completely indistinguishable from) the rest of WordPress. The PHP code consists largely of calls to WordPress functions and sparse, minimal logic to control which WordPress functions are accessed and how many times they will be called. They are derivative of WordPress because every part of them is determined by the content of the WordPress functions they call. As works of authorship, they are designed only to be combined with WordPress into a larger work.

Speaking of our specific case of Thesis again, the logic is probably less sparse than in your everyday theme, but every other word except “sparse” fully holds, so I guess it’s not that exceptional in this regard. Or can anybody with legal training assist me, am I wrong there?

The guys at Thesis now go and forbid owners of Thesis to remove the backlink to the Thesis site. I appreciate that such a backlink is a great marketing and SEO measure, but I don’t see the legal grounds for such a thing really. They can certainly sell push-style upgrades, and the images they provide with the theme, and of course their support and forums. But the theme itself seems to be necessarily open source, so the Thesis pricing model seems to need re-evaluation.

Edit 2009-07-19 16:20: Just do clarify, unless I am mistaken they can certainly ask money from people for the theme – there are no limits for monetizing distribution in the GPL. However, they don’t seem to be allowed to restrict people’s rights to redistribute and alter the theme.

Particularly in the Swiss blogosphere, with the recent Thesis craze, I think this is fairly important information. What do you think? Or did I misunderstand some legal background?

Getting MySQL 5.0 to work in Ruby 1.9.1 on Windows 7

Posted on | July 3, 2009 | 1:15 | 8 comments

So, I got MySQL to work for my Ruby on Rails development environment. Let’s be clear about what I actually wanted:

  • Ruby 1.9.1
  • Rails 2.3.2
  • Any version of MySQL whatsoever
  • Any way whatsoever to make my up-to-date Ruby on Rails talk to that MySQL

I don’t care what version of MySQL. I don’t care if I have to force platforms for Gems or recompile or whatever. I never did care, and I’ll happily even dig through code to make manual changes before compiling or what-have-you. What I do care about is actually getting this to work, so I can finally stop tinkering and start doing something productive.

Well, I learned a lot on my way there. I had a glimpse at how extconf.rb works (because I had to figure out correct parameters), I dug through rails sources to find errors that you don’t even want to know about, had another good look at makefiles, and generally tried to understand what exactly didn’t work.

Also, there is a more efficient way to do this, as pointed out by Luis in the comments. Thanks!

So, in the end, it now works

This tutorial blog post on Code Elite was very, very helpful. So were Luis comments here and elsewhere (although me being quite the newbie when it comes to gcc and the likes, they went a bit over my head).

The Code Elite post is not the best at being copy-paste-able though, the formatting kinda ruins that. It does point out the correct steps to getting MySQL to work in Ruby (and consequently, Rails).

Long story short, these are the steps that lead to a working MySQL integration:
Read more

Actually Installing Ruby on Rails, on Windows 7

Posted on | June 24, 2009 | 14:32 | 32 comments

OK, so I found out what it is that I have to install for my wonderful Ruby on Rails environment. It’s time to start installing.

Keep in mind that much of what I’m doing here is an experiment (and thanks Luis for being so patient with me). I don’t claim to know what works and what doesn’t, I’m just trying to find my way around here. Follow my steps at your own risk – they seem to lead to a working environment for now.

Update 2009-07-03 02:16: There’s a followup post now that does less evil and wrong things, hopefully. It also happens to result in a working Ruby on Rails plus MySQL environment, something this post doesn’t quite achieve.

Getting Ruby to run

Admittedly, I was a little surprised by how easy this was. Get Ruby and the Development kit from here. Extract them (using 7-Zip, which you should use by default anyway), and put all the contained directories where you want your Ruby. Mine resides in F:\Ruby.

Next, add the newly installed bin directory to your path. Quickest way: Open the control panel, search for “environment”, then click “edit the system environment variables”, and add the bin after a semicolon to the “Path” variable. Then, change the path in devkit/msys/1.0.11/etc/fstab to where you put your stuff – you won’t have to do this if you put Ruby into C:\Ruby.

This is what we get:

Ruby Installed

Ruby Installed

Yay. That was easy. And the greatest thing is that the One-Click installer (even if it’s not entirely one-click, currently) also already adds support for Ruby Gems.
Read more

Assessing Installing Ruby on Rails, on Windows 7

Posted on | June 23, 2009 | 13:48 | 10 comments

So I wanted to get up and running with a development system for Ruby on Rails, on my shiny freshly installed Windows 7 machine (so, no development stuff on it as of yet whatsoever). However, the recent Ruby update to 1.9.1 brought such big changes that apparently, many libraries don’t work with it anymore – so the installer of choice, the One-Click Ruby Installer, is (for now) stuck at supporting Ruby 1.8.6 only.

Update 2009-06-23 15:12: There seems to be a way to make the one-click installer build Ruby 1.9.1, guess I’ll have to try that out.

The One-Click Ruby Installer is not dead, and there’s even a design vote for the 1.9.1 website. But since I want my development environment bleeding edge and I want it now, I’ll just have to make do with a manual install. Since I haven’t found a tutorial detailing the steps for that, I’ll just do it from scratch and take you along the ride. Good tutorials I did find are:

So, what do we need, for a full-blown environment?

  • Ruby 1.9.1 – obviously, can’t have Ruby without Ruby
  • Ruby Gems 1.3.4 – since gems are the Ruby way of distributing anything
  • Rails 2.3 – obviously, can’t have Ruby on Rails without Rails
  • MySQL 5.1 – the database we’ll use, although others would work as well
  • Mongrel 1.1.5 – reliable and secure webserver

That’s it for the start, but for additional tool goodness (and in order to have some of the above run properly in the first place) we need more:

An intimidating list at first sight, but I did try to get everything I might need in there. The hard part then will be making all of them talk together. Concerning the actual development environment, I am as of yet undecided between gVim and an IDE like Aptana or RubyMine. Both have upsides and downsides.

So, is this list complete, do you see anything I’ve missed? Or do I have anything on it that you think is irrelevant? Let me know in the comments!

So much for talking the talk – the next step will be walking the walk, and I’ll make sure to give you a full tutorial afterwards.

Update 2009-06-24 16:05: Yep, Ruby on Rails is installed. Here is how I did it.

« go backkeep looking »
  • Categories

  • Tag Cloud

  • Feeds & Stuff