<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>source.mihelac.org - Home</title>
  <id>tag:source.mihelac.org,2009:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  
  <link href="http://source.mihelac.org/" rel="alternate" type="text/html" />
  <updated>2009-05-11T20:08:40Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/mihelac" type="application/atom+xml" /><entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2009-05-11:5122</id>
    <published>2009-05-11T20:01:00Z</published>
    <updated>2009-05-11T20:08:40Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/yXlV2cjf17g/django-testshell" rel="alternate" type="text/html" />
    <title>Django testshell</title>
<content type="html">
            &lt;p&gt;This commands runs a Python interactive interpreter with test database and data from the given fixture(s). It is &lt;a href="http://code.djangoproject.com/ticket/7857"&gt;usable&lt;/a&gt; if you want to play with test database.&lt;/p&gt;


	&lt;p&gt;See also &lt;a href="http://docs.djangoproject.com/en/dev/ref/django-admin/#testserver-fixture-fixture"&gt;testserver docs&lt;/a&gt;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;from django.core.management.base import BaseCommand

from optparse import make_option

class Command(BaseCommand):
    option_list = BaseCommand.option_list
    help = 'Runs a Python interactive interpreter with test database and data from the given fixture(s).'
    args = '[fixture ...]'

    requires_model_validation = False

    def handle(self, *fixture_labels, **options):
        from django.core.management import call_command
        from django.db import connection

        verbosity = int(options.get('verbosity', 1))

        # Create a test database.
        db_name = connection.creation.create_test_db(verbosity=verbosity)

        # Import the fixture data into the test database.
        call_command('loaddata', *fixture_labels, **{'verbosity': verbosity})

        call_command('shell')
&lt;/code&gt;&lt;/pre&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2009/5/11/django-testshell</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2009-03-16:5051</id>
    <published>2009-03-16T15:53:00Z</published>
    <updated>2009-03-16T16:00:38Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/d0YwzeAgu-8/switch-between-django-trunk-and-stable-versions" rel="alternate" type="text/html" />
    <title>Switch between django trunk and stable versions</title>
<content type="html">
            &lt;p&gt;This is snippet that I use to switch development with Django between 1.0 and trunk versions:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;#!/bin/sh
rm  /Library/Python/2.5/site-packages/django
if [ "$1" = "" ]; then
  echo "Django 1.0" 
  ln -s LOCATION_OF_SOURCE_CODE/django-1.0/django /Library/Python/2.5/site-packages/django
else
  echo "Django trunk" 
  ln -s LOCATION_OF_SOURCE_CODE/django-trunk/django /Library/Python/2.5/site-packages/django
fi&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;$ ~/djchange.sh
Django 1.0
$ django-admin.py --version
1.0-final-SVN-8977
$ ~/djchange.sh trunk
Django trunk
$ django-admin.py --version
1.1 alpha 1 SVN-10065
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Also check that django-admin.py is symbolic link to /Library/Python/2.5/site-packages/django/bin/django-admin.py&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2009/3/16/switch-between-django-trunk-and-stable-versions</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2009-03-03:4959</id>
    <published>2009-03-03T11:20:00Z</published>
    <updated>2009-03-03T11:33:38Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/Usq72u5lIao/rails-dump-database-structure-for-sql-server" rel="alternate" type="text/html" />
    <title>Rails - dump database structure for SQL Server </title>
<summary type="html">&lt;p&gt;Dumping structure with &lt;em&gt;rake db:structure:dump&lt;/em&gt; task when connecting to &lt;span class="caps"&gt;SQL&lt;/span&gt; Server will fail with &lt;em&gt;scptxfr&lt;/em&gt; not found error.&lt;/p&gt;


&lt;pre&gt;command not found: scptxfr /s  /d  /I /F db /q /A /r&lt;/pre&gt;

	&lt;p&gt;Thats documented in &lt;a href="http://dev.rubyonrails.org/ticket/3298"&gt;#3298&lt;/a&gt;.
However dump of database structure can be easily achived from ActiveRecord:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;script/console
&amp;gt;&amp;gt; ActiveRecord::SchemaDumper.dump
&lt;/code&gt;&lt;/pre&gt;</summary>  <feedburner:origLink>http://source.mihelac.org/2009/3/3/rails-dump-database-structure-for-sql-server</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-10-31:3850</id>
    <published>2008-10-31T19:29:00Z</published>
    <updated>2008-10-31T19:34:42Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/nfwqP0in4a0/satchmo-product-images" rel="alternate" type="text/html" />
    <title>Satchmo product images</title>
