Geronimo89.dk

A blog about me, my doings and everything I think deserves attention.

so many projects

So, I’ve got a lot on my hands and it’s so much fun rapidly developing and already writing on my new blog.

New blog?!

Yeah, new blog, but don’t worry icon wink so many projects This will remain
I’m going to make a blog about blogging (yay icon biggrin so many projects ) and it will be entirely in German.
It will be called Vollzeitblogger.de and I will spill all I’ve learned from blogging here and there and basically be a startup guide, improvement camp and pro tip place for aspiring bloggers.

On the page you see a little script I wrote with CodeIgniter and jQuery today. The source will probably be published once it is mature enough. It saves email adresses and names right now, later on you’ll be able to bulk email people when your project is taking off.

But what about your specialisation?

Yeah, I thought you’d ask that. I’m still working on my twitter clone ROARER and I’ll get as far as I can for the exhibition friday next week. Everybody will be able to participate, because it will be accessible for everybody at that point.

Wait, you’re doing more?

Yeah, I’m currently working on making a pastebin for translations and writing a WordPress theme. The pastebin will show original text and translation side by side. Functionality for annotations and revisions will be added later on. I feel that I’ve really lacked a tool like this, especially for showing song texts beyond the language they were written in or working on multilingual blog posts.

PS: My portfolio just reached pagerank one, yay!

Only 1 comment so far

PHP explode and implode

I think PHP is one of the few place where you can explode and implode without being a terrorist but still have fun with it. At least explode() is one of my favourite functions in PHP icon smile PHP explode and implode .

For this little quick tip I actually have a quite practical use case I stumbled upon a couple of days ago. The jQueryUI datepicker widget. It lets the user pick a date, which you automatically can insert into a form. You can define different formats like day day, month month, year year and so on, whatever makes you happy, but to save it in a MySQL database you might want to convert it to the typical yyyy-mm-dd format. For that we spread the string we pull from the form at 2 different places (where the datepicker sets the slashes).

explode()

Exploding may sound a little extreme in the beginning, but it’s just a function to split a string into an array at certain points.

$explodeable = '28/05/2011';
$exploded = explode('/',$explodeable);
print_r($exploded);

// generates output:

Array ( [0] => 28 [1] => 05 [2] => 2011 )

implode()

Now, we still have to get the year, month and day together again to put it in a MySQL DATE or DATETIME field, so let’s look at the solutions we have for that with implode. Implode just puts a string together from an array with or without a certain character between them.

$exploded = array_reverse($exploded);
print_r($exploded);

// generates output:
Array ( [0] => 2011 [1] => 05 [2] => 28 )

$imploded = implode('-', $exploded);
echo $imploded

// generates output:
2011-05-28

For this it works perfectly, but you can also chain the different values of an array as following, if array_reverse can’t do the job and you want to sort your entries manually. This solution gives you more flexibility, also with the characters in between the split values.

$chained = $exploded[2].'-'.$exploded[1].'-'.$exploded[0];
echo chained;

// generates output:
2011-05-28

Thanks for reading my little quick tip on date conversion between the jQueryUI and MySQL, have a nice time everybody icon smile PHP explode and implode

Only 1 comment so far

CodeIgniter, my personal ignition

ci logo flame CodeIgniter, my personal ignitionOkay folks, I should tell you, I’m not missing any limbs, my apartment wasn’t on fire and not even my computer. Anyways I have been digging into the PHP framework CodeIgniter. Originally CI was brought to my attention by Kenneth and recently I picked up a project that really screamed for dynamic structure, scalability and classes with some built-in security features.

What I think is remarkably positive about the framework, is that the user guide actually is shipped with it, so you easily can start learning it without constantly being on the net.

CodeIgniter does well what frameworks should do. Distribute versatile tools for faster development of common tasks. It’s like a workbench for webdevs.

The first thing I noticed when I was watching the series of video tutorials on net.tutsplus.com called CodeIgniter from Scratch, that the naming conventions have been changed. To be fair it has to be said, that these video tutorials were submitted in 2009.

What exactly changed?

The internal naming conventions of classes!

// before:
class Site extends Controller {
    function foo(){
    };
};

