soderlind.no

I code for fun

13.11.2008
by PerS
0 comments

Ex Libris

Ex Libris is a “this book I’ve read” application targeting the Norwegian Facebook community. On Ex Libris you can search for books written in and translated to Norwegian. You can add them to your book list, comment, recommend and rate books.

Coding Ex Libris was fun. It’s written in PHP and uses FBML, FBJS, Ajax, PHP MySQL wrapper, CSS The Star Matrix Pre-loaded and Bayesian Rating

As I said, it’s targeting the Norwegian Facebook community and hence in Norwegian. You’ll find it at http://apps.new.facebook.com/exlibris/

15.10.2008
by PerS
0 comments

Microsoft Hyper-V gotcha

..i.e. lack of documentation.

Today I installed Microsoft Hyper-V on our new test server, a HP DL380 with 32GB memory and plenty of disk (800GB in RAID 5 and a hot spare). The install was quick and easy, but getting it on net was not. With a new router/firewall, configuration new to us, we thought it was causing all the “pain” and struggled for hours until we decided enough is enough, let’s continue tomorrow.

Luckily, surfing the net, I stumbled upon the solution to our grieve. Microsoft Hyper-V has its firewall enabled per default (yes, I know, I should have known it was). To managed the hidden features of Microsoft Hyper-V, you have to use netsh from the command prompt, and to disable the firewall (remember I said, we’re using an external firewall, and hence we don’t need the on-board firewall) all you have to do is:

netsh firewall set opmode disable

Hopefully this information will help you when you install your Hyper-V, and hopefully Microsoft will add this to their FAQ.

9.10.2008
by PerS
2 Comments

Facebook ajax rating in php

I’ve written an ajax rating snippet, you’ll find a demo at http://apps.new.facebook.com/ajaxrating/

It is based on Paul OB’s CSS Star Matrix Pre-loaded

The source code below, should be self explanatory, but if you need input on how to do fbjs ajax, you’ll find documentation and examples over at the facebook development site

< ?php
// the $callbackroot MUST point to your server, if you point it to your app.new.facebook.com/APPLICATION, ajax will fail.
$callbackroot='http://[PLACE_YOUR_CALLBACK_URL_HERE]'; // do not add a trailing slash e.g.: http://myserver.domain.com
//AJAX Response (should be first php or in a separate php file):
if (isset($_REQUEST['rate'])) {
    //do something and return "ok" if things are fine
    echo "ok";
    exit; //Important! Stops remaining php after AJAX request is processed
} 

//what ever apicall you use to authenticate, this one is from smiley: http://svn.facebook.com/svnroot/platform/samples/packages/smiley.tar.gz
$fb = get_fb();
$user = $fb->require_login();

?>
<!--  see rate.css below -->
<link rel="stylesheet" type="text/css" href="<?=$callbackroot?>/rate.css" />
<script type="text/javascript">
function save_rating(rate) {
    // array with the class names, used when you add the new class
    var ratings = [ "nostar", "onestar", "twostar", "threestar", "fourstar", "fivestar" ];
    var ajax = new Ajax();
    ajax.responseType = Ajax.RAW;
    ajax.ondone = function(data) {
        if (data == "ok") {
            // remove old class names (I don't know which one, so I remove all of them), and add the new
            document.getElementById('rating_1').removeClassName('nostar').removeClassName('onestar').removeClassName('twostar').removeClassName('threestar').removeClassName('fourstar').removeClassName('fivestar').addClassName(ratings[rate]);
        } else {
            new Dialog().showMessage('Dialog', 'set rating failed');
        }
    }
    ajax.onerror = function() {
        new Dialog().showMessage('Dialog', 'set rating failed');
    };
    ajax.requireLogin = 1;
    var params={"rate":rate };
    ajax.post('< ?=$callbackroot?>/rate.php',params);
}
</script>