<content type="html">
            &lt;p&gt;Templatetag for &lt;a href="http://satchmoproject.com"&gt;Satchmo&lt;/a&gt; creates unordered list for product images. &lt;span class="caps"&gt;CSS&lt;/span&gt; can be applied to customize output.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;from django import template

from satchmo.product.models import Product
from satchmo.thumbnail.templatetags.satchmo_thumbnail import thumbnail

try:
    from xml.etree.ElementTree import Element, SubElement, tostring
except ImportError:
    from elementtree.ElementTree import Element, SubElement, tostring

register = template.Library()

default_opts = {
    'thumbnail': 'width=280',
    'start': 0
}

class ProductGalleryNode(template.Node):
    def __init__(self, product, **opts):
        self.product = template.Variable(product)
        self.opts = default_opts
        self.opts.update(opts)

    def render(self, context):
        actual_product = self.product.resolve(context)
        images = actual_product.productimage_set.all()
        start = int(self.opts['start'])
        if len(images) &amp;lt;= start: return ("")
        root = Element("ul", {'class': self.opts.get('class', '')})
        for (i, pic) in enumerate(images[start:]):
            li_attr = {'class': 'first'} if not i else {}
            li = SubElement(root, 'li', li_attr)
            link = SubElement(li, 'a', {'href' : pic.picture.url})
            caption = pic.translated_caption()
            src = thumbnail(pic.picture.url, self.opts.get('thumbnail'))
            img = SubElement(link, 'img', {'src': src, 'alt': caption, 'title': caption})
        return tostring(root, 'utf-8')        

@register.tag      
def product_gallery(parser, token):
    """ Returns an unordered list of image thumbnails for product.

Usage:
{% product_gallery product %}
{% product_gallery product thumbnail="width=280"%}
{% product_gallery product start=1%}
{% product_gallery product class=galeria%}

    """ 
    kwargs = {}
    bits = token.split_contents()[1:]
    product = bits[0]
    for bit in bits[1:]:
        arg, val = bit.split("=", 1)
        kwargs[str(arg)] = val.strip('"')
    return (ProductGalleryNode(product, **kwargs))
&lt;/code&gt;&lt;/pre&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/10/31/satchmo-product-images</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-10-30:3847</id>
    <published>2008-10-30T15:50:00Z</published>
    <updated>2008-10-30T15:59:01Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/bW7DI8AjKqQ/satchmo-categories" rel="alternate" type="text/html" />
    <title>Satchmo categories</title>
<content type="html">
            &lt;p&gt;Here is the templatetag for use in Satchmo. It extend existing satchmo &lt;em&gt;category_tree&lt;/em&gt; tag  allowing customizing product categories. 
&lt;em&gt;from_level&lt;/em&gt; and &lt;em&gt;deep&lt;/em&gt; affect what part of tree would be displayed while &lt;em&gt;select_parents&lt;/em&gt; makes all parent categories of active category selected.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;from django.template import Library, Node, Variable, VariableDoesNotExist
from satchmo.product.models import Category
import logging

log = logging.getLogger('shop.templatetags')

try:
    from xml.etree.ElementTree import Element, SubElement, tostring
except ImportError:
    from elementtree.ElementTree import Element, SubElement, tostring

register = Library()

def recurse_for_children(current_node, parent_node, active_categories = [], show_empty=True, deep = -1, current_deep = 0):
    child_count = current_node.child.count()

    if show_empty or child_count &amp;gt; 0 or current_node.product_set.count() &amp;gt; 0:
        temp_parent = SubElement(parent_node, 'li')
        attrs = {'href': current_node.get_absolute_url()}
        if current_node in active_categories:
            attrs["class"] = "current" 
        link = SubElement(temp_parent, 'a', attrs)
        link.text = current_node.translated_name()
        if current_deep == deep: return
        if not child_count: return
        new_parent = SubElement(temp_parent, 'ul')
        children = current_node.child.all()
        for child in children:
            recurse_for_children(child, new_parent, active_categories, show_empty, deep, current_deep + 1)

