Archive for May, 2007

You are now browsing the archive for May in 2007.

Perl: Post automatically to WordPress blog with wp-poster.pl

I just wrote a Perl script that can automatically post to a WordPress blog. This could come very handy if you want to post a certain post at times. This could be anything, from a list of what you listen to every day, to your bookmarks, to your AdSense earnings, to the status of a server.

The code was tested on the latest version of Wordpress, WP 2.2 (actually, it was WordPress MU 1.2.1), but I suspect that it will work fine for almost every version. Three HTTP requests are required; one to log in, one to get some security-check-values (_wpnonce and temp_ID), and one to make the actual post. You need the LWP (lib-www-perl) package, which you probably already do have, and if you don’t, you can get it freely at cpan.

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl
 
#    Copyright 2007 Tim Johansson
#    http://timjoh.com/
 
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
use strict;
use LWP::UserAgent;
 
# change this
my $burl = 'http://timjoh.com/'; # don't forget the trailing slash
my ( $usr, $pwd, $uid ) = ( 'USERNAME', 'PASSWORD', 1 ); # uid=1 if you are the initial administrator
 
# ua
my $ua = LWP::UserAgent->new;
$ua->agent('wp-poster');
$ua->cookie_jar( {} );
 
# login
my $req = HTTP::Request->new( POST => $burl . 'wp-login.php' );
$req->content_type('application/x-www-form-urlencoded');
$req->content( sprintf('log=%s&pwd=%s&wp-submit=1&redirect_to=wp-admin/',$usr,$pwd) );
my $res = $ua->request( $req );
 
# get _wpnonce and temp_id
$req = HTTP::Request->new( POST => $burl . 'wp-admin/post-new.php' );
$res = $ua->request( $req );
if ( $res->is_success ) {
        if ( $res->content =~ m/"_wpnonce" value="([0-9a-f9]+)".*'temp_ID' value='(-?[0-9]+)'/s ) {
                # post
                $req = HTTP::Request->new( POST => $burl . 'wp-admin/post.php' );
                $req->content_type('application/x-www-form-urlencoded');
                $req->content( sprintf(
                        '_wpnonce=%s' .
                        '&user_ID=%d' .
                        '&action=post&originalaction=post&post_type=post' .
                        '&temp_ID=%s' .
                        '&advanced_view=1' .
                        #'&comment_status=open' .
                        #'&ping_status=open' .
                        #'&post_password=' .
                        #'&post_name=' . #slug
                        '&post_status=publish' .
                        #'&edit_date=1' .
                        '&post_title=%s' .
                        '&content=%s' .
                        '&post_pingback=1' .
                        '&prev_status=draft' .
                        '&publish=Publish' .
                        '&referredby=redo'
                        ,
                        $1, #nonce
                        $uid,
                        $2, #tempid
                        'test', #title
                        'Testar.' #content
                        )
                );
                $res = $ua->request( $req );
                &debug($res, 2);
        } else { &debug($res, 1); print $res->content }
} else { &debug($res, 0) }
 
sub debug {
        my ( $res, $id ) = @_;
        print $id, ': ', $res->status_line, "\n";
        foreach ( $res->header_field_names ) {
                print $_, ': ', $res->header($_), "\n";
        }
        return;
}

Please do not use this code for any malicious purpose. Spamming is evil.

Literary Analysis of The Old Stoic, by Emily Brontë

Riches I hold in light esteem,
And Love I laugh to scorn;
And lust of fame was but a dream,
That vanished with the morn:

And if I pray, the only prayer
That moves my lips for me
Is, “Leave the heart that now I bear,
And give me liberty!”

Yes, as my swift days near their goal:
‘Tis all that I implore;
In life and death a chainless soul,
With courage to endure.

Emily Brontë’s (1818-1848) The Old Stoic explains how a stoic—an apathetic and passive person—reasons about dreams and happiness. His only wish is to leave this life and to achieve complete freedom, rejecting carnal pleasures such as material wealth, love and fame.

