Q:
[2014-04-06 14:52:47 - HelloWord] No Launcher activity found!
[2014-04-06 14:52:47 - HelloWord] The launch will only sync the application package on the device!
Ans:

= = 發表在 痞客邦 留言(0) 人氣()

筆試:
1. C語言
題目1: 程式填空




//Descript: str_parser used for parse src string into toke array


//Parameter: src = source string


//                   dst_token = save token string


//                   max_token_count


int str_parser(const char *src, char *dst_token[]; int max_token_count) {


         // You shall use malloc space to save token string


        return 0;


}


 


int main(){


    char *src = "aa bb  ccc";


    char *dst_token[];


    // Call strparser function


    return 0;


}


 





= = 發表在 痞客邦 留言(0) 人氣()

1. 取得使用者輸入的參數
     SET /P VAR1=請輸入Ruby code file path:
2.類似註解

= = 發表在 痞客邦 留言(0) 人氣()

netstat -ano:可以查出現在程式使用中的ip port和使用的程式
Note: 迅雷會佔用80 port
 




C:\Users\Genie>netstat -ano


使用中連線


協定 本機位址 外部位址 狀態 PID
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3696
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 708
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 3696
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:3300 0.0.0.0:0 LISTENING 1216
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1312
TCP 0.0.0.0:42702 0.0.0.0:0 LISTENING 3696
TCP 0.0.0.0:49152 0.0.0.0:0 LISTENING 812
TCP 0.0.0.0:49153 0.0.0.0:0 LISTENING 900
TCP 0.0.0.0:49154 0.0.0.0:0 LISTENING 1080
TCP 0.0.0.0:49157 0.0.0.0:0 LISTENING 912
TCP 0.0.0.0:49158 0.0.0.0:0 LISTENING 920
TCP 0.0.0.0:50446 0.0.0.0:0 LISTENING 4440
TCP 127.0.0.1:5939 0.0.0.0:0 LISTENING 2124
TCP 127.0.0.1:8888 0.0.0.0:0 LISTENING 1660
TCP 127.0.0.1:49155 127.0.0.1:49156 ESTABLISHED 2124
TCP 127.0.0.1:49156 127.0.0.1:49155 ESTABLISHED 2124
TCP 127.0.0.1:49495 127.0.0.1:49496 ESTABLISHED 3292
TCP 127.0.0.1:49496 127.0.0.1:49495 ESTABLISHED 3292
TCP 127.0.0.1:53399 0.0.0.0:0 LISTENING 1872


 


= = 發表在 痞客邦 留言(0) 人氣()

建立目錄
 




def create_default_dir folder
   if !Dir.exist?(folder)
      puts "%s%s" % ["Folder name = ",folder]
      Dir.mkdir(folder, 0777)
   else
      puts "Folder exist"
   end
end


def main


   create_default_dir 'rpt'


end


 


 if __FILE__ == $0
   main
end


= = 發表在 痞客邦 留言(0) 人氣()

 
傳進function裡的參數,若不固定數量,則可用*來指定參數
 




def write_log(*elements)
puts elements[0],elements[1],elements[2][0],elements[2][1],elements[3];
end


=begin
ary = Array.new(3)
ary = [1,2,3,4]
write_log(ary)
=end
a="a"
b="b"
c="c"
ary = Array.new(3)
ary = [1,2,3,4]
write_log(a,b,ary,c)


 


= = 發表在 痞客邦 留言(0) 人氣()

以下:
8進制轉10進制
16進制轉10進制
 

= = 發表在 痞客邦 留言(0) 人氣()

 
sample code 
 




=begin
Spreadsheet library
Ref. http://spreadsheet.rubyforge.org/GUIDE_txt.html
=end
require 'spreadsheet'


file_name='C:/Ruby192/atm_ruby/practice_myself/access_xls/test2.xls'


=begin
Write data into excel
=end


book = Spreadsheet::Workbook.new(file_name)


##########################################
#
# Create a Worksheet with the Name
#
##########################################
# method 1
sheet1 = book.create_worksheet
sheet1.name = 'My First Worksheet'
# method 2
sheet2 = book.create_worksheet :name => 'My Second Worksheet'