class SubcategoryTree(Node):
    def __init__(self, active = None, from_level = 0, deep = -1, select_parents = 0):
        self.active = active
        self.from_level = int(from_level)
        self.deep = int(deep)
        self.select_parents = bool(select_parents)

    def render(self, context):
        root = Element("ul")
        active_categories = []
        root_categories = None
        if self.active:
            active_cat = Variable(self.active).resolve(context)
            active_categories = [active_cat]
            if self.select_parents: active_categories.extend(active_cat.parents())
            if self.from_level:
                parents = active_cat.parents()
                parents.append(active_cat)
                index = self.from_level - 1
                if index &amp;gt; len(parents): return ("")
                root_categories = parents[index].child.all()
            else:
                root_categories = Category.objects.root_categories()
        else:
            root_categories = Category.objects.root_categories()
        for cats in root_categories:
            recurse_for_children(cats, root, active_categories, deep = self.deep)
        return tostring(root, 'utf-8')        

@register.tag                
def categories(parser, token):
    """ 
    Creates an unnumbered list of the categories. It allows to specify deep and start level.
    If select_parents all parent categories would have class="current" - this is suitable for main categories.

    Examples: 

    {% categories %}
    {% categories active=category from_level=1%}
    {% categories active=category deep=0 select_parents=1 %}
    """ 
    kwargs = {}
    for bit in token.split_contents()[1:]:
        arg, val = bit.split("=")
        kwargs[str(arg)] = val
    return (SubcategoryTree(**kwargs))
&lt;/code&gt;&lt;/pre&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/10/30/satchmo-categories</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-10-09:3753</id>
    <published>2008-10-09T15:56:00Z</published>
    <updated>2008-10-09T16:02:00Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/3LNMkMfcxkM/custom-setting-in-satchmo" rel="alternate" type="text/html" />
    <title>Custom setting in Satchmo</title>
<content type="html">
            &lt;p&gt;If you need to add some custom settings to &lt;a href="http://satchmoproject.com"&gt;Satchmo&lt;/a&gt; shop, create new app &lt;em&gt;site&lt;/em&gt; (or custom or something else), create custom settings in config and include it in models:&lt;/p&gt;


&lt;pre&gt;
# site/config.py
from satchmo.configuration import *
from django.utils.translation import ugettext_lazy as _

CUSTOM_SETTINGS = config_register(
    BooleanValue(SHOP_GROUP,
    'SHIPPING_AND_BILLING_ADDRESSES_EQUALS',
    description=_(u'Shipping and billing addreses are always equal.'),
    default = False)
    )
&lt;/pre&gt;

&lt;pre&gt;
# site/models.py
import config
&lt;/pre&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/10/9/custom-setting-in-satchmo</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-08-23:3572</id>
    <published>2008-08-23T08:30:00Z</published>
    <updated>2008-08-23T08:37:12Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/Kcm-CnuiPfg/mail-application-not-responding" rel="alternate" type="text/html" />
    <title>Mail - Application not responding</title>
<content type="html">
            &lt;p&gt;This morning Apple Mail stopped to work for me – the most solutions I found through Google did advice to delete com.apple.mail.plist file from Library/Preferences. While this seems to work when I moved this file to desktop, consequence was that all accounts should be set up again. Lazy, I looked for more plist files in preferences directory and found com.apple.mail.searchhistory.plist is resembling. Deleting this file fix the problem and I didn’t have to setup anything again.&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/8/23/mail-application-not-responding</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-07-01:3541</id>
    <published>2008-07-01T13:15:00Z</published>
    <updated>2008-07-01T13:15:48Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/Gh14wlLU3ig/programmable-screencasts" rel="alternate" type="text/html" />
    <title>Programmable screencasts</title>
<content type="html">
            &lt;p&gt;Here is screencast, how &lt;a href="http://drupal.org/project/gmaplocation"&gt;Gmaplocation&lt;/a&gt; Drupal module looks and feels on one website:&lt;/p&gt;


