Archive

Archive for the ‘Uncategorized’ Category

The many ways SSH keygen can fail on you under Windows

March 2nd, 2010

Just learned about the many ways SSH keygen can fail on you under Windows, today.

First of all, I should have told you to just press Enter when SSH keygen bothers you with questions. If you just keep on pressing Enter everything will go fine. So either you delete your keys and redo it with all Enter, or you try to fix it manually.

So your key files should be called id_rsa and id_rsa.pub and be in the C:\cygwin\home\joe\.ssh folder, where joe is your username. And then it should be accessible by you and only you. Both of which might get wrong if you manually rename and move the files.

To check that the file names are correct, please make sure you show file extensions in Windows Explorer. You set this in the extras menu under options and then in the view tab. There “hide extensions of known file types” should not be checked.

Next if you see this error message

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/home/joe/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/joe/.ssh/id_rsa

should fix the access rights of your files. To fix this type

chmod 600 /home/joe/.ssh/id_rsa

this will limit access to your private key to you and yourself only. (For the curious minds man chmod tells you more about the chmod command).

akuhn Uncategorized

Install Git for Windows

February 27th, 2010

This post should help Windows users to install Git and create their SSH key.

To install Git goto http://www.cygwin.com, download and run the installer. In the installer keep on hitting next until your reach the packages selection. There you should make sure to select the git and the openssh packages. Just use the search bar to find them and tick the first checkbox (in the bin column).

Now add C:/cygwin/bin to your path and you can run Git (and generate SSH keys) from the command prompt. If you don’t know about the command prompt and how to add a folder to your path, just bing it

Once that is done, you should be able to run Git from the command prompt. According to the Boston police you are now using two different operating systems to hide your illegal activies. One the regular Windows operating system and the other is a black screen with white font which you use to prompt commands on. Not bad, he? Verify this by running

git --version

This should tell you the version number of your Git installation. (You can of course also use Git from the bash prompt that comes with cygwin. Again, bing for more information.) No matter which prompt you’re using, continue with

ssh-keygen -t rsa

This creates an SSH key for you. You should find the key in the folder C:\cygwin\home\joe\.ssh, where joe is your username. Please mail id_rsa.pub to Patrik so he can setup your group folder on the Git server. Please include the SSH key for both team mates and all machines on which you plan to work.

Important: just keep on pressing Enter when keygen bothers you with questions. If you’ve not done so and need help fixing you keys, please refer to the many ways SSH keygen can fail on you under Windows.

Patrik’s email address is patrik dot rauber at students dot unibe dot ch.

 

NB: if you are a curious mind you can browse C:/cygwin/bin for all commands that ship with cygwin. There is quite a bit of them. Typically, you can run man command to learn more about a command…

akuhn Uncategorized

Git for Dummies (like me)

February 26th, 2010

This is my personal Git cheat-sheet for this course. I am new to git as well, it is a very new technology. We use the latest technology in the P2 course because we feel that the technology in a course should always be up to date, so you are ready to work on the job market and to contribute to open-source projects.

Here is my Git cheat sheet.

 

Download Problem Set from the Server

This cheat-sheet assumes your group number is zero zero.

git clone git@pinocchio.unibe.ch:group00
cd group00

This downloads your group repository from the server, and changes the command-line to group folder.

git config --global user.name "Joe Example"
git config --global user.email "joe@example.com"
git remote add p2ubungen git@pinocchio.unibe.ch:p2ubungen

This sets the preferences for your user name, for your email and for the P2 problem set server (whose name is p2ubungen).

git pull p2ubungen master

This downloads the P2 problem set to your computer (whose name is master, don’t ask me why).

You are ready to solve the exercises now!

 

Upload the Solution of your Problem Set

git add .
git commit -m "Uploading the solution"
git pull && git push

This uploads your files to the server. It does so in three steps: it adds your solution to the added files, and commits the added files to committed files, and pushes the committed files to the server. So obviously there are four levels where your files can be 1) on the file system 2) added 3) committed and 4) on the server. To correct your problem set we look at the files on the server only, so make sure they are on the server.

Professional gitters refer to the four levels as, 1) working tree, 2) index or stage area, 3) master, and 4) origin/master.

 

Is the Solution, like, really on the Server?

git fetch && git status

This checks if your files are on the server. You should see

# On branch master
nothing to commit (working directory clean)

if the file system and the server have the same content. If you see anything else, your solution is probably not on the server and you should repeat the steps above.

 

Don’t forget to upload your solutions by Friday, 04:00am in the night 04:00 pm in the afternoon, but no later. We do not accept any solutions after the exercise hour.

akuhn Uncategorized

Exercise for the first Week

February 26th, 2010

Welcome to the P2 course of 2010!

This week you will install your tools, get access to the exercise server, download a problem set, solve it and upload your solutions. All this must be done by next Friday, 04:00 in the night.

Install Eclipse and Git.

We work with Eclipse and Git. You use Eclipse to write code, and Git to share it with us. Please refer to http://twitter.com/p2unibe for download information.

Mail Us Your Group Information.

You work in groups of two. Please find a group mate and mail us your name, email address and matricle numbers. Also please mail us your SSH key to get access to the Git server. Please refer to http://twitter.com/p2unibe to learn how to create an SSH key.

