Archive for the ‘All’ Category.

Kilwa 1579

Situation Overview

kilwa 1579-01-01.diplomatic

General Situation

Kilwa did pretty fine conquering and colonizing East and South Africa. At the beginning of 1579 she counts 67 provinces in her realm. And she reaches out to wealthier areas in Central Africa and Indonesia. Kilwa has no threatening neighbors. On the contrary, Kilwa has a lot of little neighbors which are easily to conquer. Biggest problems in the imperium are unrest from conquered provinces and a never ending stream of unruly vezirs, who think they can take over Kilwa with the snap of a finger. They bring up the “Plotting Vezir”-event every two or so years. From a military perspective the geographical stretch from Central Africa to Cape Horn and Indonesia is a slight discomfort, as moving troops takes a lot of time.

Imperial Stretch

In 1579 Kilwa stretches on the east african coast from Cape of Good Hope to almost Cape Horn, she has some provinces in Niger / Central Africa and a view in Indonesia.

Diplomatic Situation

Currently Kilwa is at war with Warsangali, Oman and Hejaz. She was drawn into it by her ally Marehan at Cape Horn. In Central Africa Kilwa has a vassal, Mossi. I gave Mossi some poor provinces I did not want to take care of myself and whichs unrest I did not want to be part of Kilwas problems. In West Africa Kilwa has dynastic relations to Jolof. In Indonesia Mallaca is bound to her by royal marriage and alliance.

Popularity

The world, far or near, seems not to care too much about Kilwa. Everybody has pretty much no special opinion about her, except for allies and war enemies, although one might easily call Kilwa a conquering and expanding power. I just invested some diplomatic effort into good relations with with some european naval powers. Portugal came down to Central Africa with its furtherst colony.

kilwa.1579-01-01.opinion

Economic and Trade Situation

To be honest, the heartlands of Kilwa are fucking poor. Cape of Good Hope is the only province with a base tax value of above 7. The total tax base is 216. Which is (216/67) around 3 average base tax value per province.

kilwa.1579-01-01.southeast africa.base tax
A total of 67 provinces yielding a tax income of 15 gold and a production income of 12 gold per month is awesome miserable.

kilwa 1579-01-01.economy

The tax base directly influences the tax and the “provincial tax income”. Latter being the main multiplier for “goods produced”. A province with a base tax value of 5 has a provincial tax income of 100%. A base tax value of 2 yields 40% provincial tax income (the formular appears to be pti = 2 x btv x 10%).

What saves Kilwa in terms of income, are 6 provinces which produce gold directly. Allthough I spend 75 admin power to reduce inflation every 15 or so years, the gold pays a lot more than the cost for an additional administrative point from an advisor and the increased cost for various things.

Trade income could be better, I guess. The trade node of  Zanzibar is owned completely by Kilwa. The trade node of Cape of Good Hope has no trade value in it worth mentioning,  and what is there is sucked out by Kongo and Portugal.

kilwa.1579-01-01.southeast africa.trade
The trade node of Cape Horn has little trade value. But new opportunities arose with the colonies in Indonesia. The Malaccan trade node has decent trade value in it.

kilwa.1579-01-01.indian ocean. trade

Neighbor Situation

The pros are, Kilwa has no powerful, threatening neighbors, but a lot of weak, easily to conquer ones. The game already offers Ming as a suitable rival. But that is not an interesting option at the moment. Additionally there are almost no religious discrepancies as almost all neighbors are of sunni relgion, as Kilwa is. In East and South Africa are some uncalimed though very poor and aggressive provinces. And only the costal provinces among them are of strategic importance. Colonizing them would hinder Portugal or any other power to do so and gain influence in the area or establish a bridge to the Far East.

In south western africa is Kongo with a bigger territory though allied with Portugal and of katholic religion.

kilwa.1579-01-01.africa.political

Kilwas ally at Cape Horn – Marehan, is at war with its northern neighbors. Marehan is only of dynastic use. I am thinking of dissolving the alliance, not to get drawn into some stupid, unimportant war.

In Indonesia Kilwa is safely allied with and married to a big local power Malacca, who also loves Kilwa quite a lot. Indonesia has a lot of unclaimed though very poor and aggrssive provinces.

kilwa.1579-01-01.indonesia.political

Technological Situation

Regarding technology Kilwa is far behind, if not lost. Luckily Kilwas neighbors are at around the same backward technological level.

kilwa.1579-01-01.world.technology

Kilwa is at technology level 26, whereas the technological leaders in Europe are at level 43. A +50% technology cost modifier of the inidan technology group and a additional +10% modifier for a tribal government take a heavy toll. Additionally a lot of administrative expenses like core creation, inflation reduction, maintaining stability and the advancement of the ideas in the 2nd idea group leave no points to advance administrativ technology.

