• Main
  • Simple Zen
  • B2evo
  • Tutorials
  • Plugins
  • Testlab
  • Chess
  • Dilectio
  • Illacrimo

Tutorials

Tutorials and programming

Manipulating the title with a plugin

tilqicom came with a problem. He wanted some specific changes to the title of a post automated. At first I got it wrong, thinking that he wanted some text replacement in the body of a post. That's fairly easy, use the RenderItemAsHtml function in a plugin. When I finished that I heard that he specifically wanted to automatically change some text in the title. We are talking about a change like the input '[date]' to 'Tuesday March 24 2008'.

That caused some serious problems because I hadn't seen it done before. ¥åßßå however had and pointed me in the right direction, I had to use the (Un)FilterItemContents( & $params ) functions. They filter (and you can make changes) at the point where you enter the write section and at leaving it (hit 'save'). Furthermore the $params are passed through the functions so both $params[ 'title' ] and $params[ 'content' ] are available.

Let's have a look at the results. This is the FilterItemContents function that is called after leaving the edit / write section of a post:

PHP:

function FilterItemContents( & $params )
{
    $title = & $params[ 'title' ];
    $content = & $params[ 'content' ];
    
    if( strpos( $title, '[cat wrote]' ) !== false )
    {
        global $edited_Item;
        $original_title = $title;
            
        $foo = get_the_category_by_ID( $edited_Item->main_cat_ID );
 
        $title = str_replace( '[cat wrote]', $foo[ 'cat_name' ] . ' wrote: ' . implode( ', ', $edited_Item->get_tags() ), $title );
 
        $params[ 'title' ] = $title;
        $original_title = '<!-- item title ' . $original_title . ' -->';
        $content = $content . $original_title;
        $params[ 'content' ] = $content; 
    }
 
    return true;
}

The magic quote here is '[cat wrote]' in the title of the post, so we first filter the title on the presence of that line. The long codeline does the hard job, it changes the magic block into something else and if you plan to use this block, this is where you should focus your attention upon.
What's next is an improvement I made later on. We store the original title in a comment in the post. That we will retrieve in the UnFilterItemComments function.

In that function we see a partial reverse, I am trying to restore the original situation:

PHP:

function UnfilterItemContents( & $params )
{
    $title = & $params[ 'title' ];
    $content = & $params[ 'content' ];
 
    // global $edited_Item;
    if( strpos( $content, '<!-- item title' ) ) 
    {
        $original_title = $content;
        preg_match( '~<\!\-\- item title (.+?) \-\->~', $original_title, $original_title_array );
 
        $params[ 'title' ] = $original_title_array[1];        
    
        $content = preg_replace( '#<!-- item title .* -->#', '', $content );
        $params[ 'content' ] = $content;
 
    }    
 
    return true;
}

First of all we look for the comment in the body of the post. If it's there we extract the original title, place it back where it belongs and delete the comment.
So the way I did it is nearly failsafe. The only point is that the plugin needs to be set to 'always' or 'stealth' to avoid nasty complications.

Any one care to find out what *this* plugin actually does with the title?

  • By admin
  • March 25th, 2008
  • Posted in Images
  • 596 views
  • Send feedback »
  Dutch (NL)  
  Tags: filteritemcontents, php, plugin, renderitemashtml, tilqicom, title, unfilteritemcontents, ¥åßßå

Vista in Ubuntu (VirtualBox)

  • By admin
  • January 9th, 2008
  • Posted in Images
  • 832 views
  • Send feedback »
  Dutch (NL)  
 

Ubuntu on Acer Aspire 7520

I will write quick on this page and polish things later. This is supposed to become a HOWTO of installing Ubuntu on my laptop. Here is a description of the laptop. The Acer Aspire 4520 seems to have the same or at least similar specifications and problems.



I started with three problems and later on the list grew :roll::

Acer Aspiron 7520-5A2G12Mi
FunctionStatusSolved
Freezes on startupBuggoed
Low resolution on screenDriver settinggoed
No soundDriver settinggoed
No WIFIDriver settinggoed
No hibernate / sleepBug / driver:-/
Webcam / micDriver setting ??fout
Bluetooth??:?:
Card reader??:?:

Installing Ubuntu only works in the safe graphics mode or with the alternate CD. This CD is pure text based. Installation itself never gives problems.

sound

OK, I found a truly remarkable easy solution for the sound. It's just installing Backport in Synaptic. You find the packacge with a search. You install linux-backports-modules and it will find the dependencies. Now restart the computer (mayby logging out is enough) and there is sound.

screen

Okay, I've got the correct screen resolution, 1440 x 900.
What went OK? After setup, hit the restricted driver setting and allow NVidia. Restart the system. What went wrong? When selecting the screen start with the 'Widescreen' tickbox. I didn't and so the correct screen resolution never came up. This does sound silly but I didn't waste much time on the screen, because I knew that was the least of the problems. And it was.

