2015年1月9日 星期五

@ Change Code::Blocks SDK Editor Theme (Windows-10)

There are a lot of pre-defined color themes in this wiki page: Syntax highlighting custom color themes.
In this blog, I will show how to use these themes in Code::Blocks under Windows-10 platforms

1.First download the colour_themes.conf file by gist.github.com webside
   (Make sure Code-Blocks is not running.)

2.Run "cb_share_config.exe" file. It should be under the folder where you install Code::Blocks.
   And then you can see the "Welcome to Code:Blocks Share Config" Window..
   The load the "colour_themes.conf" file on your left side and the "default.conf" file is on your right.
3.Select the themes that you want to import to Code::Blocks by clicking the check boxes on      the left 
   and then select Transfer>>> and Save as well.

   I will recommend to select all of them.



4.Open Code::Blocks. Go to Settings > Editor > Syntax highlighting.
   All the themes that you have imported will be available under the color theme drop list.



5.After change the theme. You may notice that the insertion bar become hard to see
   if you use a dark background.
   But you can modify the color of the insertion bar under: Settings > Editor… > Margins and caret.   
   Change the color of the caret to some brighter colors.



 ** Also I have installed Code::Blocks Rev 16.01 on my notebook and migrated the SDK to
     chinese version.If you are searching the chinese translation package, you can download
     the dedicated "zh_TW_LC_MESSAGES_codeblocks.mo" file by following link:
     (My MEGA Web)→→ Download

2014年3月29日 星期六

@ Power Supply DIY

Adjustable DIY Power Supply - YR 2014

The 2014 latest had almost perfect - two channels, 1.2 - 30V/3A -
but there was no current limit. That's why I had search for suitable schematic to build.
What I found is this schematic: http://www.electronics-lab.com/projects/power/001/index.html.
It provided adjustable output voltage from 0 to 30V and adjustable max output current from few 
mili-amperes to 3 amperes.
As it turned out there are serious flaws in it, but in the forum where it was thoroughly discussed
and one of the member had proposed an improved schematic, in which all flaws were been addressed.
I used his schematic to build the new power supply.




   In the final version
   there will be a much bigger heatsink and maybe also a fan.

After built it and did some tests I made two changes: 
first, added 24V zener diode and resistor to stabilize supply voltage on IC1. 
This is especially important because when there is higher load and supply voltage drops 
by some volts the reference voltage on pin 6 would be changed significantly.
Second, had removed 10k trimmer resistor RV1.No need to use it anymore.

Here came the final schematic version:


The two trimmers are used for adjusting the max output current and the max output voltage.

Some snaps of the PCB and assembled board:












The additional plans were to make 2 pieces in two separate chassis and need dual voltage supply modules
also voltage higher than 30V .Will use both of them.
There are digital meters in the front of the chassis.

Finally, two transformers are ready to go.
They are able to deliver 30V/4A power sources.



As you can see, had replaced 0.47 ohm/10W resistor with two 0.68ohm/10W resistors in parallel,
because the former one had generated too much consumption in heat.
The front panel is also ready.
What else to do is to make a tiny board for fan controller.

Here is the link for downloading archive with project files in PDF format: LabPS.rar

The first one of the two PS is ready!
Here is tiny board for the fan controller:





Teh alone came the power supply :



Here is the schematic of the fan controller:




The schematic may be supplied with AC or DC voltage but not both simultaneously. If the supply voltage is DC, then B1, C2 and J3 may be omitted. With different R7 value it tunes the speed of the fan. Adjusting switch-on temperature is made with TR2.

And here is the link for downloading: FanControl.rar
The PCB is different from the one shown on picture above, because I had made some improvements and component re-locations.

The second unit is almost ready. Here is the internal snap :




The fan is secured on the bottom with double side adhesive tape.

It deliveried good job according to the schematic bellow. The bridge rectifier is replaced with two diodes. 
The negative voltage come from one of the windings. 
It is rectified by D3 and ripple stablized with C3. D1 and D2 must used of higher current rating - 
at least 5A (diodes in the schematic bellow are just for illustration).  
C3 must be 50V or 63V rating. R1 and R2 must be 2W power resistors. 
There can be added a capacitor (100uF) between -V and GND for extra stablized the negative voltage. 
If the negative voltage is bellow 1.3V, then the value of R1 and R2 can be decreased a little. 
Bear in mind that I haven't tried this schematic, just simulated it, so be careful.