kilwa.1579-01-01.technology

Kilwa has 10 ideas in the explorative and administrative idea groups.

kilwa.1579-01-01.ideas

Military Situation

The miltary situation is dense but managable. Kilwa is constantly at war with rebels and plotting vezirs (which at the current size of Kilwa rise up with 20 regiments and a 2 star military leader).  Though Kilwa has the worlds 7th largest theoretical manpower reserve which recovers at 5000+ each year,  manpower is almost always depleted and Kilwa depents heavily on mercenaries.

kilwa.1579-01-01.manpower

The current army consists of 36 regiments, where 6 or so are guarding colonies in aggressive provinces and can not be used in warfare. Kilwa has a rather puny 1-star leader at the head of her troops. Because she is stretched out so wide along the african coastline and into Indonesia, Kilwa maintains a flleet of transports, which can move all regiments anywhere in one shipment. The trade fleet of 11 ships could be larger. 8 war ships are at hand for blockading and sinking fleets of neighboring enemies, which are by no means a threat to Kilwas navy.

kilwa.1579-01-01.military

Most provinces have a level 2 fort and important provinces have a level 3 fort.

Infrastructure Situation

The income surplus is constantly re-invested into infrstructure. First into important military structures (fortification, drydocks in strategic positions), then trade and production buildings and then into buildings that support manpower. This way almost all provinces were fitted with temples, constables, and armories and Kilwa notably has the most provinces fitted with level 3 forts worldwide.

Future Plans

Short-Term Plans

Making Portugal a direct neighbor

Currently I am working to colonize  the rather uninteresting province Cape Coast which neighbors Portugals Gold Coast colony.

  • One reason is the technology cost reduction of -25%  for new technologies, if a technological advanced neighbor exists. Portugal is at technology level 40.
  • Another reason is, if I chose to westernize Kilwa, she needs a neighbor that is in the western technology group.

kilwa 1579-01-01.colonizing cape coast

Medium-Term Plans

Finishing the Adminstrativ Idea Group

  • This is necessary to reform the government into a monarchy
  • This is necessary to implement  The Colonial Adminstration Act
  • This is useful as it reduces mercenary cost significiantly

Improving Legitimacy

  • This is necessary to reform the government to a monarchy
  • I hope this will keep Vezirs from constantly plotting against the ruler of Kilwa
  • This will lower the national unrest significiantly.

Reforming the Government into a Monarchy

  • This will remove the technology cost penalty for tribal government
  • and hopefully open up new options

Implement The Colonial Adminstration Act

  • This is useful for speeding up colony growth.

Westernize Kilwa

I am not yet sure of that one. In terms of numbers it would make sense, as Kilwa has around 60 technology levels to go, which will cost her in the indian technology group around ~900 x 60 = 54.000 monarch points, but would cost her ~ 600 x 60 = 36.000 monarch points in the western technology group. The westernization costs 2000 monarch points. And lets put in another 1000 monarch points, for dealing with all the unrest. But this still would pay off within 10 levels of technological advancement. A strong option. If Kilwa is left alone and has not to deal with strong enemies. Defenitly the way to go.

Conquer Central Africa and West Africa

This is the place to expand medium-term. Central and West Africa has weaker, though wealthier nations than Kilwa. And they are sunnis, which helps a lot with dealing with unrest and managing assimilation. I will find a way, to deal with the catholics in Kongo.

kilwa.1579-01-01.africa.tax base

kilwa.1579-01-01.africa.religion

Conquer the Arabian Peninsula

Northeast africa and the arabian peninsual have poor provinces, but what else to conquer after Central and West Africa? And the arabian peninsula is a first step to a long-term goal of conquering and territorial integrating India and the Ottoman Empire.

Conquer and Colonize Indonesia

Indonesia is partly sunni, has moderate rich provinces and will be the bridge to Australia and the base for the long-term goal of conquering China.

kilwa.1579-01-01.indonesia.tax base

kilwa.1579-01-01.indonesia.religion

Long-Term Plans

  • Improving Legitimacy
  • Conquer India
  • Establish territorial integrity by conquering the Timurids
  • Conquer China
  • Colonize Australia
  • Colonize America

Pre- Finishing Plans

  • Conquer the Ottomans
  • Conquer Oirat, Kazan and Russia

Finishing Plans

  • Conquer Europe

Of course I can do that before 1850.

Alright, these are the plans of my megalomania. Let’s see.

Some Mighty Words on the Gameplay So Far

