Friday, December 2, 2011

How to record a live stream

I found a lovely post on how to record a live stream or to record whatever audio is:

I'm using the Sound Recorder application that comes in standard Ubuntu installations. To set this up using other programs (like audacity) just substitute it in these instructions.

  1. Install pavucontrol (PulseAudio Volume Control) using apt-get or the Ubuntu Software Center.
  2. Open PulseAudio Volume Control. It should be in the applications menu under Sound and Video.
  3. Open Sound Recorder and start recording. Playing any sound at this point would be helpful, as your level indicator should react once you have finished.
  4. Go to the "Recording" tab in the PulseAudio Volume Control window.
  5. Make sure that "Applications" is selected in the drop down menu on the "Recording" tab.
  6. Choose "Monitor of Internal Audio Analog Atereo" from the "Record Stream from" menu in the Sound Recorder entry of the application list.

This appears to be persistent so that you will only have to do this once, but you will have to repeat these steps to record in another application.

After this I notice that my mice is disconnected from skype. Consider this as a fix:Open “Sound Preferences” -> “Hardware” -> “Change Profile to Analog Stereo Input” -> test -> “Change Profile to Analog Stereo Duplex” -> test again.

Saturday, July 30, 2011

Updating Firefox on Ubuntu

I can't find a solid reason to update my browser (unless some site or software that I use asks me to). Today I got tempted by a message on my gmail account asking me to do that. So here is how to do it:

sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update
sudo apt-get upgrade
 

This was method 2 among 3 ways to do it that I found under this post.

One new feature Firefox5 has is the Sync feature. So now you can have all your tabs and browsing needs saved (safely as I hope) and you can access then from any machine.

Tuesday, July 12, 2011

Editing PDF files on linux, Two solutions

Since most our meetings and seminars are presented as PDF files. I finally realised that I need some way to edit them on Linux. Something as simple as adding comments and such would do. couple of research attempts lead me to the following link:
http://www.cyberciti.biz/tips/open-source-linux-pdf-writer.html


I tried PDFedit instantly and it did deliver what it promised. the only problem is the limited selection of arrow shapes (hard to use for Feynman diagrams).


To install and run:
$ sudo apt-get install pdfedit
$ pdfedit /path/to/pdf.file & 

The code runs smoothly but has it's limits; If the document had symbols unrecognised by it (Say Japanese characters or Math symbols). It will open but with many of it's functions missing. 

Another option is Open office! They new release (3.0 and after) has a package that is able to open PDF files on a drawing pad. you will even get to stick comments and such. This approach also suffers when opening some unrecognised set of fonts or objects. It will still be fully functional but the locations will be misset up as well as missing some symbols. 

We conclude this note with Images. Where your best bed is with GIMP. Which is a standard release in UBUNTU. Once you do the changes make sure to save as xcf. then using the command:
$  convert file.xcf file.pdf

You will get he new file in the required form.

Sunday, July 3, 2011

ROOT after a little bit of C++

I made a recent revision for Malik's excellent book about C++. This time I made it up to chapter 14 where I learned a lot about pointers. It turns out that this concept is heavily used in ROOT. For example here is a snippet of a code I am using to create plots of publication quality:

#include
#include "TInterpreter.h"
#include "TCanvas.h"
#include "TLatex.h"
#include "TROOT.h"
#include "TH2F.h"
#include "TGraphErrors.h"
#include "TLegend.h"
#include "TPad.h"


These are preprocessor statements to include libraries and header files. the <> symbol is doe standard libraries. and the ones between quotes "" is for libraries made.
void readRFPAS2RHWZ2() {



This starts the function of the type void called readRFPAS2RHWZ2()




float x = 0.446127; //The coordinate of 900GeV labe (t1d, t2d, etc)
float y = 0.190389;
float x1 = 0.2000; //The coordinates for the legends.
float y1 = 0.326465;
float x2 = 0.50275;
float y2 = 0.551054;

Simple variable declaration.

 TInterpreter::Instance() -> LoadMacro("tdrstyle.C");
This is a bit odd as an expression. I am not sure how to interpret it but here is a try. There is a space TInterpreter with an class Instance that has an object LoadMacro. it is called as a pointer:

(*TInterpreter::Instance).LodMacro = tdrstyle.C

What this does is to ask our code to use that macro.
 gROOT -> Reset();

Basically calling another pointer.
(*gROOT).Reset();
 TInterpreter::Instance() -> Execute ("setTDRStyle","");

Same as above.

 TCanvas *c1 = new TCanvas("c1","different scales hists",600,600);

new means we are creating a dynamic variable. in this case of the type TCanvas. it is assigned to the pointer c1.

 c1->Range(-100,-100,10,10);

now c1 points to another object in TCanvas.
(*c1).Range = (-100,-100,10,10);

 TH1F *Dist_Nch_pT20_ = new TH1F("Dist_Nch_pT20_","title",100,-0.5,30);

also TH1F is a data type. with the pointer Dist_Nch_pT20_ is set with the address of the class named Dist_Nch_pT20_  with the parameters needed. next we assign the objects:
 Dist_Nch_pT20_->SetXTitle("N_{ch}");

etc.

So we conclude it is nothing but a bunch of dynamic classes assigned by pointers.

Friday, February 11, 2011

Fixing touch pad from shell

Today while I was working while watching a movie online. suddenly my touch-pad frozen. More specifically the left button option on my Dell Inspiron E1505. As hard as it was to surf the web this way. I found a lovely fix:

gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true

Thanks to Ubuntu's website

Monday, January 17, 2011

Starting Open Office from shell

I ran across this excellent reference on how to start OO from shell. instead of that silly file name I just opened it on my desktop and dumped the code. What it worth mentioning is that it opens whatever release you currently have. for completion the code it below:

################
import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

import java.io.IOException;
import java.io.InputStream;

/**
 *
 * @author bobohead2
 */
public class StartOpenOffice {
   
    private String unoUrl =
            "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager";
   
    /** Creates a new instance of StartOpenOffice */
    public StartOpenOffice() {
    }
   
    public boolean startOpenOffice(String p_scriptpfad){
        boolean loaded = false;
        try {
          // loads the script
            String cmd = p_scriptpfad     //home/bobohead2/OpenOffice.org1.1/ListenOffice.sh";
            Process process = Runtime.getRuntime().exec(cmd);
            InputStream processOut = process.getInputStream();
            InputStream processErr = process.getErrorStream();
           
        } catch (IOException ioe) {
            ioe.printStackTrace(System.out);
        }
        while(loaded == false){
            try{
               // open Office may take a while to open
                XComponentContext xLocalContext =
                       com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
               
                XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
               
                Object urlResolver  = xLocalServiceManager.createInstanceWithContext(
                        "com.sun.star.bridge.UnoUrlResolver", xLocalContext );
                // query XUnoUrlResolver interface from urlResolver object
                XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(
                        XUnoUrlResolver.class, urlResolver );
               
                // Second step: use xUrlResolver interface to import the remote StarOffice.ServiceManager,
                // retrieve its property DefaultContext and get the remote servicemanager
                Object initialObject = xUnoUrlResolver.resolve( unoUrl );
                loaded = true;
            }catch(Exception e){
                // open office is not ready yet
                loaded = false;
                // wait a liitle bit and try again
                for(int i=0;i< 10000;i++){
                   
                }
            }
        }
        return loaded;
    }
}
##########################

and to run it just type:
#!/bin/sh
/opt/openoffice.org2.0/program/soffice "-accept=socket,port=8100;urp;"