Installing Git with Gitosis

Posted by Ktoso under Project13, coding, guide, java (No Respond)

Git is really simple and VERY powerfull. It makes svn look like an idiot – but that’s just my personal opinion ;-)

Anyways, I’m using github most of the time, but now I’d like to hava a non public repository (yet remote) for some small project. I’ve been commiting to a local git instance from the begining of this project so just pushing it into a new repo will be really simple.

I wanted to have som easy to administer localozed git to serve hit hosting for my friends etc. So this is how I did it:

On server:

# do this as root of course
  1. cd ~/src
  2. git clone git://eagain.net/gitosis.git
  3. cd gitosis
  4. ./setup.py install
  5. useradd git
  6. #end of obvious stuff
  7.  
  8. gitosis-init < /location/of/administrators/public/id_rsa.pub #this will allow you to administer gitosis remotely
  9. sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update # in case gitosis-init didn't do this already

Now we can do all the administration without being logged in into our server – just by using git!

#all of the following is done LOCALLY!
  1. git clone git@stratos:gitosis-admin.git
  2. cd gitosis-admin
  3. vim gitosis.conf #edit groups and repositories
  4. writable = bla is responsible for the repositories
  5. #for example you could setup:
  6. #then just do the stuff you would normally do with git:
  7. #[group secret-group]
  8. #writable = bla
  9. #members = ktoso@homunculus ktoso@protos
  10. #here's how your dir structure should look like
  11. #├── gitosis.conf #repository configuration
  12. #└── keydir #put all (ssh) public keys of your users in here
  13. #    ├── ktoso@homunculus.pub
  14. #    └── ktoso@protos.pub
  15. #now just do what you would normally do with a git repository
  16. git add .
  17. git commit -m 'new repo: bla'
  18. git push

You can then just pull/clone this repo:

git clone git://stratos/bla.git

Yeah, this post isn't much of an discovery - yet I wanted to show you how SIMPLE and SCALABLE a simple git repository can be. For mor information about git and gitosis see: a simple google search

Tags: , , , , , , ,

Bizet’s “Carmen”

Posted by Ktoso under fun (No Respond)
carmen

"Carmen" at Cracow's Opera

Today we were with my girlfriend to see Bizet’s “Carmen” at the Cracow Opera – celebrating one of your special days. The opera didn’t move me as much as Rigoletto did, but it still was a great spectacle in 4 acts. One has to say that the scene was heavily and very creatively used, as seen on the above picture. Music and singing were also top class. I did miss some more powerfull or dramatic pieces – that’s not really something Carmen has to offer – but that’s just my personal opinion – Kasia enjoyed it very much :-)

If anyone is considering going somewhere more “cultural” anytime soon, I’d really recommend some Opera – it’s an amazing form of expression.

Tags: , ,

YES! Native Zen coding in Intellij IDEA EAP 9.0.2

Posted by Ktoso under coding, fun (No Respond)

Zen points directly to the human heart,
see into your nature and become Buddha.

- Hakuin Ekaku (1685–1768)

For those who don’t know about zen coding (where have you been guys?) here’s a little sample:

Instead of writing:
<form class="form-comment" id="comment">
<fieldset>
<input id="myid" name="name" type="" />
<input onclick="hideMe()"
type="" />
</fieldset>
</form>

You write

form.form-comment#comment>fieldset>input#myid[name=name]>input[onclick=hideMe()]

and hit [TAB].

To understand zen, you must understand yourself. (yet I also strongly suggest watching this video)

Links:
http://confluence.jetbrains.net/display/IDEADEV/Maia+EAP – IntelliJ IDEA Early Access Program
http://code.google.com/p/zen-coding/ – zen coding website

Tags: , , , , , , , , ,

Terminal Heroes 8: Memory usage scripts

Posted by Ktoso under coding, terminal heroes (No Respond)

I have a low-memory VPS running online and thus always have to worry about what uses how much memory… Of course top and my favorite htop are very good tools to check this, but sometimes I just want to get a super simple report if I’m overusing memory or not yet. The bellow scripts (most of them was found online or hacked up from multiple scripts to fit my needs) print simple yet very readable memory usage information.

memused