Upon receiving your SSH keys, we will assign you a group number and provide you with the problem set. Please make sure to mail us the keys by no later than Monday noon.

Solve the Problem Set

You will implement a regular expression parser. It should take about 2–8 hours. You will receive access to the problem set once you’ve sent us your SSH keys. Further information on how to solve the problem set and how to submit it can be found in a file called readme.md in the problem set.

akuhn Uncategorized

Arrays considered harmful

April 20th, 2009

Java offers to kind of containers, arrays and collections.

As a rule, you should always prefer collections. Collections offer a higher level of abstractions. The way arrays are realized in Java is a reminiscence of lower level languages, as for example C. The role of arrays in Java is not for end-user application programmer but for building of high-level library constructions.

Arrays do not follow Java’s usual semantics, they neither are full objects nor do they have real classes. They do not have a meaningful toString() output. They have a final length field instead of a size() method. They offer no useful methods beside that. You cannot implement your own array classes. And worst, their type system is broken. You can assign an A[] array to a B[] array if B is a subtype of A (called covariance), and thus bad things may happen

Object[] array = new String[10];
array[3] = new Square();

The above code fails at runtime with an ArrayStoreException because you try to store a square in an array of strings. Collections avoid this problem (even though generics aren’t without pitfalls either).

You should not return an array as the value of a public method or property. If an Object returns an array, it exposes its internal state because an array is always mutable. Client can modify the array and thus peek and poke the internal state of your object. This violates encapsulation!

The same problem arises when returning a collection, just here we can do either of two things: return an immutable collection, or (even better) return an iterable. Recall that the caller is requesting values, not variables. And typically even, the caller will just enumerate over the values rather than accessing them by index. Thus the best practice is:

class Folder {
    private List<File> files;
    public Iterable<File> files() {
        return files; // list implements iterable, lucky us
    }
    public int filesCount() {
        return files.size();
    }
}

Method files() returns the files as a stream of values rather than by index. Clients can only enumerate over the values, for example using a for loop, but not modify the underlying collection (ignoring iterator’s unlucky remove method #java #fail). An iterable is a factory for iterables, thus the client can even iterate multiple times over the collection. Basically, we what return is a view on the collection where only its iterator() method is visible. (Of course, they could still cast it to a list, but this is considered very bad style in static typing world).

(parts via Eric Lippert and Reinier Zwitserloot and rssh)

akuhn Java, Patterns, Uncategorized

Week 06, Missing Slides

March 31st, 2009

The exercise of this week contains dangling references to lecture slides. However, these slides are missing since Oscar reorganized the slides this year. Please find the required interface IBoardGame below

public interface IBoardGame {
    public boolean gameOver();
    public Player getCurrentPlayer();
    public Player getWinner();
    public void movePlayer();
}

and refer to Slide 6.12 with regard to the AbstractBoardGame hierarchy.

akuhn Uncategorized

Serie 5, keine Umfrage

March 27th, 2009

Es ist keine Umfrage Auszufüllen! Wegen technischer Schwierigkeiten konnte ich keine Umfragen auf euere Konten hochladen, die Umfrage wird damit auf nächste Woche verschoben. Teil 2 der Serie 5 entfällt damit.

 

TLDR, keine Umfrage diese Woche.

akuhn Uncategorized

Wählt TUX Partei!

March 25th, 2009

Warning up front, what follows is shameless political promotion:

Vote TUX Party!

There are only a few days left to go out and vote on the legislative body of the student union of the University of Bern. So if you are an undergrad, go and vote online (preferably voting for the Tuxpartei) while you still can.

via http://pbunge.crimson.ch/2009/03/sub-elections

akuhn Uncategorized

Meet the Pros

May 5th, 2008

Jazoon, one of the world leading Java conferences takes place in Zurich. Jazoon is Europe’s leading Java conference, and as such, is most probably world’s second most important Java conference beside JavaOne. There will be technical talks about current technologies and latest trends in Java. I can only recommend to visit such a conference as a student, you will learn there stuff that goes beyond what we can teach you in the classroom.

The conference takes place fom June 23–26 in Zurich, and the best is—full registration is almost free for students, 48 CHF only.

Participants must be over 18 and for qualifying for the Student Special rate not older than 24 (on 24 June 2008). To qualify for the student registration fee, students must present proof of fulltime enrolment at a recognized university or college at both the time of registration and during the conference. Please contact the Jazoon registration department at students@jazoon.com to request a student voucher. A copy of your student ID must be attached to the email. Students must present their original student ID on-site in order to receive their conference badge and keep it available during all times at the conference. The registration fee for students includes entry to all conference sessions, access to the exhibition area, the opening and the closing sessions and the Jazoon After Hours networking events. During the conference, food & beverages are included (coffee breaks and lunches).

Go ahead, take your chance!

admin Uncategorized

Trend search

April 25th, 2008

Google trends reverses the usual search, rather than searching for documents, you search other peoples search queries.

It is even possible to compare trends

You’ll certainly find more queries yourself…

NB there is an art project from Martin John Callanan that takes the content generated by trend search and removes all chart junk. It reduces the visualization to its most essential elements: search terms, frequency mentioned & a timeline (via information aesthetics).

admin Uncategorized