Showing posts with label community. Show all posts
Showing posts with label community. Show all posts

03 May 2010

Setting-up a GIT remote repository : my notebook

Here are my notes for setting-up a GIT remote repository on ubuntu. It basically requires to create a new user @gituser on a server. @gituser will be used as a central repository and people will be allowed to publish their changes using their public ssh key. The problems I encountered were due to our internal firewall and to my poor knowledge of SSH.

Initialize the SSH key for 'lindenb'


As user 'lindenb'
mkdir -p .ssh
ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/lindenb/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/lindenb/.ssh/id_rsa.
Your public key has been saved in /home/lindenb/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx lindenb@yokofakun


more .ssh/id_rsa.pub
ssh-rsa M3d(...)BuQ0J9x== plindenbaum@yahoo.fr

Create a 'gituser' user


As 'root':
/usr/sbin/useradd --shell /usr/bin/git-shell -c "GIT Version-Control-System" -m gituser
cd ~gituser
mkdir .ssh

Add lindenb's public key to the list of gituser's authorized_keys


As 'root'
cat ~lindenb/.ssh/id_rsa.pub >> ~gituser/.ssh/authorized_keys

Change the permissions to 'gituser' in .ssh


As 'root'
chown -R gituser:gituser ~gituser/.ssh

Create a new empty project in gituser


As far as I understand, this should be done for every project.
As 'root'
mkdir -p ~gituser/src/project01.git
cd ~gituser/src/project01.git
git --bare init
Initialized empty Git repository in /home/gituser/src/project01.git
chown -R gituser:gituser ~gituser/src

Create my git project


as 'lindenb'
mkdir /home/lindenb/src/mygitproject
cd /home/lindenb/src/mygitproject
git init
Initialized empty Git repository in /home/lindenb/src/mygitproject/.git/

Add some files into the project


echo -e "hello:\n\tgcc -o \$@ hello.c\n" > Makefile
echo -e '#include<stdio.h>\nint main(int argc,char **argv)\n{\nprintf("Hello.\\n");\nreturn 0;\n}\n' > hello.c

git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# Makefile
# hello.c
nothing added to commit but untracked files present (use "git add" to track)


git add .

git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: Makefile
# new file: hello.c
#


git commit -m 'initial commit'
[master (root-commit) b1ed0a2] initial commit
2 files changed, 10 insertions(+), 0 deletions(-)
create mode 100644 Makefile
create mode 100644 hello.c


## modify Makefile
echo -e "\nclean:\n\trm -f hello *.o\n" >> Makefile

git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Makefile
#
no changes added to commit (use "git add" and/or "git commit -a")


git diff
diff --git a/Makefile b/Makefile
index a329f85..7b0f9d1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,7 @@
hello:
gcc -o $@ hello.c

+
+clean:
+ rm -f hello *.o
+



git commit
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Makefile
#
no changes added to commit (use "git add" and/or "git commit -a")


git commit -a -m "added clean target in Makefile"
[master 8662812] added clean target in Makefile
1 files changed, 4 insertions(+), 0 deletions(-)


Tell the world, publish the project


git remote add origin gituser@localhost:src/project01.git
git push origin master

ssh: connect to host localhost port 22: Connection refused
fatal: The remote end hung up unexpectedly


#huhoo, I'm missing the ssh server
sudo apt-get install openssh-server
git push origin master
Agent admitted failure to sign using the key.

#I fixed the problem with https://bugs.launchpad.net/ubuntu/+source/gnome-keyring/+bug/201786
export SSH_AUTH_SOCK=0

git push --verbose origin master
Pushing to gituser@yokofakun:src/project01.git
Enter passphrase for key '/home/lindenb/.ssh/id_rsa':
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 674 bytes, done.
Total 7 (delta 0), reused 0 (delta 0)
To gituser@yokofakun:src/project01.git
* [new branch] master -> master
updating local tracking ref 'refs/remotes/origin/master'


Clone the project


cd /home/lindenb/src/
git clone gituser@yokofakun:src/project01.git
Initialized empty Git repository in /home/lindenb/src/project01/.git/
Enter passphrase for key '/home/lindenb/.ssh/id_rsa':
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 7 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (7/7), done.


ls -la project01
total 20
drwxr-xr-x 3 lindenb lindenb 4096 2010-05-03 11:42 .
drwxr-xr-x 7 lindenb lindenb 4096 2010-05-03 11:41 ..
drwxr-xr-x 8 lindenb lindenb 4096 2010-05-03 11:42 .git
-rw-r--r-- 1 lindenb lindenb 84 2010-05-03 11:42 hello.c
-rw-r--r-- 1 lindenb lindenb 53 2010-05-03 11:42 Makefile


Do some changes in project01
echo -e "test:hello\n\t./hello\n" >> Makefile