Boot

The startup problem is in another stage. This is the post I wrote in the Ubunto forum:

I somehow got a step further. From the suggested post I recognized at least the splash error so I did:

Code:

sudo nano /etc/usplash.conf

I changed the splash settings from 1280x1024 to 1024x768. The screen is a 17" wide 1440x900. After saving I did

Code:

sudo update-initramfs -u

This should and could solve some problem, but not the startup at boot error. Whereas It first gave notices about splash screen sizes tried and failed, it now reports:

Code:

Check root= bootargs cat /proc/cmdline
or missing modules, device: cat /proc/modules ls /dev
ALERT! /dev/disk/by-uuid/9c183c8d-2249-4669-974d-dd4deb9c5241 does not exist. Dropping to a shell!
 
Busybox v1.1.3 (Debian 1:1.1.3-5ubuntu7) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
 
(initranfs)

I sincerely hope some one can help with this.

Tx

== UPDATE ==
I tracked it down to this bugreport as a likely source of the problem. The question now is if there is a solution.

== UPDATE ==
from the bugreport I did:

Code:

sudo update-initramfs -u -k 2.6.22-14-generic

If it works or not, I don't know yet. If it does, I'll be surprised. What changed with this line?

== UPDATE ==
It is reported to this as well:

Code:

sudo update-initramfs -u -k 2.6.22-14-386

On my laptop it cannot find "/lib/modules/2.6.22-14-386".

I will now carefully examine if this can be a temperature related issue.

== UPDATE ==
I installed Sidux as a reference. It sure was am ye opener. In Sidux I experienced exactly the same problems as in Ubuntu. For the bott issues: their forum aslo reports this and they are focussed on temperature issues. Further reading: Sidux forum. No solution here.

== UPDATE ==
I think I founf the solution. I looked at some links in this post and so I accidentally discovered an answer. Tho problem is that at boot the harddisk is not always recognised. The solution is: add all_generic_ide to the startup command at boot. Most easily that is done by editing grub:
sudo gedit /boot/grub/menu.lst
The line is "kernel" at Ubuntu 7.10, kernel 2.6.22-14-generic. I have high hopes, but time will tell.

WIFI

For the WIFI I need to do this: Ticket #1679 (new enhancement) from Madwifi. There is a solution. That's the good news. Now getting it on my laptop. That's another point. The other solution would be Nsdiwrapper, but I tried that and didn't get it running. Both solutions are reported to work on the same or a similar laptop, so I'll eventually work my way through this problem.

== UPDATE ==
I got WIFI working with Madwifi patched with the AR5007EG driver. This patch is only a few days old. It works beautifully. I will take some time to describe what went wrong during installation. it was a nightmare.

== UPDATE ==
Here is my version of the HOWTO to install the correct driver:
1) Disable / remove ndiswrapper
2) Download: http://snapshots.madwifi.org/special/madwifi-ng-r2756+ar5007.tar.gz
This is Madwifi with the driver for AR5007EG patched
3) Follow this manual: http://madwifi.org/wiki/UserDocs/FirstTimeHowTo
Do not download the packet as suggested there, but use the one I mentioned in 2)
I ran into two issues. First where it says
Code:

./madwifi-unload.bash

do
Code:

./madwifi-unload

Second more serious. I couldn't compile and got errors.It turned out (this took me two days) that C++ is not installed.So fire up Synaptic and search for G++. With that package installed it should work fine.

One thing to remember. When you installed ndiswrapper you needed to disable madwifi and some components. I think installing again brings them back, but there maybe traces of the removal left in the blacklist. That's located here: /etc/modprobe.d/blacklist
A fresh install of Ubuntu before you start should prevent issues here

== UPDATE ==
I found this site: http://www.ubuntugeek.com/atheros-5007eg-with-madwifi-on-i386-platform.html that discusses this solution. This code is easier to understand.

Acpi

The hibernation issue is still under investigayion. I installed acer-acpi. Acpi is the way the computer handles extra buttons, leds and hibernation stuff. Due to compatibility issues, errors occur. For the Acer laptop there is a specific Acpi.
Open system -> ?? -> Synaptic. Go to Settings -> Repositories -> Third Party software and add: "deb http://www.mumblyworld.info/ubuntu gutsy main" In the Synapyic main menu (after hitting refresh) you can now search "acer-acpi" and install it.

I once used the <Fn> <Zz> option and it went to sleep, but had difficulties to wake up. It did, but the screen was less bright than I was used to. I rebooted.

Under investigation.

== UPDATE ==
The acer_acpi driver is the best we can do. Acer has a flaw in the acpi. That's the bios talking to the OS and sending signals like WIFI, temperature and extra button actions. The team from acer_acpi does all it can, but it's a black box type situation. They will never get it completely right. Still the driver is a must have. Many things do work and probably even more in the future.

