GrabIt – Repair it – out the name of the par2 file from the command line

Is your GrabIt newsgroup leecher not unpacking your downloads anymore? Does it flash the following warning at the bottom of the screen:

Repair it - out the name of the par2 file from the command line

If you have this problem, then I have your solution! Check your download folder and see if any foldername ends with “.par2” or “.PAR2” or “.par” or “.PAR” or anything like that. If you found folders ending with “.par2” you should remove that from the folder name, so just rename it and remove the .par2/.PAR2/.par/.PAR from the folder name. It is a folder and not a par file, so it should not have this extension in the folder name.

Note: You should only change the foldername when GrabIt is DONE downloading/extracting, or change a folder name GrabIt is not currently using to download to or extract from. If you do this anyways you will mess things up and I will not take responsibility for it…

When you resolved all folder names to be without .par(2) extensions the repair and extract now functionallity will once again work like it has before!

What GrabIt does is checking all files/folders in the download folder and checks to see if the file/foldername has some kind of .par extension. Because it can’t handle a folder to use as par file you will receive the error message stated above.

Good luck resolving your problems!

Happy downloading!

Server refused our key

I have been trying all day to set up SSH keys on a linux server and Windows 7 client, finally with succes.

The way I managed to finally do it is like this:

  1. Log into your linux server
  2. Type:
    ssh-keygen -t dsa
  3. Accept default filename
  4. Provide a strong passphrase
  5. The keygen will create two files: id_dsa.pub, and id_dsa. The first one is the public key (.pub), the second one it the private key, copy this to your Windows 7 client.
  6. While stil on your server, now put the contents of id_dsa.pub into ~/.ssh/authorized_keys
  7. Make sure you
    chmod 600 ~/.ssh/authorized_keys
  8. Now move to your Windows 7 client and run puttygen.exe
  9. Load the id_dsa you have copied from the server
  10. Enter the passphrase
  11. Now use the save private key button to save the private key in putty .pkk format
  12. Now open putty and go to: Connection » SSH » Auth and browse for the .pkk to use as private key
  13. Now click open and you should be able to login into your server without the text: Server refused our key

If you followed the above and it still shows the text: Server refused our key, just read on…

Bonus steps that might solve your problem:

  1. In your server console issue the command: hostname
  2. Your hostname will be shown now, write it down or remember it
  3. Now start putty and in the Host Name (or IP address) input field enter that hostname (I am assuming you have allready set up a working hostname)
  4. With the .ppk selected as in step 11 press Open and you will be able to login without the text: Server refused our key

The first 13 steps are quite obvious, but it took me some time to notice that you really have to use the hostname. Before when I was just using a local IP address like 192.168.178.100 I could still login with putty, but the key would not be accepted, now that I’m using my hostname I can succesfully login on the server. There are a lot of tutorials like this one on the web, but none of them told me to use the hostname you have set up on your server!

PHP Singleton

Singleton Design Pattern for PHP5.3

I would like to share a very simple Singleton class with you. I’ve created this long time ago, but since I decided to continue blogging again, I will just copy paste this with some explanation to make a start at blogging again:

First take a look at the code, then read the explanation that follows.

<?php
/**
* Very simple Singleton object
*
* @author Dino Hensen
*
*/
abstract class Singleton
{
/**
* Member variable holding an Singleton instance
*
* @var Singleton
*/
protected static $_instance = null;
/**
* Returns new or existing instance of Singleton.
*/
final public static function getInstance()
{
if(null === self::$_instance) {
self::$_instance = new static();
}
return self::$_instance;
}
/**
* Prevents external object creation
*/
final private function __construct() { }
/**
* Prevents object cloning
*/
final private function __clone() { }
}
?>

Singleton code Explanation

A class for which you want only one instance to exist at all times is very common in software systems. It is called a Singleton!
A Singleton design pattern ensures that it is never possible to create more than one instance of a class that extends the Singleton class defined below.

By using a private constructor you ensure that no other class will be able to create an instance of Singleton class. By adding final to all functions you ensure that no extending class will be able to override this functionality and thus hack your Singleton class.

