Simple redirection using PHP and HTML meta tag
Something everyone needs once in a while… maybe you moved a file on your server or you did not install wordpress in the root folder of your webserver – like I did neither
– a redirection or forwarding can be an easy answer.
The script is rather simple – it redirects in three ways to provide a reasonable fall back if any of the automatic redirecting fails. To use it on your server, just enter the URL/address/file name/folder you would like the user to be redirected to in the second line of the page/script.
<?php
$url = 'put your URL between the parenthesis';
header("Location: $url");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta http-equiv="refresh" content="0;url=<?php echo $url; ?>"/>
<title>You will be redirected... </title>
</head>
<body>
If you are not redirected automatically, please click <a href="<?php echo $url; ?>">here</a>.
</body>
</html>
fixing flex VideoDisplay CuePointManager
I was creating a Flex application to show slides and a presentation video of previously recorded presentations. Accordingly, each slide should appear at a certain point of time in the video – calls for cue points!
As all slides and there appearance are stored in a text file in my case, I started adding cue points with ActionScript. But as soon as the video can be controlled with a slider, allowing to shift for- and backwards, the event handler “cuePoint” was not triggered any more. Thus, the slides where not changed correctly as the user jumps ahead, as the cue points between the previous and the new position did not cause and cue point event.
Finally I wrote AdvCuePointManager, inheriting from CuePointManager, but which can deal with jumping back- and forward.
Copy it to “<your source folder>/net/svenbuschbeck/flex/video” and use it as follows:
<mx:VideoDisplay cuePointManagerClass="net.svenbuschbeck.flex.video.AdvCuePointManager" />
how to install memchached 1.2.2 from source
I have installed an instance of memchached version 1.2.2 on one of our servers (Debian etch) today and to keep you from spending a whole afternoon, see my everything-step-by-step instruction below.
Memchached is a distributed hash map, which can be used for example to speed up any kind of web application, see website for details. In our case, we want to use it as temporary data store. I will report about the experiences in a latter post.
introduction
Always refer to this page for details, but I created a version with less text but including steps to really start from scratch.
All lines starting with # are command lines, i.e. you need to type into a linux shell.
Output of any kind is always surrounded by ” even if it is multiline output.
content
a. get libevent (needed to install memcached)
b. get memcached and verify installation
c. use and test memcached within Java with junit/ant
a. installing libevent 1.3
a.1. check for current version of libevent
a.1a.
Log in as root or get super user rights by calling su
# updatedb
# locate libevent
If there is output including “libevent1″ and/or “libevent-1″ (ignore package files like *.deb) -> a.1b, otherwise a.2
a.1b. removing old libevent version
# apt-get remove –purge libevent1
# Y
# updatedb
# locate libevent
Should now return nothing or package files only, i.e. you are ready for installation
a.2. installing libevent 1.3
a.2a downloading and unpacking
# cd /usr/local/src
# wget http://monkey.org/~provos/libevent-1.3b.tar.gz
# tar zxvf libevent-1.3b.tar.gz
# cd libevent-1.3b
a.2b. configuring
# ./configure
check the output, if it contains something like “configure: error: no acceptable C compiler found in $PATH” -> a.2c. otherwise a.2d.
a.2c. compiling
# apt-get install gcc
Redo a.2b.
I got output like “C compiler cannot create executables”, reading file ‘config.log’ did not help me at all. Googling finally did, as I found a forum entry, pointing out a missing lib.
So try this:
# apt-get install libc-dev
Redo a.2b.
If that did not solve it… sorry … google on, there is no sense in going on without solving this issue. :-/
a.2d. make it!
# make && make install
If you get something like “-bash: make: command not found” -> A.2e, otherwise A.3.
a.2e.
# apt-get install make
Redo a.2d.
a.3. configuration
Press the Esc key as you read [esc] in the commands below.
# vim /etc/ld.so.conf.d/libevent-i386.conf
# i/usr/local/lib/[esc]:wq
# ldconfig
b. install memchached and verify installation
b.1. download, unpack and install memchached
# cd /usr/local/src
# wget http://danga.com/memcached/dist/memcached-1.2.2.tar.gz
# tar zxvf memcached-1.2.2.tar.gz
# cd memcached-1.2.2
# ./configure
# make && make install
After installing gcc and libc-dev in section a, this one went easily for me – if you skipped section a and run in problems here, please install gcc and libc-dev (see a.2c).
b.2. verify installation of memchached
b.2a. start memchached server
# memcached -u www-data -vv
Output should end with line “<3 server listening”. Perfect!
b.2b test server
I will refer to this shell in front of you as server shell below. Now, open another shell on the same machine, I will refer to it a client shell.
# telnet localhost 11211
You should see something like “<7 new client connection” on the server shell, switch back to client shell.
# set test1 1 10000 1
# a
You should see “STORED” on client shell and the two following lines on server shell
“<7 set test1 1 10000 1
>7 STORED”
Perfect!
You did it, your memcached is up and running
c. memcached and Java
I wrote a little test package using a Java client library for memcached from here, together with junit and ant. You can download it to have a look how simple using memcache is and to verify your installation with an included junit test, automated with an ant build file.