The interesting thing in this game so far is to cope with expansion and unrest and internal nation management. Also I am still in the state of figuring out how this game work, let alone how to play it in an efficient way. This is my longest game so far and the 3rd one I tried playing for a longer while. I just seriously tried and seriously failed two times before with Austria. Therefor there are enough challenges to keep me interested. But if i knew the game well and knew how to play it efficiently, it would be boring. This game I play on normal difficulty. Maybe hard difficulty is the choice of the next game. Or itry again with Austria. …

Serving Static Files in Django

Note to Public Visitors

This article and its contained information are intended as additional information for myself on top of what can be found on the internet in general. By no means it is covering the topic exhaustingly.

Software Versions in this How-To

  • Ubuntu 10.04
  • Apache 2.2.14
  • Python 2.6
  • Django 1.15

Resources

dev server

  • https://docs.djangoproject.com/en/1.5/howto/static-files/

production server

  • https://docs.djangoproject.com/en/1.5/howto/static-files/deployment/
  • https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/#serving-files

Information

  • STATIC_ROOT = '/static/'

    will serve the static files from the domains root path where as

    STATIC_ROOT = 'static/'

    will serve the static files from the path that was requested via the url plus a “static” segment

  • The contents of the variable STATICFILES_FINDERS
    STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    #'django.contrib.staticfiles.finders.DefaultStorageFinder',
    )
    

    determine the following:

    • how (and thus where) the dev server will search for static files when it wants to serve them
    • how (and thus where) django will search for static files when the shell-command
      python manage.py collectstatic
      

      is used.

  • When
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    

    is used in variable STATICFILES_FINDERS

    • the static files have to reside in a subfolder called ‘static/’ within an apps folder (eg: MyProject/App1/static/)
    • no static files will be collected from the projects own package folder (eg: MyProject/MyProject/static/)

Dos and Don’t Dos

  • when using the dev server for a project, in any case use
    STATIC_ROOT = '/static/'
    • because the dev server serves the website at the root of ‘localhost:<port>’
    • and the static files being served at ‘localhost:<port>/static/’ fits this behavior.

How Tos

Serving a Django Project from an URL-Path on a Production Server

Important Note

This howto just contains the differences in the setup from the setup of django project/a website in a domains root path.

Basic Explanation of how it works

The shell command

python manage.py collectstatic

will be used to collect all static files once to a folder, from where Apache will serve them later on. In Apaches config file an alias has to be set, which maps the the URL-path from where Apache serves the static files to the folder on the server.

Configuration of the Django Project

settings.py

  • Set STATIC_URL to the absolute url-path from where the static files for this project shall be served (eg.: /project89/static/).
  • Set STATIC_ROOT to the folder on the server where the static files (will be collected to and will be served from by apache) shall reside, using an absolute path (eg: /home/user/djangoprojects/project89/collectedstaticfiles/).

Configuration of Apache

httpd.conf

Note that any changes to httpd.conf require a restart of apache.

  • The alias config string that maps the url-path of the static files to a folder on the server has to include the full path in the url
    eg:

    Alias /project89/static/ /home/user/djangoprojects/project89/collectedstaticfiles/
    

Version Control

Why Version Control?

  • To be able to revert changes.
  • Because it is a code backup solution.
  • Because one can see what exact changes were made to resolve an issue.
  • To be able to re-establish the state of the code, at any given point in the development process.
  • To be able to re-establish the state of the code, for any version of the product.

WordPress Plugin “Table of Contents Plus”

This is a must have for bloggers who write long structured articles and posts. It automatically adds a table of contents element to a page or post. It bases its contents on headings in the post. Fully configurable. Great benefit! Thanks to the author!

Plugin download page at wordpress.org:
http://wordpress.org/plugins/table-of-contents-plus/

Plugin homepage:
http://dublue.com/plugins/toc/

Code Syntax Highlighting in WordPress: Plugin “SyntaxHighlighter Evolved”

There is a nice plugin for that: “SyntaxHighlighter Evolved”
http://wordpress.org/plugins/syntaxhighlighter/

Some documentation can be found here:
http://en.support.wordpress.com/code/posting-source-code/

Adding a Template to a WordPress Theme

WordPress version: 3.5

Create a php-file in the theme folder, with whatever name you choose. E.g.

MyTemplate.php

The php-file has to contain at least the following code to be recognized as template:

<?php
/*
Template Name: A Nice Template Name
*/
?>

Replace the string “A Nice Template Name” with whatever string by which you want it to be selectable. The string can contain spaces and special characters. The template now will be recognized by WordPress and you can choose it, for example, as template for a new page. The template will be selectable by the name “A Nice Template Name”. It just would not display anything.

Usually a template is aligned with the theme by using the themes header and footer at least.

<?php
/*
Template Name: A Nice Template Name
*/
get_header();

