Archive for category ‘Misc’

JavaScript minifier filter module for Roxen

Nowadays web sites and web applications tend to be more and more JavaScript driven which results in humongous JavaScript files. It’s not uncommon to have several 100 of bytes of JavaScript on a site. Of course web browsers cache stuff like JavaScript so that it only is requested from the server once. But judging from the visitor logs at work most people only visit our site once a month or so which means that cache will expire and all those scripts has to be requested upon the first visit.

Now, there are several ways to compact JavaScripts: Packer, YUI Compressor, Shrink Safe, jsmin and many more. Some of these just remove redundant white space and comments, some obfuscates the code and shortens variable and function names and what not. Many of these scripts and programs are very fine but they require you to manually minify your scripts, and that’s just a hassle!

But since we use Roxen CMS at work things get much easier if you write your own Roxen filter module which automatically minifies JavaScripts on the fly, given they meet certain criteria. And so I did!

I ported the original jsmin code written in C to Pike. Then it was just a matter of creating a simple filter module for Roxen. And then it was all done.

You can use two criteria to determine if a script should be minified or not:

  1. Path glob: In the module settings you can specify any number of directory globs or full paths. If a requested JavaScript either is in a directory matching a glob or is a direct match it will be minified.
  2. Query string variable: In the module settings you can define a variable name that if exists as a query string variable in the request the JavaScript will be minified. So:
    <script type="text/javascript" src="myscript.js?jsmin=1"></script>

    will minify myscript.js

And that’s that!

jsmin Roxen filter module 13:34, Mon 28 June 2010 :: 6.1 kB

Blue Screen of Death

You don’t get surprised when you get to work one morning and your monitors looks like this, given your computer is running the bless from Redmond!

Man I wish I was running Linux at work as well!

(And no: I hardly drink any Coca Cola at all ;) )

Gravatar module for Roxen

Although I’m working on some social web related Pike modules where a Gravatar module is included I needed a Gravatar module right now at work so I hacked up a standalone Gravatar Roxen module.

This is how it works

12 lines of RoXen Macro Language
  1. <ul>
  2. <emit source="sql" host="mydb"
  3. query="SELECT name, email, `date`, body FROM my_comments"
  4. >
  5. <li>
  6. <gravatar-img email="&_.email;" rating="pg" size="32"
  7. default-image="/path/to/icon.png"
  8. /> &_.name; wrote at <date iso-time="&_.date;" />
  9. <wash-html paragraphify="">&_.body;</wash-html>
  10. </li>
  11. </emit>
  12. </ul>

Download the Gravatar Roxen module 14:20, Wed 09 December 2009 :: 7 kB

A change of times

old Pripps ad

Times are changing! This old beer ad is in Swedish but in short it says:

Pripps in a new disposable pack, for the sailing tripp. Extra tip: Make a hole in the bottom of the empty pack and it will sink faster.

It feels we at least have come some way regarding recycling.

Click on the image for a full scale version.

Annoying Wordpress thing…

It seems Wordpress is hard coding the domain name into the database. How smart is that, or have I missed something? When I first set the site up on my local development server I soon noticed that various links were written hard with the domain and everything. Obviously that would f**k thing up once the site was moved to the public server. So I went into the settings and saw that there were two fields – Wordpress address and Blog address – containing absolute paths. So I changed them to relative onces, e.g /blog instead of http://strindberg.loc/blog and things seemed to work properly.

Now I just realized that the guids in the RSS feed pointed to my development server. I looked in the database table and saw that there were hard coded references to http://strindberg.loc. So with a little UPDATE wp_posts SET guid = REPLACE(guid, 'strindberg.loc', 'www.poppa.se') I thought I had solved the problem. But then I realized some other guids in the RSS is generated on the fly, and they get f**ked up since the Wordpress address now is relative and thus some guids looks like http:///blog/some-url/. Is that good or what?

And try to figure out how to find out where those guids gets generated. My idea was to find where they are generated and there insert the HOST dynamically, but since there’s a zillion apply_filter(...) it’s virtually impossible to find where the shit gets generated (thanks to Netbeans it’s otherwise simple to follow the chain of execution. Just ctrl+click on a function call and the source of that function will be loaded.)

Ok, so now I have to put on my Sherlock hat and see if I can solve this. I find it hard to believe you shouldn’t be able to move a Wordpress site from one domain to another without having to work your ass off!

If anyone have a solution – it’s perfectly possible I’m missing out on something here – I’m happy to know!

Finally a new site!

New version of poppa.se

It hit me I hadn’t done anything to my site for three years. After all I’m a web developer and some kind of standard must be met and kept!

