顯示具有 program skill 標籤的文章。 顯示所有文章
顯示具有 program skill 標籤的文章。 顯示所有文章

2012年6月15日 星期五

[Linux] copy image to tftp && download code into board

#!/bin/bash

# cp file from A place to tftp

cp -a /home/freeman/111.2.1.148/luke/UBEE_D3_CableRG/build/dgwsdk/images/dgwsdk-3.0.0.125-120207.img /home/freeman/tftp

chmod 777 ./dgwsdk-3.0.0.125-120207.img

# change ifconfig eth0 IP address

sudo ifconfig eth2 192.168.100.2

ifconfig

sleep 1

#use xdotool finish download code into board

xdotool key alt+1

xdotool type 'set UBFINAME1 dgwsdk-3.0.0.125-120207.img'

xdotool key 'Return'

xdotool type 'run update1'

xdotool key 'Return'

2012年2月7日 星期二

[Terminal] One terminal open multiple screen



You can do it in screen the terminal multiplexer.




  • To split vertically: ctrla then |.


  • To split horizontally: ctrla then S (uppercase one).


  • To unsplit: ctrla then Q (uppercase one).


  • To switch from one to the other: ctrla then tab



EDIT, basic screen usage:




  • New terminal: ctrla then c.


  • Next terminal: ctrla then space.


  • Previous terminal: ctrla then backspace.


  • N'th terminal ctrla then [n]. (works for n∈{0,1…9})


  • Switch between terminals using list: ctrla then " (useful when more than 10 terminals)


  • Send ctrla to the underlying terminal ctrla then a.



Reference :



Linux - How to split the terminal into more than one “view”?


2012年2月6日 星期一

[Linux] copy image to tftp && download code into board


#!/bin/bash

# cp file from A place to tftp

cp -a  /home/freeman/111.2.1.148/luke/UBEE_D3_CableRG/build/dgwsdk/images/dgwsdk-3.0.0.125-120301.img /home/freeman/tftpboot/

chmod 777 ./dgwsdk-3.0.0.125-120207.img



# change ifconfig eth0 IP address

sudo ifconfig eth1 192.168.100.2

ifconfig

sleep 1



#use xdotool finish download code into board

xdotool key alt+1

xdotool type 'set UBFINAME1 dgwsdk-3.0.0.125-120301.img'

xdotool key 'Return'

xdotool type 'run update1'

xdotool key 'Return'

2012年2月1日 星期三

2012年1月14日 星期六

[program skill] FUNCTION dominance_count


/* ------------------------------------------------------ */

/* FUNCTION dominance_count :                             */

/*    Given two sorted (increasing) arrays, this function */

/* computes the number of pairs that satisfies f[i]>g[j]. */

/* This function is similar to coincidence_count().       */

/*                                                        */

/* Copyright Ching-Kuang Shene               June/30/1989 */

/* ------------------------------------------------------ */

 

#include <stdio.h>

 

int  dominance_count(int f[], int g[], int m, int n)

{

     int  index_f, index_g;

     int  count;

 

     count = index_f = index_g = 0;

     while (index_f < m && index_g < n){

    printf("\n index_f = %d  index_g = %d \n",index_f,index_g);

          if (f[index_f] <= g[index_g])

               index_f++;

          else

               index_g++, count += m - index_f , printf("\n count = %d \n",count);

     }

     return count;

}

 

 

/* ------------------------------------------------------ */

 

 

 

int main(void)

{

     int  x[] = { 1,3,5,7,9};

     int  nx  = sizeof(x)/sizeof(int);

     printf("sizeof(x) / sizeof(int) = %d /%d , nx = %d",sizeof(x),sizeof(int),nx);

 

     int  y[] = {2,3,4,7,8};

     int  ny  = sizeof(y)/sizeof(int);

 

     int  i;

 

     printf("\nDominance Count of two Increasing Arrays\n");

     printf("\n  #   Array 1   Array 2");

     printf("\n --   -------   -------");

 

     for (i = 0; i < nx; i++)

          printf("\n%3d%10d%10d", i, x[i], y[i]);

     printf("\n\nThere are %d Dominance Pairs. \n",  

            dominance_count(x, y, nx, ny));

    return 0;

}



Result :



sizeof(x) / sizeof(int) = 20 /4 , nx = 5

Dominance Count of two Increasing Arrays



  #   Array 1   Array 2

 --   -------   -------

  0         1         2

  1         3         3

  2         5         4

  3         7         7

  4         9         8

 index_f = 0  index_g = 0



 index_f = 1  index_g = 0



 count = 4



 index_f = 1  index_g = 1



 index_f = 2  index_g = 1



 count = 7



 index_f = 2  index_g = 2



 count = 10



 index_f = 2  index_g = 3



 index_f = 3  index_g = 3



 index_f = 4  index_g = 3



 count = 11



 index_f = 4  index_g = 4



 count = 12





There are 12 Dominance Pairs.



 



Cpmpile code :




  • Save file as xxx.c (note : small c not a big C)


  • Compile gcc -Wall GT_COUNT.c -o GT_COUNT


  • Execute ./GT_COUNT