#!/bin/bash
  1.  
  2. #if [ $1 = '']; then
  3. #    ps auxf | awk '{sum=sum+$6}; END {print sum/1024}';
  4. #else
  5. #    ps auxf | grep $1 | awk '{sum=sum+$6}; END {print sum/1024}';
  6. #fi
  7. bean=`cat /proc/user_beancounters` guar=`echo "$bean" | grep vmguar | awk '{ print $4;}'` burst=`echo "$bean" | grep privvm | awk '{ print $5;}'` priv=`echo "$bean" | grep privvm | awk '{ print $2;}'`
  8. let total=guar/256 let used=priv/256 let burst=burst/256
  9. echo "VPS memory usage:"
  10. echo "Used: $used MB"
  11. echo "Total: $total MB"
  12. echo "Burstable to: $burst MB"

Sample output:
VPS memory usage:
Used: 296 MB
Total: 256 MB
Burstable to: 512 MB

memfree

#!/bin/bash
  1. #
  2. # Revised 02-Feb-2007: include kernel memory (kmemsize) in 'used' calculation
  3. # and show percentages in output.
  4. #
  5.  
  6. BEAN=`cat /proc/user_beancounters`
  7. GUAR=`echo "$BEAN" | grep vmguar | awk '{ print $4;}'`
  8. PRIV=`echo "$BEAN" | grep privvm | awk '{ print $2;}'`
  9. KMEM=`echo "$BEAN" | grep kmem | awk '{ print $3;}'`
  10.  
  11. let TOTL=$GUAR/256
  12.  
  13. let KMMB=$KMEM/1048576
  14. let PVMB=$PRIV/256
  15. let USED=$KMMB+$PVMB
  16. let FREE=$TOTL-$USED
  17.  
  18. if [ "$FREE" -gt "0" ]; then
  19.     let UPER=$USED*100/$TOTL
  20.     let FPER=100-$UPER
  21. else
  22.     let UPER="100"
  23.     let FPER="0"
  24. fi
  25.  
  26. echo "VPS Memory:"
  27. echo " Total: $TOTL mb Used: $USED mb (${UPER}%) Free: $FREE mb (${FPER}%)"

Sample output:
VPS Memory:
Total: 256 mb Used: 302 mb (100%) Free: -46 mb (0%)

memheld

#!/bin/bash
  1. grep oomguarpages /proc/user_beancounters | awk '{s=$2;t=$3;u=$4; {print "VPS Memory Usage\nCurrent Held: " s/256 "MB\nMax Held: " t/256 "MB\nBarrier: "u/256"MB" }}'

Sample output:
VPS Memory Usage
Current Held: 160.832MB
Max Held: 294.605MB
Barrier: 256MB

memps

#!/bin/bash
  1.  
  2. echo "ps axo pmem,pcpu,comm | sort"
  3. ps axo pmem,pcpu,comm | sort

Sample output:
ps axo pmem,pcpu,comm | sort
0.0 0.0 script
0.0 0.0 script
0.1 0.0 init
#...
2.2 0.0 httpd
4.0 0.0 mysqld
7.3 0.0 httpd
8.0 0.0 httpd
%MEM %CPU COMMAND

memprivmpages

#!/bin/bash
  1.  
  2. beans=`cat /proc/user_beancounters | grep priv`
  3. max=`echo $beans | awk '{ print $4;}'`
  4. use=`echo $beans | awk '{ print $2;}'`
  5. let "per=$use*100/$max"
  6. let "mb=$use/256"
  7. let "mmb=$max/256"
  8.  
  9. echo "privvmpages usage: $mb MB ($per% of $mmb)"

Sample output:
privvmpages usage: 296 MB (57% of 512)
For those wondering, yes I do have memory usage above “100%” in the output of some of these scripts, and it’s partially true. A VPS does usually have some guaranteed memory, and some “burstable” – so you can use more than just the guaranteed memory for some period of time. On the mashine I ran this I have 256 guaranteed and a “total” of 512MB – including the burstable memory.

If you like any of these, feel free to use them. I use them by creating a scripts directory and adding it to the PATH, so I can simply invoke them from anywhere.

PS: For more detailed memory usage information (as graphs etc), I’m using Munin and really recommend it. The graphs it draws are really nice, and it doesn’t inflict heavy load on the server, and it can monitor remote hosts if needed!

Tags: , , , , , , ,

Interesting talk with Sun Microsystems’ Director of Web Technologies Tim Bray

Posted by Ktoso under coding (No Respond)

I just stumbbled uppon an very interesting talk with Sun Microsystems’ Director of Web Technologies Tim Bra, abour the future of the Java Platform. They also mention stuff about REST/SOAP, SOA, Grails/Grails/Django etc. Is’s interesting to see how “bigshots” view these technologies.