The poem consists of three stanzas, containing four lines each. All twelve lines rhyme according to the rhyming scheme ABAB, CDCD, EFEF. This is common among Old English poetry, and leaves more energy for the reader to analyze the content of the poem. Also common is the iambic rhythm. Brontë varies regularly between iambic tetrameter for odd-numbered lines, and iambic trimeter for even-numbered lines. This creates a certain flow in the poem, which makes it easy to read. The polysyndeton at the lines two and three further helps simplifying the text.

The Old Stoic has a tone of simplicity. Most words used are from the Anglo-Saxon language, such as “love”, “laugh” and “death”. Very few advanced words are used, with “liberty” being the only one with more than two syllables. By applying this vocabulary, Brontë makes the “old stoic” seem unintelligent, while at the same time letting the reader focus on the message of the poem.

Each stanza of The Old Stoic deals with a different part of the stoic’s thoughts. Throughout the poem, the stoic is the narrator. In the first stanza, he describes that he finds the worldly things unnecessary: “Riches I hold in light esteem”. He also tells that he did have a wish to be famous, but it “vanished with the morn”, where the “morn” could symbolize the melancholy resulting from realizing how sad life is.

In the second stanza, the narrator reveals his current wish, which is to become free—“give me liberty!”—but he also states that this can only be achieved through death, since he wants to “Leave the heart that now I bear”. The narrator’s wish remains in the third stanza, but there, he adds that he needs the “courage to endure”. I interpret it as the courage to endure life until his soul will be set free.

Since Brontë is very straight-forward in this poem, there is not much to analyze. I am unable to detect any sign from the writer that there is a deeper meaning than what the stoic says himself. Thus, there are two alternatives; Brontë could be using the stoic as a medium for communicating her opinions, or she could be sarcastic.

Emily Brontë died from tuberculosis, after having rejected any medical treatment. This suggests that she was of opinions similar to the old stoic , and thought that we can be free only when we are not bound by things such as medicines. Another fact which favors the former theory is that female authors were looked down upon at that time. Expressing opinions through a man, even if he was fictional, was a better way if a woman wanted to be taken seriously.

Damaetas, by Lord Byron

In law an infant, and in years a boy,
In mind a slave to every vicious joy;
From every sense of shame and virtue wean’d;
In lies an adept, in deceit a fiend;
Versed in hypocrisy, while yet a child;
Fickle as wind, of inclinations wild;
Women his dupe, his heedless friend a tool;
Old in the world, though scarcely broke from school;
Damætas ran through all the maze of sin,
And found the goal when others just begin:
Even still conflicting passions shake his soul,
And bid him drain the dregs of pleasure’s bowl;
But, pall’d with vice, he breaks his former chain,
And what was once his bliss appears his bane

Damaetas was written by George Byron, the 6th Baron Byron (1788–1824). It tells the story of a boy’s decadent life. The first six lines explains the boy’s childhood; how he was easily tempted, and how he had lies by heart as he grew. Byron goes on describing the boy’s adulthood, which is equally decadent with sins and temptations. However, the plot experiences a sudden twist in the last two lines, where the character turns against everything that he has done and changes his lifestyle.

Stylistic devices abound in Damaetas. The rhyming scheme–AABBCC, and so on–is regular and strictly followed throughout the poem. No additional rhymes can be found. Like the rhyming scheme, the rhythm is very regular. Every line contains exactly ten syllables and is written as an iambic pentameter, except for line 13, which disturbs the pattern slightly. Despite this line, the regularity of the poem makes it fluent and easy to read. Further simplifying reading, Byron makes good use of assonances. Some examples are line four, “in deceit a fiend”, and the final line, “what was once”, which is also an alliteration.

It is worth to note that the poem contains just a single stanza. The effect of this is that it is read more as an ongoing story, as opposed to a story split into chapters, where there are pauses to make. This makes the end, which will be further discussed later, come more suddenly and have a larger element of surprise.

