»

How to view embedded PDFs in Firefox with Evince?

, , — mab — 10:37 am Abril 1, 2012

1) Install Mozplugger

$> sudo apt-get install mozplugger

2) Place the following in ~/.mozilla/mozpluggerrc

application/pdf: pdf: PDF file
application/x-pdf: pdf: PDF file
text/pdf: pdf: PDF file
text/x-pdf: pdf: PDF file
application/x-postscript: ps: PostScript file
application/postscript: ps: PostScript file
    repeat noisy swallow(evince) fill: evince "$file"

3) Restart Firefox

How to now the version of libc currently in use?

, , — mab — 10:21 am

Execute the libc linary, as in

$> /lib/libc.so.6

or, if not possible in your platform, execute

$> ldd --version

What are my usual valgrind command line parameters?

, , , — mab — 10:14 am
$> valgrind --leak-check=full --show-reachable=yes --track-origins=yes \
            --track-fds=yes --demangle=yes --max-stackframe=256000 executable

Experiments towards a generic index_of function…

, , — mab — 11:05 am Março 18, 2012
#include <cstdlib>
#include <iostream>

/**
 * Find the index in the array of the first element accepted by the predicate
 **/
template<class T, class UnaryPredicate>
size_t index_of( T array[], size_t size, UnaryPredicate pred )
{
    for(size_t i = 0; i < size;i++)
    {
        if(pred(array[i]))
            return i;
    }

    return size;
}

/**
 * The function object defining the "less_than" predicate
 **/
template<typename T>
class less_than
{
public:
    less_than(T value): value_(value) {};

    bool operator() (T value)
    {
        return value < value_;
    } 

private:
    T value_;
};

/**
 * The function object defining the "between" predicate
 **/
template<typename T>
class between
{
public:
    between(T lower, T upper): lower_(lower), upper_(upper) {};

    bool operator() (T value)
    {
        return lower_ <= value && value <= upper_;
    } 

private:
    T lower_;
    T upper_;
};

/**
 * Macro to get the size of the array
 **/
#define SIZEOF(A) (sizeof A / sizeof A[0])

/**
 * Example of usage...
 **/
int main(void)
{
    double a[] = {56,200,643,45,8,1,3,1,23,5};

    std::cout << index_of(a, SIZEOF(a), less_than<double>(45)) << std::endl;
    std::cout << index_of(a, SIZEOF(a), between<double>(44, 46)) << std::endl;
}

How to check for endianess?

, , , — mab — 7:24 am Março 9, 2012
bool is_system_big_endian()
{
   long one = 1;
   return !(*((char *)(&one)));
}

How to remove the Help preferences page?

, , , — mab — 12:27 pm Janeiro 23, 2012

Add the following to your application’s WorkbenchAdvisor to remove the “Help” preference page:

@Override
public void postStartup() {
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager( );
    pm.remove( "org.eclipse.help.ui.browsersPreferencePage" );
}

How to remove Restore Defaults and Apply buttons from preferences page?

, , , , — mab — 5:03 pm Janeiro 16, 2012

PreferencePage.noDefaultAndApplyButton();

How to install the GCC from sources?

, , — mab — 6:19 pm Dezembro 30, 2011
  1. Had to install the following prerequisites, while using a Ubuntu box. Some might have already been installed. Check the list of prerequisites.
  2.   $> sudo apt-get install libmpc-dev libgmp3-dev libmpfr-dev
    
  3. Select a mirror and download the required version through http://gcc.gnu.org/releases.html.
      $> wget http://mirrors-us.seosue.com/gcc/releases/gcc-4.6.2/gcc-4.6.2.tar.gz
    

    Extract the downloaded package archive into a temporary source directory (SRC_DIR).

  4. Prepare the object directory (OBJ_DIR) and configure the build. Consider setting the PREFIX_DIR (e.g. /opt/gcc-4.6.2) in configure conmmand.
  5.   $> mkdir $OBJ_DIR
      $> cd $OBJ_DIR
      $> $SRC_DIR/configure --prefix=$PREFIX_DIR --enable-languages=c,c++,fortran
          --disable-bootstrap --disable-multilib
    
  6. Compile
  7.   $> make
    
  8. Install
  9.   $> make install
    

How to toggle Firefox Bookmarks Toolbar?

, , , — mab — 2:57 pm Dezembro 28, 2011

The following works with Firefox 9.0.1 (installed in a Ubuntu Linux PC):

  1. Install keyconfig extension, available at mozillazine foruns.
  2. Go to Tools -> Keyconfig…, add a new key binding for (Ctrl+Alt+B) named “Bookmarks Toolbar”
  3. Setup the key binding code to
    var E=document.getElementById('PersonalToolbar');
    if(E.collapsed){E.removeAttribute('collapsed')}
    else{E.setAttribute('collapsed',true)}
    
  4. Restart firefox.

[no title]

, , — mab — 2:07 pm Dezembro 27, 2011

página seguinte »
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 [Divagações Diárias] | powered by WordPress with Barecity