The previous version of this site was built on my home cooked blog application. But that was written three years ago and you learn, and develop skills, a lot over three years, so I didn’t feel like reusing it and it was kind of limited regarding lots of stuff – like social networkning – that has emerged over the past few years.

Since I’m an open source advocat I decided to live as I learn and went for Wordpress. It was really simple to setup and the admin interface is rather uncluttered and easy to use. Although I’m not too fond of how the backbone of Wordpress is coded and structured it’s fairly easy to bolt on your own functionality.

Hopefully this new version of the site will make me write more than two posts a year, but I wouldn’t bet on it ;)

Visual C# 2008 Express bug

The other day at work I was hacking up a console application that converts an Excel workbook to chosen format. This is to be used in a web application where some people can upload an Excel file that will populate a MySQL database. To make it easier to parse the Excel file the console application will save a copy of the file as a tab separated file that is easier to parse (I will share the code when done).

vs-express-def
Visual C# 2008 default layout

Anyhow! At work I use Visual C# 2008 Express Editon when – very rarely – hacking C# and it annoyed me that the code part was too far to the left for me to feel comfortable. So I though I could displace the right column with class viewer and solution explorer and put that on my right screen, narrowing the main window and put farther to the right on my left screen.

Error message when Visual C# crashes

So I did and it felt alright – until I tried to compile the application. Visual C# just crashed big time! I didn’t have any clue why at that moment so I fired it up again and had to displace the right column again and put everything where I wanted it. I tried to compile again and boom, crash again!

So I thought: What the heck! Fired the thing up again, displaced the right column but this time I thought I’d just close the application so it would remember my settings the next time it was started. So I just hit ALT+F4 and boom, crash again. After repeating this again I came to the conclusion that Visual C# 2008 crashes if you displace the right column and then tries to either compile the current project or close the application it self. There’s probably some other actions that will cause it to crash as well.

vs-expressMy desired layout

The final conclusion is that I will have to use the application layout dear Microsoft has decided I should use. Thank you very much! Okey, I can live with it but it’s a bit annoying!

Firefox Domain-Swapper extension

The Domain Swapper extension is hosted here at poppa.se now a days.

Anybody working on a replicated web site (with an edit/backend server and one or more frontend servers) with perhaps lots of sub sites has probably experienced the hassle of switching domains between the backends and frontends.

Say you get an email saying: Can you change … to … on http://some-front-end.com/some/path/to/a/page.html. You click on the link, since you’r lazy, and then have to change the domain in the address bar to your backend domain and 40% of the time you misspell and have to go up there again and…

Anyhow! I got tired of this so I created a domain swapping extension to Firefox. It adds a context menu (right-click on any page) where you can choose to change to another domain – the URL will stay intact.

So if you are working with replicated sites the extension is free to download at:

http://www.tekniskaverken.se/fishnet…pper/index.xml

A couple of wallpapers

Lately I have found a new time waste – playing with Photoshop and Gimp to create desktop wallpapers. I must say Gimp isn’t too bad although it’s quite far behind Photoshop when it comes to usability and especially layer styles. I downloaded a plug-in that works pretty well and similar to the effects in Photoshop, but the big difference is that the effects will be put in separate layers in Gimp which means you can’t fine tune them in real time afterwards. And one really misses the layer folders! Anyway, Gimp works pretty well and when you get used to the differences from Photoshop and you learn the shortcuts it’s quite usable after all.

All wallpaper are in 1680×1050px

Chocolate – Made with Photoshop
Chocolate

Fairytale – Made with Photoshop (image and butterfly from Stock exchange)
Chocolate

Gnome Shield – Made with Photoshop
Gnome Shield

Gnome Shield 2 – Made with Gimp
Gnome Shield 2

Gnome Shield 4 – Made with Gimp
Gnome Shield 4

Roxen User Conference (cont’d)

So the Roxen User Conference has come to an end. It’s always nice to meet with people who speak the same “language” (the language of the geeks perhaps), to share experiences and solutions. And of course it was nice to see the Roxen Editorial Portal in action. That’s a pretty cool piece of web based software. It was also nice to get a preview of Roxen CMS 5.0. It will have a few new features that will be nice and perhaps the greatest thing is that it will incorporate Pike 7.8 (which in it self hasn’t been released yet).

Anyway! For me it was a great experience talking to other Roxen customers and share some ideas and views. Oh, and one more nice thing: during the conference Roxen released a community site – planet.roxen.com. I hope it will be a great resource for us Roxen customers and users.

Roxen User Conference