2012年11月11日 星期日

@ 來點雜質吧 !

人生不要苛求自己純淨無瑕,試著容納些許雜質 !

如果某些雜質是組成美好的元素,我會有什麼想法???

許久,固態科學家發現將"鍺"提煉可以製成極優異的電晶體之後,
就開始有人嘗試將"鍺"中所有雜質去掉,讓純度達到100%,
卻沒有任何人成功..

SONY 的江崎玲於奈博士與助手黑田百合子逆向奇想 (給"鍺"添加一些雜質)
當江崎博士對眾多同領域高手公佈這想法時,反對與嘲諷接踵而至,
更有者竟公然弔言 (如果透過加入雜質來對"鍺"提煉會成功,除非地球倒轉!!!)
然而,江崎玲於奈-(Leo.Esaki) 博士以此法成功提煉出極為穩定,快速優異的
電晶體-量子隧道效應 (Quantum tunnelling effect),也因此獲頒1973年
諾貝爾物理學獎!

人云 (水至清則無魚,人至察則無徒),
正所謂 (在雜質中,潛匿著深刻的美!!!)


2012年11月3日 星期六

@ 網路世界中的小丑


蝙蝠俠這系列的電影,有一個很矛盾的現象,就是蝙蝠俠永遠都不會是主角(可能因為都戴著面罩,
大家都不會記得蝙蝠俠是誰演的),之所以有那麼多人演過蝙蝠俠,但是沒一個令人印象深刻的。

而『黑暗騎士』也仍然不會打破這個規則,但是它卻出現了一個會令人沒辦法忘掉的惡人代表-小丑
(希斯萊傑-飾演),或許是希斯萊傑揣摩的無懈可擊,這讓『黑暗騎士』一片,幾乎成為專門為小丑
這個角色所打造,極其具有深度的片,也可以說讓黑暗騎士成為希斯萊傑最後完美且成功的代表作。

如果談到希斯萊傑的演技,還真的是無懈可擊,包括他因嘴割裂過會不時吸舔口水的小動作,到小丑
講話有點鴨子的腔調,甚至到小丑走路有點跛有點跳動的模樣,都是揣摩到入木十分之至!更不用說
他演小丑那極其黑暗及扭曲的心裡層面。

在特效化妝的臉龐背後,小丑代表著憤世嫉俗、善於挖掘人類黑暗面等超越世俗想像的個性,卻也因
如此而格外地迷人,這些元素都難以在其他漫畫角色中得以尋獲。希斯萊傑為小丑改變的不光是聲線
發音與表情猙獰,那些基本配備只顯得匠氣,他難得的是把洞悉人性的自信寫在臉上,即使被蝙蝠俠
打到奄奄一息也不改其嘻皮笑臉。

黑暗騎士整個故事可以說完全是環繞小丑而生,小丑代表了人性最黑暗而醜陋的那一面,卻也代表了
最高水準的道德跟無私,很矛盾吧,這個角色如此出類拔萃之處!利用人性的弱點來摧毁人類以達到
某種救贖的意義,這也就是我所說的小丑代表了極高的道德跟無私。

希斯萊傑為了全力投入揣摩小丑扭變的個性卻泥深無法自拔.後來過世而肇因於萊傑同時服用鎮痛藥 
(羥考酮)、止痛劑、抗焦慮藥、鎮靜劑、安眠藥六種藥物來嘗試慰撫自我.

如果我們能用點心,從另一個觀點來發展.跳脫自我矛盾黑暗,反覆拘泥及扭曲矛盾的內心.也許在這個
新網路世界的上層心靈溝通網站,你將是另一位小丑,但不是要你去摧毁人類吧!


2012年4月1日 星期日

@ 好色男人

void (Backup from 2013 iPhone-4 auto-archived folder)

雖然我是悶騷好色男,但還有很多我不瞭解的色男人真相 !!

曾和兩位女性探討關於男人好色的問題,兩位都已結婚,但觀點一致:“這男人要是不好色還有什麼意思啊?”說得多好啊!
這麼多年都沒找到理論基礎,這回在現實中得到了印證。