// now:
class Site extends CI_Controller {
    function foo(){
    };
};

If you don’t take this into account you’ll receive error messages like:

Fatal error: Class ‘Controller’ not found

Now if you think I’m paid by the tutsplus guys, you’re wrong, but still here’s a list of chapters, covered in the video lessons:
Overview of chapters:

  1. Getting Started With the Framework
  2. Database Selecting Methods
  3. Sending EmailsNewsletter
  4. Signup
  5. CRUD
  6. Login
  7. Pagination
  8. AJAX
  9. File Uploading and Image Manipulation
  10. The Calendar Library
  11. File and Directory Operations
  12. Shopping Cart
  13. Extending the Framework
  14. Security
  15. Profiling, Benchmarking and Hooks
  16. Displaying & Sorting Tabular Data
  17. Search Results without Query Strings

You don’t have to watch them in this order, because mostly you can learn independently about the separate chapters. Though I would recommend, that you in any case start out with 1, because it also gives you an idea how the model, view, controller (MVC) pattern works.

I really thank the author, Jeffrey Way, for making this series. He’s done very well, although sometimes not everything is planned out, facebook is accidentally open, typos happen and sometimes windows are switched to switch back again. This all still makes it authentic and the quality of the screen cast is improving with every episode.

I’m not through with all the videos, but so far I can really recommend them.

EDIT: Wed May  4 03:00:48 CEST 2011
I just noticed, that in episode 6 there was an error I could not easily overcome. I got the following error message:
Fatal error: Call to undefined method CI_Controller::Controller() in /Users/gero/Sites/my_proj/application/controllers/site.php on line 7

file: site.php

// before:
function __construct()
{
	parent::Controller();
	$this->is_logged_in();
}

// fix:
function __construct()
{
	parent::__construct();
	$this->is_logged_in();
}

Simply change the Controller to __construct and you’re going again. In the CI forums it’s recommended to use a library for authentication though.

2 comments already

freshing up my blog

Since my portfolio has been up, my blog has not gotten the love it used to get, so I decided to strip some things off and give it a new sexy booty face! So this is what it looks like so far. There is still some optimising ahead, but this is the general layout.

Primarily I used a custom written theme with that sexy little date box. The rounded corners are CSS3 without IE fallback (suck on it sucky browser users) and the blueprint css framework. The Fonts used are ChunkFive and DeJaVu Serif.

For everybody interested I have made the use of borders a little easier for me by putting them into separate classes for easier re-use.

.border_top {
	-webkit-border-top-left-radius: 10px;
	-webkit-border-top-right-radius: 10px;
	-moz-border-radius-topleft: 10px;
	-moz-border-radius-topright: 10px;
	border-top-left-radius: 10px;
	border-top-right-radius: 10px;
}

.border_bottom {
	-webkit-border-bottom-right-radius: 10px;
	-webkit-border-bottom-left-radius: 10px;
	-moz-border-radius-bottomright: 10px;
	-moz-border-radius-bottomleft: 10px;
	border-bottom-right-radius: 10px;
	border-bottom-left-radius: 10px;
}

.border_all {
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
}
8 comments already

Making exceptions for WordPress URL rewriting

If you, as a bunch of other people out there, also are running a WordPress powered website, you may also want to use it for something else. To do that, you have to access data around WordPress rewriting engine. The rewriting is responsible for showing urls instead of urls like:

http://jmh-visual.com/?p=32

you get:

http://jmh-visual.com/2011/03/colourful-night-in-kolding/

which is great! They are a lot more understandable for humans. Problematic is a case when you just want to put a a file, another web-project, or even just demonstrate something for a tutorial you wrote. WordPress will capture, what you write behind your domain name and try to assign it to content in the system. To change that, we just need to change the .htaccess file in the root folder of your webspace. Connect to your webspace with an ftp client like Cyberduck and open .htaccess (If you don’t see that, try enabling hidden files).
You’ll probably see something like this:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

So let’s say we want to make the folder helloworld in the root folder accessable to people, without WordPress trying to find a page or post with that name.

# BEGIN WordPress
RewriteEngine On

RewriteBase /

RewriteRule ^helloworld($|/) - [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Only 1 comment so far