##########################################
#
# Add data into the Worksheet
# Method: 1.concat
# 2.push
# 3.replace
# 4.update_row
##########################################
# About concat->Concatenates Concatenates the given object to str
sheet1.row(0).concat %w{Name Country Acknowlegement}
sheet1[1,0] = 'Japan'
row = sheet1.row(1)
row.push 'Creator of Ruby'
# About: unshift->Prepends objects to the front of self, moving other elements upwards.
row.unshift 'Yukihiro Matsumoto'
sheet1.row(2).replace [ 'Daniel J. Berger', 'U.S.A.',
'Author of original code for Spreadsheet::Excel' ]
sheet1.row(3).push 'Charles Lowe', 'Author of the ruby-ole Library'
sheet1.row(3).insert 1, 'Unknown'


sheet1.update_row 4, 'Hannes Wyss', 'Switzerland', 'Author'
##########################################
#
# Add font format
#
##########################################
sheet1.row(0).height = 18


format = Spreadsheet::Format.new :color => :blue,
:weight => :bold,
:size => 18
sheet1.row(0).default_format = format


bold = Spreadsheet::Format.new :weight => :bold
4.times do |x|
sheet1.row(x + 1).set_format(0, bold)
end


# Write excel
book.write(file_name)


=begin
Parse excel data
=end


book = Spreadsheet.open file_name


# Select worksheet
# method 1
sheet1 = book.worksheet 0
# method 2
sheet2 = book.worksheet 'My Second Worksheet'


sheet1.each do |row|
puts "%s %s\n" % [row[0],row[1]]
end


printf "\n\n\n"


sheet1.each 1 do |row|
puts "%s %s\n" % [row[0],row[1]]
end


 


= = 發表在 痞客邦 留言(0) 人氣()

解壓縮 tar.gz     =>     tar -zxvf filename.tar.gz

壓縮 tar.gz       =>      tar -zcvf filename.tar.gz /folder

解壓縮 tar.bz2   =>     tar -jxvf filename.tar.bz2

= = 發表在 痞客邦 留言(0) 人氣()

 





include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <linux/types.h> 
#include <sys/socket.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#define IP_STR "10.0.41.0" 
typedef     unsigned char           u8; 
typedef struct {
    u8      version;            // 4 for IPv4, 6 for IPv6
    u8      address[16];        // pad zero for IPv4
} ipAddress_t;
void dec_to_ip(int32_t snmp_ip, char *ipv4)
{
    int ip3;
    int ip2;
    int ip1;
    int ip0;
    ip3 = (snmp_ip >> 24) & 255;
    ip2 = (snmp_ip >> 16) & 255;
    ip1 = (snmp_ip >>  8) & 255;
    ip0 = (snmp_ip      ) & 255;
    sprintf(ipv4,"%d.%d.%d.%d", ip0, ip1, ip2, ip3);
}
int main(char *args, int argc){
    ipAddress_t    r_ip;
    ipAddress_t    router_ip;
    char ipv4_str[32];
    struct in_addr    router_addr;
    memset(&r_ip, 0x00, sizeof(ipAddress_t));
    memset(&router_ip, 0x00, sizeof(ipAddress_t));
    r_ip.version                     = 4;
    inet_pton(AF_INET, IP_STR, r_ip.address);
    memcpy(&router_addr, r_ip.address, 4);
    /* dec format*/
     printf("ip %d\n",router_addr.s_addr);
    /* string format*/
    dec_to_ip(router_addr.s_addr,ipv4_str);
    printf("ip %s\n",ipv4_str);


    return 0;
}





= = 發表在 痞客邦 留言(0) 人氣()

coredump是用來debug看程式哪個環節error了,程式掛了後,會產生core檔案
可用gdb來看此檔
用法:
step 1:

= = 發表在 痞客邦 留言(0) 人氣()

linux version : debian
預設使用的顏色定義在/usr/bin/dircolors,想要改變的話
需自已建立個檔案
cd到dircolors目錄下,

= = 發表在 痞客邦 留言(0) 人氣()

1 2 3
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。