<ul id="rating_1" class="rating nostar">
<li class="one"><a href="#" title="1" onclick="save_rating(1); return false;">1</a></li>
<li class="two"><a href="#" title="2" onclick="save_rating(2); return false;">2</a></li>
<li class="three"><a href="#" title="3" onclick="save_rating(3); return false;">3</a></li>
<li class="four"><a href="#" title="4" onclick="save_rating(4); return false;">4</a></li>
<li class="five"><a href="#" title="5" onclick="save_rating(5); return false;">5</a></li>
</ul>

A how-to and the rate.css are located at http://forum.developers.facebook.com/viewtopic.php?id=22547

18.4.2008
by PerS
8 Comments

WP-DenyHost

This is a plugin that will block a spammer if he already has been tagged as a spammer. I use it together with the Akismet plugin. Akismet tags the spammer, and wp-denyhost prevents him from adding more comment spam.

Core functionality :

define('PS_DENYHOST_THRESHOLD', 5);
function ps_denyhost() {
    global $wpdb;

    $suspect = $this->get_IP();
    $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_author_IP = '$suspect'");

    if ($count > PS_DENYHOST_THRESHOLD) {
        exit;
    }
}
add_action('init', 'ps_denyhost');

Download / install: http://wordpress.org/extend/plugins/wp-denyhost/

View-sourcehttp://soderlind.no/code/view/ps_wp_denyhost.php

Changelog (updated 28.12.2009):

v1.1.3: Fixed a minor bug
v1.1.2: Added response 403 Forbidden
v1.1.1: Added languages/wp-denyhost.pot
v1.1.0: Major rewrite. Added option page
v1.0.1: Replaced LIKE (‘%$suspect%’) with = ‘$suspect’ i.e. look for exact match
v1.0: Initial release

11.4.2008
by PerS
0 comments

Last night I became a jQuery fan

You know how it’s like. You start to use a javascript library and you tend to stick with it. I’ve been drifting between Prototype.js and Moo. I’ve looked at jQuery but stuck to Prototype/Moo since I “knew it”.

Last night I decided to rewrite my old check for new ImageManager version routine. Being a script junkie, I thought I give jQuery a chance. It was a joy .. I really like jQuery!

BTW, here’s the result:

<pre><script type="text/javascript">
/**
* @desc ImageManager check for new version script
* @author Per Soderlind - soderlind.no
*/
jQuery(document).ready(function() {
    jQuery.get('http://soderlind.no/imagemanagerversion.txt', function(newversion){
        if (251 < newversion) { // 251 is the version number for the installed plugin, I set number this using PHP
            jQuery('#plugins td.name').filter(':contains(ImageManager)').append('<small>new version available').css('color','red');
        }
    });
});
</script></pre>

Explained:

