2023年10月24日 星期二
從資料庫產生entity&mapper
2023年10月17日 星期二
全局date time
當回應的日期格式中有T還有毫秒的時候
或許我們會思考如何改它的格式
有一個方法, 可以做全局的統一
@Configuration
public class LocalDateTimeConfig {
/*
* 序列化内容
* LocalDateTime -> String
* 服务端返回给客户端内容
* */
@Bean
public LocalDateTimeSerializer localDateTimeSerializer() {
return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
/*
* 反序列化内容
* String -> LocalDateTime
* 客户端传入服务端数据
* */
@Bean
public LocalDateTimeDeserializer localDateTimeDeserializer() {
return new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
// 配置
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
return builder -> {
builder.serializerByType(LocalDateTime.class, localDateTimeSerializer());
builder.deserializerByType(LocalDateTime.class, localDateTimeDeserializer());
};
}
}
透過上面的方式, 就能統一格式
結果:
2023年8月11日 星期五
linux note-2
分辨文件 文件夾
ls -l
其中d開頭為文件夾, -開頭為文件
cat 支持看文件
但是當文件太長的時候, 變得難以閱讀
ex
cat /etc/services
而 翻頁查看 可以方便看長文件
ex
more /etc/services
翻頁 按 空白鍵
退出 按 q
小結
1. touch命令
用于创建一个新的文件
语法:touch linux 路徑
参数必填,表示要创建的文件的路径,相对、绝对、特殊路径符都可以使用
2. cat命令
用于查看文件内容
语法:cat linux 路徑
参数必填,表示要查看的文件的路径,相对、绝对、特殊路径符都可以使用
3. more命令
用于查看文件内容,可翻页查看
语法:more linux路徑
参数必填,表示要查看的文件的路径,相对、绝对、特殊路径符都可以使用
使用空格进行翻页,使用q退出查看
2023年6月29日 星期四
linux note-1
cd ~
2022年10月23日 星期日
面試紀錄
問get post的差異-其中有說明post在資安上是比較安全
使用 GET 的時候我們直接將要傳送的資料以 Query String(一種Key / Vaule的編碼方式)加在我們要寄送的地址( URL )後面,然後交給郵差傳送。使用 POST 的時候則是將寄送地址( URL )寫在信封上,另外將要傳送的資料寫在另一張信紙後,將信紙放到信封裡面,交給郵差傳送。
POST 是將表單的內容放在 body 裡面,在不看封包的情況下似乎較為安全,此外在傳送檔案時會用到 multi-part 編碼,將檔案與其他表單一併放在 body 中傳送
@Autowired
標記,因此框架會從容器中找出對應類別的元件,自動注入到計算器中。具體來說,TDD 流程可以分成五個步驟:
步驟一:選定一個功能,新增測試案例
- 重點在於思考希望怎麼去使用目標程式,定義出更容易呼叫的 API 介面。
- 這個步驟會寫好測試案例的程式,同時決定產品程式的 API 介面。
- 但尚未實作 API 實際內容。
步驟二:執行測試,得到 Failed(紅燈)
- 由於還沒撰寫 API 實際內容,執行測試的結果自然是 failed。
- 確保測試程式可執行,沒有語法錯誤等等。
步驟三:實作「夠用」的產品程式
- 這個階段力求快速實作出功能邏輯,用「最低限度」通過測試案例即可。
- 不求將程式碼優化一步到位。
步驟四:再次執行測試,得到 Passed(綠燈)
- 確保產品程式的功能邏輯已經正確地得到實作。
- 到此步驟,將完成一個可運作且正確的程式版本,包含產品程式和測試程式。
步驟五:重構程式
- 優化程式碼,包含產品程式和測試程式(測試程式也是專案需維護的一部份)。
- 提升程式的可讀性、可維護性、擴充性。
- 同時確保每次修改後,執行測試皆能通過。
每個功能重複上述步驟,就是 TDD 的開發流程。
https://tw.alphacamp.co/blog/tdd-test-driven-development-example
問 Java 8 特性
https://www.796t.com/p/570214.html
https://blog.51cto.com/u_15236724/5368640
2022年9月12日 星期一
Big O
Overview
Big O help us find out how well the problem is solved.
We use it to distinguish that code from good code, good code from great code.
->great developer
What is good code?
1. Readable
2. Scalable
Big O allow us to measure the idea of scalable code.
How can we make sure that there is a way for us to measure in terms of efficiency, what is good code,
what is bad code, and what is code that can scale that as the number of arrays or inputs increases,
it doesn't constantly slow down more and more.
We can compare it to different algorithms or in this case, function using big O and say which one is better than the other when it comes to scale. Regardless of our computer differences.
When we talk about Big O and scalability of code, we simply mean when we grow bigger and bigger with inputs, how much does the algorithm or functions slow down.
When the Elements increase, the number of operations increased over and over. Some increase much, some doesn't increase much.
Instead of using performance and using time to measure the efficiency of our function, we can just calculate how many operations a computer has to perform because each operation takes time on a computer.
O(n)
The picture describes that 4 item in an array.
We do the asking loop "is it the nemo ?" 4 times 4 operations
As the items increased, the operation increased.
This is linear. We can say this findNemo notation O(n).
As the item increased, we find the time scaled.
O(1)
This is O(1), what we called constant time.
It is how many items in boxes, we just grasping the first item in the array.
The number of operations just stay flat.
2022年8月4日 星期四
swarm intelligence 群體智慧- 托福 聽力46-2 部分內容
Swarm intelligence is a collective behavior that emerges from a group of animals, like a colony of termites, a school of fish, or a flock of birds.
群體智能是一群動物的集體行為,如白蟻群、魚群或鳥群。
Let's first consider the principles behind swarm intelligence, and we'll use the ant as our model.
Now, an ant on its own is not that smart. When you have a group of ants, however, there you have efficiency in action.
You see, there's no leader running an ant colony.
讓我們首先考慮群體智能背後的原理,我們將使用螞蟻作為我們的模型。
現在,一隻螞蟻本身並不那麼聰明。 然而,當你有一群螞蟻時,你就有了行動的效率。你看,沒有領導者管理蟻群。
Each individual, each individual ant operates by instinctively following a simple set of rules when foraging for food.
Rule number 1: Deposit a chemical marker... called a pheromone. And rule 2: Follow the strongest pheromone path.
The strongest pheromone path is advantageous to ants seeking food.
So, for example, when ants leave the nest, they deposit a pheromone trail along the route they take.
If they find food, they return to the nest on the same path and the pheromone trail gets stronger—it's doubled in strength.
Because an ant that took a shorter path returns first, its pheromone trail is stronger, and other ants will follow it, according to rule 2.
And as more ants travel that path, the pheromone trail gets even stronger.
每個個體,每個個體的螞蟻在覓食時都本能地遵循一套簡單的規則。規則 1:存放一種化學標記物……稱為信息素。 規則 2:遵循最強的信息素路徑。最強的信息素路徑有利於螞蟻尋找食物。因此,例如,當螞蟻離開巢穴時,它們會沿著它們所走的路線放置一條信息素軌跡。如果它們找到食物,它們會沿著同一條路徑返回巢穴,並且信息素痕跡會變得更強——它的強度會增加一倍。因為根據規則 2,走較短路徑的螞蟻首先返回,它的信息素軌跡更強,其他螞蟻會跟隨它。隨著越來越多的螞蟻在這條路上旅行,信息素的踪跡變得更加強大。
So, what's happening here?
Each ant follows two very basic rules, and each ant acts on information it finds in its immediate local environment.
And it's important to note: Even though none of the individual ants is aware of the bigger plan, they collectively choose the shortest path between the nest and a food source because it's the most reinforced path.
By the way, a-a few of you have asked me about the relevance of what we're studying to everyday life.
And swarm intelligence offers several good examples of how concepts in biology can be applied to other fields.
Well, businesses have been able to use this approach of following simple rules when designing complex systems, for instance, in telephone networks.
When a call is placed from one city to another, it has to connect through a number of nodes along the way.
那麼,這裡發生了什麼?
每隻螞蟻都遵循兩條非常基本的規則,每隻螞蟻都根據在其直接本地環境中找到的信息採取行動。重要的是要注意:即使沒有一隻螞蟻知道更大的計劃,它們也會集體選擇巢穴和食物來源之間的最短路徑,因為它是最堅固的路徑。順便說一句,你們中的一些人問過我我們正在學習的內容與日常生活的相關性。群體智能提供了幾個很好的例子,說明生物學中的概念如何應用於其他領域。好吧,在設計複雜系統時,例如在電話網絡中,企業已經能夠使用這種遵循簡單規則的方法。當從一個城市向另一個城市撥打電話時,它必須通過沿途的多個節點進行連接。
At each point, a decision has to be made: Which direction does the call go from here?
Well, a computer program was developed to answer this question based on rules that are similar to the ones that ants use to find food.
Remember, individual ants deposit pheromones, and they follow the path that is most reinforced.
Now, in the phone network, a computer monitors the connection speed of each path, and identifies the paths that are currently the fastest—the least crowded parts of the network.
And this information, converted into a numeric code, is deposited at the network nodes.
This reinforces the paths that are least crowded at the moment.
The rule the telephone network follows is to always select the path that is most reinforced.
So, similar to the ant's behavior, at each intermediate node, the call follows the path that is most reinforced.
This leads to an outcome which is beneficial to the network as a whole, and calls get through faster.
在每一點上,都必須做出決定:呼叫從這裡往哪個方向進行?
嗯,開發了一個計算機程序來回答這個問題,其規則類似於螞蟻用來尋找食物的規則。請記住,個體螞蟻會沉積信息素,它們會遵循最強化的路徑。現在,在電話網絡中,計算機監控每條路徑的連接速度,並識別當前最快的路徑——網絡中最不擁擠的部分。這些信息,轉換成數字代碼,存放在網絡節點上。這加強了目前最不擁擠的路徑。電話網絡遵循的規則是始終選擇最強化的路徑。因此,類似於螞蟻的行為,在每個中間節點,調用遵循最強化的路徑。這導致對整個網絡有利的結果,並且呼叫更快地通過。
量身訂做建議(37 歲,6 年 Java 後端工程師)from chatgpt
🎯 量身訂做建議(37 歲,6 年 Java 後端工程師) 1️⃣ 先看你的條件 年齡 37 屬於「中高年資」工程師,履歷上的 深度 / 系統設計能力 會比「語言多寡」更重要。 6 年 Java 後端 代表你在 Spring Boot、資料庫、API 設計...
-
如果想到快, 可能直覺就是Redis, 但是... 問:瞬間有100-200萬筆資料量進來, 如果存到redis, 這樣操作有沒有可能壓垮redis? 答: 在瞬間大量資料(如100-200萬筆)快速進入Redis,確實有可能導致Redis的性能瓶頸甚至崩潰,特別是在以下情況下:...
-
把JSON存進資料庫的欄位, 要做以下的設置 @Entity(name = "patient_xxx") @TypeDef(name = "json", typeClass = JsonType.class) public class ...
-
處理dependency check 的問題接近尾聲, 大致上能改的只剩下itext 上面是有發生問題的套件 而~itext 在五版5.5.12才有解決這方面問題 然而itext從5以後都是follow AGPL的協定 AGPL意思是~我的東西全部是開放的, 可使用, 但是不可修...