Tkat said, if you have 30min to spare, or just want to play it in the background while working as I did: http://itspice.net/cms/it-news/podcast/what-next-in-java-web-development-tim-bray-podcast

  • The recodring is from 2009 – back ind the days with Sun still existent ;-)
  • Weird that they didn’t know about Symfony – the very awesome and scalable PHP Framework.
Tags: , , , , , ,

Kill only Tomcat

Posted by Ktoso under coding, java (No Respond)

There is sometimes the need to kill some JVM, I usually use “killall java” and that works fine as long as that’s in fact what I want – kill ALL. But let’s say i just want to kill Tomcat and not my IDE? The below method works quite well in such an situation:

[ktoso@homunculus ~]$ sudo netstat -lpn | grep 8080
  1. tcp        0      0 :::8080                     :::*                        LISTEN      18525/java
  2. [ktoso@homunculus ~]$ kill 18525 # you might need to add -9 here (SIGKILL)

A quickly hacked up version of an simple shell script to kill this tomcat could look like (I still suck at awk…):

#!/bin/sh
  1. kill -9 `netstat -lpn | grep 8080 | awk '{print $7}' | awk -F/ '{print $1}'`

The above obviously sux, as we’re using two awk commands after another… Ans also in the above examples, I’ve assumed that tomcat is listening on 8080, this may not always be the case, since with mod_proxy_ajp, there is no need fot it to listen on it’s default port and just the one to communicate by AJP. Let’s use it’s name to find it’s PID, we’ll use ps and grep and awk – life is simple with them. :-)
Here’s the final version of this command:

#!/bin/sh
  1. kill -9 `ps aux | grep catalina | awk '{print $2}'`
Tags: , , , , , ,

JavaCamp #2

Posted by Ktoso under coding, java (2 Responds)

Yup, it’s time for another JavaCamp “review”.
This time I was able to attend the whole thing, and didn’t miss the pizza – well, I just got one slice since we were so busy talking about Google’s Android with other programmers… ;-) The agenda was shorter than last time, but it still “had it’s moments”:

Łukasz Lenart – “Google AppEngine – chmura na Ja(v)wie”

Łukasz, from the Warsaw JUG, was talking about Google’s AppEngine – it’s baisically Just Another Servlet Container but since it’s in a Cloud, it’s (potentially) easy to scale an application deployed on it… But the biggest benefit of deploying to the AppEngine is in my opinion: free java hosting. If our app doesn’t exceed some specyfic quotas (most importantly is smaller than 500MB – concerning the Data/Blob Stores) we don’t have to pay Google for the hosting. You could call this a free cloud for beginners, and if your app gets bigger, you’re kinda trapped in this clound, and then have to pay google some fees for the extra bandwidth etc.

Sadly not everything is “allowed” and we are restricted by a Java Class WhiteList. Also, there is no Relational Database available for us on the AppEngine – instead we can use the “DataStore” with GQL (or JDO or JPA) and for files there is the (now in “beta” status) BlobStore – the name explaing everything I guess… ;-) Another “restriction” would be not being able to access the filesystem. I can only guess why, but it would seem that this would make the AppEngine easier to scale… (sadly I’m not an AppEngine Developer so that’s just my wild guess). Ok, but why did I put the word “restriction” in quotes? Because I don’t think this “restriction” is that much of a hurdle… We can always use resources from inside our WAR by using Class.getResource() (I didn’t test this on the AE, but it sounds plausible and should work) and for uploaded files there’s the BlobStore. There are some more “services” like simplified threading (normal java threads wouldn’t be easy to controll by the AppEngine I guess, so that’s why they introducet this option) and some more – there’s XMPP, Mailing support etc…

All in all, I wasn’t a big fan of cloud’s to begin with, and even though the AppEngine seems like a nice place to Deploy, I’m not really convinced to go with it. The presentation was all right and I did learn some thing’s about the AE I didn’t know before – and the “show what doesn’t work and not what does work out of the box” apparoch Łukasz took, was really nice much more interesting than just “click… yay it’s working” – as it doesn’t go like that IRL most of the time…
That said, I’ll stick with a Tomcat server for my GWT-Crossword.

Oh, and the slides are available here and the source code of the demo (“Struts2 on AppEngine”) he showed can be pulled from mercurial by:

hg clone https://lukaszlenart-wjug.googlecode.com/hg/ gruuf-done