Ok, so now the first day of Roxen User Conference is about to end. The has been some interesting speaks today and a few new acquaintances. The most impressive thing is to have see how different companies and institutions have implemented the Roxen platform. To me Roxen is not just a CMS but a great development platform and from my new experiences from all over the world today my conclusion is I’m not the only one with that standpoint.

Of course there’s been a few drinks (beer, wine, whiskey and what not) but also some new friends and faces to known names. And of course there’s also been some sharing of code concepts and what not.

Tomorrow there will be some more hands on workshops. Roxen will demo their new “Link management module” which will be part of the 5.0 release. It looks really promising from the previews we’ve seen today.

In the 5.0 release they will also bring to live a new patch module which will ease the maintenance of a Roxen empowered server park in a tremendous way. That feature will be awesome.

One cool thing in particular is to have seen a demo of the Roxen Editorial Portal. A few newspapers are already running it located from Sweden to USA to Australia. A really cool achievement for such a new product! You guys at Roxen rules!

I will give a new sum-up of tomorrow’s events!

Back from vacation

So after five weeks of vacation I’m back at work. The most sensational thing must be that I didn’t write a single line of code in these five weeks! It was a much needed break from computers and the longest one I’ve had for the nine years or so I’ve been programming. The vacation it self isn’t much to talk about. I visited friends and family and spent a lot of time in the sofa watching the olympics – and playing some Play Station 3 as well ;)

I also just bought an Asus EEE which I think is quite cool. I’m actually writing this blog post on it. I threw out the Xandros operating system and installed Ubuntu EEE instead which feels a great deal better. I’ve installed a lot of developer tools and they actually run rather smoothly.

Screen shot Ubuntu EEE
Screenshot Ubuntu EEE

Roxen user conference

Next week, Thursday and Friday, I will attend the Roxen user conference which I’m really looking forward to. I’ll give a report from there when it happens.

International Womens Day

Logo: International Womens DayI thought I should honor the fact that today is the International Women’s Day. I think this is a day when we all should take the time to think about how the equality between men and women is holding up. It’s a fact that men has advantages in society at large; higher salary for equal work, more higher placed posts in powerful positions (take a look at Worldwide Guide To Women In Leadership) – more power for short – and the list can be made long. To honor this day I will below make a tribute to women I admire! And the order in which they appear i purely random.

Susanna Kallur

Susanna KallurSusanna – or Sanna as she’s called in Sweden – is currently the worlds fastest short hurdle runner and holds the 60 meters hurdle indoor world record – 7,68 seconds. I’m probably not the only guy (or woman) who like her since she’s probably the most beloved athlete in Sweden. What I like about Sanna is that she seems to be so incredibly secure in her self, extremely humble and very witty. It’s always great fun hearing her being interviewed after a race. So besides the fact that I find her to be very beautiful I admire her for the fact that she’s one of the most shining track and field stars in the world and still being so down-to-earth, but still you wouldn’t mess with her!

And by coincident she’s running in the World Indoor Championships this very day! Go Sanna

The image of Sanna Kallur is stolen from Aftonbladet.se and I am shameful!

Women in computing

Logo: LinuxChixIt’s no secret that women are under-represented in the world of web and software development! The reason for this I believe is purely an environmental/socializational thing. The same phenomenon can be seen in a wide range of areas and goes both ways for men and women. We are as children being taught what to wear, what to play with, how to speak and behave and so on, and the difference in how parents treat their sons and daughters is vast. It is, or at least it has been, a social standard that girls don’t get encouraged “playing” with computers which means they don’t grow any interest in using a computer in any other way than just using it! I’m will not bother ranting about this since there’s a ton of sociological studies addressing this problem – and I don’t mean the specific computer thing ;)

One thing that we male web and software developers can do to make it easier for women to participate in the world of software development is stop being so freaking sexist and boyish on email-lists and web forums. Sometimes you get worried when you see the tone in which some of the discussions is conducted on web forums for developers and I can really see why women get scared away. On one forum I participate in a girl asked a question – it was her first post on the forum – and the first reply she got was something in line with: Oh, you are a girl! Are you good looking?. No wonder I never saw her signature there again! I think we have a “Moment 22″ here: Since there’s almost only guys on these places it’s easy the tone gets boyish and that scares women away. So I think we guys need to think carefully about how we express our selfs on public email lists and web forums.

This is something that has been addressed by women and there seems to be a few organizations for “women in computing” that strives to make a change in, among other things, this area. Some organizations that deserves attentions is LinuxChix, Debian Women and GenderIT and I’m certain there are more than those two.

And here’s something to dig into: HOWTO Encourage Women in Linux, which I think also addresses women in computing in general.

Go ladies!

Women in my life

