Sunday, November 28, 2010

sample Makefile

#

SOURCES=my_main.cpp

INC_PATH=~/tools/ImageMagick-6.6.5-4/Magick++/lib

LIBRARY_PATH=~/tools/ImageMagick-6.6.5-4/Magick++/bin

all:
    g++ -g -L$(LIBRARY_PATH) -O0 -o my_main $(SOURCES)

gdb

(gdb) kill ---> kill the session and keep your breakpoints...
(gdb) run ---> restart a new session
(gdb) info locals ---> local variables
(gdb) quit ---> exit gdb, lose your breakpoints...

(gdb) bt or backtrace ---> call stack
(gdb) bt full ---> call stack + all variables
(gdb) x/200s 0x89b8a8 ---> display mem as string

A blank line repeat the previous command

  • Debugging STL
    Add a file .gdbinit to debug STL, see this link:
    http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF

    Then you can use it like this:
    pmap params char* char*

    See "Run / Debug Configurations" and debugger tab to specify a particular .gdbinit. Note that I had to add the .gdbinit full path, otherwise it would not work

  • gdb with arguments
    gdb --args your_bin -c ~/2.2.25/etc -t 16

  • Debugging a core dump:
    - gdb MyBin core.14694
    and then bt for backtrace

    .
  • Thursday, November 25, 2010

    Sorting

    from wikipedia:

    Name Best Average Worst
    Memory Stable Method
    Other notes
    Insertion sort  \mathcal{}  n  \mathcal{}  n^2  \mathcal{}  n^2 \mathcal{} {1} Yes Insertion Average case is also \mathcal{O}\left( {n + d} \right), where d is the number of inversions
    Binary tree sort \mathcal{} {n \log n} \mathcal{} {n \log n} \mathcal{} n Yes Insertion When using a self-balancing binary search tree
    Cycle sort  \mathcal{}  n^2  \mathcal{}  n^2 \mathcal{} {1} No Insertion In-place with theoretically optimal number of writes
    Selection sort  \mathcal{}  n^2  \mathcal{}  n^2  \mathcal{}  n^2 \mathcal{} {1} No Selection Its stability depends on the implementation. Used to sort this table in Safari or other Webkit web browser [2].
    Bubble sort \mathcal{} n \mathcal{} n^2 \mathcal{} n^2 \mathcal{} {1} Yes Exchanging Tiny code
    Merge sort \mathcal{} {n \log n} \mathcal{} {n \log n} \mathcal{} {n \log n} Depends Yes Merging Used to sort this table in Firefox [3].
    Quicksort \mathcal{} n \log n \mathcal{} n \log n \mathcal{} n^2 \mathcal{} \log n Depends Partitioning Can be implemented as a stable sort depending on how the pivot is handled. Naïve variants use \mathcal{O} \left( n \right) space

    Saturday, November 13, 2010

    Quotes




  • "If I asked my customers what they wanted, they'd have said a faster horse." Henry Ford
  • "If you can't see the future, you won't have one." Noah Everett
  • "People often overestimate what will happen in the next two years and underestimate what will happen in ten." Bill Gates
  • "I have had all of the disadvantages required for success." Larry Ellison 
  • "There is no point in starting your own business unless you do it out of a sense of frustration." R. Branson
  • "Il y a trois manières de se ruiner: le jeu, les femmes — et les ingénieurs. Les deux premières sont plus agréables — mais la dernière est plus sûre." Rothschild
  • "You have got to find a controversial strategy. The more controversial, the better. That’s the way to differentiate yourself from everybody else. Then you've got to get really good at what you’re doing. And that’s how you will beat the competition!" Scott Mc Neally
  • "Fire kept us warm and cooked our food but also burnt down our houses. Every technology has had its promise and peril." Ray Kurzweil
  • "On regrette de ne pas avoir fait, on ne regrette pas d'avoir fait" OH
  • "The great opportunities come when your business idea isn’t as much about the product but is a different view of the industry,"  Capital One Founder, Chairman, and CEO Rich Fairbank
  • "If I were to awaken after having slept for a thousand years, my first question would be: Has the Riemann hypothesis been proven?"  D. Hilbert (Quoted in Mathematical Mysteries : The Beauty and Magic of Numbers (1999) by Calvin C. Clawson, p. 258)
  • « Je suis dans l’œil du cyclone, il n’y a plus de ciel, tout est amalgame, il n’y a que des montagnes d’eau autour de moi », dernier message  de Alain Colas
  • "Listen, invent, personalize"  Jeff Bezos
  • "What do you want to accomplish in the 12 coming months ?"  Me
  • "it should not be the user that is searching for news/products, but the news/product that is coming to the user" Taboola
  • "It has been my experience that folks who have no vices have very few virtues."  Abraham Lincoln
  • "A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P if its performance at tasks in T, as measured by P, improves with experience E." "   Tom M. Mitchell. 
  • "A man is but the product of his thoughts; what he thinks, he becomes" ( By Mahatma Gandhi)
  • "Simplicity is the ultimate sophistication" (Leonardo da Vinci, repeated by Steve Jobs)
  • "Jerrold Zacharias, my mentor, told me "you are not as stupid as you look", and it is important that people tell you that" Rainer Weiss (nobel price in physics).
  • "Quand les hommes ne peuvent changer les choses, ils changent les mots" Jean Jaures
  • O Breizh, ma Bro, me 'gar ma Bro
  • "Dire fait rire, faire fait taire". Jean Le Cam
  • "La vie a plus d'imagination que toi"   mère de Najat Vallaud-Belkacem
  • "n’attendez pas que ça change si vous continuez à faire la même chose tous les jours" Ophely Winter
  • "Ton devoir réel est de sauver ton rêve" Modigliani
  • "Optimism is an essential ingredient of innovation. How else can the individual welcome change over security, adventure over staying in safe places" Robert Noyce
  • "il y a ceux qui voudraient bien, ceux qui veulent, et enfin ceux qui veulent absolument" Bernard Tapie
  • "The greater danger for most of us lies not in setting our aim too high and falling short; but in setting our aim too low, and achieving our mark." Michelangelo
  • "I always invest in companies that can be managed by stupid people, because one day or another that happens" Warren Buffet
  • "“Le bonheur est souvent la seule chose qu'on puisse donner sans l'avoir et c'est en le donnant qu'on l'acquiert.” Voltaire
  • "le bateau à voile est le moyen le plus cher d'aller qq part gratuitement"
  • "Television is programs around advertisement" Sylvio Berlusconi
  •