Miroslav Kopecky – “Outlook to Android Application Development” (yup, another Google product today)

I own an Android powered (and there for Linux powered :-)) HTC Hero since two days, but am not “new” in the Android API as I’ve been reading quite a bit about it since it was announced alongside with the G1 (or was it announced before the phone..? hmm…). Mirek’s presentation was an introduction into the Android Platform, or as we noticed “Framework”, as coding Android apps feel’s very much like using an framework (yes, every API is more or less something like a framework, but the “feel” here is really framework-ish, with lot’s of method overriding etc.). After some introduction into an Android Apps structure, Mirek went on and showed 4 application demos. They were using simple layouting, Contact access and at the end event Google Maps. It may have been hard to follow for people not accustomed to Android and wasn’t all too in depth, but the overall idea most probably came through.

I’ll write some Android App for sure in some time – first I’ll have to quickly finish my GWT-Crossword… It’ll probably be a ContactMerger – something that’s clearly missing in all google apps and is constantly nagging me. That is, an app to easily merge contact duplicates into one contact. This could be really nicely automated, and when some conflicts are detected a normal 3-diff-like dialog would be enough to quickly merge a few contacts into one… Sadly my HTC Hero still has the uber-old Android 1.5 and the contact’s access API has significantly changed since then… I think that by the time I’m ready to code for android  the 2.1 ROM Upgrade for my Phone should be available… So I’m focusing just on the “Level 7″ API (“level 7″ means “android 2.1″, whereas “level 3″ means “android 1.5″).

Piotr Maj – “Jak czerpać przyjemność z programowania w świecie krótkich terminów i parcia na słupki”

This presentation really stood outfrom the rest, it was fun and while not really tech focused, quite interesting. Piotr started out with some awesome [plastelina] figures that his wife made esspecially for this presentation: a “Garniturek” (Marketing Guy), an Programmer and an Evil Looking Tester. The figures were really hilarious… :-) Anyways, he started out with showing sources of [depresion] bad feelings in our day to day jobs, and pointing out that if we do something again and again, and still are doing it the same way – something’s not right, we don’t evolve if we code like that… Then he went on with introducing the Tester figure and some scenarios of a Tester humiliating Programmers. A few words about Selenium and then we were talking about how writing tests it both necessary and potentially really interesting. So in the end, we ended up talking about Unit/Functional Testing and Test Coverage – who would have thought, by the title of the presentation I was expecting something else, but it was a really plesant presentation nonetheless, and the need of testing code can’t be stressed enough I guess – maybe I’ll start to have a major test coverage of my code thanks this constant nagging about them ;-)

Pizza Time

During the pizza-break we had a long talk with Miroslav, and people could play around with the Nexus One he brought especially for this presentation. It’s interesting to hear out other developers views on some API. I for example find the Android API quite nice. The “J2ME Hell” I have been coding some stuff for burns even fiercer now that I have the option to choose another Mobile Java Platform – at last with cool things like SQLite, Widgets and Easy Touch Responsiveness – oh an the BackGroundTasking is a great feature – something J2ME never had I think, on the other hand, what good stuff did basic J2ME have? Yeah there were some JSRs that made life not so painful on ME, but on most of my phones there always were problems with them – MMAPI for example, where you sometimes had to code something SE or NOKIA specific – so where is that “write once” gone on ME eh…? Later on we talked with Miroslav and it seems that he’ll be at our SFI next month – yet another great conference… :-)

One of the developers had an Motorola DROID, which I have considered buying but decided for the HERO – for money reasons… The DROID’s (MILESTONE’s) phicical keyboard really sucks, by the way. That, plus the fact of how awesome the on-screen-keyboard of Android is made me not regret buying a phone without phisical keyboard… ;-)

Marcin Kalas – “Java/JEE Performance Test Planning – How To Plan Successful Performance Tuning of Java/JEE applications”

I had really high hopes for this presentation, as I’m currently doing JMeter Load Testing on MySQL engines at my University. Sadly this wasn’t a “practical” or “hands-on” presentation. Yeah, I understand that it’s really hard to show this kind of stuff in such a short period of time, nonetheless I hoped for some more “tricks and advices”. The some tips about the JVM and multiple GC Strategries were quite interesting, but that’s something I’ll need to lookup and read about when I’m going to need it as it’s clearly a very big topic.