Mystery, danger and decadence are words which describe the tone of the poem. These must be used in conjunction, since only one of them cannot portray the whole atmosphere. What is dangerous is often mystical, and when it comes to this kind of long-term life-style-dependent danger, it is often referred to as decadent. Byron uses a certain vocabulary with the intention to enhance this feeling.

Words connected to magic and other mystic topics are used when other words would suffice, such as line four, “adept” and “fiend”, and line 13, “drain”. Line ten sees the metaphor of an abstract maze, which is often used to describe enigmatic situations. Grand words–for instance “virtue” (line three), “passions” (line 13) and “bliss” (line 15)–contribute to the atmosphere of decadence, since that word is often connected to whole life-styles, which are dangerous and morally questionable, instead of just dangerous actions.

It is reasonable to assume that the main character of the poem bears the name Damaetas. Despite extensive research, though, I was unable to find any information about that name. The only reference to Damaetas in literature is in the 1673 poem Lycidas by John Milton, in which the name is mentioned once: “And old Damaetas lov’d to hear our song”. Unfortunately, this brings no deeper understanding on why Lord Byron chose this name.

The first line of Byron’s poem is ambiguous. I interpret it as if Damaetas grows rapidly; when he was legally an infant, his body was that of a boy. However, it could be a simple observation of his age, i.e. He was an infant according to law, and just a couple of years old, that is, a boy. Line two tells of his tragic disposition to temptations, using the hyperbole “in mind a slave”. The fourth and fifth lines describe how he was brought up with lies, and how he learnt to use them himself.

Line six notes Damaetas’s impulsiveness; he would “fickle as wind”, and the wind is unreliable. This is yet another one of many attributes, which are associated with failures, given to the boy. The subsequent line tells of how he lived for women, which is also looked down upon. In line ten, Byron summarizes the main character by writing that he ran through the “maze of sin”.

At the beginning of line 14, the turning point of the poem, Damaetas is “pall’d with vice”. “pall’d”, which has an omitted E, is the past participle of “pall”. One meaning of that word is “to weaken”. A vice is a bad habit; the antonym of virtue. Thus, Damaetas, despite his former failures, starts afresh and, as the final line reads, turns his previous bliss to his bane.

I believe that what Lord Byron wants to convey is that it is never too late for change. He makes a very effective introduction, portraying the boy as the archetype of a failure, until he swiftly swings everything around.

December Elegy, by Morten Veland for Tristania

May, thou carry me to the sea
Like Autumn leaves, heaven withers
Savage is the winter prevailing within
I fall for thee
Sorrow entreating me
Makes me leave heaven

I find thy lilies there in snow
where once I died, weeping for thee
Everlasting seems the strife ascending within
Falling for thee
Darkness confounding me
Makes me leave life

Breed my woe
Descend with broken wings
Midwinternight inside
Merged by life
Like thousand frozen tears
Come melt the ice, maytime

December Elegy

An “elegy” is a type of poetic metre, which was used in Ancient Greece. However, it is nowadays used as a general denomination for poems which describe sorrow and mourning. December Elegy was written in 1998 by Morten Veland for the musical group Tristania, and thus its name derives from the modern meaning of “elegy”. The poem describes the narrator’s wishes for summer during wintertimes.

December Elegy is divided into three stanzas, consisting of six lines each. There is a seemingly random rhyming scheme. The first stanza rhymes ABCAAD, and the second EACAAF. Note that several of these rhyming pairs are repetitions, such as “within” and “within”. The only true rhymes found in those stanzas are “sea”, “thee” and “me”, and only the former is used just a single time. The third and last stanza seems to abandon rhymes altogether; disregarding “life” rhyming on itself from the prior stanza, there is only “woe”, which rhymes on the first line of the second stanza, “snow”.

