People who can code

87 days ago

“People who can code in the world of technology companies are a dime a dozen and get no respect. People who can code in biology, medicine, government, sociology, physics, history, and mathematics are respected and can do amazing things to advance those disciplines.”

Zed Shaw

Martin Gross

,

---

Gegenwart

216 days ago

“Nur wenige leben in der Gegenwart; die meisten bereiten sich darauf vor, demnächst zu leben.” Jonathan Swift

Martin Gross

,

---

Why does Test Driven Development matter?

223 days ago

An excellent Talk by Robert Martin called “What Killed Smalltalk Could Kill Ruby, Too” that shows why test driven development (TDD) as a concept is so important, not only for Ruby projects but for every software project.

The TDD relevant part starts at 23m 56s .

Martin Gross

,

---

JRuby as an exceptions-as-flow-control detector

223 days ago

Chris Heald shows in his article ‘JRuby Performance: Exceptions are not flow control’ how the anti-pattern of using ‘exceptions as flow control’ has an serious effect on the performance.

Thanks to headius logging the exceptions is as easy as:

jruby -Xlog.exceptions=true -Xlog.backtraces=true -Xlog.callers=true -S trinidad 2>&1 | grep "Backtrace generated" -A4

BTW: trinidad is used to run rails and rackup applications in an embedded Apache Tomcat

Martin Gross

,

---

UML Notation auf einer Seite

353 days ago

Eine der besten und prägnantesten Übersichten für die UML (Unified Modelling Language) habe ich bei Wikipedia gefunden.

Leider wurde es dort nur im PNG bzw. SVG Format veröffentlicht. Daher habe ich es vom Vektorformat direkt nach PDF konvertiert, das sich am besten von allen Formaten ausdrucken läßt.

Herunterzuladen hier:

UML-Diagramme.pdf

Martin Gross

,

---

Die Sprache von Skype in Englisch ändern auf einem deutschem Mac OSX

447 days ago

  1. Skype beenden, falls es läuft
  2. Den Finder öffnen, Programme in der linken Seitenleiste auswählen
  3. Skype im Finder auswählen, Rechtsklick, Paketinhalt zeigen
  4. Es öffnet sich ein neues Finder Fenster mit mehreren Verzeichnissen
  5. Das Verzeichnis Resources öffnen und nach einem Verzeichnis mit dem Namen de.lproj suchen. Dieses einfach umbennen oder löschen.
  6. Skype starten

Hintergrund: Applikationen speichern meist ihre Anpassungen an andere Sprachen in eigenen Verzeichnissen. Ein Verzeichnis mit dem Namen de.lproj deutet auf eine deutsche Anpassung hin. Wenn die Applikation diese Sprachdateien nicht mehr findet, nimmt sie die Standardsprachversion, hier also Englisch.

Martin Gross

,

---

BTrace

449 days ago

You can think of BTrace as a scriptable debugger or logger: you set breakpoints and when your breakpoints are hit some script gets executed:

  1. It is a dynamic tracing tool for Java.
  2. It instruments classes of a running Java program.
  3. BTrace inserts tracing actions into the classes of a running Java program.

This means you can inject tracing into an already running java program. No changes to the source code of your program are needed. No additional jars need to be loaded by your program.

The scripting is done in Java and no compilation step is needed. See the example below.

The btrace download is available here .

The user guide is here .

How to use it

Let’s assume we want to get a notification every time a thread is started.

Now let’s create the tracing script i.e. java class. Create a java class named BTraceThread.java:

 import com.sun.btrace.annotations.*;
 import static com.sun.btrace.BTraceUtils.*;

@BTrace public class BTraceThread { // @OnMethod annotation tells where to probe. // In this example, we are interested in entry // into the Thread.start() method. @OnMethod( clazz=“java.lang.Thread”, method=“start” ) public static void func() { // println is defined in BTraceUtils // you can only call the static methods of BTraceUtils println(“about to start a thread!”); } }

If it ain’t running already, start the program that shall be traced. I’ll use JRuby IRB to start some threads interactively.

We need now the pid of the IRB. Find the already running Java programms with
jps -l

Which returned on my machine:
17404 org.jruby.Main

Which means we got 17404 as the pid of our programm.

Now run your btrace script with:
btrace 17404 BTraceThread.java

Everything is in place now. Let’s start some threads using JRuby IRB:
t = Thread.new do puts "New thread started at #{Time.now}" end

Everytime a new thread starts you should see ‘about to start a thread!’ .

D:\>C:\Programme\Java\btrace\bin\btrace 17404 BTraceThread.java
about to start a thread!
about to start a thread!
about to start a thread!
about to start a thread!
about to start a thread!
about to start a thread!
about to start a thread!
about to start a thread!
Martin Gross

,

---

Performance Testing: Quick Tip: Handling very large log files

469 days ago

Flex

Logfiles tend to grow and grow and grow. The other day I had a log file about 1.3 GB large.

The relevant logging was only in one part of the file. Handling such a big file is a nightmare using most editors. I could open it but the editor would crash as soon as I tried to delete some parts of the file.

What I needed was the part of the file which contains the log entries for the load test, i.e. split the file into smaller parts – or – even better, cut the parts off that I would not need for my analysis.

As expected Unix-based operating systems have some built-in tools for this task:

split : Splits a file into equal-sized parts.

or

csplit : Splits a file into context-based parts.

Examples:

Create a new file named ‘output.log.00’ . It should contain only the part of the file input.log beginning with the line that matches the regular expression ‘^17:15:’ . I.e. give me everything from 17:15 until the end of the file:

csplit -f output.log. input.log '%^17:15:%'

Now create two files out of ‘output.log.00’: One containing everything before 18:00 (6pm) and one for the remaining part. I.e. I want a file named ‘log.17.00’ which contains all log entries from 17:15 until 18:00 .

csplit -f log.17. output.log.00 '/^18:/'

Using Windows? I’d recommend to install cygwin which provides split/csplit and many other useful Unix tools. In my opinion a must-have for every serious software developer working on this platform.

Martin Gross

,

---

A dirty hack to get through an authenticating proxy with open-uri

497 days ago

I had problems parsing a webpage with Nokogiri on JRuby 1.5.2 . The proxy authentication was the issue.

Here is how I solved this issue:

Set your environment variable HTTP_PROXY with your proxy data (user, password, URL, port) e.g.

HTTP_PROXY=http://prxuser:prxpasswd@prx-server:8080

Then change in lib\ruby\1.8\open-uri.rb, line 216, from:

klass = Net::HTTP::Proxy(proxy.host, proxy.port)

to:

klass = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password)

And test it with:

require 'rubygems'
require 'nokogiri'
require 'open-uri'
html_doc = Nokogiri::HTML(open("http://www.google.com/search?hl=de&q=software"))
html_doc.css('h3>a').each do |node|
  puts node.text
end
Martin Gross

,

---

Symbolic links for directories on Win XP

506 days ago

Symbolic links for directories are known as NTFS junctions in Windows. Sysinternals provides a tool for creating junctions: Junction.zip

More about it at: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

Martin Gross

,

---

« Older