March 25th, 2012
The following code demonstrates a technique to create a variable from a first object instance, and pass them to the instance of a second object, without copying the contents in the memory. The variable is shared between the objects, modifications can be done from all contexts.
<PRE>
<?php
class MainObject {
public $my_variable;
public function __construct(){
$this->my_variable = 'My variable in the original constructor';
}
public function &get_reference() {
return $this->my_variable;
}
public function display(){
echo $this->my_variable . "\n";
}
}
class SecondObject {
public $my_variable; //will be a reference to $my_variable in the MainObject / mo
public function __construct(){
}
public function pass_reference(&$my_variable){
$this->my_variable = &$my_variable;
}
public function modify(){
$this->my_variable = 'Modifying from SecondObject.';
}
}
echo "Passing by reference multi Test\n";
$mo = new MainObject();
//obtaining a variable by reference for the main execution context
$my_variable = &$mo->get_reference();
echo $my_variable . "\n"; //accessible from main context
//writing from main context
$my_variable = 'Changed from main context.';
$mo->display(); //it is written in the object!
//Passing by reference to a second object
$rt = new SecondObject();
$rt->pass_reference($my_variable);
$rt->modify();
$mo->display(); //it is written to mo = MainObject!
?>
Posted in PHP | Tags: PHP by reference | No Comments »
March 18th, 2012
Der verurteilte NS-Kriegsverbrecher John Demjanjuk ist im Alter von 91 Jahren in einem bayerischen Pflegeheim gestorben. Bis zuletzt hatte er keine Reue gezeigt. Sein Sohn stellt ihn nun als Sündenbock dar, der für die Taten der "Nazi-Deutschen" habe büßen müssen. (Spiegel.de)
Ein alter Mann, der im Pflegeheim lebt, und immer noch an Konstrukten festhält die unsere Geseelschaft iakzeptabel findet … ein Sohn der versucht ihn als Helden darzustellen … sehr traurig das ganze!
Posted in Uncategorized | No Comments »
March 14th, 2012
To understand the following very cool posting a little better, you have to be an Indian, or have seen Sita Sings the Blues (another very cool project btw).
http://www.themattefinish.com/blog/2009/08/if-the-ramayan-were-on-facebook/
Posted in Uncategorized | No Comments »
March 11th, 2012
Alles am Weibe ist ein Rätsel, und Alles am Weibe hat Eine Lösung: sie heißt Schwangerschaft. Der Mann ist für das Weib ein Mittel: der Zweck ist immer das Kind.
Posted in philosophy | No Comments »
March 10th, 2012
Short version:
it does not work.
Long version:
Shoes.setup do
gem 'mysql2'
end
require 'mysql2'
Shoes.app do
flow do
stack :width => 200 do
caption "Control"
button("Run Query") {
Thread.start do
@log.text += "Run query executing\n"
#Thread.start do
@client = Mysql2::Client.new(:host => "localhost", :username => "myusername", :password => "mypassword", :database => "shoes_test", :async => true)
#end
@log.text += "Post connection\n"
@results = @client.query("SELECT * FROM test")
@log.text += "Post query execution"
@results.each do |row|
@log.text += "Keys: " + row.keys
end
end
}
button("Test Interface"){
@log.text += "\n\tSuccess!\n"
}
end
stack :width => -200 do
caption "Output"
@log = para "App initialised\n"
end
end
end
To be able to execute the code above, you will have to jump through a couple of hoops. We’re assuming the policeman build of shoes here, which ships Ruby 1.9.1 internally.
The shoes version can be found out by going
shoes –v
on the windows console.
- Shoes will download install the Mysql2 gem. Very elegant!
- Obtain the mysql.dll from the MySQL download page (use the C Connector, mysql-connector-c-noinstall-6.0.2-win32.zip )
- get mysql.dll from this package
- put it into your shoes directory where the other dlls reside: C:\Program Files (x86)\Common Files\Shoes\0.r1514
- patch shoes.rb ( C:\Program Files (x86)\Common Files\Shoes\0.r1514\lib\shoes.rb ), by adding these new encodings:
class Encoding
%w[ASCII_8BIT US_ASCII Big5 Windows_1250 Windows_1251 Windows_1256 Windows_1257 CP850 CP852 IBM866 Windows_31J EucJP_ms EUC_KR EUC_CN GBK ISO_8859_7 ISO_8859_8 KOI8_R KOI8_U ISO_8859_1 ISO_8859_2 ISO_8859_9 ISO_8859_13 MacCentEuro MacRoman SHIFT_JIS TIS_620 EucJP_ms UTF_8 UTF_16BE UTF_16LE UTF_32BE UTF_32LE].each do |ec|
eval "#{ec} = '#{ec.sub '_', '-'}'"
end unless RUBY_PLATFORM =~ /linux/
end
- Now the program will execute in Shoes, but it will hang forever at the Mysql2::Client.new line. Test this by putting it into a thread of its own.
- The problem seems to be Windows and Ruby 1.9+ specific, unfortunately there seems no easy solution for this, short of recompiling the gem.
- if you find a solution, please post it here as a comment, thank you!
Some Screenshots:
Shoes Version:


