Recent Updates RSS Toggle Comment Threads | Keyboard Shortcuts

  • tuxdna 12:10 pm on January 29, 2012 Permalink | Reply
    Tags: jruby, rails, ruby, rvm   

    JRuby on Rails with RVM ( on Fedora ) 

    First install RVM and set it up:

    sudo yum install rubygem-rvm
    rvm-install
    

    To include RVM into your bash shell, add following line to ~/.bashrc:

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
    

    Now install JRuby and use it as default Ruby interpreter:

    source ~/.bashrc
    rvm install jruby-1.5.6
    rvm use jruby-1.5.6
    

    Setup Rails environment:

    gem install rails
    gem install bundler
    

    Lets create a new Rails application:

    rails new rails-app
    cd rails-app
    bundle install
    rails g scaffold Person name:string
    rake db:migrate
    rails s
    

    Now go to http://localhost:3000/people/
    Yay! Your new Rails application is up and running, powered by JRuby ( setup using RVM ).

     
  • tuxdna 11:00 am on January 27, 2012 Permalink | Reply
    Tags: , packaging, rpm   

    Packaging Java JARs as RPM packages 

    At JUDCon 2012, I had a discussion and argument with Jaikiran Pai and Ravi Maurya on “Packaging Java JARs as RPM packages”.

    Well it is not just RPM, it could be any package management system ( eg. dpkg, protage etc. ), doesn’t matter as long as it serves the purpose of:

    • automatic dependency resolution
    • installation of dependencies
    • rollback an install step
    • install multiple versions of a (JAR) package
    • ensure the packages are authentic ( for security )

    How is all this achieved in Java world? Simple. Just package all the required JARs in a single JAR or WAR or an EAR for that matter. And trust the packager for its security. But:

    • Is this a good practice?
    • What happens when you want to install the same package on multiple systems?
    • Can you roll back changes easily on multiple installations?
    • How are JARs shared across different kind of projects, some which use the same version of the same JAR package?

    Consider the case of Maven, with which you can easily specify the dependencies and Maven does all the work of dependency resolution.
    However, it solves the problem only at the developer’s level. JARs are still bundled inside the output application package (JAR / WAR / EAR). And everytime this application is distributed, it will contain “ALL” the dependencies. That is clearly an overhead.

    That makes me think, why JARs don’t work like Shared Libraries, which can be shared across applications. Every classloader / JVM instance has its own version of the same JAR file on-disk! Can’t they be shared? That too is clearly an overhead. I am not aware of the reasons why it is so, which I would definitely like to know.

    The point is, since a package manager has all the functionality, why not just leverage it? Java community is either unaware of it, or doesn’t care.

    No problem. There are efforts already in place.

    Anyway, of other things Jaikiran told me that, JBoss AS7 has how better and modular class loading which is based on JBoss Modules. This appears to me similar to how Maven structures it JAR repositories.

    Here are some resources:

    Thats it folks!

     
    • Matěj Cepl 12:14 pm on January 27, 2012 Permalink | Reply

      Would it be possible to create Project Jigsaw packages with some external tools even before the arrival of Java 8?

    • Chaitannya Mahatme 12:53 pm on January 27, 2012 Permalink | Reply

      Yup, I think the Java world doesn’t care, since they have a full-fledged packaging utility. I typically face this issue when working with Eclipse. We are working on debugger. So it’s like I would first launch 2 instance of eclipse, and then in the second instance I would launch another debugger. In this case JVM consumes 1 GB of Ram, otherwise which is normally in the range of 250-300 mb.

      If you look at the plugins (jar packages) which I am using, 90-95% are the same ones. But in this case they have to be launched thrice.

      • Chaitannya Mahatme 12:56 pm on January 27, 2012 Permalink | Reply

        One more thing … I guess Java would lose it’s reputation of build once, run it everywhere if we have a packing system which is native to the OS.

        • tuxdna 12:58 pm on January 27, 2012 Permalink

          Thats a good point. Therefore the packaging mechanism should be platform / OS agnostic.

  • tuxdna 7:21 am on January 27, 2012 Permalink | Reply
    Tags: drools, , jboss, judcon, redhat   

    JUDCon 2012 – an experience! 

    My first Java exclusive conference!

    I arrived at the venue right on time. Surprize, there were a lot of people already holding their welcome kits. Conference was already running quite smoothly. Wifi worked most of the time. The sessions, lunch, tea were always on time. Actually, there were people assigned to ring bells, just like in schools, to notify timeout during lunch and tea breaks :)

    The whole confenence was revolving around four major topics: JBoss AS7, Infinispan, Drools and OpenShift.

    Opening talk was given by Harish Pillay, Red Hat Global Community Architecture Team.

    The Keynote of the day was by Bruno Georges. He mentioned some interesting trends of which are:

    • There are about 4 times the processors compared to the number or people in United States alone and growing. Meaning that the processing power is available in abundance.
    • There is a significant growth in Ad-Hoc Social Networks for businesses

    Now where is the industry heading? In perspective of Java, Java ME/EC is going to be merged with Java SE/EE. SQL based data is moving towards NoSQL which is now leading us to NewSQL. The software stacks are moving towards ubiquitous computing i.e. even smaller handheld devices, are capable of running these software stacks. To sum it up, it was a very factual and a visionary talk by Bruno.

    I will defer the other topics till later. Let me talk about the topics I liked the most:

    JPA – Painless Persistence

    Painless Persistence by Greg Kable was a very engaging talk. It was kind of an OOPS/ORM primer. The concepts were explained in a very general terms like “why/when to use ORM and when not to”, Skinny Objects and their pitfalls. Why to avoid optimization? Such concepts could be applied to any kind of ORM in practice. Even if you didn’t know anything about JPA or Hibernate, you could understand the point Greg was trying to make. And by the way, there are 3 rules of optimization: don’t do it, don’t do it, don’t do it. Before deciding on optimizing part(s) of your application always think of these 3 rules. It is just as a reminder that it might not make sense to put efforts on optimizing your applications first of all.

    Future of Seam Framework

    Seam 3 is final release of Seam project. That’s it. All future efforts are directed towards Apache DeltaSpike from now on. So, do think twice before using Seam for your new projects. However, Seam being a widely used framework, the bugfixes and mainitainence will still be available. And contributes, checkout the DeltaSpike project now!

    Polyglot Revolution

    This was an intersting topic. What it means is that many JVM based languages (ceylon, scala, clojure, ruby, python) and their frameworks ( like Ruby On Rails ) will be available integrated with JBoss AS. TorqueBox is a unique example of this. With this effort, you can use all the power and features of Java EE stack right into your other language frameworks. Same argument applies for Immutant.

    JBoss Application Server

    In the recent years, JBoss has seen a lot of increase in the number of hits on its project sites from the Indian region. Most of these hits are by the users who use JBoss. But what about the size of contributers? What is the plan ahead for community engagement? Well that is the question I asked the panel. JBoss Heroes is project that is supposed to address this issue. Lets see when it is going to actually materialize. JBoss AS7, the latest release, is fully EE6 compliant, is very lightweight and is blazing fast with a boot time less that 3 seconds!

    Infinispan

    I don’t know why but there were just too many talks on Infinispan alone ( over 6 talks ! ). Inifinispan is a data grid platform based on the design of Amazon Dynamo ( has many implementation including Apache Cassandra ). Infinispan spans a very broad set of usecases. It can act as an in memory cache, persistent cache, distributed cache, replicated cache for high availablity. Also it provides plugins for different backends like Arjuna TM, BDB, JDB, JDBC etc.

    Essentially it acts a key/value store. Its real power comes from its flexibility, which allows it to be adapted for many many use cases.

    Becoming an Open Source developer

    “When in fight, I start to fear that if I get hit by my oppnent, worse is going to happen, and I will lose.” Well, dont! Believe in how good things are going to be if you succeed. Always think that you are going to bring the opponent down no matter what. Never fear of failure. Fear the fear itself, and put your best. That is the mantra of successful Open Source developers, quite well explained by Dmitris in his talk Becoming an Open Source developer. Fight the problem until you solve it. Isn’t that straight forward ;-)

    Drools – Rules Engine and Complex Event Processing

    In the talk “Declarative Rules” by Mark Proctor ( co-creator and founder of Drools ), he explained that Drools is Declarative Rules based engine. He demonstrated a simple game Wumpus World, that can be completely created using only rules. No other code required, which simplifies the whole process. Of the other things in his talk, there qere queries regarding Fuzzy logic support in Drools. Rules reduction or compaction process in Drools. Also rules processing on distributed and unstructured data, which is an inherently hard nut to crack.

    In a subsequent talk “Demystifying Complex Event Processing” by Mark Proctor again, he explained how CEP works. How Complex Event Processing (CEP), Event Stream Processing (ESP) and Event Drive Architecture (EDA) are closely related. Drools Fusion is the CEP tool by JBoss. To learn more about Drools / CEP there are many books available: The Power of Events, Event Drive Architecture, Drools JBoss Rules 6.0 Developer’s Guide, JBoss Drools Business Rules

    I am happy to have met a lot of people Jaikiran Pai, Sachin Patil, Ray Ploski, Radoslav Husar, Ales Justin, Dmitris Andreadis, and many other whom I only listened to ;-)

    However, I also missed a few things that would have made this conference even better in my opinion. There could have been an inclusion of activities like Hackathon, Bug Squadding or Workshop ( hands-on sessions ).

    It has been a great learning experience. Keep them coming – the events – JUDCon 2012, you rock!

    PS: I don’t see any slides nor the videos from JUDCon 2012 on their website yet. When are they coming?

     
  • tuxdna 11:14 am on January 14, 2012 Permalink | Reply  

    Potential bug in Ruby bindings of Apache Qpid 

    I wanted to experiment with Ruby bindings of Apache Qpid.

    Lets install the the server and client:

    $ sudo yum install qpid-cpp-server ruby-qpid qpid-tools
    $ service qpidd start
    

    Now check which version of Ruby bindings have we installed here:

    $ rpm -qi ruby-qpid
    Name        : ruby-qpid
    Version     : 0.8
    Release     : 2.fc15
    Architecture: x86_64
    Install Date: Fri 13 Jan 2012 06:21:55 PM IST
    Group       : Development/Ruby
    Size        : 219877
    License     : ASL 2.0
    Signature   : RSA/SHA256, Wed 27 Jul 2011 06:41:06 PM IST, Key ID 067f00b6a82ba4b7
    Source RPM  : ruby-qpid-0.8-2.fc15.src.rpm
    Build Date  : Wed 09 Feb 2011 03:48:16 PM IST
    Build Host  : x86-11.phx2.fedoraproject.org
    Relocations : (not relocatable)
    Packager    : Fedora Project
    Vendor      : Fedora Project
    URL         : http://qpid.apache.org/
    Summary     : Ruby language client for AMQP
    Description :
    The Apache Qpid project's Ruby language client for AMQP.
    

    Okay, now lets create a simple script and send some messages.

    #!/usr/bin/ruby
    # file: qpid-test.rb
    require 'qpid'
    
    host = "localhost"
    port = 5672
    address = "amq.topic"
    spec_marshal_file = "/usr/lib/ruby/site_ruby/1.8/qpid/spec_cache/amqp.0-10-qpid-errata.rb_marshal"
    spec_object = Marshal.load(File.open(spec_marshal_file).read())
    
    socket = TCPSocket.new(host, port)
    connection = Qpid::Connection.new(socket, :spec => spec_object)
    puts "Connection instance created..."
    
    connection.open
    
    puts "Connection instance opened..."
    
    session    = connection.create_session
    puts "Session initiated..."
    
    receiver   = session.create_receiver address
    puts "Receiver object created..."
    
    sender     = session.create_sender address
    puts "Sender object created..."
    
    
    sender.send Qpid::Message.new :content => "Hello world!"
    
    message = receiver.fetch Qpid::Messaging::Duration::SECOND
    puts "#{message.content}"
    session.acknowledge
    connection.close
    

    On running the script we should get a “Hello world!” message.

    $ ruby qpid-test.rb
    Connection instance created...
    qpid-test.rb:13qpid-test.rb:13: [BUG] Segmentation fault
    ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
    
    Aborted (core dumped)
    

    This is not what we expected. What is wrong here? Perhaps a bug in the Ruby bindings.

    Then I went to the source code repository of Ruby bindings on github.com:

    https://github.com/apache/qpid/tree/trunk/qpid/cpp/bindings/qpid/ruby

    According to the instructions I installed the latest bindings:

    $ sudo gem install qpid
    

    And removed the one I installed earlier

    $ yum erase ruby-qpid
    

    Now thats funny because the gem I ended up installing using the command is:

    http://rubygems.org/gems/qpid

    QPID (Queriable Patient Inference Dossier, developed at Massachusetts General Hospital), which is not even related to Apache Qpid.

    How am I supposed to installed the latest Ruby bindings for Apache Qpid client?

     
  • tuxdna 9:05 am on December 10, 2011 Permalink | Reply  

    Symlink loop is still an unsolved problem 

    How do I dereference a symbolic link?

    $ ls -l /usr/bin/java
    lrwxrwxrwx. 1 root root 22 Jul 20 2010 /usr/bin/java -> /etc/alternatives/java
    $ ls -l /etc/alternatives/java
    lrwxrwxrwx. 1 root root 30 Aug 9 2010 /etc/alternatives/java -> /usr/java/jdk1.6.0_20/bin/java
    $ ls -l /usr/java/jdk1.6.0_20/bin/java
    -rwxr-xr-x. 1 root root 50810 Apr 13 2010 /usr/java/jdk1.6.0_20/bin/java

    Lets create a chain of symbolic links:

    mkdir /tmp/symlink
    cd /tmp/symlink
    echo "this is a test file" >  abc.txt
    ln -s abc.txt link1
    ln -s link1 link2
    ln -s link2 link3
    ln -s link3 link4
    

    Now lets use the last link that we created:

    cat link4
    this is a test file
    

    What if we make it a circular link?

    rm link1
    ln -s link4 link1
    

    Now lets try to use one of the symbolic links:

    cat link4
    cat: link4: Too many levels of symbolic links
    

    You noticed that? Okay, lets move further:

    # we will create a chain of symlinks, which is 50 links deep
    mkdir /tmp/links
    cd /tmp/links
    for i in {0..50}
    do
      ln -s l${i} l$(expr $i + 1)
    done
    echo hello > l0
    

    Lets see what files/links this script has generated:

    cd /tmp/links
    ls -l
    

    You will notice that all the symlinks upto l40 resolve correctly:

    $ cat l40
    hello
    $ # notice that:
    $ # all links from l41 and above will not resolve
    $ cat l41 
    cat: l41: Too many levels of symbolic links
    $ cat l51
    cat: l51: Too many levels of symbolic links
    

    Lets print the whole link path now:

    # doesn't handle circular symlink loops at the moment
    F=l51
    while [ -h "$F" ]
    do
      G=$(readlink $F)
      echo "$F -> $G"
      F=$G
    done
    echo "Finally -> $F"
    

    OUTPUT:

    l51 -> l50
    l50 -> l49
    l49 -> l48
    ...OUTPUT SKIPPED..
    l3 -> l2
    l2 -> l1
    l1 -> l0
    Finally -> l0
    

    What’s the bottomline?

    • Even if there is no circular symlink loop, the symlink might fail to resolve. This depends on the MAXSYMLINK limit.
    • UNIX / Linux doesn’t handle symlink loops at all. The whole assumption is based on a limit. If the symlink chain grows more than a certain limit, we will get a “Too many levels of symbolic links” error, regardless of the symlink loop or not.

    References:

    http://lwn.net/Articles/91959/

    http://www.itworld.com/nls_unix_symboliclinks060622

     
  • tuxdna 9:20 am on November 29, 2011 Permalink | Reply  

    How to resize a VM and its partitions? 

    In this post I am going to list the steps to resize a Virtual Machine image created using virt-install

    There are three steps:

    • Resize the VM image
    • Resize the LVM volume inside the VM ( both physical volume and logical volume )
    • Resize the filesystem on the LVM volume

    First locate where the image for your VM is stored.

    # virsh dumpxml vm2 | xpath /domain/devices/disk/source
    Found 1 nodes:
    -- NODE --
    <source file="/export/vmimgs/vm2.img" />
    

    Mine is stored at /export/vmimgs/vm2.img

    It is 5GB VM which I want to resize to 10GB. And then, I basically want more space for root partition ( mount point / ).

    Step 1: Resize the VM image

    Shutdown the VM and take a backup;

    # virsh shutdown vm2
    # cd /export/vmimgs
    # cp vm2.img vm2.img.backup
    

    First lets find the disk devices within our VM:

    # virt-filesystems --long -h -a  /export/vmimgs/vm2.img
    Name                   Type        VFS   Label  Size
    /dev/sda1              filesystem  ext4  -      500M
    /dev/VolGroup/lv_root  filesystem  ext4  -      1.5G
    
    # virt-filesystems --long --parts --blkdevs -h -a  /export/vmimgs/vm2.img
    Name       Type       MBR  Size  Parent
    /dev/sda1  partition  83   500M  /dev/sda
    /dev/sda2  partition  8e   1.5G  /dev/sda
    /dev/sda   device     -    5G    -
    

    Now we resize our VM image ( +5GB ):

    # cd /export/vmimgs
    # truncate -r vm2.img vm2.img.new
    # truncate -s +5G vm2.img.new 
    # virt-resize --expand /dev/sda2 vm2.img vm2.img.new
    Examining vm2.img ...
    **********
    
    Summary of changes:
    
    /dev/sda1: This partition will be left alone.
    
    /dev/sda2: This partition will be resized from 4.5G to 9.5G.  The LVM 
        PV on /dev/sda2 will be expanded using the 'pvresize' method.
    
    **********
    Setting up initial partition table on vm2.img.new ...
    Copying /dev/sda1 ...
     100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ 00:00
    Copying /dev/sda2 ...
     100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ 00:00
     100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ --:--
    Expanding /dev/sda2 using the 'pvresize' method ...
    
    Resize operation completed with no errors.  Before deleting the old 
    disk, carefully check that the resized disk boots and works correctly.
    

    Did you notice that /dev/sda2 was resized using ‘pvresize’. Thats because
    its a LVM physical volume.

    Now we move the new image vm2.img.new to the actuall image, taking backup for safety:

    # chmod +x vm2.img.new
    # mv vm2.img vm2.img.original
    # mv vm2.img.new vm2.img
    

    Step 2: Resize the LVM volume inside the VM – logical volume

    Login into guest and resize the logical volume:

    [root@localhost ~]# lvresize -L +5G /dev/VolGroup/lv_root
    

    Step 3: Resize the filesystem on the LVM volume.

    Resize the ext4 partition:

    [root@localhost ~]# resize2fs /dev/VolGroup/lv_root
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
    old desc_blocks = 1, new_desc_blocks = 1
    Performing an on-line resize of /dev/VolGroup/lv_root to 1708032 (4k) blocks.
    The filesystem on /dev/VolGroup/lv_root is now 1708032 blocks long.
    
    [root@localhost ~]# df -h
    Filesystem                    Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root  6.5G  1.4G  4.8G  23% /
    tmpfs                        1004M     0 1004M   0% /dev/shm
    /dev/vda1                     485M   31M  429M   7% /boot
    

    Thats it. I hope that helps.

    References:

    http://libguestfs.org/virt-resize.1.html

    http://virt-tools.org/learning/install-with-command-line/

    http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization/sect-Virtualization-Virtualized_guest_installation_overview-Creating_guests_with_virt_install.html

     
    • rich 5:59 pm on November 29, 2011 Permalink | Reply

      Rather than using the separate lvresize step, you can add this option to virt-resize:
      --lv-expand /dev/VolGroup/lv_root. This option requires virt-resize > 1.2 IIRC.

      • rich 6:00 pm on November 29, 2011 Permalink | Reply

        .. which resizes the filesystem in the LV too.

  • tuxdna 3:46 pm on November 28, 2011 Permalink | Reply  

    zif critical errors 

    Every once in a while I get these errors when installing a package using zif:

    Downloading        [==================================================================] (59%)
     packages/glusterfs-server-3.2.4-2.fc16.x86_64.rpm [2.9 MB/s] om 64 to 52 on 0x1fb60b0!
    5) zif-main.c:2590 (5/6)
    4) zif-main.c:2401 (3/5)
    3) zif-transaction.c:3989 (1/3)
    2) zif-package-array.c:243 (0/1)
    1) zif-package-remote.c:416 (2/3)
    0) zif-store-remote.c:505 (1/2)
    
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 60 to 19 on 0x78e6410!
    4) zif-main.c:2590 (5/6)
    3) zif-main.c:2401 (3/5)
    2) zif-transaction.c:3989 (1/3)
    1) zif-package-array.c:243 (0/1)
    0) zif-package-remote.c:416 (2/3)
    
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 64 to 27 on 0x7f5f4c0!
    3) zif-main.c:2590 (5/6)
    2) zif-main.c:2401 (3/5)
    1) zif-transaction.c:3989 (1/3)
    0) zif-package-array.c:243 (0/1)
    
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 64 to 27 on 0x1fb63e0!
    2) zif-main.c:2590 (5/6)
    1) zif-main.c:2401 (3/5)
    0) zif-transaction.c:3989 (1/3)
    
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 61 to 31 on 0x7909ae0!
    1) zif-main.c:2590 (5/6)
    0) zif-main.c:2401 (3/5)
    
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 49 to 40 on 0x1fb62d0!
    0) zif-main.c:2590 (5/6)
    Completed          [==================================================================] (100%)
                                                                   m 59 to 52 on 0x1fb60b0!
    Transaction success!
    

    Although the packages get installed, this is makes me uncomfortable.

    And how are these stack-traces generated for C code ?

     
  • tuxdna 12:42 pm on November 24, 2011 Permalink | Reply  

    zif – Package management done faster 

    On Fedora 16, I used zif. zif is an alternative to yum and its fast!

    How to setup zif?
    So easy: sudo yum install zif zif-tools

    All set!

    Search for packages using zif:
    sudo zif search mongodb

    Do a offline serach ( like cached -C in yum ):
    sudo zif search -o mongodb

    Install packages using zif:
    sudo zif install mongodb-server mysql-server

    Update all packages:
    sudo zif update

    And if you feel like canceling the operation using Ctrl+C, it happens almost instantaneously!

    I like it.

     
    • Michael 9:57 am on November 27, 2011 Permalink | Reply

      Thanks for sharing.
      Any idea why this is not the default package manager for Fedora? If it has all the mentioned benefits including all of the functionality of yum, this would make sense (to me).?

    • tuxdna 3:43 pm on November 28, 2011 Permalink | Reply

      No idea!

    • rich 6:03 pm on November 29, 2011 Permalink | Reply

      I’d love to see faster and more intelligent depsolving, either in yum or some alternative (zif, zypper?)

      There was a rather extensive argument on fedora-devel-list a few months ago about this, if you can stomach it:
      https://lists.fedoraproject.org/pipermail/devel/2011-September/thread.html#157023

  • tuxdna 5:49 am on November 17, 2011 Permalink | Reply  

    How to setup multiple monitors on Xfce desktop?

    I just followed the instructionson Xorg RandR 1.2 wiki

    http://www.thinkwiki.org/wiki/Xorg_RandR_1.2

    Lets find out how many monitors we have connected?

    $ xrandr -q
    Screen 0: minimum 320 x 200, current 1280 x 800, maximum 8192 x 8192
    LVDS1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 261mm x 163mm
       1280x800       60.0*+   50.0  
       1024x768       60.0  
       800x600        60.3     56.2  
       640x480        59.9  
    VGA1 connected (normal left inverted right x axis y axis)
       1680x1050      60.0 +
       1280x1024      75.0     60.0  
       1152x864       75.0  
       1024x768       75.1     60.0  
       800x600        75.0     60.3  
       640x480        75.0     60.0  
       720x400        70.1  
    HDMI1 disconnected (normal left inverted right x axis y axis)
    DP1 disconnected (normal left inverted right x axis y axis)
    HDMI2 disconnected (normal left inverted right x axis y axis)
    DP2 disconnected (normal left inverted right x axis y axis)
    DP3 disconnected (normal left inverted right x axis y axis)
    

    Now ask Xrandr to configure them:

    $ xrandr --output LVDS1 --auto --output VGA1 --auto --right-of LVDS1
    

    Now thats simply cool!

     
    • Siddhesh 2:25 pm on November 17, 2011 Permalink | Reply

      Here’s a script I’ve written to do this with any external display (monitor, projector, etc.). Execute it after connecting the display to your box:

      #!/bin/sh

      typeset -a resx
      typeset -a resy
      typeset -a screen
      typeset -i name=1
      typeset -i count=0

      tmpfile=$(mktemp)
      cmd=”xrandr –fb ”

      xrandr | grep -A 1 ” connected ” | grep -v “^–$” | awk ‘{print $1}’ > $tmpfile
      count=0

      for line in $(cat $tmpfile); do
      if [ $name -eq 1 ]; then
      screen[$count]=$line
      name=0
      else
      line=$(echo $line|sed ‘s/[Xx]/ /g’)
      resx[$count]=$(echo $line | awk ‘{print $1}’)
      resy[$count]=$(echo $line | awk ‘{print $2}’)
      count=$((count+1))
      name=1
      fi
      done

      total_width=0
      prev_scr=
      max_height=0
      for i in $(seq 0 $((count-1))); do
      if [ $max_height -lt ${resy[$i]} ]; then
      max_height=${resy[$i]}
      fi

      cmd_ext=”$cmd_ext –output ${screen[$i]} –mode ${resx[$i]}x${resy[$i]}”
      if [ -n "$prev_scr" ]; then
      cmd_ext=”$cmd_ext –right-of $prev_scr”
      fi
      prev_scr=${screen[$i]}

      total_width=$((total_width+${resx[$i]}))
      done

      cmd=”xrandr –fb ${total_width}x${max_height} $cmd_ext”

      echo “Running command: $cmd”
      eval $cmd

      rm -f tmpfile

    • tuxdna 2:36 pm on November 17, 2011 Permalink | Reply

      Thanks for sharing. I have created a gist for the same:

      https://gist.github.com/1373278

  • tuxdna 5:40 am on November 15, 2011 Permalink | Reply  

    Emacs key binding Ctrl+Space not working on Fedora 16 GNOME or XFCE 

    I installed Fedora 16 x86_64 and then installed Emacs. Then I logged in into (XFCE or GNOME) desktop and started Emacs.
    For text selection in Emacs I use Ctrl+Space ( which is the default in Emacs ), and is no longer working. So I cannot select text using Ctr+Space.

    However, if I login into virtual terminal ( Ctrl+Alt+F3 ), then login and start Emacs, the key-binding (Ctrl+Space) for text selection works fine. Therefore there is no problem in Emacs itself.

    I suspect that the Ctrl+Space key strokes are intercepted by something in between i.e. either GDM or IBus but I am not sure which one. How can I fix it?

     
    • tuxdna 6:01 am on November 15, 2011 Permalink | Reply

    • wks 12:24 pm on November 15, 2011 Permalink | Reply

      As for me, ctrl+space has been for toggling between Chinese (and other languages) and English since I was using M$ Windows. I was using ctrl+@ to select text in Emacs because I was so comfortable to have ctrl+space as a language switcher that I could not change my habit. And ctrl+@ is not as easy to use as ctrl+space (and this is partially why I ended up using VIM). After I began using GNOME3, this combo fails to work from time to time. That should be Gnome Shell’s bug. Now I am training myself to use right-alt to switch languages, instead.

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel
Follow

Get every new post delivered to your Inbox.