==UPDATE==
There is a new version of acer_cpi presented through autoupdate. I noticed no difference though.

Webcam

The driver dor the webcam is uvcvideo. It is compiled in Ubuntu and recognised with:

Code:

locate uvcvideo

.
I use Cheese to test the webcam. No show so far. Latest thing I tried was:

Code:

sudo su
modprobe uvcvideo

It has a low priority.

== UPDATE==
The webcam is working. I actually did two things, so I cannot tell you which one did the trick.
First I recompiled the uvcvideo drivers again. I did so with the help of the tutorial on Ubuntu.
I read somewhere that the Acer Crystal Eye only works with a specific protocol, from memory that's MPEG. Knowing this I downloaded a few video playing software programs hoping to catch the correct driver. And I did. I think this is what makes it happen "out of the box" ny many users. First thing they do is playing a video ;)
It works. Tested in Cheese. I didn't test the mic.

  • By admin
  • December 15th, 2007
  • Posted in Images
  • 2172 views
  • Send feedback »
  Dutch (NL)  
 

Mosaic image effect in GIMP

This is a Gimp adaptation of a technique described for Paint Shop on the site of Design Spice

Queen of Hearts pixelized
Formula 1

To create a nice image effect using GIMP I did the following.
1. To start I had an image of a playing card. Here it's displayed half the original size:

Queen of Hearts

For this effect to be succesfull, it's best to start with a large picture; you can always scale it down. Furthermore the picture shouldn't be too detailed. You'll see why if you grasp the idea of this effect.
2. First this picture is blurred through: <Image> -> Filters -> Blur -> Pixelize.

Pixeleren

I took 15x15 px as a measurement. In the next step we are going to make a pattern, with a circle in it. In Gimp some circles are predefined as pencil stroke: 1x1 through 19x19 (odd numbers only). Actually, we are making a dot with these predefined sizes. In that step you want a 1px white border, so take your Pixelize setting odd also. If possible, take the original measurement of the picture in account as well.
This is how the picture looks after Pixelization (picture half size):

Queen of Hearts Pixelised

3. Now we want to make a custom pattern. I addressed the issue of size earlier, but these are the steps.

  • create a new image size 15 x 15 px. This 15 x 15 px is specific for this image because that is my setting for the pixelization. In your picture you would want this canvas setting to be the same size as the pixelization.
  • Add an alphachannel <Image> -> Layers -> Transparency -> add Alphalayer.

Draw a circle (dot) in black that is 2px smaller as the canvas size:

  • Set <Main> Pencil -> Circle (13x13)
  • Set the size (view) of your canvas to 800% and draw the dot
  • Now <Image> Select -> Select colour and select the inner circle (black)
  • <Image> Edit -> Remove (<ctrl>+K)

This leaves a white border with a transparent circle, like this one (blown to 800%):

Circle

4. Now save this thing in the map patterns (GIMP_2.0 -> Share -> GIMP -> 2.0 -> Patterns) as 'circle.pat'. It will ask for a pattern name. Choose 'circle 15x15' (don't leave the default 'Gimp pattern').

Nearly done.
5. Go to the image of the playing card. Add an invisilble layer (<Image> Layer -> New layer -> Invisible)

  • In <Main> choose the Bucket Fill icon. Choose Pattern Fill Coose pattern (your 'circle 15x15').
  • In <Image> Activate -> Layers. Choose the new transparent layer.
  • Do <Image> Edit -> Fill with Pattern (<ctrl>+;) and now you you are ready (picture size reduced to half):
Queen of Hearts pixelized

6. Well done. You might play around with these effects. Make changes in the pattern, like a new white 7 x 7 dot in the alpha circle like so:

Circle fill

This way the fllowing effect is created:

Queen of hearts hollow circle

Have fun and let me know if you liked it and if you have any suggestions.


Thanks to all those wonderful sites out there that give me inspiration.
 

 

  • By admin
  • February 6th, 2007
  • Posted in Images, GIMP
  • 426 views
  • Send feedback »
  English (US)  
  Tags: GIMP
  • July 2008
    Sun Mon Tue Wed Thu Fri Sat
     << <   > >>
        1 2 3 4 5
    6 7 8 9 10 11 12
    13 14 15 16 17 18 19
    20 21 22 23 24 25 26
    27 28 29 30 31    
  • Tutorials

  • Things that interest me, so it might interest you ;)

  • Adsense

  • Search




    • Recently
    • Archives
    • Categories
    • Latest comments
  • Categories

    • All
    • Images
      • GIMP
  • XML Feeds

    • RSS 2.0: Posts, Comments
    • Atom: Posts, Comments
    • _sitemap: Posts, Comments
    What is RSS?
  • User tools

    • Login
    • Register
    • Admin
  • Adsense


Contact | Credits: Foppe Hemminga | Powered by b2evolution