commit the changes:
git commit -a -m "added test target in Makefile"
[master 1de291c] added test target in Makefile
1 files changed, 3 insertions(+), 0 deletions(-)

and tell the world
git push origin master
Enter passphrase for key '/home/lindenb/.ssh/id_rsa':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 353 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To gituser@yokofakun:src/project01.git
8662812..1de291c master -> master

go back to 'mygitproject' and update the code
cd /home/lindenb/src/mygitproject/
git pull origin master
Enter passphrase for key '/home/lindenb/.ssh/id_rsa':
From gituser@yokofakun:src/project01
* branch master -> FETCH_HEAD
Updating 8662812..1de291c
Fast forward
Makefile | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)




That's it
Pierre

22 November 2008

A Web Service for ONSolubility.

This post is about the ONSolubility project (For references search FriendFeed for Solubility). This post is about how I've used Egon's code to create a web service to query the data of solubility. Egon has already done a great job by using the google java spreasheet API to download Jean-Claude's Solubility data. On his side, Rajarshi Guha wrote an HTML page querying those data using the Google Query-API. Here I show how I have created a webservice searching for the measurements based on their solvent/solute/concentration.

Server Side


Classes


I've added some JAXB(Java Architecture for XML Binding) annotations to Egon's Measurement.java. Those annotations help the web-service compiler (wsgen) to understand how the data will be transmitted to the client.
@javax.xml.bind.annotation .XmlRootElement(name="Measurement")
public class Measurement
implements Serializable
{
(...)

Then we create the WebService ONService.java. This service is just a java class containing also a few annotations. First we flag the class as a webservice:
@javax.jws.WebService(
name="onsolubility",
serviceName="ons"
)
public class ONService
{
Then comes the function seach provided by this service. This function will download the data from google using Egon's API and will return a collection of Measurement based on their solute/solvent/concentration. Again the java annotations will help the compiler to implement the service
@WebMethod(action="urn:search",operationName="search")
public List search(
@WebParam(name="solute")String solute,
@WebParam(name="solvent")String solvent,
@WebParam(name="concMin")Double concMin,
@WebParam(name="concMax")Double concMax
) throws Exception
{....
. The web service is launched with only 3 lines of code (!).
ONService service=new ONService();
Endpoint endpoint = Endpoint.create(service);
endpoint.publish("http://localhost:8080/onsolubility");

Compilation


I've create a ant file invoking wsgen generating the stubs and installing the webservice. Here is the ouput
compile-webservice:
[javac] Compiling 1 source file to /home/pierre/tmp/onssolubility/ons.solubility.data/bin
[wsgen] command line: wsgen -classpath (...) -verbose ons.solubility.ws.ONService
[wsgen] Note: ap round: 1
[wsgen] [ProcessedMethods Class: ons.solubility.ws.ONService]
[wsgen] [should process method: search hasWebMethods: true ]
[wsgen] [endpointReferencesInterface: false]
[wsgen] [declaring class has WebSevice: true]
[wsgen] [returning: true]
[wsgen] [WrapperGen - method: search(java.lang.String,java.lang.String,java.lang.Double,java.lang.Double)]
[wsgen] [method.getDeclaringType(): ons.solubility.ws.ONService]
[wsgen] [requestWrapper: ons.solubility.ws.jaxws.Search]
[wsgen] [should process method: main hasWebMethods: true ]
[wsgen] [webMethod == null]
[wsgen] [ProcessedMethods Class: java.lang.Object]
[wsgen] ons/solubility/ws/jaxws/ExceptionBean.java
[wsgen] ons/solubility/ws/jaxws/Search.java
[wsgen] ons/solubility/ws/jaxws/SearchResponse.java
[wsgen] Note: ap round: 2

publish-webservice:
[java] Publishing Service on http://localhost:8080/onsolubility?WSDL
.
And... that's it. When I open my browser on http://localhost:8080/onsolubility?WSDL , I can now see the WSDL description/schema of this service.

Client Side


Writing a client using this api looks the same way I did for a previous post about the IntAct/EBI API where the wsimport command generated the stubs from the WSDL file. I then wrote a simple test ONServiceTest.java, invoking our service several times.
private void test(
String solute,
String solvent,
Double concMin,
Double concMax)
{
try
{
Ons service=new Ons();
Onsolubility port=service.getOnsolubilityPort();
List data=port.search(solute, solvent, concMin, concMax);

for(Measurement measure:data)
{
System.out.println(
" sample :\t"+measure.getSample()+"\n"+
" solute :\t"+measure.getSolute()+"\n"+
" solvent :\t"+measure.getSolvent()+"\n"+
" experiment:\t"+measure.getExperiment()+"\n"+
" reference :\t"+measure.getReference()+"\n"+
" conc :\t"+measure.getConcentration()+"\n"
);
}
} catch(Throwable err)

{
System.err.println("#error:"+err.getMessage());
}
}
private void test()
{
test(null,null,null,null);
test("4-nitrobenzaldehyde",null,null,null);
test("4-nitrobenzaldehyde",null,0.3,0.4);
}
Here is the output
ant test-webservice
Buildfile: build.xml
test-webservice
[wsimport] parsing WSDL...
[wsimport] generating code...
[javac] Compiling 1 source file to onssolubility/ons.solubility.data/bin
[java] ##Searching solute: null solvent: null conc: null-null
[java] sample : 9
[java] solute : D-Glucose
[java] solvent : THF
[java] experiment: 1
[java] reference : http://onschallenge.wikispaces.com/JennyHale-1
[java] conc : 0.00222
[java]
[java] sample : 6
[java] solute : D-Mannitol
[java] solvent : Methanol
[java] experiment: 1
[java] reference : http://onschallenge.wikispaces.com/JennyHale-1
[java] conc : 0.00548
[java]
(...)
[java]
[java] sample : 10
[java] solute : D-Mannitol
[java] solvent : THF
[java] experiment: 1
[java] reference : http://onschallenge.wikispaces.com/JennyHale-1
[java] conc : 0.01098
[java] ##Searching solute: 4-nitrobenzaldehyde solvent: null conc: 0.3-0.4
[java] sample : 2b
[java] solute : 4-nitrobenzaldehyde
[java] solvent : Methanol
[java] experiment: 212
[java] reference : http://usefulchem.wikispaces.com/exp212
[java] conc : 0.38

That's it and that's enough code for the week-end.

Pierre

11 June 2007

Nature Scintilla


just like Deepak, I've received an invitation from Euan Adie (thanks Euan) to join the new service from Nature http://scintilla.nature.com/.

Scintilla collects data from hundreds of news outlets, scientific blogs, journals and databases and then makes it easy for you to organize, share and discover exactly the type of information that you're interested in.

For example, you can keep track of life science podcasts, or the latest papers on schizophrenia, DNA methylation or immunology. Interested in physics blogs? Scintilla can help.

Euan is already the author of www.postgenomic.com and the two tools seem to have an identical function at first glance. This also reminds me Aggademia, a tool created and tested by Alf Eaton a year ago.

I just had on overview of this tool but I already I found it interesting to add a pubmed query in my collection of sources. The service is distinct from Connotea and network.nature.com but with those three tools you can create a group, send some invitations (people around me are annoyed with all my invitations) and I hope all of this will be merged in the future.

Shall I use this tool ? I don't know. I already use google-reader , technorati , etc.. to handles my resources, just tell me why I should change.

Science Magazine ? Science Magazine ? Where are you ?


Pierre

15 February 2007

Tips: Sending Batch Invitations to Nature-Network.

A few minutes ago, I was looking for an quick method to send batch invitations to join Nature Network to my colleagues. I found a solution using the cURL utility.


  1. Open firefox


  2. log in to Nature Network


  3. the site stores a cookie called '_session_id' on your browser. Open your Cookie Panel: Tools -> Options -> Privacy -> Cookies". Note the value of the cookie _session_id associated to the site network.nature.com


  4. use cURL to send the form.

    curl -L -b '_session_id=THE_VALUE_OF_YOUR_COOKIE' -d 'referral[name]=Name' -d 'referral[email]=nobody.nowhere@mycompagny.com' -d 'referral[message]=this is an invitation to another social network' -d 'commit=send' 'http://network.nature.com/referrals/create?locality='


    the option -L is used to follow any http redirection, -b set a cookie, -d set a key/value from the original html form. You can automatize this process using a simple loop over your addresses.



This solution worked fine at the time I wrote this post.

Pierre

network.nature.com is alive

.
A quick post: it seems that the global scientific social network network.nature.com global (previously known as Nature Network Boston) is now alive. I created two groups Bioinformatics and Semantic Web for the Life Sciences.

Pierre

23 January 2007

Nature Network Reloaded


Nature Network Boston(NNB) is a networking tool for scientists in the Boston area. It was created last year and I was little bit disappointed when I compared it to www.linkedin.com or www.openbc/xing.com.


Today I received this mail from NNB:

(...)
Thank you for setting up the Bioinformatics and Semantic Web groups on Nature Network Boston. I know it's been a while, but I finally have news about the website to report.

At the end of February/early March, Nature Network Boston will become part of a new website called Nature Network, which will be global in scope so we will be inviting scientists from all over the world to use the site. NNB will become a local channel within Nature Network (with local news and events).

Groups will still be there. On Nature Network, they will be labeled as either global or local (Boston-based) in scope. When we go live with Nature Network, all existing groups on NNB will, by default, be labeled a Boston group.

The other new thing going live in early March: each group will get its own discussion forum, so that group members can post messages and respond to each other. I'll send you another email in a few weeks with more details about how to be a moderator in your group forums.



Great ! I'm impatient to see this :-)