Friday, April 22, 2011

Select a stock quantity for 2 distinct shops

SELECT product.id AS product_id,
stock1.quantity AS quantity1,
stock2.quantity AS quantity2
FROM product
LEFT JOIN stock stock1 ON stock1.product_id = product.id AND stock1.shop_id = 1
LEFT JOIN stock stock2 ON stock2.product_id = product.id AND stock2.shop_id = 2

Tuesday, April 12, 2011

Find files newer than

First create a dummy file for 2011 April 11, 18:00
touch -t 201104111800 /tmp/lundi
Then find files newer than this file
find . -newer /tmp/lundi -print

Wednesday, April 6, 2011

virtualbox downloads

http://download.virtualbox.org/virtualbox/

Install .deb on ubuntu

sudo dpkg -i package.deb

lave vaisselle Bosch: l'eau ne s'evacue pas completement

Cette page donne la solution:

J'ai eu le même problème . J'ai réussi à remettre à neuf le répartiteur en utilisant un déboucheur liquide style" D----P" .
Effectuer le démontage du coté gauche (2 vis sous le joint de porte) enlever les 2 brides métalliques (2 vis et coulisser vers la gauche) Enlever les 2 angles plastique dont celui arriere est fixé par une vis .
Débrancher les tuyaux de la vidange ( tirer pour déboiter, joint torique) et celui de remplissage (pincer le collier pour le faire coulisser et débrancher le tube)
Sortir le répartiteur en le soulevant délicatement pour débrancher les 4 autres tubes .
Vous avez le répartiteur en main . L'angle supérieur gauche comporte un flotteur qui est bloqué dans les résidus de tartre et graisse .
Faire pivoter cet angle vers le bas, après vous être équipé de gants et lunettes faire couler le déboucheur par le tube de vidange afin de le produit pénètre par un petit conduit débouchant dans la vidange . Laisser une journée (trouver un moyer stable de le maintenir dans cette position et ATTENTION à ce que personne n'y touche DANGER), vider rincez abondamment en remuant pour créer un mouvement même léger au niveau du flotteur .Renouveler l'opération tant que nécessaire ( Je l'ai fait 3 fois pour en venir à bout )
Le remontage effectue en sens inverse.

Clearcase merge (alternative)

ct findmerge SCCP-MIR.xml -fversion /main/sw8/cr16532/LATEST -merge -gmerge
     |
     1
     |   \
  LATEST   1'
C’est 1’ qui est merge.
Puis faire ci.

crtool master BOD, where?

cd /ccase/cm/crtool-1.3/var/mbods

Compile without winking

clearmake -u
or
clearmake -V
Do not use swmake!

Who is owning the branch?

ct des bin/version.pl@@/main/sw9/eecn_902_sp4_patches

Get synchronization status

multitool lsepoch

Date of a label type

ct des lbltype:SW-9.02-SP4-DROP3

Changes from date

cd /vob/signalware/Master/
ct find -all -version '{brtype(cr25396a) && created_since(19-aug)}' -print -nxname

Merge files from cr19287a to current branch

ct findmerge -all -c "Merge back from tip" -fversion /main/sw9/cr19287a/LATEST -merge -gmerge

Show files to merge from cr19287a to current branch

ct findmerge -all -c "Merge back from tip" -fversion /main/sw9/cr19287a/LATEST -print

Cannot checkout

When we get this error:
[gallinar@chablis] gallinar_cr31703_sun 698 > crtool co -nc Imakefile
cleartool: Error: Unable to access "/view/admin@@/vob/signalware/main/sw9/3/Master/main/sw9/eecn_902_sp4_nsignia/2/xua/main/sw9/4/m3ua/main/sw9/5/s7ip/main/sw9/2/src/main/sw9/eecn_902_sp4_nsignia/0/c7/main/sw9/eecn_902_sp4_nsignia/cr31703a/CHECKEDOUT.21177515/Imakefile//main/sw9/2": No such file or directory.

This means that a directory in the current path is checked-out, and prevent the remote command from succeeding.
Solution:
Check-in the concerned directory, force a Clearcase synchro. and start again the CO.

Size of views

To get the top10 biggest views, “crtool :top10” is only effective for cm on peche.
Instead of using this command,
ssh peche
cd /export/ccase2/gallinar
du -sk | sort

Change CO reserved into CO unreserved

Nancy, You can change Gary's checkout to unreserved by setting his view and using
cleartool unres "filename"
PQ

Change rights on Clearcase directory

ct protect -chmod g+w triggers

Synchronize

Synchronize from the US to France:
ct sched -host walter -run 11
Synchronize from France to the US:
ct sched -host peche -run 11

Back in time

Use the -time option in config spec
E.g.:

element * /main/sw9/eecn_902_sp5/LATEST -nocheckout -time 1-Sep-2008.00:00:00

Unable to create config spec

If crtool displays this message when createing a view (on k2632 for example), proceed as follows:
root> domainname fr.ulticom.com
and try re-creating the view.

ERROR: SITE UNKNOWN

If we get this error:
[gallinar@lili] gallinar_cr34559_k2632 698 > ct ci -nc ./lib/sctp_stat.c
ERROR: SITE UNKNOWN
cleartool: Warning: Trigger "Get_CR_info_and_Validate" has refused to let checkin proceed.
cleartool: Error: Unable to check in "./lib/sctp_stat.c".

then
root> domainname fr.ulticom.com

Changes between labels SW-9.02-SP4-DROP3 and SW-9.02-SP4-DROP4

ct find . -ver 'lbtype(SW-9.02-SP4-DROP3)' -print | sort > drop3.txt
ct find . -ver 'lbtype(SW-9.02-SP4-DROP4)' -print | sort > drop4.txt
diff drop3.txt drop4.txt

Set a new label

> ct mklbtype -c "my comment" LABEL
> ct mklabel [-rec] [-rep] LABEL

-rep permet de deplacer un label deja pose

Checkout UpdateSwmml.pm

Just add the following line in config spec.:
element /vob/int_tools/... /main/LATEST

iMovie 09 or 11 crashes when importing from Panasonic GH2

Symptoms: plug the GH2 to the PC and start the synchro from the device causes iMovie to crash inevitably.
To see the error message:
> cd /Applications/iMovie.app/Contents/MacOS
> ./iMovie

will get
Error getting a reference to /options

Solution:
Install a fixed AppleSMBIOS.kext in /S/L/E (e.g. with Kext Utility).
The one to pick is AppleSMBIOS.kext_MacBookPro.zip to be found @ Fully fixed AppleSMBIOS driver

Upgrade LeoHazard 10.6.2 into 10.6.7 on AMD

Conf. recap:
Gigabyte K8NF9 ultra
AMD athlon64 3500+
GeForce 240 GT 512Mb GDDR5

Instructions:
  1. Download Apple 10.6.7 update combo (see Apple support downloads)
  2. Download Nawcom's legacy kernel Darwin 10.7.0 installer
  3. Run the Apple updater, but do not reboot
  4. Run Nawcom's kernel installer
  5. Reboot.

Note: 
  • It may happen that the kernel installer completes saying installation failed. Just do it again, it will pass eventually.
  • First boot won't complete (Kernel Panic). Reboot again.

Tuesday, April 5, 2011

Setup networking on ubuntu

Problem: no eth0 in ifconfig, only l0
> sudo ifconfig eth0 up
eth0: ERROR while getting interface flags: No such device

Then
> sudo ifconfig eth1 up
Change eth0 into eth1 in /etc/network/interfaces
Restart networking:
> sudo /etc/init.d/networking restart

Setup nVidia 240 GT on snow leopard 10.6.2

GeForce GT 240 512Mb GDDR5 (device ID 0x0ca3)

You only need to have the correct device ID set in NVEnabler kext info.plist like in:
<key>IOPCIPrimaryMatch</key>
<string>0x0ca310de</string>

Important: do not change /S/L/E/NVDAResman.kext or /S/L/E/NVDANV50Hal.kext like explained in [55] or QE won't work

Print current date

#include sys/types.h
#include time.h
{
    char buf[40];time_t tm = time(0);struct tm* ptm = localtime(&tm);
    strftime(buf, 40, "%d-%b-%Y %T", ptm);
    fprintf(stderr,"==> jg: T6 expiration @ %s\n", buf);
 }

Test ith bit

(bits & 1<<i)>>i
gives 1 if set, and 0 otherwise.

Set ith bit

bits |= 1<<i

static inline vs. extern inline

  • “static inline” means “we have to have this function, if you use it but don’t inline it, then make a static version of it in this compilation unit”
  • “extern inline” means “I actually have an extern for this function, but if you want to inline it, here’s the inline-version”

Why do {...} while (0); in macros?

There are a couple of reasons:

  • (from Dave Miller) It gives you a basic block in which to declare local variables.
  • (from Ben Collins) It allows you to use more complex macros in conditional code. Imagine a macro of several lines of code like:
    #define FOO \
    printf(“arg is %s\n”, x); \
    do_something_useful(x);

Now imagine using it like:

if (blah 2) FOO(blah);
This interprets to:
if (blah  2)
    printf("arg is %s\n", blah);
    do_something_useful(blah);

As you can see, the if then only encompasses the printf(), and the do_something_useful() call is unconditional (not within the scope of the if), like you wanted it. So, by using a block like do{...}while(0), you would get this:

if (blah == 2)
    do {
        printf("arg is %s\n", blah);
        do_something_useful(blah);
    } while (0);

which is exactly what you want.

  • (from Per Persson) As both Miller and Collins point out, you want a block statement so you can have several lines of code and declare local variables. But then the natural thing would be to just use for example:
    #define exch(x,y) { int tmp; tmp=x; x=y; y=tmp; }

However that wouldn’t work in some cases. The following code is meant to be an if-statement with two branches:

if(x>y)
  exch(x,y);          // Branch 1
else  
  do_something();     // Branch 2

But it would be interpreted as an if-statement with only one branch:

if(x>y) {                     // Single-branch if-statement!!!
  int tmp;            // The one and only branch consists
  tmp = x;            // of the block.
  x = y;
  y = tmp;
}
;                             // empty statement
else                  // ERROR!!! "parse error before else" 
  do_something();

The problem is the semi-colon (;) coming directly after the block.

The solution for this is to sandwich the block between do and while(0). Then we have a single statement with the capabilities of a block, but not considered as being a block statement by the compiler.

Our if-statement now becomes:

if(x>y)
  do {
    int tmp;
    tmp = x;
    x = y;
    y = tmp;
  } while(0);
else
  do_something();

The # and ## Preprocessor Operators

The # and ## preprocessor operators are used when using a macro #define.

The # operator turns the argument it precedes into a quoted string. For example, given:

#define mkstr(s) # s

the preprocessor turns the line

printf(mkstr(I like C);

into

printf("I like C");

The ## operator concatenates two tokens. For example, given:

#define concat(a, b) a ## b
int xy=10;
printf("%d",concat(x, y);

the preprocessor turns the last line into:

printf("%d", xy);

struct pointer + 1

Given

toto_t* p_toto = ...;

then

p_tata = (tata_t*)(p_toto + 1)

means that p_tata points sizeof(toto_t) further than p_toto.

p_tata = (tata_t*) p_toto + 1

means that p_tata points sizeof(tata_t) further than p_toto.

Block / unblock signals

static sigset_t osset;
void block_signals()
{
    sigset_t sset;
    sigemptyset(&sset);
    sigaddset(&sset, SIGABRT);
/*     sigprocmask(SIG_BLOCK, &sset, &osset); */
    pthread_sigmask(SIG_BLOCK, &sset, &osset);
    signal(SIGABRT, SIG_DFL);
}

void unblock_signals()
{
    sigset_t sset;
    sigpending(&sset);
    if (sigismember(&sset, SIGABRT))
    {
        fprintf(stderr, "\njg ==> was interrupted\n");
        exit(1);
    }
/*     sigprocmask(SIG_SETMASK, &osset, NULL); */
    pthread_sigmask(SIG_SETMASK, &osset, NULL);
}

BRD-OFFLN-DIAG

  • No, the 300-series boards do not support offline diagnostics. It was found that the diagnostics in the 200-series cards were of little or no benefit so it was not felt necessary to move that feature forward into the new line of cards.
  • Startup diagnostics are by default enabled on all 200-series boards.
  • The CC, TCAP, and CLIENT MML commands are all related to the Client/Server feature of Signalware that Siemens does not use; unfortunately all Signalware man pages come in one package (the OMNI-MAN package) so you receive man pages that you do not use. As such they should be ignored.
  • This may be a question for you, Petra: when the HLRi/MAP applications are put in the cestart file, do you use CREATE-PROCESS(8s)? If so, what application name (APPL parameter) is used? If none, then that’s why DISPLAY-APPLICATION(8s) does not show the application. If you put the processes in manually, there is a field in the cestart file that describes the “application” that each process is associated with.
  • The board diagnostics on the 200-series cards can be used to test those cards; with the 300-series cards the fact that the card comes up (e.g., it passes POST) is the best test short of aligning links and passing traffic.

Install boards binaries

To install PCIM binaries in a (reference) view, do:

crtool swimport -tag cm_t_12_sun_m12sus90-sp4-patches -host walter -pkg PCIM -rcmd scp

Local bison complains about m4sugar.m4

The error is:

bison: cannot open file `/usr/local/share/bison/m4sugar/m4sugar.m4': A file or directory in the path name does not exist.

Solution:

export BISON_PKGDATADIR=/u/gallinar/downloaded/bison-2.3/data

How to manage packages in ubuntu?

Install:
> sudo apt-get install libzip-dev
Uninstall:
> sudo apt-get remove libzip-dev
Search a package name:
> apt-cache search libzip
Check if a package is installed:
> dpkg -l | grep libzip