Marcin surely has a lot of experience in performance tuning apps that’s clear and it was really interesting to see some people (Java Gurus) from the audience throw some interesting stuff into the presentation. Real JEE apps are really something amazing, I hope I’ll be able to code and work with such apps in my future, it’s an amazing world full of Gigantic DataCenters and Techniques no small app would ever find any use for… For now I’ll have to get good at the basic stuff I guess, I’ve still got some time. What I found very interesting were the Load/Stress “Patterns” Marcin displayed. For example if your application is always busy, or strangely idle – even with lots of request’s comming in etc. It’s something that really makes you think about the app/server and bottlenecks… Sadly I can’t seem to find anything similar about those online – maybe I’m just not searching well enough. I hope to see some of those behaviours while testing our databases, we don’t have multiple application layers in these tests and finding bottlenecks should be easy – it should be, right? ;-) Anyway, I hope to have some fun experiments with our mini-server.

GeeCON 2010

The whole event was also a small GeeCON campain. People got some stickers and [smycze] with GeeCON branding. I’m planing to go there as it seems like an very amazing event… This year it’s in Poznań, and it’s being organized with cooperation of the Poznań and Polish JUGs. I’ll keep you up to date about upcomming Java Events – the next being SFI and then *something special* in April :-) Well then… “Let’s move the Java World!”

Tags: , , , , , ,

MySQLIntegra: dbfiller & wiki

Posted by Ktoso under coding, null (No Respond)

I passed all my exams at my first attempt and should have now some time to relax, right? Well something like that, I’m actually doing quite a lot these days. We’re on the roll with MySQL Integra.

Our server “Kopiec” is somewhat online (running CentOS off course) – we’re able to start/stop if thanks to a tool that’s called “remote insight”, and I’ve put 3 databases on there. MariaDB, InfiniDB and a clean MySQL instalation. We’re somewhat having problems with TokuDB, but that’s going to be our 4th database of interest. If you want to keep track of our test’s you can take a look at: http://mysqlintegra.project13.pl/.

The first step in getting things tested is filling those db’s with some data, and I mean a LOT of data. So we hacked up a more or less quick and dirty python script called dbfiller (source code avaiable on github) that would simulate a very simple table generation scheme (people working on shifts and checking in when they’re finished or start some activity). If you’re interested, our task is specyfied in the /doc/Opis.pdf file (sorry, only in polish). After a few days it’s up and running and we’re moving on to filling up those databases with some gigabytes of data.

Next we’re going to write some SQL Views/Procedures and then we’ll use Apache JMeter to run some performance benchmarks of some interesting data storage engines.

PS: If you’re wondering about my GWT-Crossword project – yeah, it’s still actual, and I’ll get right on it when done with some of the stuff here.
PPS: Yes, an Linux powered phone AT LAST in my hands! The HTC HERO is comming to me really soon – never again shall I use a ShitOS like WindowsMobile 6.5.

Tags: , , , , , , , , , , , , , ,

“Teamwork” – my simple blender animation for class

Posted by Ktoso under fun, null (No Respond)

It’s an increadibly tought time now at my Uni, lots and lots of exams, stuff to hand in etc… One of such things is this simple blender animation which I have created with my friend Tomek in order to pass Graphics class:

httpvhd://www.youtube.com/watch?v=sGeEmUGQfo8

Yeah it’s simple, rough anc certainly not the next Katedra… ;-) But as a person that totaly sux at graphics I’m quite happy with it, take a look and let me know what you think.

Oh and some other animations by my classmates are avaiable on this youtube playlist, feel free to check it out – some are really nice.

Tags: , , , ,

Current small project: GWT-Crossword

Posted by Ktoso under coding, fun, java (No Respond)

I am currently working on a simple but still quite fun/interesting (as is any project with a new framework :-)) webapp using Google Web Toolkit (it’s basically Google’s JEE framework for creating RIA). The webapp is an online crossword generator. The goal is to provide crosswords online and allow users solving them online with a nice and intuitive GUI etc… It would be cool if I’d manage to create this as an “embed on any website” script, but I can’t guarantee this functionality.

I’m coding this project to get used to some of the basic JEE stuff, such as Hibernate for example (it is quite amazing and very elegant – especially HQL), and to have a good time while coding in Java…

The source is avaiable under the AGPLv3 on github: http://github.com/ktoso/gwt-crossword
At some places it is still a mess so please keep in mind that it’s still under initial development (and I’m having a tough time at the uni and can’t code gwt-crossword everyday :\), that aside, feel free to take a look on the source!

Tags: , , , , , , , , ,