The getInstance function works as follows: the first time the function is called a Singleton object is instantiated for which protected static $_instance holds a reference to this object. The next time you call getInstance the instance already exists so the reference to the instance is returned. Remember, PHP5 does not pass objects by-value anymore, but instead passes by-reference.

Notice

The Singleton code relies on using PHP5.3 because of something called late static binding.

self::$_instance = new static();

new static() in PHP 5.3’s late static binding refers to whatever class in the hierarchy which you call the method on. We need this because PHP needs to know which object to instantiate, that is a ‘Singleton’ or ‘Boss’ object. You can read more about late static bindings at: http://www.php.net/manual/en/language.oop5.late-static-bindings.php

Usage

And this is how you use it:

<?php
require_once "singleton.class.php";
class Boss extends Singleton {
/**
* Returns a bossy text
* @return string
*/
public function whoIsTheBoss()
{
return "I am the boss!";
}
}
$boss = Boss::getInstance();
echo $boss->whoIsTheBoss();	//I am the boss!
?>

You can create a new class which extends Singleton and give it some functionality. Then you can create the object using the public static getInstance function which returns a reference to a Boss object. You now safe the reference in the variable named $boss. When running the code it shows you who’s the boss!

PHP Tutorial 2 – Basic syntax

Hello this is tutorial #2!

This tutorial will teach you basic PHP syntax. Any PHP scripting block always starts with <?php and ends with ?>, although some server configurations allow <? for a starting tag, I recommend always using <?php as a starting tag for maximum compatibility. So we always start and end like this:

<?php
//some code here...
?>

In my code fragment above you might have noticed ‘//some code above‘ The two forward slashes mean a comment is following. This kind of comment is called a single-line comment and is terminated when you insert a newline character.
For multi-line-comment use this construction:

<?php
/* Multi Line Comment started...
You can continue on this line...
and even on this line...
But after the multi line comment stop, things you type will be interpreted as code again
*/
echo "This is a little bit of code that will be executed";
// echo "This line wont be executed because it's commented!";
// So after the */ you can type code again
?>

So now that you know basic php syntax for starting and ending a php scripting block, I will finally introduce you to using variables! Continue reading PHP Tutorial 2 – Basic syntax

PHP Tutorial 1 – Getting started with PHP using WampServer2 on Windows 7

Hello all,

Here is the first of tutorials that I will make to cover the basics of PHP. My goal is not to have yet another tutorial-blog/site, but to show how I got started with PHP and eventually show some advanced things you can do with it. To reach that goal, I first want to introduce ‘newbies’ to PHP. In this tutorial I’m going to assume you have basic knowledge of HTML, which will be used sometimes in examples. If you don’t know HTML, I recommend visiting w3schools.com

What is PHP?

PHP is a scripting language which is used among others for creating dynamic web pages.

What does PHP stand for?

PHP stands for: Hypertext Preprocessor. You might ask me what the first P stands for… well, back in the days PHP used to mean: Personal Home Page, but then they wanted something more sophisticated and changed it a little while keeping the first P.

What can you do with it?

There infinitely many things you could do with PHP, but it comes down to this list of general subjects:

  • create dynamic web page
  • create web application
    • PhpMyAdmin (database management system)
  • create a CMS(content management system)
    • WordPress
    • Drupal
    • Joomla
  • create <script_name_here>

Continue reading PHP Tutorial 1 – Getting started with PHP using WampServer2 on Windows 7

Clone Object as instance

Autodesk 3DS Max + OgreMax exporter

The goal of this tutorial is to create instances of objects instead of copies to improve loading time in games developed using the Ogre3D Graphics Engine in combination with a so-called DotSceneLoader. A DotSceneLoader is a library that loads a ‘.scene’ file generated by OgreMax exporter. OgreMax exporter is used to export 3D scene’s created in Autodesk 3DS Max. The problem is that sometimes when you want a lot of same objects in your scene, you have to clone those objects, seems obvious…… Continue reading Clone Object as instance

First post

Hi all,

I’ve decided to stop my php framework development to create my website, because I just don’t have enough time to do it anymore. Instead I will now use WordPress, because it’s plain and simple and easy to install!

I wanna post some random stuff about things I’m doing, think about PHP/MySQL/HTML/Ajax webdevelopment or die-hard programming C++/C/Java.

~Dino (yes this is really my name)