1. Account settings -> Composition and Addressing 에서 "Compose message in HTML format"을 uncheck


2. Preferences -> Composition -> Send Options -> Text Format에서 "Convert the message to plain text"로 변환


Posted by code cat
프로그래밍/python2014. 4. 24. 17:23

참조: 열혈강의 파이썬, 이강성 저

 

Class 는 하나의 이름 공간이며 기본적으로 다음과 같다.


위에서 상속도 나와있는데 OOP를 아는 사람이라면 쉽게 이해가 가능하다.

class Name:  #header
  pass          #body

class는 위와 같이 header와 body의 형태이며, header의 경우, :를 붙인다.  pass는 아무 일도 하지 않고 자리를 채우는 명령문이다.

 

method의 정의는 다음과 같다.

class MyClass:
  def set(self, v):
    self.value = v
  def put(self):
    print self.value

method를 정의하기 위해서는 def를 사용하며, 첫 인수로 self를 사용한다.  이는 자바에서 쓰는 'this'와 유사하다고 보면 된다.(자기자신의 인스턴스 객체를 가리킨다)

 

method 호출은 두가지 방법이 있다.

1. Unbound Class Method

>>> MyClass.set(c, 'egg')
>>> MyClass.put(c)

egg

2. Bound Instance Method

>>> c = MyClass()

>>> c.set('egg')

>>> c.put()

egg

 

class 내부에서의 method 호출은 self. 를 이용하여야 한다.

Posted by code cat
프로그래밍/C2014. 4. 13. 20:27

출처: http://en.wikipedia.org/wiki/%3F:

GNU확장은 다음과 같이 값을 프로세싱을 한번 이상 할 경우, 문제가 되는 경우를 대비해 다음과 같이 operand를 스킵할 수 있게 한다.


a = x ? : y;


상기 라인은 아래와 같다.

a = x ? x : y;


만일 x가 expression이라면, 한번만 프로세싱된다.


Posted by code cat
안드로이드/포팅2014. 4. 13. 18:36

[    3.11328] init: skipping insecure file '/default.prop'
[    3.133259] init: skipping insecure file '/init.rc'

라는 에러 메세지가 나오면서 부팅이 안되면, 이는 다음과 같이 젤리빈(이상버전 동일?)에서 다음과 같이 파일 스탯을 참조하여, owner외에 writable 못하게 막아놓았기 때문이다.