首先,性趨向不常規的男士(還有什麼表述清楚又不帶歧視色彩的詞彙嗎),肯定就不近女色了,這也是女性最接受不了的,
除非你們想扮演一對貌合神離的夫妻。當然如果你碰巧遇到Tom-Ford這樣的雙性戀男人,也只能自己作出選擇了。 

曾有一個自稱不好色的男人站在你面前,你信嗎?有一種說法是這個社會的發展靠的就是男人雄性激素的分泌。
所以對那些擺出道貌岸然姿態的男人,你都可以管他們叫“ 大尾巴狼”,這種人更危險。以紳士面貌進入你的生活,
一有機會就會露出狼的本色,低劣的角色扮演。相反,一個敢於承認自己好色的男人,你絕不能說他思想複雜,他是單純,
不愛掩飾而已。而且當你面對這種坦蕩的男人時,你會很容易洞察他的性情,不喜歡也可以趕緊避讓,安全係數相對較高。 

大師李敖從來沒否認過自己對女人的喜愛,一邊在宣揚自己的幸福家庭,一邊又在電視節目中自報最後一任女朋友是幾年前
認識的一個1984年出生的美女,看來在他的字典裡沒有“ 晚節不保”這個詞語。

他最經典的理論就是:一個男人遇到喜歡的姑娘就一定要表達出來,很多人因為愛面子而退縮,一個男人如果愛面子超過
愛女人,那將是件可悲的事情。

大師李敖曾自誇:
中國近代史寫白話文前三名是...李敖, 李敖, 李敖

我倒是有感而言出:
中國近代史最好色的男人是.......李敖, 李敖, 李敖 ! 哈~



2011年4月1日 星期五

@ Crazy Code-2

有一個日本網友發了個問題貼子,說他正在學習在線的C語言課程,要完成一個作業,用程式來輸出以下的結果,而他的老師在美國,因為時差問題,他無法和他聯系,所以只有上網來尋求幫助。

         *
       ***
     *****
   *******
 *********
 *********
   *******
    *****
      ***
        *

很明顯,在comp.lang 上發這種貼子是一定會被轟的很慘,這樣的事,以前在SUN的論壇上也發生過。
一般人可能會回復很簡單幾行程式即可完成 :

#include "stdio.h"

int main()
{
    int i, j, k;
    for(i=1;i<=5;i++) {
       for(j=i;j<5;j++) { printf(" "); }
       for(k=1;k<(i*2);k++) { printf("*"); }
       printf("\n");
    }
    for(i=4;i>=1;i--) {
       for(j=5;j>i;j--) { printf(" "); }
       for(k=1;k<(i*2);k++) { printf("*"); }
       printf("\n");
    }
    return 0;
} 
然後,所有人看到了一個另類回覆者提供這樣的一段程式:
#define      M 002354l
#define     A   000644l
#define    G     000132l
#define     I   000322l
#define      C 000374l
#define                a ;
#define               b for
#define              c    ++
#define             d       %
#define            e       int
#define           f           ,
#define          g             -
#define         h             011
#define        i                 =
#define       j                   {
#define      k                     )
#define     l                    '\n'
#define    m                      main
#define    n                         <
#define     o                       }
#define      p                     >
#define       q                  &&
#define        r                 (
#define         s              ||
#define          t             ?
#define           u     putchar
#define            v      void
#define             w     '*'
#define              x     :
#define               y ' '
#define                _ /
#define           C_O_O_L return
                   e u r e k a
                         e
                        m r
                       v k j
                      j j j j
                     j j j j j
                    j j j j j j
                   j j j j j j j
                  j e z a b r z i
                 M _ A _ G _ I _ C
                a z n G a u r z d h
               + z _ h p M _ A q z d
              h + z _ h n M _ G q z _
             h n z d h + M _ I q z _ h
            p z d h g M _ C t w x y k f
           z d h g h + 1 s u r l k f z c
          k a u r l k a j j j j j j j j j
         j j C_O_O_L M _ A _ G _ I _ C a o
        o o o o o o o o o o o o o o o o o o
                      o o o o
                      o o o o
                      o o o o
                      o o o o