&amp;lt;object type="application/x-shockwave-flash" height="309" data="http://web.mojgost.com/video/player_flv_maxi.swf" width="490"&gt;
&amp;lt;param name="movie" value="/video/player_flv_maxi.swf" /&gt;
&amp;lt;param name="allowFullScreen" value="true" /&gt;
&amp;lt;param name="FlashVars" value="flv=http://web.mojgost.com/video/update_google_map_location.mov.flv&amp;showplayer=1&amp;showfullscreen=1&amp;autoload=1&amp;width=490&amp;height=309&amp;" /&gt;
&amp;lt;/object&gt;

	&lt;p&gt;The video is created with &lt;a href="http://gadgets.inventivelabs.com.au/castanaut"&gt;Castanut&lt;/a&gt;, tool that allows one to write script that will move mouse, open webpages, enter text and record all this into the screencast. Castanaut scripts are written in &lt;a href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt; and commands are scripts are relatively easy to write.&lt;/p&gt;


	&lt;p&gt;Here is excerpt of the script:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;#!/usr/bin/env castanaut
ishowu_start_recording
move to_element('a[title="Adjust basic site configuration options."]')
click
pause PageLoadTime
move to_element('a[title="Configure Google Maps location."]')
click
pause PageLoadTime
move to_element('[id="edit-gmaplocation-address"]')
click
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Please note, that it is MacOSX Leopard only tool (there is a fork on GitHub that allows it to be used with 10.4 thought).&lt;/p&gt;


	&lt;p&gt;I had some problems with dissapearing mouse cursor using Snapz Pro X capture tool and it draws up that Snapz Pro X is currently not ready to be used together with scripting yet. Guys in &lt;a href="http://www.ambrosiasw.com/utilities/snapzprox/"&gt;Ambrosia Software&lt;/a&gt; are working on the next generation and it would probably allow Snapz Pro X to be used with Castanaut . On the end of the day I bought &lt;a href="http://www.shinywhitebox.com/home/home.html"&gt;iShowU&lt;/a&gt; which did not had any problems.&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/7/1/programmable-screencasts</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-06-05:3518</id>
    <published>2008-06-05T09:44:00Z</published>
    <updated>2008-06-18T14:46:07Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/x7x5Tss-f0I/gmaplocation-drupal-module-for-geographic-location-via-google-maps" rel="alternate" type="text/html" />
    <title>gmaplocation - Drupal module for geographic location via Google Maps</title>
<summary type="html">&lt;p&gt;The gmaplocation is Drupal 5.7 module that allow displaying of your geographic location via Google Maps. It has following features:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;show Google Maps with marker on your location&lt;/li&gt;
		&lt;li&gt;editor can drag marker to fine-tune position in case when geolocating from address is not accurate&lt;/li&gt;
		&lt;li&gt;creates a block with static image of map and link to gmaplocationpage&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Here are some screenshoots of gmaplocation in action:&lt;/p&gt;


	&lt;p&gt;&lt;img src="/assets/source.mihelac.org/2008/6/5/gmaplocation.png" alt="" /&gt;
gmaplocation page and static block in right sidebar&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;The gmaplocation is Drupal 5.7 module that allow displaying of your geographic location via Google Maps. It has following features:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;show Google Maps with marker on your location&lt;/li&gt;
		&lt;li&gt;editor can drag marker to fine-tune position in case when geolocating from address is not accurate&lt;/li&gt;
		&lt;li&gt;creates a block with static image of map and link to gmaplocationpage&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Here are some screenshoots of gmaplocation in action:&lt;/p&gt;


	&lt;p&gt;&lt;img src="/assets/source.mihelac.org/2008/6/5/gmaplocation.png" alt="" /&gt;
gmaplocation page and static block in right sidebar&lt;/p&gt;
&lt;p&gt;&lt;img src="/assets/source.mihelac.org/2008/6/5/gmaplocation_admin.png" alt="" /&gt;
gmaplocation admin page&lt;/p&gt;


	&lt;p&gt;&lt;img src="/assets/source.mihelac.org/2008/6/5/gmaplocation_finetune.png" alt="" /&gt;
fine tuning location with drag and drop&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://drupal.org/project/gmaplocation"&gt;Module page on Drupal.org&lt;/a&gt;&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/6/5/gmaplocation-drupal-module-for-geographic-location-via-google-maps</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-05-13:3495</id>
    <published>2008-05-13T04:45:00Z</published>
    <updated>2008-05-13T06:57:41Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/cfopTPzJVYY/static-variables-and-unset" rel="alternate" type="text/html" />
    <title>Static variables and unset()</title>
