start ssh-agent
because i always forget how to start ssh-agent, here it is:
eval $(ssh-agent)
in a project with java and .net komponents we needed to share some validation-code. this code should be executable on both platforms and act against pocos (plain old clr objects) and pojos (plain old java objects). we tested python as a language that can be executed on both sides using jython for java and ironpython for c#. i want to show you how simple an integration of python is here.
for c# and ironpython:
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 | using System; using IronPython.Hosting; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; namespace IronPythonValidationTest { internal class Program { private static void Main(string[] args) { string code = @" if this.Von > this.Bis: result = 'von soll kleiner sein als bis' elif this.Child.Name != '': result = 'name soll gefüllt sein'"; ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); scope.SetVariable("this", new TestType {Von = DateTime.Now.AddDays(1), Bis = DateTime.Now, Child = new TestTypeNested()}); ScriptSource source = engine.CreateScriptSourceFromString(code, SourceCodeKind.SingleStatement); source.Execute(scope); string validationResult = scope.GetVariable("result"); Console.WriteLine(validationResult); Console.ReadKey(); } } public class TestType { public string Name { get; set; } public DateTime Von { get; set; } public DateTime Bis { get; set; } public TestTypeNested Child { get; set; } } public class TestTypeNested { public string NochName { get; set; } } } |
and almost the same for java:
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 | import org.python.util.PythonInterpreter; import org.python.core.*; public class JythonValidationTest { public static void main(String[] args) { PythonInterpreter python = new PythonInterpreter(); String code = "if this.Von > this.Bis:\n result = \"von soll kleiner sein als bis\"\nelif this.Child.Name != \"\":\n result = \"name soll gefüllt sein\""; PyCode pc = python.compile(code); TestType l = new TestType(); l.setVon(2); l.setBis(1); python.set("this", l); } } // this has to be a public class, so one could not put it in one classfile public class TestType { public int von; public String name; public int bis; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getVon() { return von; } public void setVon(int von) { this.von = von; } public int getBis() { return bis; } public void setBis(int bis) { this.bis = bis; } } |
remaining problems:
drop a file from the explorer to a textbox and make the path the text of that textbox:
// imports omitted, dont know why... public class Foo extends TransferHandler { //... /* DRAG & DROP */ @Override public boolean importData(JComponent comp, Transferable t) { // Make sure we have the right starting points if (!(comp instanceof JTextField)) { return false; } if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { return false; } // Grab the tree, its model and the root node JTextField textField = (JTextField) comp; try { List data = (List) t.getTransferData(DataFlavor.javaFileListFlavor); for (Object object : data) { File f = (File) object; textField.setText(f.getAbsolutePath()); } return true; } catch (UnsupportedFlavorException ufe) { System.err.println("Ack! we should not be here.\nBad Flavor."); } catch (IOException ioe) { System.out.println("Something failed during import:\n" + ioe); } return false; } @Override public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) { if (comp instanceof JTextField) { for (DataFlavor transferFlavor : transferFlavors) { if (transferFlavor.equals(DataFlavor.javaFileListFlavor)) { return true; } } return false; } return false; } }
last time i told you about launchy as a program starter. this time i want to talk about window handling.
to switch between windows most people know that you can flip through your open applications with alt+tab. but in vista and 7 you can after you entered alt+tab once move through the applications with the cursor. e.g. when you have many open applications they are arranged in a row-column-layout when pressing alt+tab. the first item is highlighted. then instead of going though all the items one-by-one you can go down and right for example.
see this video:
next thing: window management with winsplit revolution:
see this video:
here are the keycombinations:
it is a great tool – really.
to be continued…
on my daily work i try to become better in not using the mouse for almost anything. starting programs, file system tasks, navigating the internet, programming, handling windows (as in dialogs not as in os) and more…
i want to show some of that stuff:
but more on that step by step.
launchy, free, (Win, MacOS, Linux)
launchy is a program launcher. you can start it with a keycombination (default is alt+space) then an entryfield shows up and you can type any part of a programs name you have installed and launchy will show a list of matches. usually a simple enter will start the found program. thats great for starters.

launchy app starter
but there is more: launchy supports plugins. two of them i wanna show:
putty-launchy-plugin: tell it where your putty lives and it can start saved putty sessions via defined (default “ssh”) shortcut. have a session called “webserver” start it with alt+space, ssh we. if you have putty and your ssh configured for public-key-authentication (and you should have) you are now ready to use your shell.
runner (default installed): you can launch special programs from here with parameters you like and give it a special shortcut. e.g. i have special two-letter shortcuts for important specification documents or processexplorer.
to be continued…
puh man again nearly going crazy over a simple problem.
the environment:
what happened: everywhere the encoding was correct beside one file. in that file my umlauts where messed. in my eclipse build (warning: not using the ant there) everything was fine. but when is looked at the file in teamcitys build directory it was messed. at first i thought of subversion. checked everything out by hand on the linux box => fine. then i tried to find out how teamcity uses svn. they have their own implementation. so i figured they do something wrong. so i updated teamcity from 4.5 to 5.0.2…same result. so i waited about a week.
then with a fresh mind i looked at the ant script when it hit me: i had a replace task to set the buildnumber in the messed sourcecode file (perhaps an unusual attemped but…). and replace uses the default encoding of the executing jvm. i neede to set the encoding for the javac task but i forgot or better didnt consider it a problem for the replace.
with the encoding set everything was fine. see how:
[source language='xml']
[/source]
man…always fighting to get a recent version of anything to run on the debian 4 (etch) vps i have. this time: ruby on rails. ruby v1.9.1, gems 1.3.5 and ror 2.3.4 is what i had i mind.
first step: download ruby. execute the usual ./configure && make && make install triplet. worked fine. then download ruby gems. but when i tried to run anything with gem i got:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:5
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:167:in `load_and_instantiate'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:88:in `[]'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:144:in `find_command'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:131:in `process_args'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:102:in `run'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run'
from /usr/local/bin/gem:21
after googleing and trying some stuff i solved it this way:
next step. successfully let gem install rails. but then ruby script/server stopped with:
=> Booting WEBrick
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/initializer.rb:271:in `rescue in require_frameworks': no such file to load -- openssl (RuntimeError)
from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/initializer.rb:268:in `require_frameworks'
from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/initializer.rb:134:in `process'
from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
from /var/www/rails/ukk/config/environment.rb:9:in `
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `block in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/commands/server.rb:84:in `
from script/server:3:in `require'
from script/server:3:in `
after a another round i found this site with help:
that worked. nice. so now i am waiting for the next fail
dont know if someone besides thilo noticed, but since i reinstalled my server (2 weeks ago) all the links in this blog (running wordpress) where broken.
wordpress uses an apache module called mod_rewrite to rewrite the url. so what u see in the adressbar in your browser is not like
www.batterslave.com/?p=9
but
www.batteryslave.com/2009/02/lixhot-boysmeisenfrei-log/
a bit more readable. but i forgot to enable the module. that is an easy step if you running a standard debian 4.0 linux on your server like i do. apache 2 comes with some little helper scripts for managing modules and sites. in my case the script a2enmod will do the job (# will symbolise my prompt):
# a2enmod rewrite
after that you call
# /etc/init.d/apache2 reload
so apache relaods the module and config. and we are ready to run.
there is a .net user group forming in aachen. we met twice. next time we meet end of januar 2009 and there will be a presentation about wpf.
i am adding myself into the line of book-shelf-sharers. after michel, björn and stefan here is my shelfari.