2016年8月5日 星期五

android 增加防火牆規則擋IP

iptable加rule時,如果使用網址,只會在當下做解析,加入對應IP,如果對應有改變或是網站本身有做load balance,就無法完全擋掉

如果真的要擋網址,可能需在DNS 部分修改,在查詢某網址時記錄所有對應的IP,並動態更新iptables


(以鳥哥網站上的圖做修改)




PlantUML - 使用文字快速轉換成UML


以前畫UML 都使用Microsoft Visio, 但工作的電腦上沒有這套軟體,搜尋了一下發現PlantUML簡單好用,也可直接裝chrome外掛來做轉換








C程式 - X-Macro

Trace code 時看到類似用法,覺得很特別,做一下筆記

X-Macro 是一個可以在compile time 去對類似架構程式做簡化的寫法



X Macro is a technique in the C programming language for generating repeating code structures at compile time. It is used when the same operation has to be executed for a list of items, but regular for loops cannot be used.
Usage of X Macros dates back to 1960's.[1] It remains useful also in modern-day C, but is nevertheless relatively unknown.[2] [3]



An X-macro consists of two parts: the list, and the execution of the list. The list is just a #define construct which generates no code by itself. The execution of the list provides another #define macro, which is expanded for each entry in the list.




This example defines a list of variables, and automatically generates their declarations and a function to print them out.
First the list definition. The list entries could contain multiple arguments, but here only the name of the variable is used.
#define LIST_OF_VARIABLES \
    X(value1) \
    X(value2) \
    X(value3)

Then we execute this list to generate the variable declarations:
#define X(name) int name;
LIST_OF_VARIABLES
#undef X
In a similar way, we can generate a function that prints the variables and their names:
void print_variables()
{
#define X(name) printf(#name " = %d\n", name);
LIST_OF_VARIABLES
#undef X
}
When run through the C preprocessor, the following code is generated. Line breaks have been added for ease of reading, even though they are not actually generated by the preprocessor:
int value1;
int value2;
int value3;

void print_variables()
{
    printf("value1" " = %d\n", value1);
    printf("value2" " = %d\n", value2);
    printf("value3" " = %d\n", value3);
}


以上內容來自 <http://en.wikipedia.org/wiki/X_Macro> 



參考

Linux kernel - RCU (read-copy-update) 簡介





研究 - Virtual Instruction Set Computing

這個概念當初看到相當驚艷,不過兩年過去了似乎沒有甚麼其他消息!

當初研究所在看異質多核時,完全都只是學術型的研究,沒想到過幾年ARM就提出了big.LITTLE架構

希望之後能看到VISC商業化的產品出現


Virtual Instruction Set Computing:VISC

http://rsim.cs.illinois.edu/Pubs/12-HotPar-VAdve.pdf
http://www.extremetech.com/extreme/192858-visc-cpu-virtual-core-design-emerges-could-this-be-the-conceptual-breakthrough-weve-been-waiting-for
http://www.techbang.com/posts/20601-king-of-computers-newly-established-virtual-core-cpu-research-and-development-company-will-be-twice-faster-than-solid-core-times

DIY google cardboard

從十元的店買了一個望遠鏡來拆鏡片,加上手機盒製成,跟手機搭配性100%






使用Arduino 搭配光電晶體(非光敏電阻)來偵測螢幕高速閃動


這是當初為了工作,偵測螢幕閃動頻率所做的小玩具
使用光電晶體是因為影片通常為30 or 60 fps, 33ms的速度對光敏電阻來說反應太慢

兜起來後發現如果解析度要高,需使用極大的電組(100M歐姆以上),
到電子材料行找了好久才找到一些10M歐姆的來串聯





AR底盤四驅車,改用鋰電與降壓電路調速

原本使用兩顆3號電池約3V, 直接改成兩顆14500鋰電約7.2V
14500大小與3號電池相同,但由於電池是平頭,須對底盤稍微修正干涉的部分

之後在馬達與電池接觸的銅片間斷開,串接上開關是降壓電路以調速




田宮 plasma 馬達電刷折斷修復




透過分解,學習數位由標尺定位的原理





自製簡易14500鋰電定電壓充電器


DIY 修復破箱的行李箱

1. 沿著裂縫邊鑽一對對的洞
2. 使用束線帶縫合
3. 使用3M duct tape (你沒聽錯,就是流言終結者最愛用的那個)黏起來防水





DIY 更換Zenfone2 ZE551ML 螢幕

基本上沒什麼難度,就一直拆螺絲
只有電池黏超緊拆下來時要很小心








PID study


很不錯的影片表示PID 間的關係
https://www.facebook.com/permalink.php?story_fbid=1127678127264480


超淺顯易懂的教學
http://robotrabbit.blogspot.tw/2012/12/pid-pid.html?m=1

自製田宮四驅車改遙控車



補充,沒想到網路上也有人跟我做類似的事....
https://www.facebook.com/gesarichi/videos/10207311536620297/




自製四驅車改裝遙控車,且加裝轉向機構
(#15258 http://www.tamiya.com/english/products/15258steering/steering.htm)

目前已經可以使用遙控器,像遙控車一樣控制
電池的做法跟之前改裝類似(http://ddddiy.blogspot.tw/2016/08/ar.html),所以可以沿用四驅車的開關
電源直接提供給電子變速器,電變內建BEC供電給接收機

接收機接受到訊號後,一動輸出用來控制電變改變車速,另一動用來做轉向





去公園實際試跑,發現跟真的遙控車相比有幾個缺點
1. 改裝的這顆電變只有前進和剎車沒有後退
2. 前輪轉向幅度不夠,造成轉彎半徑太大,且轉到底時阻力太大<==#15258機構問題
3. 輪徑太小且無避震,在溜冰場之類的平地比較適合






2016年8月4日 星期四

DIY寶特瓶抽絲器

Diy寶特瓶抽絲器

山寨網路上的創意
使用一塊木頭
1. 橫切深度比刀片短邊小一點點
2. 直切一條縫
3. 最後使用金屬墊片固定刀片






我的第一台穿越機 - kingkong250

這是一開始為了研究CC3D 飛控組的
馬達/電變/機身都是kingkong出品,出名的CP值高

由於塑膠機身太不耐摔了,後來已經改成使用碳纖機架
    http://ddddiy.blogspot.tw/2016/08/qav250.html