<content type="html">
            &lt;p&gt;In Drupal many things are cached with static variables and this is often main source of headache. I just submitted small patch for bug where &lt;a href="http://drupal.org/node/257787"&gt;static cache does not work as it should&lt;/a&gt;. Bug report and this example shows that unset() should not be used with static variables:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&amp;lt;?php
function locale_supported_languages($reset = FALSE, $val = array()) {
  static $all = NULL;

  if ($reset) {
    // If a static variable is unset() inside of a function, unset() destroys the variable only in the context of the rest of a function. Following calls will restore the previous value of a variable.
    unset($all); // this would not work
    //$all = NULL; // this would work
  }

  if (is_null($all)) {
    $all = array();
    foreach ($val as $key =&amp;gt; $value) {
      $all[$key] = $value;
    }
  }
  return $all;  
}

echo "\narray should have 'cached' element (PASS):";
print_r(locale_supported_languages(FALSE, array("first" =&amp;gt; "cached")));

echo "\narray should have 'new' element (PASS):";
print_r(locale_supported_languages(TRUE, array("first" =&amp;gt; "new")));

echo "\narray should have 'new' element but have 'cached' (FAILS):";
print_r(locale_supported_languages(FALSE));&lt;/code&gt;&lt;/pre&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/5/13/static-variables-and-unset</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-05-08:3492</id>
    <published>2008-05-08T07:39:00Z</published>
    <updated>2008-05-08T07:44:13Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/tcKcjSHuAL0/drupal-replace-colors-in-buttons-with-color-module" rel="alternate" type="text/html" />
    <title>Drupal - replace colors in buttons with color.module</title>
<summary type="html">&lt;p&gt;&lt;img src="/assets/2008/5/8/color-module-example_2.gif" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Drupal Color.module allows the admin to change the color scheme of a theme completely. 
Color module basically fill viewport with 5 choosen colors, layout transparent &lt;span class="caps"&gt;PNG&lt;/span&gt; on it and then makes image slices and update &lt;span class="caps"&gt;CSS&lt;/span&gt; with this colors.&lt;/p&gt;


	&lt;p&gt;I would like to share some code that customize color.module further. After color scheme is choosen specified images would be copied and colors updated to reflect current color scheme. This is especially useful for creating buttons that should be color aware.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;&lt;img src="/assets/2008/5/8/color-module-example_2.gif" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Drupal Color.module allows the admin to change the color scheme of a theme completely. 
Color module basically fill viewport with 5 choosen colors, layout transparent &lt;span class="caps"&gt;PNG&lt;/span&gt; on it and then makes image slices and update &lt;span class="caps"&gt;CSS&lt;/span&gt; with this colors.&lt;/p&gt;


	&lt;p&gt;I would like to share some code that customize color.module further. After color scheme is choosen specified images would be copied and colors updated to reflect current color scheme. This is especially useful for creating buttons that should be color aware.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**
  * Form alter hook
  */
function mycolormodule_form_alter($form_id, &amp;$form) { 
  if ($form_id == 'system_theme_settings') {
    $form['#submit']['mycolormodule_system_theme_settings'] = array();
  }
} 

/**
 * Copy PNG images and change color in images with color from palette. 
 * 
 * Settings in color.inc $info array:
 *
 *     'change_color' =&amp;gt; array(
 *        'images/form_buttons.png' =&amp;gt; array("#3CC6F5" =&amp;gt; "bottom"), // Color #3CC6F5 will be updated with color of "header bottom" 
 *    ),
 */