143    char *data;
144    int sz;
145    int fd;
146    struct stat sb;
147
148    data = 0;
149    fd = open(fn, O_RDONLY);
150    if(fd < 0) return 0;
151
152    // for security reasons, disallow world-writable
153    // or group-writable files
154    if (fstat(fd, &sb) < 0) {
155        ERROR("fstat failed for '%s'\n", fn);
156        goto oops;
157    }
158    if ((sb.st_mode & (S_IWGRP | S_IWOTH)) != 0) {


그럼 간단히, 644 혹은, 655 정도로 파일 퍼미션을 바꿔주면 된다.

Posted by code cat
리눅스/커널2014. 4. 8. 15:10

dentry cache hash table size 지정은,

fs/dcache.c에서 alloc_large_system_hash를 통해서 된다. 그전에 dhash_entries는 kernel cmdline에서 지정하여 원하는 값을 패스 할 수 있다.

2965static void __init dcache_init(void)
2966{
2967        int loop;
2968
2969        /* 
2970         * A constructor could be added for stable state like the lists,
2971         * but it is probably not worth it because of the cache nature
2972         * of the dcache. 
2973         */
2974        dentry_cache = KMEM_CACHE(dentry,
2975                SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD);
2976
2977        /* Hash may have been set up in dcache_init_early */
2978        if (!hashdist)
2979                return;
2980
2981        dentry_hashtable =
2982                alloc_large_system_hash("Dentry cache",
2983                                        sizeof(struct hlist_bl_head),
2984                                        dhash_entries,
2985                                        13,
2986                                        0,
2987                                        &d_hash_shift,
2988                                        &d_hash_mask,
2989                                        0);
2990
2991        for (loop = 0; loop < (1 << d_hash_shift); loop++)
2992                INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
2993}


그리고 만약 dhash_entries값이 0이면(전역비초기화 변수 이므로 0으로 되어 bss영역에 있을 것이다) 5395라인 하위로 타고 들어가, nr_kernel_pages에 기반을 둔 2의 배수를 설정하고 기타 log2작업(아 이건 나중에 보자...)을 통해 hash table size를 출력한다.

5381void *__init alloc_large_system_hash(const char *tablename,
5382                                     unsigned long bucketsize,
5383                                     unsigned long numentries,
5384                                     int scale,
5385                                     int flags,
5386                                     unsigned int *_hash_shift,
5387                                     unsigned int *_hash_mask,
5388                                     unsigned long limit)
5389{
5390        unsigned long long max = limit;
5391        unsigned long log2qty, size;
5392        void *table = NULL;
5393
5394        /* allow the kernel cmdline to have a say */
5395        if (!numentries) {
5396                /* round applicable memory size up to nearest megabyte */
5397                numentries = nr_kernel_pages;
5398                numentries += (1UL << (20 - PAGE_SHIFT)) - 1;
5399                numentries >>= 20 - PAGE_SHIFT;
5400                numentries <<= 20 - PAGE_SHIFT;
5401
5402                /* limit to 1 bucket per 2^scale bytes of low memory */
5403                if (scale > PAGE_SHIFT)
5404                        numentries >>= (scale - PAGE_SHIFT);
5405                else
5406                        numentries <<= (PAGE_SHIFT - scale);
5407
5408                /* Make sure we've got at least a 0-order allocation.. */
5409                if (unlikely(flags & HASH_SMALL)) {
5410                        /* Makes no sense without HASH_EARLY */
5411                        WARN_ON(!(flags & HASH_EARLY));
5412                        if (!(numentries >> *_hash_shift)) {
5413                                numentries = 1UL << *_hash_shift;
5414                                BUG_ON(!numentries);
5415                        }
5416                } else if (unlikely((numentries * bucketsize) < PAGE_SIZE))
5417                        numentries = PAGE_SIZE / bucketsize;
5418        }
5419        numentries = roundup_pow_of_two(numentries);
5420
5421        /* limit allocation size to 1/16 total memory by default */
5422        if (max == 0) {
5423                max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4;
5424                do_div(max, bucketsize);
5425        }
5426
5427        if (numentries > max)
5428                numentries = max;
5429
5430        log2qty = ilog2(numentries);
5431
5432        do {
5433                size = bucketsize << log2qty;
5434                if (flags & HASH_EARLY)
5435                        table = alloc_bootmem_nopanic(size);
5436                else if (hashdist)
5437                        table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL);
5438                else {
5439                        /*
5440                         * If bucketsize is not a power-of-two, we may free
5441                         * some pages at the end of hash table which
5442                         * alloc_pages_exact() automatically does
5443                         */
5444                        if (get_order(size) < MAX_ORDER) {
5445                                table = alloc_pages_exact(size, GFP_ATOMIC);
5446                                kmemleak_alloc(table, size, 1, GFP_ATOMIC);
5447                        }
5448                }
5449        } while (!table && size > PAGE_SIZE && --log2qty);
5450
5451        if (!table)
5452                panic("Failed to allocate %s hash table\n", tablename);
5453
5454        printk(KERN_INFO "%s hash table entries: %ld (order: %d, %lu bytes)\n",
5455               tablename,
5456               (1UL << log2qty),
5457               ilog2(size) - PAGE_SHIFT,
5458               size);
5459
5460        if (_hash_shift)
5461                *_hash_shift = log2qty;
5462        if (_hash_mask)
5463                *_hash_mask = (1 << log2qty) - 1;
5464
5465        return table;
5466}


'리눅스 > 커널' 카테고리의 다른 글

커널 디버깅 방법  (0) 2014.09.19
syslog LOCAL7  (0) 2014.08.28
Memory 정보 출력되는 곳  (0) 2014.04.07
driver 초기화 시에 쓰이는 module_init  (0) 2014.04.04
Machine 이름 바꾸기  (0) 2014.04.03
Posted by code cat