Slides from the talk I did at OpenSolaris Day in Porto Alegre.
Download: hpc_and_OpenSolaris.odp
You should know that variable values are cyclic in Java.
public class Test{
public static void main(String args[]){
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);
int x = Integer.MAX_VALUE + 1;
System.out.println(x);
}
}
This produces:
2147483647
-2147483648
-2147483648
Boris Wilson, my girlfriend’s pet, a siamese cat. He loves play in a new box.
Sometimes we just need an good template for organizing a OpenSolaris event, I didn’t found a good one in a reusable format so I did this empty OpenSolaris SVG Poster.
Download the svg file: opensolaris_poster.svg
But why an SVG poster? SVG means Scalable Vector Graphics, an XML specification and file format for describing two-dimensional vector graphics. If you use a typical bitmap format like png, gif or jpg and need to scale the image you will loss image quality.
Using a vector graphics format you can scaled the image indefinitely without loss of image quality.
Additionally is a free and open format and also very reusable. You can edit and use it in a broad set of tools, from a scalable image editor like Inkscape to, believe it or not, Netbeans!
Vending Machines, Creative Commons photo by Abuckingham
Those days I was walking in a college to a tech demo and saw a lot of vending machines for soft drinks, coffees and snacks. So I thought “For a college student can be easier get a soda than a free software copy, like opensolaris”. Wouldn’t be nice if we have an OpenSolaris vending machine?
I sketched this idea:
OSVM, Open Solaris Vending MachineBut notice that is not just an CD/DVD vending machine. The OSVM could deliver the newest version of the OpenSolaris distributions to places where internet connections aren’t easy or cheap enough to download entire DVD images. A way to deliver open software to people who would have otherwise not been able to acquire it! Just choose, pay and get your free software.Press button, Receive bacon OpenSolaris.
Someho, yes, some similar idea. IBM did a similar project some year ago and there’s too the cool Freedom Toaster that is similar in some points.
Is just a open idea. You can comment, suggest and I’d love to see that implemented.
Update 20.Out.2008: Thanks for those who are helping this idea and giving more ideas. Specially thanks for Everton Rodrigues. Maybe in some time we have an prototype.
A really cool piece of code I read today in the book Ruby on Rails: Up and Running.
class Talker
def method_missing(method)
if method.to_s =~ /say_/
puts $'
end
end
end
t = Talker.new
t.say_hello
t.say_something
t.say_goodbye
And running
$ ruby Talker.rb
hello
something
goodbye
But why do that when we have parameters? Because you can do some methods really dynamic with a clear semantic, just looking for them you know are they are doing.
public class PreventTimeTravelers {
public static void main(String args[]){
long startTime = System.currentTimeMillis();
long endTime = System.currentTimeMillis();
assert endTime >= startTime: "We came back in time!";
}
}
Please do not execute this code in a time machine.
NumberFormatException: Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.
An simple example:
public class SummationExample {
public static void main(String args[]){
int sum = 0;
for(String arg: args){
System.out.println("+" + arg);
sum += Integer.parseInt(arg);
}
System.out.println("= " + sum);
}
}
$ javac SummationExample.java
$ java SummationExample 1 2 3 4 5
+1
+2
+3
+4
+5
= 15
but
$ java SummationExample 1 2 3 4 five
+1
+2
+3
+4
+five
Exception in thread “main” java.lang.NumberFormatException: For input string: “five”
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:497)
at SummationExample.main(SummationExample.java:6)
So
public class SummationExample {
public static void main(String args[]){
int sum = 0;
for(String arg: args){
try {
sum += Integer.parseInt(arg);
System.out.println("+" + arg);
} catch (NumberFormatException e) {
// nothing
}
}
System.out.println("= " + sum);
}
}
now
$ javac BetterSummationExample.java
$ java BetterSummationExample 1 2 3 4 5
+1
+2
+3
+4
+5
= 15
and also
$ java BetterSummationExample 1 2 3 4 five
+1
+2
+3
+4
= 10
JRuby is a Java implementation of the Ruby interpreter, with an tightly integrated with Java. In this examples you will call swing components.
On Ubuntu you can get it installing the package jruby (a meta package for jruby1.0 or jruby0.9 packages).
To test it save this code as test.rb and invocate it with the jruby interpreter:
require 'java' frame = javax.swing.JFrame.new() frame.getContentPane().add(javax.swing.JLabel.new('Hello, JRuby World!')) frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE) frame.pack() frame.set_visible(true)
$ jruby1.0 test.rb
ps: We did not define a close method, so to close this windows you’ll need to kill its process or press Ctrl+C in your terminal.