function mycolormodule_system_theme_settings($form_id, $values) {

  $theme = $values['theme'];
  $target = variable_get('color_'. $theme .'_stylesheet', NULL);
  if (!$target) return;
  $files = variable_get('color_'. $theme .'_files', array());
  $target = dirname($target) . "/";
  $info = $values['info'];
  $source = drupal_get_path('theme', $theme) .'/';
  foreach ($info['change_color'] as $file =&amp;gt; $replace_array) {
    $base = basename($file);
    $source = $source . $file;
    // NOTE: change color
    $im = imagecreatefrompng($source);
    foreach ($replace_array as $old =&amp;gt; $new) {
      $old_arr = _color_unpack($old);
      $index = imagecolorexact($im, $old_arr[0], $old_arr[1], $old_arr[2]);
      $new_arr = _color_unpack($values['palette'][$new]);
      imagecolorset($im, $index ,$new_arr[0], $new_arr[1], $new_arr[2]);
      $files[] = $target . $base;
    }
    imagepng($im, $target . $base);
  }
  variable_set('color_'. $theme .'_files', $files);
}&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Buttons from above image are based on &lt;a href="http://www.hedgerwow.com/360/dhtml/css-round-button/demo.php"&gt;Wii buttons demo&lt;/a&gt;.
Using color.module is described in details &lt;a href="http://drupal.org/node/108459"&gt;here&lt;/a&gt;.&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/5/8/drupal-replace-colors-in-buttons-with-color-module</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-04-22:3485</id>
    <published>2008-04-22T17:25:00Z</published>
    <updated>2008-04-23T13:15:23Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/3yJwCPGNkM4/drupal-forms-first-argument-is-expected-to-be-a-valid-callback" rel="alternate" type="text/html" />
    <title>Drupal Forms - First argument is expected to be a valid callback</title>
<content type="html">
            &lt;p&gt;While creating an installation profile for Drupal based websites I lost a day tracking what should look like a small error. This seems to be often error and it seems there are many possiblities why this and similiar errors can occur:&lt;/p&gt;


&lt;pre&gt;warning: call_user_func_array() [&amp;lt;a href='function.call-user-func-array'&amp;gt;function.call-user-func-array&amp;lt;/a&amp;gt;]: First argument is expected to be a valid callback, 'page_node_form' was given in /Users/bmihelac/Sites/drupal/tsitedemo/includes/form.inc on line 221.&lt;/pre&gt;

	&lt;p&gt;This error occure in &lt;a href="http://api.drupal.org/api/function/drupal_retrieve_form/5" title="$form_id"&gt;drupal_retrieve_form&lt;/a&gt; function of form.inc and means that Drupal did not found &lt;em&gt;callback_function&lt;/em&gt; for creating &lt;em&gt;$form_id&lt;/em&gt; form.&lt;/p&gt;


	&lt;h3&gt;How Drupal retrieves form:&lt;/h3&gt;


	&lt;ol&gt;
	&lt;li&gt;&lt;em&gt;drupal_retrieve_form&lt;/em&gt; function invokes &lt;em&gt;hook_forms&lt;/em&gt; on all modules and statically cache returned forms&lt;/li&gt;
		&lt;li&gt;it execute &lt;em&gt;callback&lt;/em&gt; for given &lt;em&gt;$form_id&lt;/em&gt; is it exists, if &lt;em&gt;callback&lt;/em&gt; does not exists &lt;em&gt;drupal_retrieve_form&lt;/em&gt; calls function named &lt;em&gt;$form_id&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;node.module&lt;/em&gt; defines &lt;em&gt;hook_forms&lt;/em&gt; so every content type has form_id in format &lt;em&gt;&lt;span class="caps"&gt;CONTENT&lt;/span&gt;-TYPE_node_form&lt;/em&gt; (page_node_type for example). Callback for all node forms is same and it is &lt;em&gt;node_form&lt;/em&gt;. It is important to know that &lt;a href="http://api.drupal.org/api/function/node_forms/5"&gt;node_forms&lt;/a&gt; calls &lt;a href="http://api.drupal.org/api/function/node_get_types/5"&gt;node_get_types&lt;/a&gt; to obtain available node types and this function statically cashes node types.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;h3&gt;Possible solutions&lt;/h3&gt;


	&lt;p&gt;In my case the error occured because I created custom node type and wanted to create nodes via drupal_execute_macro in same script. &lt;a href="http://api.drupal.org/api/function/node_get_types/5"&gt;node_get_types&lt;/a&gt; returned caches node types and custom node was not in it. That also explains while same code worked if it was split in two scripts. Once the problem is found, solution is easy as reloading node types:&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://api.drupal.org/api/function/node_get_types/5"&gt;node_get_types(‘types’, &lt;span class="caps"&gt;NULL&lt;/span&gt;, TRUE);&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;If you have similiar problems you can:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;check if you can retrieve form with &lt;em&gt;drupal_retrieve_form($form_id)&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;check if $form_id is created in &lt;em&gt;module_invoke_all(‘forms’)&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;check if module that should create form is loaded with &lt;em&gt;module_list(FALSE, &lt;span class="caps"&gt;TRUE&lt;/span&gt;, FALSE)&lt;/em&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Thanks for reading and hope this will save you some time.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;:&lt;/strong&gt; I noticed that some other functions statically cache variables so similiar problems occured when creating multilanguage nodes. The best solution for now seems to create content types, blocks, etc in installation profile and create content in other script.&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/4/22/drupal-forms-first-argument-is-expected-to-be-a-valid-callback</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2008-02-16:1822</id>
    <published>2008-02-16T20:40:00Z</published>
    <updated>2008-02-16T21:07:58Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/ayr5Jqf4hgs/breaking-the-silence" rel="alternate" type="text/html" />
    <title>Breaking the silence</title>