Illustrating the Encoding constant error (solution provided)

This is what the app looks like.
Posted in Ruby | Tags: Mysql2, Ruby, Shoes | No Comments »
March 8th, 2012
Eine wunderschöne Schrift. Und auch noch frei zum Download. Respekt!
Beachtet auch das PDF was auf dieser Seite verlinkt ist, maarvellllous design.
Posted in art | Tags: fonts, Schriftsätze, Type | No Comments »
March 8th, 2012
Digital Rube Goldberg Processor from The Product on Vimeo.
Es wurde unter anderem die Programmiersprache Processing eingesetzt.
Posted in art, Fun | Tags: IT, Rube Goldberg | No Comments »
March 7th, 2012
Today I found an interesting page, from a woman entrepreneur’s blog. It’s a short history of her experiences. There’s one sentence in particular which strikes me as significant: “Instead I wasted my time wating for other people to give me what I wanted”. Yeah, do not wait for your lucky break. Create it to order!
This gets me thinking especially about a CD series and DVD series with fantastic chillout music I was planning …. I intended to go the original “looking for a label route”. But – Jini’s idea is much better! Just start producing the music yourself, set up your own label, … and there you go.
Another point (from her site) is, know the stuff you are controlling – i.e. website design / programming, but use this knowledge to control other people’s work. I know this theoreticallly, but lapse persistently into doing it myself …
Yet another point: Anita Roddick apparently never researched the market, but said – if she needed it, that others would probably too, and just launched it.
Posted in English, entrepreneurship | Tags: entrepreneurship, motivation, self-reliance | No Comments »
March 4th, 2012
We are rapidly advancing towards the possibility of stomping out Malaria and many other diseases. There are some diseases, which only befall humans, whilst others also plague the animal kingdom, and of course many plant illnesses.
Some philosophical, ethical and rational questions are raised:
- Is it ethical to destroy life-forms, albeit pathogenic ones, or ones essential to pathogen success (i.e. Mosquitos) ?
- Will these illnesses be replaced by something even more sinister? There is a condition known as toxic megacolon, a complication of pseudomembranous colitis, which in turn is caused by killing “good” bacteria, so the Clostridium difficile bacteria have an open field to play it. There is the theory that excessive cleanliness may cause autoimmune diseases.
- Where should we start, which things demand most immediate action?
- Destroying pathogens may leave us with a few hyperresistent pathogens, which will be much harder to fight. MRSA – Methicillin resistant Staphylococcus aureus is but one example of multi-resistance against classic antibiotics.
- What about animals, plants and their suffering? Is it ok to be selfish and start with ourselves as a race? How much resources should be dedicated to non-human ailments?
- What about bio-eco-systems? If we take out the mosquitoes out of the equation, will other, desirable systems collapse?
These, and many more questions need to be raised constantly. Great power demands great responsibility.
Posted in philosophy | Tags: Ailments | No Comments »
March 4th, 2012
Wenn man einen API Key holen will, gibt es da so einen Smiley. Selbst wenn man also ein privates Blog betreibt, oder so was kommunales und gemeinnütziges wie die Synapse Redaktion, muss man da durch, und das Smiley traurig machen. Habe ich bisher nicht geschafft. Mal schauen, ob ich mich doch noch überwinden kann – und die Augen vor diesem Smiley verschließen kann.
Richtig glücklich wird es allerdings erst wenn man 120 $ pro Jahr zahlt.
Posted in Internet | Tags: Akismet | No Comments »