2023-07-20

[心得] 房貸分期付款,抗通膨

 看過一篇文章,講到房貸分期支付才是抗通膨的方法.巴菲特:抗通膨最好的辦法就是靠房貸!如何增加貸款成數? 「4方法」曝光


裡面講的概念是, 現在房貸利率 1.x % ,如果 每年物價指數增加率 高於 1.x %.  那將提前還款的錢,留在身邊或者投資. 比直接還房貸會是更好的選擇. 

2023-07-15

如何使用Gmail 發送自己的 domain mail 並透過 cloudflare domain 設定

之前設定可以透過 cloudflare , 把自己的 domain host 到 cloudflare. 

並且透過 cloudflare 轉發 mail 到 gmail 上去,達到收到自己的 domain mail. 

如果要透過 gmail 發送自己 domain mail 的方式如下,要達到該方法. 最主要的概念是,提供gmail 一組自己該帳號的 app passwork,並設定到 gmail 設定->帳號->自己的 domain mail.

1. 新增 一組 自己帳號的 app password. 連結: https://myaccount.google.com/apppasswords

2. 記下產生的 app password 

3. 開啟 gmail -> 設定 -> 帳號和匯入-> 選擇寄送郵件-> 新增另外一個電子郵件

4. 新增電子郵件的 smtp server 使用 smtp.gmail.com

5. 輸入 剛剛第一部所使用的 gmail and password. 


參考 

https://community.cloudflare.com/t/solved-how-to-use-gmail-smtp-to-send-from-an-email-address-which-uses-cloudflare-email-routing/382769/3 

2023-06-27

所得稅使用信用卡與拆分說明

 今年再繳交所得稅時,研究要如何使用信用卡繳稅.  要使用那種信用卡可以獲得較高的回饋. 

最後結論如下 : 

1. 使用台新gogo卡, 搭配在 7-11 ,使用 台新pay 繳納.

2. 使用 所得稅線上拆分繳款單 ,讓每張繳款單低於3萬,才可以在便利商店繳納

3. 在 5/31 那一天繳納最後一張所得稅,這樣可以同時使用 五月與六月的優惠額度. 


Reference 


https://roo.cash/blog/income-tax/

https://roo.cash/blog/income-tax-split-bill/

https://www.etax.nat.gov.tw/etwmain/etw144w/15G

2023-03-22

[java] Jackson 解析 Java 8 的 LocalDate 問題

 直接使用Jackson 解析 Java 8 之後提供的 LocalDate 會發生,Java 8 date/time type not supported by default. 

找到的解決方法. 

Java 8 LocalDate With Jackson In Spring Boot

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
    <version>2.9.3</version>
</dependency>


ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule()); 
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);

2023-03-16

[spring] Spring boot application profiles and config properties include

 最近開發一個小的 sprint boot app,有使用到 db and amqp.  原先研究的方法是使用 profile 方式來區隔相關的環境使用的 config properties. 但是,後面還是遇到疊加與重複撰寫的問題。

研究一陣子,使用 application profile + include 方式來處裡這樣多變化的組合. 


第一步

首先,  application profile 其觀念是,每一次 spring boot 還是會讀取 application.proerpties ,再去讀取設定的 application-{profile}.properties。只是後面的會蓋掉前面的設定,所以差異化要做在後面那些 profile.  因此在 application.properties 只包含最簡單的. 設定 

application.properties

application.name=Gateweb Billing Agent
spring.profiles.active=local

application-local.properties

server.port=8181

spring.config.import=db-h2.properties,amqp-test.properties

application-test.properties

server.port=8080

spring.config.import=db-test.properties,amqp-test2.properties

第二步

將相關的資料 通通分開不同的設定檔. 

db-h2.properties

spring.sql.init.mode=always
spring.sql.init.platform=h2
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=sa

##spring.datasource.schema=file:./test-data/schema-h2.sql
## Jpa Config
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.show-sql=false 

amqp-test.properties

amqp.broker.host=cougar.rmq.cloudamqp.com
amqp.broker.vhost=xelvnewm
amqp.username=xelvnewm
amqp.password=SE6RHeTCJIf6E0KrxIOkDbdrEsYx82u2


db-test.properties

# Spring DB MySql
spring.sql.init.mode=never
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://test.mysql.database.azure.com:3306/test?useSSL=true&requireSSL=false
spring.datasource.username=test
spring.datasource.password=testpassword

# MySql Jpa Config
#spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.properties.hibernate.dialect.storage_engine=innodb
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.show-sql=true
spring.jpa.open-in-view=false

amqp-test2.properties

amqp.broker.host=cougar.rmq.cloudamqp.com
amqp.broker.vhost=xelvnewmsdsd
amqp.username=xelvnewmsdsd
amqp.password=SE6RHeTCJIf6E

第三步

修改 build.gradle 新增 相關 bootRun task 

tasks.register('bootRunLocal') {
dependsOn 'bootRun'
bootRun.systemProperty('spring.profiles.active', 'local')
}

tasks.register('bootRunTest') {
dependsOn 'bootRun'
bootRun.systemProperty('spring.profiles.active', 'test')
}