get_footer();
?>

.NET Lambda Expression Cheat Sheet

Resources

A Simple Lambda Expression

A simple lambda expression looks like this:

x => x + x
  • => is called the lambda operator.
  • The left side of the lambda operator holds the parmeter / the parameters to the lambda expression.
  • The right side of the lambda operator holds an expression or a statment block.

Parameters to a Lambda Expression

  • Parameters to a lambda expression are on the left side of the lambda operator
  • Multiple parameters have to be enclosed in parentheses
(x, y, z) => x + y + z;
  • A single parameter can be written without parentheses
x => x + x
  • For a paramterless lambda expression, only the parentheses have to written.
() => 5 + 5

Type Inferrence

  • The rules for type inferrence apply to lambdas as to everywhere else in c#.

The following two examples are equal:

(x, y, z) => x + y + z;

 

(int x, int y, int z) => x + y + z;
  • A single but explicitely typed parameter to a lambda also has to be enclosed in parentheses
(int x) => x + x

Make Use of a Lambda Expression with Delegates

  • To make use of a lambda, it has to be assigned to a delegate.
delegate void MyDel (int x);
...
MyDel lx = x => x + x;
Console.WriteLine(lx(5));//10
  • A lambda can also be used where a delegate is expected. In this case it will automatically be assigned to a delegate of the expected type.

In the following example the function DelegateCaller expects a delegate of type int(int).

using System;
namespace LambdasDemo
{
    class Program
    {
        delegate int IntDel(int i);
        static void Main(string[] args)
        {
            Console.WriteLine(DelegateCaller(x => x + x, 5)); //10
        }

        static int DelegateCaller(IntDel del, int x)
        {
            return del(x);
        }
    }
}

Statement Lambdas

  • Statement lambdas hold a statement block on the right side of the lambda operator.
  • The statement block has to be enclosed in curly brackets as in every other function in c#.
  • To pass something back from the statement lambda to the caller, the return keyword is used (as in every other function in c#).
x => {int y = 2*x; return y;}
  • If return is not used explicitely, the statement lambda implicitely returns void.
delegate void MyDel (int x);
...
MyDel lx = x => {int y = 2*x; Console.WriteLine(y);};

Expression Lambdas

  • Expression lambdas hold an expression on the right side of the lambda operator.
  • Per definition an expression is everything, that returns something.
(int x) => x + x

… returns int.

(string name) => "Hello " + name + "!"

… returns a string

x => Console.Writeline(x)

… returns void (because Console.WriteLine(…) returns void).

  • This way a statement block of a statement lambda can also be viewed as an expression.  The statement block as a whole always returns something. Either somethding, that was passed explicitely or an implicitely passed void.

It Is Important to Know What a Lambda Returns and Why

The following expression lambda and statement lambda are equal:

(int x) => x + x

 

(int x) => {return x + x;}

… they both return int.

d => Math.Floor(d)

… returns int. Int is the return type of Math.Floor(…).

d => {Math.Floor(d);}

… returns void. Void is the implicit return type of the statement block.

d => {return Math.Floor(d);}

… returns int. Int is the explicit return type of the statement block.

Josef Hader – So ist das Leben

wrapping javascript into a CDATA section

good idea so it does not get affected by content changing javascript (like gtranslate)

<script type="text/javascript">
 //<![CDATA[
 jQuery('input#shippingSameBilling').click(function(){
 if(jQuery('input#shippingSameBilling').is(':checked'))
 {
 jQuery('tr.wpsc_shipping_forms').fadeOut(200);
 }
 else
 {
 jQuery('tr.wpsc_shipping_forms').fadeIn(200);
 }
 });
 //]]>
</script>

Apache 2.2.14 (ubuntu) & Ubuntu 10.04 LTS

Information Resources

http://httpd.apache.org/docs/2.2/en/

Shell Commands
sudo apache2ctl
sudo apache2ctl -v //show version number
sudo apache2ctl start
sudo apache2ctl stop
sudo apache2ctl restart
Location of Configuration Files
apache config:
etc/apache2/apache2.conf

site configs are in:
/etc/apache2/sites-available

default site config:
/etc/apache2/sites-available/default

If you are not sure if this is the file apache is using to load the configuration from, try this:

  • Put a typo into the configuration file, like “xyz”.
  • Let apache check the configurations syntax
    user@machine:~$ sudo apache2ctl -t
    Syntax error on line 240 of /etc/apache2/apache2.conf:
    Invalid command 'xyz', perhaps misspelled or defined by a module not included in the server configuration
Setting the DocumentRoot

Change the DocumentRoot directive in the default site configuration (/etc/apache2/sites-available/default) from

DocumentRoot /var/www

to your path.