這段程式是可以編譯通過的,沒有任何問題,而且還是可以得到正確的結果的。
呵呵。當然,你並不需要在你的C/GCC SDK 下編譯這段代碼,現在什麽都有在線了,編譯器當然也在線了,上去編譯一下你就可以看到結果了。

在comp.lang的這個貼子中看到了很多不錯的“如何教新手編程”的觀點,下面舉例一些:

1)你把你自認為最好程序貼出來,我們會幫你看,但是不會幫你寫的。

2)要解決程式問題,需要先觀察輸出,然後找到規律性,算法總是去描述一些有規律的事情。關於這個程序,
很明顯,你可以分成兩個部分,一個正三角,一個倒三角,每一行的星號都是連續的奇數,1,3,5,7,9,
而前面的空格又是順序的自然數:4,3,2,1,你看這樣的規律用程序來幹不是正合適嗎?

從這兩個例子,我們可以看到,老手應該如何去教新手,那就是,
a)讓其獨立思考,
b)步步為營的引導,
c)教一種方法而不是直接給答案。希望與大家共勉。

2011年3月31日 星期四

@ Crazy Code


下面的5個程序片段主要完成這些事情:輸出Hello, World
所有程序都可以在GCC下編譯通過。

Hello1.c
#define _________ }
    #define ________ putchar
    #define _______ main
    #define _(a) ________(a);
    #define ______ _______(){
    #define __ ______ _(0x48)_(0x65)_(0x6C)_(0x6C)
    #define ___ _(0x6F)_(0x2C)_(0x20)_(0x77)_(0x6F)
    #define ____ _(0x72)_(0x6C)_(0x64)_(0x21)
    #define _____ __ ___ ____ _________
    #include
    _____

Hello2.c
#include "stdio.h"
    #define __(a) goto a;
    #define ___(a) putchar(a);
    #define _(a,b) ___(a) __(b);
    main()
    { _:__(t)a:_('r',g)b:_('$',p)
      c:_('l',f)d:_(' ',s)e:_('a',s)
      f:_('o',q)g:_('l',h)h:_('d',n)
      i:_('e',w)j:_('e',x)k:_('\n',z)
      l:_('H',l)m:_('X',i)n:_('!',k)
      o:_('z',q)p:_('q',b)q:_(',',d)
      r:_('i',l)s:_('w',v)t:_('H',j)
      u:_('a',a)v:_('o',a)w:_(')',k)
      x:_('l',c)y:_('\t',g)z:___(0x0)}

Hello3.c
#include "stdio.h"
    main(){
      int x=0,y[14],*z=&y;*(z++)=0x48;*(z++)=y[x++]+0x1D;
      *(z++)=y[x++]+0x07;*(z++)=y[x++]+0x00;*(z++)=y[x++]+0x03;
      *(z++)=y[x++]-0x43;*(z++)=y[x++]-0x0C;*(z++)=y[x++]+0x57;
      *(z++)=y[x++]-0x08;*(z++)=y[x++]+0x03;*(z++)=y[x++]-0x06;
      *(z++)=y[x++]-0x08;*(z++)=y[x++]-0x43;*(z++)=y[x]-0x21;
      x=*(--z);while(y[x]!=NULL)putchar(y[x++]);
    }

Hellow4.c
int n[]={0x48,
    0x65,0x6C,0x6C,
    0x6F,0x2C,0x20,
    0x77,0x6F,0x72,
    0x6C,0x64,0x21,
    0x0A,0x00},*m=n;
    main(n){putchar
    (*m)!='\0'?main
    (m++):exit(n++);}

Hello5.c
#include "stdio.h"
    #define _(_) putchar(_);
    int main(void){int i = 0;_(
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++i)_(++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++i)_(++++++++++++++
    i)_(--++i)_(++++++i)_(------
    ----------------------------
    ----------------------------
    ----------------------------
    ----------------------------
    ----------------i)_(--------
    ----------------i)_(++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++i)
    _(----------------i)_(++++++
    i)_(------------i)_(--------
    --------i)_(----------------
    ----------------------------
    ----------------------------
    ----------------------------
    ----------------------------
    ------i)_(------------------
    ----------------------------
    i)return i;}