- 不確定與變異越大,是否具備選擇權與可選擇性便越重要。就人生而言,如果世界的變化越大,而你有比較多的選擇權與選擇性彈性,那麼長久下來,你的表現會比別人好。
- 力量越強大、影響越深遠的抽象事物,越難用語言表達;很多時候,我們沒辦法正面描述它是什麼,只能明確說出它不是什麼
- 認清騙子的簡單的方法是,騙子只給你正面的建議,對於失敗的可能性與後遺症隻字不提
- 你要多善用否定法,例如生物的演化就是物競天擇,適者生存;圍棋大師贏的策略就是不要輸;變成有錢人的方式就是不要破產;人生中要學的是避開什麼事;想要擁有反脆弱的能力,就是不要當冤大頭。我們只要採取一小部分安全措施,便能大幅降低個人發生意外的大部分風險。
- 知識是透過減法來獲得成長 (即移除我們認為是錯誤的知識),而不是加法。
- 真實生活具備高度隨機性,我們搞不清楚:是成功的人具有長才,還是具有長才的人會成功? 但我們可以預測:不具長才與機運的人最後會失敗。
- Negative (即減法) knowledge 會比 positive (即加法) knowledge 更加 robust。例如當我看見一隻黑天鵝,我就能知道『所有的天鵝都是白的』這句話是錯誤的;但如果我從來都沒看過黑天鵝,我無法保證『所有的天鵝都是白的』這句話一定是正確的
- 『失敗與反證 (disconfirmation)』相較於『成功與證實 (confirmation)』能帶來更多的資訊,這也是為什麼 negative knowledge 會較 robust 的原因
- 良好的政治體系,應優先去除掉壞人,單一壞人造成的傷害大於一群好人的行動;一個好的體系要能保護一般民眾受到壞蛋的影響
- 減法知識就是一種槓鈴 (barbell),也是一種凸性 (convex)。什麼是錯誤的,就是相當健全的知識,那些你說不知道的就是脆弱與臆測,你不能將其視為理所當然且不會傷愛你,萬一這些知識是錯誤的話
- 我們應該用否定法來解決問題,消除錯誤的知識。否定法的應用是建立在少即是多的 (less is more) 觀念上,把有限的資源投注在掃除風險。作者認為,對於創新與發明,不需要理論的指導,嘗試錯誤的貢獻遠大於正規科學。
- 這個世界的分布越來越不平等 (winner-take-all effect),已經從過去提到的 80/20 走向 99/1: 99% 的網際網路流量是由 < 1% 的網站所貢獻的;99% 的書籍銷售量是由 < 1% 的作者所造就的;以美國的健保來說,半數的人僅用了 3% 的健保成本,但是罹患重病的 10% 的病人卻耗用了整體健保大餅中的 64%
- 如果你做某件事情的理由超過 1 個,那就不要去做。如果有人用1個以上的論點,抨擊某本書或觀念,你便知道那不是事實。沒人會說「他是殺人犯,而且餐桌禮儀很差,又有口臭,開車非常莽撞。」
- 清楚的決策 (robust to error) 不需要超過一個理由。這並不是說一個理由優於兩個理由,而是你在想辦法尋找更多的理由說服自己去做某件事情。
- 許多領域的問題,一堆人可以直覺地找出解決方式。你應該秉持少即是多 (less is more) 的原則,如在房地產,最重要的三大要素就是:地點、地點與地點。你應該專注於最重要的事情,其他事情就讓他們自己去照顧自己,記得要抓大放小
- 即便是諾貝爾獎,獲獎的人通常不是擁有多個研究方向、發表一堆論文的人,獲獎的人通常是在某一領域,有主要一個展現出傑出貢獻的人士
- 林迪效應(Lindy Effect):是指對易損的東西來說,每多活一天,都會縮短其壽命;相反的,對於不易損的東西來說,每多活一天,都將更拉長其存在壽命。舉個例子來說,在書籍領域,已經存在超過一整個世紀的書籍,持續時間將會越來越長,下個世紀依然仍看到它的存在。不過,對於新出版的書籍來說,它所存在的持續時間只會越來越短,最後終將消失在人們的眼中。
- 用數學運算來說明 lindy effect, 不會損壞的事物 (nonperishable) 的預期壽命會隨著每天的存活下來而增加,如已經存在最久的書籍,將持續最長時間;已經存在最久的科學成果,將持續最長時間 (這些科學成果通常都很無趣,看看高中物理、化學課本就知道了)
- 回顧之前提到的非對稱性 (asymmetry),antifragile 可以從不穩定 (violatility) 與混亂 (disorder) 中獲益,fragile 則是從不穩定與混亂中受到傷害。時間與混亂是一樣的,將時間軸拉長就知道誰是 antifragile、誰是 fragile。antifragile 隱含著舊的會比新的好,無論某個東西你現在看起來非常新穎、智慧,時間會說明其脆弱性,只要在需要的時候將其擊潰
- 科技本身就是 fragile,或許可以主宰世界一段時間,但是終將被另外一個新科技所取代,而另外一個新科技就是個不可預測 (unpredictable) 的事物
- 預言是減法、不是加法:要預測會出現哪些新東西、這些東西是否會席捲全球很難;但是一些已經存在很久的東西(鍋碗瓢盆),它們有很大的機率會繼續存在下去
- 預測的有趣矛盾: 長期的預測比短期更為可靠,然而預測的準確度往往會隨著時間拉長而退化,準確度變糟
- 米開朗基羅對待雕塑的態度也是應用了否定法:教皇問米開朗基羅,他成為天才的奧秘在哪裡,尤其是他如何雕刻出了大衛雕像,這個被視為所有傑作中的傑作的雕像。米開朗基羅的回答是:『這很簡單,我只是剔除了所有不屬於大衛的部分。』
- 對過去和歷史保持尊重,不要輕易就對過去的智慧說不。現在的人類都患上了「新事物狂熱症」,唯新不愛。若要治療新事物狂熱症,你需要「對過去保留一些尊重,對歷史記錄保留一些好奇,對老人的智慧保留一絲渴求。換句話說,你將被迫重視能世代流傳、能倖存下來的東西。」
- 資訊有個很糟糕的特質:隱藏失敗。很多人受到一些在股市致富的新聞所影響 (因為失敗的新聞都被掩蓋,讓我們沒機會去聽到),導致高估了成功的機會。
- 有愈來愈多證據顯示,人們在意許多彰顯地位的物品。美國當地一項調查發現,當鄰居所得增加時,個人幸福感反而大幅降低。當人們設法藉由更努力工作來增加所得,卻發現別人也這麼做,所以自己並沒有如願以償時,就會出現著名的跑步機效應 (treadmill effect),再怎樣拼命工作,幸福還是停滯不前。所以,我們何不學會從水車上跳下來,別再費力地踩。減速者已經想通,金錢不能買到滿足。人們以為金錢會讓自己幸福,但事實多半不是這樣,金錢沒有這種功效。
- 快樂跑步機(hedonic treadmill)指的是一種(社會頂層)永不滿足的嫉妒心態, 由普林斯頓大學心理學家丹尼爾‧卡尼曼(Daniel Kahneman)所提出。 卡尼曼曾得過諾貝爾經濟學獎,他運用水車的形象來解釋, 為什麼生活環境改善 (例如財富增加) 與『生活滿意度』沒有多大關連。 Kahneman 指出,最有錢的人未必最快樂,當財富增加,我們的期望也會調高, 嚮往更高尚、花費更多的娛樂,有如一部運轉不息的跑步機 (treadmill),就連億萬富翁也不例外。 富人享有的樂趣也許高於窮人,但是他們需要更多的樂趣才能滿足。
- 嗜新狂(neomania)是一種當代病,會帶來脆弱。導致人們對技術過度狂熱的心理偏誤包括︰資訊會隱藏失敗,讓我們將「必要」與「原因」混為一談;我們總是注意到變動,不注意靜態事物,讓我們不大留意角色重大但不變的事物,並只注意不斷嘗試的新事物,沒留意大部份嘗試行為並不持久。嗜新狂會帶來跑步機效應 (treadmill effects),我們購買新物品後滿意感會急速上升,但很快就厭倦自己已擁有的事物,開始尋找新的新東西。
- 經不起時間考驗的資訊同樣脆弱,只上市一年的書籍通常不值一讀,不論當時它多麼熱門,已存在十年的書會再存在十年,已存在二千年的書會繼存在很長時間。學術工作也是如此,很多論文只是雜訊,唯有在時間考驗下才知道是否有突破。以嗜新狂熱看待科學成果與科學家,會將科學領域貶抑為運動競賽,讓科學變得脆弱。
- 人造的深奧系統往往會引發一發不可收拾的連鎖反應,而降低或甚至消除可預測性,並且製造出黑天鵝事件。因此現代世界的技術知識不斷增加,但是事情的發展卻遠比從前難以預測。每一樣東西的設計變得十分複雜,而失去強固性,使得黑天鵝到處亂飛。對新穎科技的盲目追求,《反脆弱》提出一種稱為嗜新狂(neomania)的新疾病。可是我們相反的,更應該珍惜已經經得起時間長久考驗的舊事物。
Total Pageviews
2019/02/01
[閱讀筆記] Antifragile: Things That Gain from Disorder (9/10)
Labels:
Reading
2019/01/15
[Java] [Spring] An example to Spring @Value
This summary is not available. Please
click here to view the post.
Labels:
Spring
2019/01/14
[Tools] [Cmder] 如何修改開啟 Cmder 的初始路徑
Problem
我希望打開 Cmder 後,預設路徑是 F:\git
How-To
Settings => Startup => Tasks => {cmd:Cmder} => 增加 -new_console:d:"F:\git" => Save settings
我希望打開 Cmder 後,預設路徑是 F:\git
How-To
Settings => Startup => Tasks => {cmd:Cmder} => 增加 -new_console:d:"F:\git" => Save settings
Labels:
Tools
2019/01/13
[Tools] [Cmder] 繁體中文亂碼問題
Problem
當我透過 Cmder 要查看 commit history 時,發現 Cmder 無法正確顯示繁體中文
How-To
Settings => Startup => Environment => 在環境變數增加 set LANG=zh_TW.UTF8 => Save settings
關閉 Cmder,再看一次 git commit history,就可發現已可正常顯示中文
當我透過 Cmder 要查看 commit history 時,發現 Cmder 無法正確顯示繁體中文
How-To
Settings => Startup => Environment => 在環境變數增加 set LANG=zh_TW.UTF8 => Save settings
關閉 Cmder,再看一次 git commit history,就可發現已可正常顯示中文
Labels:
Tools
2019/01/12
[Java] [POI] org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML.
Problem
Here has a code snippet to read excel file (.xls file)
But when I provide xlsx file, it will throw exception:
How-To
If I would like to read xlsx file, the code snippet should be modified as bellow:
If you don't care about xls or xlsx file, your can modify your code as follows:
Reference
[1] https://stackoverflow.com/questions/31844308/java-poi-the-supplied-data-appears-to-be-in-the-office-2007-xml
Here has a code snippet to read excel file (.xls file)
try (InputStream inputStream = new FileInputStream(new File(xlsFile)); Workbook workbook = new HSSFWorkbook(inputStream);) { Sheet sheet = workbook.getSheetAt(0); // ignore implementation details } catch (IOException e) { throw new IOException("讀取 Excel file 發生錯誤", e); }
But when I provide xlsx file, it will throw exception:
org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
How-To
If I would like to read xlsx file, the code snippet should be modified as bellow:
try (InputStream inputStream = new FileInputStream(new File(xlsxFile)); Workbook workbook = new XSSFWorkbook(inputStream);) { Sheet sheet = workbook.getSheetAt(0); // ignore implementation details } catch (IOException e) { throw new IOException("讀取 Excel file 發生錯誤", e); }
If you don't care about xls or xlsx file, your can modify your code as follows:
try (Workbook workbook = WorkbookFactory.create(new File(xlsOrXlsxFile));) { Sheet sheet = workbook.getSheetAt(0); // ignore implementation details } catch (IOException e) { throw new IOException("讀取 Excel file 發生錯誤", e); }
Reference
[1] https://stackoverflow.com/questions/31844308/java-poi-the-supplied-data-appears-to-be-in-the-office-2007-xml
2019/01/11
[Spring] Spring Data JPA - “No Property Found for Type” Exception
Problem
I am using Spring data as my persistence-tier implementation.
As I try to add custom functionality to spring data repository, it throw “No Property Found for Type” Exception.
How-To
As per the spring data documentation, if your repository is PostOfficeRepository, the implementation of your custom repository should be name as PostOfficeRepositoryImpl, that's why it throws the exception.
Reference
[1] https://stackoverflow.com/questions/19583540/spring-data-jpa-no-property-found-for-type-exception
I am using Spring data as my persistence-tier implementation.
As I try to add custom functionality to spring data repository, it throw “No Property Found for Type” Exception.
How-To
As per the spring data documentation, if your repository is PostOfficeRepository, the implementation of your custom repository should be name as PostOfficeRepositoryImpl, that's why it throws the exception.
Reference
[1] https://stackoverflow.com/questions/19583540/spring-data-jpa-no-property-found-for-type-exception
2019/01/10
[Git] How to revert multiple git commits?
Problem
Here is my commit history:
If I would like to revert to B, how to do it?
How-To
Git commands:
Reference
[1] https://stackoverflow.com/questions/1463340/how-to-revert-multiple-git-commits/1463390#1463390
Here is my commit history:
If I would like to revert to B, how to do it?
How-To
Git commands:
git reset --hard B git reset --mixed E git commit
Reference
[1] https://stackoverflow.com/questions/1463340/how-to-revert-multiple-git-commits/1463390#1463390
Labels:
Git
2019/01/09
[Spring] How to sort by multiple properties in Spring Data?
Problem
I have a table:
I am using spring data to find all data, and expect to sort by config_type and key columns.
The code snippet looks like:
But I get this exception:
How-To
The method name should be updated as bellows:
Reference
[1] https://stackoverflow.com/questions/25380984/how-to-sort-by-multiple-properties-in-spring-data-jpa-derived-queries
I have a table:
I am using spring data to find all data, and expect to sort by config_type and key columns.
The code snippet looks like:
List<CommonConfig> findAllByOrderByConfigTypeAndKey();
But I get this exception:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property andKey found for type String! Traversed path: CommonConfig.configType. at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE] at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE] at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:334) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE] at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:368) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE] at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:392) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
How-To
The method name should be updated as bellows:
List<CommonConfig> findAllByOrderByConfigTypeAscKeyAsc();
Reference
[1] https://stackoverflow.com/questions/25380984/how-to-sort-by-multiple-properties-in-spring-data-jpa-derived-queries
Labels:
Spring
2019/01/08
[Html] [Java] Method of embedding images and other files in webpages as a string of text
Problem
If I would like to embed image in webpage as a string of text (using base64 encoding), how to do it?
How-To
Add two dependencies in your pom.xml
Java code (build data uri string):
HTML code (assign data URI in img src):
Reference
[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
[2] https://blog.csdn.net/dac55300424/article/details/21093347
If I would like to embed image in webpage as a string of text (using base64 encoding), how to do it?
How-To
Add two dependencies in your pom.xml
<dependency> <groupId>org.apache.tika</groupId> <artifactId>tika-core</artifactId> <version>1.18</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>23.0</version> </dependency>
Java code (build data uri string):
package demo.util; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.util.Base64; import org.apache.tika.Tika; import com.google.common.io.Files; public class FileContentCodecUtils { /** * 產生 data uri (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs). * * @param base64str * base 64 string * @return data URI 給 img src, 如<img src="data:application/octet-stream;base64,xxxxxxx"> * @throws IOException */ public static String getDataUri(String base64str) throws IOException { Tika tika = new Tika(); String contentType = tika.detect(new org.apache.commons.codec.binary.Base64InputStream( new ByteArrayInputStream(base64str.getBytes("UTF-8")))); StringBuilder dataUri = new StringBuilder(); dataUri.append("data:").append(contentType); dataUri.append(";base64,").append(base64str); return dataUri.toString(); } }
HTML code (assign data URI in img src):
<img src="data:image/png;base64,xxxxxx" />
Reference
[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
[2] https://blog.csdn.net/dac55300424/article/details/21093347
2019/01/07
[Database] [Sybase] How to implement trim() in Sybase?
Problem
If I would like to remove unnecessary space from a column value, how to do it in Sybase?
Sybase does not have trim function which provide by Oracle.
How-To
You can use ltrim and rtrim to fulfill this requirement:
If I would like to remove unnecessary space from a column value, how to do it in Sybase?
Sybase does not have trim function which provide by Oracle.
Error: Function 'trim' not found. If this is a SQLJ function or SQL function, use sp_help to check whether the object exists (sp_help may produce a large amount of output). SQLState: S1000 ErrorCode: 14216
How-To
You can use ltrim and rtrim to fulfill this requirement:
select ltrim(rtrim(' 123aa '))
Labels:
Database
2019/01/06
[Java] How to generate XSD file from Java Bean?
Problem
How to generate XSD file from Java Bean?
How-To
Take one Dto class for example:
Sample code for conversion:
Xsd file:
How to generate XSD file from Java Bean?
How-To
Take one Dto class for example:
package com.demo.dto; import lombok.Data; import lombok.ToString; @Data public class M7480CallDto { private String m7480CallId; private String agentId; private String agentName; private String agentExtension; private String callTimeStr; private String answerTimeStr; private String callDisconnectionTimeStr; private String endPcpTimeStr; private Integer callWaitingDuration; private Integer callAgentDuration; private Integer callTalkingDuration; private Integer callPcpDuration; private Integer callDisconnectionStatus; }
Sample code for conversion:
package com.demo.util; import java.io.File; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.SchemaOutputResolver; import javax.xml.transform.Result; import javax.xml.transform.stream.StreamResult; import com.demo.dto.M7480CallDto; import lombok.extern.slf4j.Slf4j; @Slf4j public class XsdUtils { private final static String XSD_DIR = "F:\\git\\demo\\src\\main\\resources\\xsd\\"; public static void main(String[] args) throws Exception { XsdUtils.generateXsdFile(M7480CallDto.class, "m7480CallData.xsd"); } public static void generateXsdFile(Class clazz, String fileName) throws Exception { try { (JAXBContext.newInstance(clazz)).generateSchema(new SchemaOutputResolver() { @Override public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { return new StreamResult(new File(XSD_DIR + fileName)); } }); log.debug("成功產生 Xsd 檔案到 " + XSD_DIR + fileName); } catch (IOException | JAXBException e) { log.error(e.getMessage()); throw new Exception("產生 Xsd 檔案發生錯誤,錯誤原因" + e.getMessage()); } } }
Xsd file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="m7480CallDto"> <xs:sequence> <xs:element name="agentExtension" type="xs:string" minOccurs="0"/> <xs:element name="agentId" type="xs:string" minOccurs="0"/> <xs:element name="agentName" type="xs:string" minOccurs="0"/> <xs:element name="answerTimeStr" type="xs:string" minOccurs="0"/> <xs:element name="callAgentDuration" type="xs:int" minOccurs="0"/> <xs:element name="callDisconnectionStatus" type="xs:int" minOccurs="0"/> <xs:element name="callDisconnectionTimeStr" type="xs:string" minOccurs="0"/> <xs:element name="callPcpDuration" type="xs:int" minOccurs="0"/> <xs:element name="callTalkingDuration" type="xs:int" minOccurs="0"/> <xs:element name="callTimeStr" type="xs:string" minOccurs="0"/> <xs:element name="callWaitingDuration" type="xs:int" minOccurs="0"/> <xs:element name="endPcpTimeStr" type="xs:string" minOccurs="0"/> <xs:element name="m7480CallId" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:schema>
Labels:
Java
Subscribe to:
Posts (Atom)