The lack of a rhyming scheme suggests that the rhymes, which do exist, are a coincident. Since they are so far apart, they do not have any appreciable effect on the reader. However, the repetitions are effective. The two lines ending in “thee” are merely rewordings of each other, and such emphasize the fact that the narrator is falling for “you”. The third lines in both stanzas constitute the “within”-rhyme. These two lines both describe what is happening inside the narrator; about the dominating winter and the interior strife. This theme also carries on to the third stanza, although it uses a synonym of “within” instead: “Midwinternight inside”.

Partly due to the lack of rhymes, the rhythm cannot be easily discerned. It can be seen that the first two stanzas are very alike in the number of syllables per line, differing only slightly in the third and last lines, although this does not simplify reading out aloud. There is thus no apparent rhythm.

Winter, darkness and sorrow are themes which appear throughout the poem, and this influences the tone. Veland has chosen lyrics with connotations of negative feelings, such as coldness. Some of these words are “winter”, “frozen”, “savage” and “wither”. In some way, nearly all of the words are connected to winter. This creates an unfriendly atmosphere.

Veland also uses intricate and rare words. An obvious example is the archaic pronouns “thou” and “thee”. “Entreating” and “confounding” are two other words which are not common today. These archaisms produce the feeling that this happened a long time ago. They also contribute to the feeling of distance and coldness, since it is distant in time.

As noted above, December Elegy is divided into three stanzas. These constitute three different parts, or modes, of the poem. The first stanza begins with an invocation to May, defining that month as “thou” in the poem. In the rest of the stanza, the narrator explains how wonderful May is, e.g. “I fall for thee”, and how the winter arrives, for example “Like Autumn leaves, heaven withers”, which describes the whitening of the sky.

In the second stanza, the narrator becomes more desperate after May. He sees lilies, which are known for forming leafless bulbs for protection against winter, lying in the snow. As May is absent, he finds it difficult to stay alive: “Everlasting seems the strife”. Darkness engulfs him, and he completely loses his will to live: “Makes me leave life”.

The last stanza sees a cry for help, directed at May. Veland begs May to come down to him: “descend with broken wings”. Again, he emphasizes the coldness, now with midwinter, which is the middle of the winter, and thus the strongest and most harsh. The poem finishes with a final request that May melts the winter.

December Elegy could be interpreted as a simple tribute to summer and the happiness which it brings. However, there are several arguments against this. First, the title of the poem reveals that it is an elegy, which, as noted in the introduction, is used to describe feelings of sorrow and mourning. Also, the feelings expressed within the poem are very deep, which the writer achieves mainly through his use of words with epic connotations. As an example, the “everlasting strife” of which Veland writes is an inappropriate hyperbole for three months of winter.

I believe that the December Elegy tells not of the loss of summer in a strict literary sense, but of the loss of the metaphorical summer of the narrator, most probably a beloved person. This theory is further reinforced by the fact that May is also both female name and a surname. Instead of the joys of summer, the joys, which this person constitutes for the narrator, are told of.

The second stanza mentions lilies in the snow. Snow is an antonym of summer, which indicates the absence of May, and thus the absence of the narrator’s beloved. Lilies are commonly used on funerals. This gives another clue that the first person has lost someone. The final line could be interpreted as the person dreaming –or trying to dream—of the days when his beloved was there, the “maytime”.

There might be a message in the poem that one should not cling too hard to lost things. However, I believe that it is merely a depiction an event. Another interpretation would be that the poem really does describe the change of seasons, and that the message is that you always get a new chance. There is always a new summer after every winter.

Perfect Stranger: Strange and Scary

Perfect Stranger contains an intricate plot, with several twists. On the same time, its psychological aspects are scary. The regular black-and-white, good-and-bad separation of characters does certainly not work here, no matter how much of the movie you watch.

Another nice point with the movie is that they actually use Google and not some home-made search engine.

FireStats iconAnvänder FireStats