A day as this I must of course acknowledge the women that means the most to me, namely my Mom, my two sisters and my three sisters daughters. I love you all and I highly admire my sisters for their strength of personality, for what they have become and for how good mothers they are and for their beautiful families.

Now I just have to meet girlfriend!

A tribute to the International Womens Day

Firefox 3, Thunderbolted lightning…

What have they done to Firefox 3? I have a 64 bit system and still there are some things that doesn’t run on 64 bits, Adobe® Flash Player® being one of them. Another, more important, thing that doesn’t run when launched from a 64 bit browser is my Citrix® VPN client which I use when logging on at work from home. Anywho! There’s a browser called Swiftfox which is an optimized build of Mozilla Firefox® for Linux. The good thing is that Swiftfox runs in 32 bit mode so the Flash Player works and my Citrix client starts.

So what am I talking about! I noticed when I started using Swiftfox – which is built on a Firefox 3 beta release – that it’s insanely faster than Firefox 2. And I really mean insanely faster. Of course, as I said before, Swiftfox is an “optimized build of Mozilla Firefox for Linux” but I have used Swiftfox built on Firefox 2 before and that one wasn’t close to as fast as this last one is.

I think the Firefox team must have done some wonders to the rendering engine. I must admit that Firefox always has been a bit slower on Linux than on Windows and Mac so I pleased that Firefox 3 seems to be fastest browser ever known to mankind ;)

My first GIMP job, Gnomealicious!

Although I’ve been using Linux for eight years I have never really used GIMP since I’m brought up with Photoshop. But lately I’ve started using it to make a few layout elements for various web projects and although It’s quite frustrating when you all the time hit Photoshop shortcuts and end up with the wrong tools and what not, GIMP really isn’t that awful when you start to get grip of it.

Anyway, I did a re-install of Ubuntu the other day and found a theme for Gnome that I really liked but I had no desktop wallpaper that fitted so I though I’d better make my own. And so I did!

Screenshot
Gnome Compiz-Fusion screen shot

The wallpaper, 1680×1050
Gnomealicious desktop wallpaper

So I’m about to become better friends with GIMP!

Peace out!

Better late than never

It’s amazing that I havn’t posted an entry here for more than six months! I’ve had so much to do at work so I havn’t had the driving force to bother! We’re about to release a redesign of www.tekniskaverken.se which have taken quite much time. We’re also about to update both the server hardware and software. We’re going to use Roxen replication and load balancing which means we’re going from one standalone server to three servers!

I’ve also been busy developing “My Pages” at Tekniska Verken where our customers can log on and view consumption statistics for water, district heating, electricity and waste and much more. The statistics part has existed for years but the functionality has been rewritten from scratch where webservices SOAP) for our business system has been developed and the overall functionality has been extended and improved.

The fun thing is that I have written the SOAP clients in Java – since Pike (the language used in Roxen) doesn’t have a SOAP implementation yet but do talk to Java quite nicely – which I’ve never touched before. Java is a nice language but the Classpath thing drives you crazy! Anyway, with WSDL and Eclipse there has been no problems. There’s currently 13 webservices available and I don’t think I’ve even written 2000 lines of Java to implement them. SOAP is really nice I must say! So now I also can add Java to my CV ;)

Hopefully the new www.tekniskaverken.se will be released within a month or so!

Syntaxer 2.0.2 released

This script is part of PLib

A few bugs was fixed in this release. I also noted a few new ones but that was mostly in the SyntaxMap class which gererates PHP arrays from the SyntaxMap files.

Changelog for this version

  • Fixed a bug where the end of strings (quotes) wasn’t found correctly in languages that has no escape character (like XSL, XML and HTML).
  • Also changed the Syntaxer::AutoDetect() method to return the extension of a file if no alias was found. In this way we can pass a path to the method and use the result directly as argument to `Sytaxer::__construct()`
4 lines of PHP
  1. $file = '/some/path/to/file.xsl';
  2. $lang = Syntaxer::AutoDetect($file);
  3. $stx = new Syntaxer($lang);
  4. $stx->Parse(file_get_contents($file));

The Syntaxer can be read about and downloaded over here.

Redroom with no comment spam?

So I’ve worked some on Redroom and the main thing was to stop the ability for robots to add comments. It will be interesting to see if it works or not, but if it doesn’t work I have a Captcha solution ready to use.

Since Captcha might be troublesome for people with impaired vision I tried a homebrewed version that doesn’t include an obscured image. The downside is that it doesn’t work with JavaScript turned off but on the other hand that means that robots shouldn’t be able to spam either.

Other than that this version of Redroom doesn’t include any new features. Some minor bug fixing was done and some code cleaning.