jQuery(document).ready(function() {
Wait until the DOM is loaded
jQuery.get(‘http://soderlind.no/imagemanagerversion.txt’, function(newversion){
Get http://soderlind.no/imagemanagerversion.txt, and put its content into the variable newversion
jQuery(‘#plugins td.name’).filter(‘:contains(ImageManager)’).append(‘<small>new version available</small>’).css(‘color’,'red’);
In the <div id=plugins>, find <td class=name> which contains the text ImageManager
and append <small>new version available</small>. Using css, set the text color to red.

5.4.2008
by PerS
1 Comment

ImageManager and WordPress 2.5

ImageManager supporting WordPress 2.5 will hopefully be ready by the end of next week.

Update 8.4.2008: ImageManager 2.5 is “working” in WordPress 2.5, but you’ll have to give me a couple of days to get rid of bugs (mainly javascript errors). I’ve been firebugging all night, now I’m off to my day job. I will continue debugging ImageManager later today (i.e. tonight .. this is a midnight hack) .

Update 9.4.2008: All javascript errors are found (according to Firebug) and fixed. Tomorrow night I will do testing.

10.4.2008: ImageManager 2.5.0 is released, you’ll find it at http://soderlind.no/ImageManager

16.4.2008: ImageManager 2.5.2 supporting WPMU 1.3.3 is almost done (should also support WPMU 1.5 when it’s released). I will also test it against WordPress 2.3.x prior to release. The plan is to release it by the end of this week

17.4.2008: I just released v2.5.2 which supports WP 2.5, WP 2.3.3 and WPMU 1.3.3

Note: This is a maintenance release (i.e. no new features are added). It’s only tested with WordPress 2.5 , WordPress 2.3.3 and WPMU 1.3.3, and in IE 7 / Firefox 2.x

PLEASE REPORT BUGS AT: http://soderlind.no/forum

28.10.2007
by PerS
0 comments

Project Portal

The company I work with just launched Project Portal Team Portal.

Project Portal

The key features are:

Project Management Office solution – central location to manage multiple projects

  • Multi-level project/program management hierarchy
    • Portfolio, Program, Project, Sub-Project
  • Customizable in terms of project levels, naming and the amount of process involved at each level
  • Cross project reports
    • At each level of hierarchy
    • For project collections across the various hierarchies

Pre built, standards-based templates to get you on the right road quickly

  • Issue Manager
    • This template is designed for projects where you just want to “manage by exception” by only tracking issues related to the project and not details related to actions, tasks, deliverables, etc.
  • Commitment Manager
    • The Commitment – Issue – Action template is useful for a semi-structured project where you want to manage more than the issues by adding in goal and task lists, but you do not need a fully structured site with a more extensive process.
  • Business Project Manager
    • This template is useful for a range of departments to run their projects including sales, marketing, engineering, etc. It provides a well-defined structure that can be easily customized to meet the specific process and taxonomy for each department and project.
  • IT Project Manager
    • This is a highly structured template that bakes in the Microsoft Solutions Framework v3 to provide a robust process for managing IT projects such as system implementations and upgrades. It includes a pre-defined hierarchy of phases, milestones, deliverables, tasks, issues, and risks.
  • Agile Software Manager
    • This is a fully structured template that includes support for the most common agile process and deliverables for the various project iterations (personas, scenarios etc). This approach is based on the iterative-agile model contained in MSF v4..

Rich project management processes and elements

  • Key project management elements included:
    • Project statement, roles, teams, risk, issues, tasks, etc.
  • Every process element has project management features added
    • Including reference numbering, push notification to assignees, and custom alerts
  • Each element is modifiable in its own right
  • Process elements can be connected in parent-child type relationships

Rich reporting provides visibility to all levels in the organization

  • Pre-defined views for each project management process element including Gantt charts
  • Cross-list work reports for each project template so the team members know what to do
    • Examples: team member work, my work, and upcoming work
  • Variety of convenient distribution methods
    • Printable, Excel – dynamic link or static export, email – on demand or scheduled
  • Reports are easily modifiable by end users without IT support
  • New reports can be created leveraging pre-built reports and some XML coding
  • Report data is exportable to SQL Server Reporting Services for advanced analysis

Securely collaborate and communicate across the extended team

  • Document management – share project documents centrally and use version control to make sure the entire team has the most current information and plans
  • Alerts – keep team members aware of work assignments, e.g., tasks, or be notified when items change
  • Role-based security – assign groups and individuals to appropriate roles on the project team, ensuring they can take appropriate actions and see appropriate information for their role
  • Tight integration with Microsoft Live Meeting and implemented solutions for planning, setting up, conducting and archiving phone and video conferences directly from your project room gives you added control of your project

7.1.2007
by PerS
0 comments

Sandbox Skin Editor

Note: This is work in progress, when the editor is done, it will be announced here.

I’m coding a skin editor for the sandbox theme. The code will be gpl, so you can adjust it to other themes, but I will only support the sandbox theme.

Here’s a demo of the prototype: http://soderlind.no/demo/skineditor.php

v1.0 will:

  • support both WordPress 2.x and MU
  • have a preview
  • allow you to save a style to a temporary file prior to publishing it (for testing)
  • in MU, save the style to wp-content/blogs.dir/$wpdb->blogid/css
  • filter the saved css to prevent xss

btw, if you don’t know the Sandbox theme, have a look here: http://www.plaintxt.org/themes/sandbox/. It is one of the easiest/best themes to use as a building block for creating your own themes using css.