<content type="html">
            &lt;p&gt;Visited &lt;a href="http://barcamp.ini.hr/"&gt;BarCamp Zagreb&lt;/a&gt; in december and I really liked it.&lt;/p&gt;


	&lt;p&gt;I like seeing new local ruby groups arise, we have &lt;a href="http://groups.google.com/group/ruby-hr"&gt;Ruby Hrvatska&lt;/a&gt; and &lt;a href="http://groups.google.com/group/ruby-slovenija"&gt;Ruby Slovenija&lt;/a&gt; groups.&lt;/p&gt;


	&lt;p&gt;We plan to do some unconference in Ljubljana or Maribor in march to exchange ruby knowledge, socialize and drink few beers. I plan to make short presentation about ruby/rails testing techniques in everyday work. If you are interested check us at &lt;a href="http://ruby.meetup.com/126/boards/thread/4192845"&gt;Ruby Meetup&lt;/a&gt;.&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2008/2/16/breaking-the-silence</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2007-09-07:372</id>
    <published>2007-09-07T22:05:00Z</published>
    <updated>2007-09-07T22:09:52Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/vBE7Q-2OGho/railsconf-berlin" rel="alternate" type="text/html" />
    <title>RailsConf Berlin</title>
<content type="html">
            &lt;p&gt;&lt;img src="http://www.railsconfeurope.com/images/railseurope2007/layout/railseuro_logo.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;See ya there, friends!&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2007/9/7/railsconf-berlin</feedburner:origLink></entry>
  <entry xml:base="http://source.mihelac.org/">
    <author>
      <name>bmihelac</name>
    </author>
    <id>tag:source.mihelac.org,2007-08-14:254</id>
    <published>2007-08-14T15:56:00Z</published>
    <updated>2007-08-14T16:00:54Z</updated>
    <link href="http://feedproxy.google.com/~r/mihelac/~3/d2o0KhipvHw/punbb-to-beast-converter" rel="alternate" type="text/html" />
    <title>PunBB to Beast converter</title>
<content type="html">
            &lt;p&gt;&lt;img src="http://source.mihelac.org/assets/2007/8/14/punbb_to_beast2.gif" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Rails plugin punbb_to_beast would convert &lt;a href="http://www.punbb.org"&gt;PunBB&lt;/a&gt; to &lt;a href="http://beast.caboo.se/"&gt;Beast&lt;/a&gt; forum data.&lt;/p&gt;


	&lt;p&gt;Repository is here:&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://site-express.biz/svn/svn_r/plugins/punbb_to_beast/"&gt;http://site-express.biz/svn/svn_r/plugins/punbb_to_beast/&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;To install and run assuming beast and punbb are in same database and punbb tables are prefixed with /punbb/:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;ruby script/plugin install -x http://site-express.biz/svn/svn_r/plugins/punbb_to_beast/
rake punbb_to_beast:import SRC_PREFIX=punbb
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;See &lt;a href="http://site-express.biz/svn/svn_r/plugins/punbb_to_beast/README"&gt;readme&lt;/a&gt; for more info.&lt;/p&gt;


	&lt;p&gt;This plugin is work in progress.  It work for me and I tested it with latest clean PunBB installation but didn’t had time to test it throughly (so backup db before). Let me know if it works for you.&lt;/p&gt;
          </content>  <feedburner:origLink>http://source.mihelac.org/2007/8/14/punbb-to-beast-converter</feedburner:origLink></entry>
</feed>
