揭祕 Go sync-Map 設計與實現
什麼是 sync.Map————我們都知道在 Go 語言中,普通的 Map 是非併發安全,併發讀寫時會 panic,sync.Map 則是官方庫提供的一種特殊的併發安全的映射類型,能保較高的性能的同時,還能保證併發安全。sync.Map 有以下幾個特點:sync.Map 特點併發安全: sync.Map 無需額外的鎖機制即可在多個 goroutine 中安全地進行讀寫操作。這對於高 ⌘ Read more
Go 項目使用 Makefile 構建版本信息完整教程
目錄結構我們以最小目錄結構爲例進行說明,如下這是我們此次示例的目錄結構。$ tree -L 3.├── main.go├── Makefile├── pkg│ └── version│ └── version.go├── README.md代碼內容主要有兩部分代碼,分別爲 main.go,內容如下:package mainimport ( ”eastMoney/pkg/ver ⌘ Read more
Go 語言實現高性能文本壓縮算法 Brotli
在信息爆炸的時代,數據如同洪流般湧現,如何高效地存儲和傳輸這些數據成爲了一項至關重要的技術挑戰。壓縮技術應運而生,它如同一位技藝精湛的魔術師,能夠將龐大的數據文件 “化繁爲簡”,在不損失信息或損失極少信息的情況下將其壓縮成更小的體積,從而節省存儲空間、提高傳輸效率。壓縮技術主要分爲兩大類:無損壓縮和有損壓縮。無損壓縮:顧名思義,這種壓縮方式能夠在解壓縮後完全恢復原始數據,不會造成任何信息損失。常見 ⌘ Read more
Apple Seeds watchOS 11.1 Release Candidate
Apple today seeded the release candidate version of an upcoming watchOS 11.1 update to developers and public beta testers for testing purposes. The new software comes approximately week after Apple released the fifth beta.
watchOS 11.1 can be installed by going to the Apple Watch … ⌘ Read more
Go 中祕而不宣的數據結構 runq- 難怪運行時調度那麼好
首先,讓我們先來回顧 Go 運行時的 GPM 模型。這方面的介紹網上的資料都非常非常多了,但是我們也不妨回顧一下: GPM 模型中的 G 代表 goroutine。每個 goroutine 只佔用幾 KB 的內存, 可以輕鬆創建成千上萬個。G 包含了 goroutine 的棧、指令指針和其他信息, 如阻塞 channel 的等待隊列等。 P 代表 processor, 可以理解爲一個抽 ⌘ Read more
解讀 Golang 標準庫裏的 varint 實現
最近發現 Golang 標準庫竟然自帶了 varint 的實現,代碼位置在 encoding/binary/varint.go。剛好藉助 golang 標準庫的 varint 源碼,我們來系統地學習和梳理下 varint。熟悉 protobuf 的人肯定對 varint 不陌生,protobuf 裏面除了帶 fix (如 fixed32、fixed64) 之外的整數類型, 都是 varint 編碼 ⌘ Read more
Monero Tech meeting scheduled for 28 October 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, October 28 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:
Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.
This meeting’s chai … ⌘ Read more
How to Re-Enable Slow Motion Effects on MacOS
If you’re a long time Mac user, you might recall the Slow Motion effect that could be applied by holding the Shift key while minimizing and maximizing windows, as well as for other animations like opening Launchpad or using Mission Control. Some of the fun eye-candy effects on Mac go way the early days of … Read More ⌘ Read more
Go 信號處理:優雅地關閉你的應用
在構建健壯且可靠的應用程序時,優雅地處理系統信號至關重要。系統信號,如 SIGINT(中斷信號,通常由 Ctrl+C 觸發)和 SIGTERM(終止信號),允許我們以可控的方式關閉應用程序,執行必要的清理操作,例如關閉連接、釋放資源和保存狀態。本文將深入探討在 Go 語言中如何處理系統信號。我們將涵蓋以下主題:理解系統信號 使用 os/signal 包捕獲信號 實現優雅的關閉機制 ⌘ Read more
Go 每日一題:併發下載與合併
答案–實現思路:文件分割: 將目標文件分割成多個大小相等的塊(例如 10MB / 塊)。 併發下載: 爲每個文件塊創建一個 goroutine,每個 goroutine 負責下載對應塊的內容並保存到臨時文件中。 同步與合併: 使用 channel 來同步所有 goroutine 的下載進度,並在所有塊下載完成後,按順序合併所有臨時文件,最終得到完整的原始文件。 代碼示例:pac ⌘ Read more
一文掌握 Go 語言 I-O 操作中的 io-Reader 和 io-Writer
在 Go 語言中,io.Reader 和 io.Writer 是兩個至關重要的接口,它們爲處理輸入輸出操作提供了強大且靈活的抽象。本文將深入探討這兩個接口的機制、常見用例、潛在陷阱以及一些高級應用,幫助你更好地掌握 Go 語言的 I/O 操作。io.Reader 接口:數據讀取的基礎———————-io.Reader 接口定義了讀取數據的通用方法:type Reader ⌘ Read more
Hot chips: The split that sparked a $97 billion meltdown
It is an industry crucial to the 21st century but two of its biggest players are going in opposite directions. ⌘ Read more
** Sleepy garden beds **
This afternoon I put the garden to sleep for the fall; in the past we’ve had some fall and winter vegetables going, but this year that didn’t happen, so, I emptied out the rain barrels, cleaned them out, trundled them to a place where they wouldn’t get blown around by any winds, mulched some of the beds, weeded and generally plotzed around like a garden goblin.
I’ve fallen into the habit of making a big thing of rice over the weekend — I always intend to do something with this rice, but instead I use it for s … ⌘ Read more
Police Reports Written by AI… Seriously.
A police report written by ChatGPT? What could possibly go wrong?! ⌘ Read more
Go 中祕而不宣的數據結構 spmc- 10 倍性能於 channel
Go 標準庫和運行中中,有一些專門針對特定場景優化的數據結構,這些數據結構並沒有暴露出來,這個系列就是逐一介紹這些數據結構。這一次給大家介紹的就是一個 lock-free、高性能的單生產者多消費者的隊列:PoolDequeue 和 PoolChain。 到底是一個還是兩個呢? 主要是 PoolDequeue, 它是一個固定尺寸,使用 ringbuffer (環形隊列) 方式實現的隊列。PoolCh ⌘ Read more
Sam Whited: Coffeeneuring 2024
Every year in October I participate in Love To Ride’s (psst, sign up using
that link so I can get some extra points when you do your first bike ride!)
Biketober competition.
The TL;DR is that for every day that you go for a ride, for every mile that you
ride, and for every new rider that you invite you get points for your team.
At the end of the month winners are announced and there are some fun prizes.
It’s not about bi … ⌘ Read more
深入理解 Go 語言的棧
本期深入研究 Go 堆棧的工作原理以及作爲程序員爲什麼要關心它。本篇內容是根據 2023 年 3 月份#288 A deep dive into Go’s stack[1] 音頻錄製內容的整理與翻譯過程中爲符合中文慣用表達有適當刪改, 版權歸原作者所有. Mat Ryer: 大家好,歡迎收聽 Go Time。我是 Mat Ryer[2]。今天我們要討論的是 Go 的棧。究竟什麼是棧?它的作用 ⌘ Read more
溫故知新——Golang GMP 萬字洗髓經
0 前言—-我在 23 年初曾發佈過一篇——golang gmp 原理解析,當時剛開始接觸 go 底層源碼,視野廣度和理解深度都有所不足,對一些核心環節的思考和挖掘有所欠缺,對其中某些局部細節又過分拘泥,整體內容質量上還是有所不足.隨着近期嘗試接觸了 golang 以外的語言,通過橫向對比後,對於 golang 中 gmp 的精妙設計也產生了一些新的感悟. 於是就藉着這個契機開啓一個重置篇,對 ⌘ Read more
Monero Tech meeting scheduled for 21 October 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, October 21 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:
Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.
This meeting’s chai … ⌘ Read more
深入理解 go unsafe
Go 是支持指針的語言,但是爲了保持簡潔、安全,Go 的指針有很多限制,但是一些場景又需要繞過這些安全限制,因此提供了 unsafe 包,unsafe 可以繞過:指針運算、不同的指針類型不能轉換、任意類型指針等限制,進而可以實現更高級的功能。下面通過對比可以更直觀的瞭解 unsafe 的特點:支持指針運算——Go 的指針是不支持指針運算的,指針運算在直接操作內存有很大作用,例如:通過指針運 ⌘ Read more
揭祕 Go 併發利器 WaitGroup
在 Go 語言的併發編程世界中,WaitGroup 是一個至關重要的工具,它爲開發者提供了一種簡單而有效的方式來管理和同步多個協程的執行。本文將深入揭祕 WaitGroup 的實現原理、注意事項、使用示例。什麼是 WaitGroup————-WaitGroup 是 Go 標準庫中 sync 包提供的一種同步原語,用於等待一組(可能是併發的)操作完成。它的主要作用是讓主協程(即調用 ⌘ Read more
7 個實用技巧幫助你更好地玩轉 Go Structs
在本文中,我們將探討使用結構體的 7 個技巧,掌握它們能夠幫助開發者寫出更高效、更可維護的 Go 代碼。Go 中的結構體是一種複合數據類型,它將變量集中在一個名稱下。它們是許多 Go 程序的支柱,是創建複雜數據結構和實現面向對象設計模式的基礎。但結構體的功能遠不止簡單的數據分組。1. EmbeddingEmbedding 是 Go 的一項強大功能,它允許將一個結構包含在另一個結構中,提供了一種合成 ⌘ Read more
golang 是如何防範 SQL 注入、CSRF、XSS 攻擊 的
在 Go 語言的 Web 開發中,常見的安全問題包括 SQL 注入、CSRF(跨站請求僞造)、和 XSS(跨站腳本攻擊)。Go 提供了多種機制與工具庫來防範這些攻擊。以下是針對每種攻擊的防範措施:防範 SQL 注入————SQL 注入 是一種通過修改 SQL 查詢的輸入,使攻擊者能夠執行未授權 SQL 語句的攻擊手段。防範 SQL 注入的關鍵是避免直接拼接 SQL 字符串,而是使用 ⌘ Read more
Web interface is deleted in https://git.mills.io/saltyim/saltyim/commit/376de2702319686c902ec03b8ca1e17b020fc639 but seems incorrectly (in source i see git lfs metadata). Can be builded if you grab https://git.mills.io/saltyim/saltyim/src/commit/15a64de82829/internal/web/app.wasm and place it in source (go directory has cached source) and rebuild
Go 語言中的 os-Stat– 與 os-Lstat–
文件操作是系統編程中至關重要的一部分,而 Go 語言提供了通過其 os 包訪問文件元數據的直觀方法。兩個常用的函數,os.Stat() 和 os.Lstat(),允許您收集有關文件和符號鏈接的信息,但它們的作用不同。本文將解釋這兩個函數之間的關鍵區別,說明它們的實際應用,並深入探討一些高級注意事項,例如錯誤處理和性能。Go 中的文件信息———Go 語言中的 os.FileInfo 接口 ⌘ Read more
Apple Card High-Yield Savings Account Getting Yet Another Interest Rate Cut
Apple is once again planning to cut the interest rate of its Apple Card high-yield savings account, with the new rate set to go live on Friday, October 11.
The Apple Card savings account’s annual percentage yield (APR) will drop to 4.10 percent, down from 4.25 percent. This is the … ⌘ Read more
在兩個大文件中找出相同的記錄,用 golang 如何寫?
在 Go 語言中找出兩個大文件中相同的記錄,可以採用以下策略:思路讀文件:按行逐行讀取兩個文件中的記錄,假設每個文件的每一行代表一條記錄。 使用哈希集合(Set):因爲哈希集合能夠快速判斷某個記錄是否存在,所以我們可以將第一個文件中的記錄放入集合中,之後讀取第二個文件時逐行判斷該記錄是否也存在於集合中。如果存在則是相同的記錄。 性能優化: 如果文件非常大,避免一次性全部加載到內存 ⌘ Read more
Honestly… not much. Have abandon two projects (both private) on Golang and one related to cryptography. My mostly languages are Python and Javascript (also can PHP). After writing code on Go i spend same time on fixing dumb errors
New repository: aquilax/slide2marpit - Go preset slide to marpit markdown converter
什麼是 WebSocket?Go_WebSocket 編程來了!
爲什麼要有 WebSocket?—————-已經有了 HTTP 了爲什麼還要有 WebSocket 呢?因爲,HTTP 的請求只能由客戶端發起,服務器接收。但是,現在想要讓服務器端也可以主動發起請求。那麼使用 HTTP 是無法滿足的。其次,還有一種就是,如果想要監聽服務端發送的請求。那麼,可以讓客戶端始終處於一種輪詢狀態。客戶端每隔一段就發起一個詢問,看一下服務端有沒有請求信息 ⌘ Read more
MacBook Pro With M4 Chip May Support Up to Two External Displays
Apple’s upcoming entry-level M4 14-inch MacBook Pro may be capable of supporting up to two external displays, up from one display supported in the current M3 model, if recent leaks are anything to go by.
Apple’s existing M3 14-inch MacBook Pro comes with two Thunderbolt 3 USB-C ports, not three Thunderbolt 4 … ⌘ Read more
GNOME Foundation Broke, Lays Off 33% of Staff
Just as The Lunduke Journal said was going to happen after the GNOME Shaman disaster. ⌘ Read more
Monero Tech meeting scheduled for 14 October 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, October 14 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:
Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.
This meeting’s chai … ⌘ Read more
@3r1c@3r1c.net I think I’m gonna like that blog. 😅 https://unixdigest.com/articles/is-the-madness-ever-going-to-end.html
Same! Great joke!
Same! Great joke!
Spotify Launches Offline Backup Feature for Premium Users
Spotify has announced a new feature called Offline Backup, designed to give Premium subscribers an additional way to listen to music offline without manually downloading playlists. Rolling out globally this week, the feature aims to address situations where users find themselves without an internet connection and haven’t … ⌘ Read more
I share I did write up an algorithm for it at some point I think it is lost in a git comment someplace. I’ll put together a pseudo/go code this week.
Super simple:
Making a reply:
- If yarn has one use that. (Maybe do collision check?)
- Make hash of twt raw no truncation.
- Check local cache for shortest without collision
- in SQL:
select len(subject) where head_full_hash like subject || '%'
- in SQL:
Threading:
- Get full hash of head twt
- Search for twts
- in SQL:
head_full_hash like subject || '%' and created_on > head_timestamp
- in SQL:
The assumption being replies will be for the most recent head. If replying to an older one it will use a longer hash.
I share I did write up an algorithm for it at some point I think it is lost in a git comment someplace. I’ll put together a pseudo/go code this week.
Super simple:
Making a reply:
- If yarn has one use that. (Maybe do collision check?)
- Make hash of twt raw no truncation.
- Check local cache for shortest without collision
- in SQL:
select len(subject) where head_full_hash like subject || '%'
- in SQL:
Threading:
- Get full hash of head twt
- Search for twts
- in SQL:
head_full_hash like subject || '%' and created_on > head_timestamp
- in SQL:
The assumption being replies will be for the most recent head. If replying to an older one it will use a longer hash.
@prologic@twtxt.net I wanted to wait for things to settle down. It’s still unclear to me in which direction we’re going – and if that new/different stuff is even possible to implement in jenny. That said, I’ve been really busy with private stuff these last few days, I’ve lost track of most of what you’re discussing. 🥴
If we stuck with Blake2b for Twt Hash(es); what do we think we need to reasonably go to in bit length/size?
=> https://gist.mills.io/prologic/194993e7db04498fa0e8d00a528f7be6
e.g: (turns out @xuu@txt.sour.is is right about Blak2b being easy/simple too!):
$ printf "%s\t%s\t%s" "https://example.com/twtxt.txt" "2024-09-29T13:30:00Z" "Hello World!" | b2sum -l 32 -t | awk '{ print $1 }'
7b8b79dd
@prologic@twtxt.net Regarding the new way of generating twt-hashes, to me it makes more sense to use tabs as separator instead of spaces, since the you can just copy/past a line directly from a twtxt-file that already go a tab between timestamp and message. But tabs might be hard to “type” when you are in a terminal, since it will activate autocomplete…🤔
Another thing, it seems that you sugget we only use the domain in the hash-creation and not the full path to the twtxt.txt
$ echo -e "https://example.com 2024-09-29T13:30:00Z Hello World!" | sha256sum - | awk '{ print $1 }' | base64 | head -c 12
RavenTree:輕量級的 Go HTTP 請求庫,內置重試機制和錯誤處理
RavenTree 是一個輕量級的 Go 庫,旨在通過提供易於使用的接口、內置對各種 HTTP 方法的支持、接受重試處理等功能來簡化 HTTP 請求。它爲開發者提供了一種高效便捷的方式與網絡服務進行交互。RavenTree 的核心功能—————易於使用的接口: RavenTree 提供了一個簡單直觀的 API,可以方便地創建和發送 HTTP 請求。 內置支持各種 HTT ⌘ Read more
Golang 中你應該知道的 noCopy 策略
在 Go 開發中,我們經常遇到 noCopy 這種結構體,並伴隨一個常見的註釋 “must not be copied after first use”。本文將深入探討 noCopy 的作用,以及 Go Vet 如何幫助我們避免潛在的錯誤。sync.noCopy 的作用—————–sync.noCopy 結構體通常與 sync.WaitGroup 等同步原語一起出現,例如:t ⌘ Read more
@anth@a.9srv.net you wrote:
“Edits and Deletions should go; see also Section 6. This is probably the worst example of this document pushing a text document to do more protocol-like things.”
Edit and deletions are precisely what brought us here. Currently, if one replies to a twtxt, and the original gets later edited, it breaks replies, and potentially drastically changes context.
Go 語言與 SQL 數據庫的交互方式
Go 語言作爲一門簡潔高效的語言,在與關係型數據庫交互方面也擁有着豐富的選擇。本文將深入探討 Go 語言中幾種常見的與 SQL 數據庫交互方式,並通過示例代碼、優缺點分析和擴展知識點,幫助你更好地理解和選擇適合你的方案。Go 語言與 SQL 數據庫交互的常見方式———————Go 語言標準庫提供了database/sql包,它是一個基礎的 SQL 數據庫驅動接口,爲各種 ⌘ Read more
Golang 實用技巧:使用 go-nanoid 高效生成唯一隨機 ID
作爲一名程序員,我們經常會遇到需要生成唯一標識符(ID)的場景。不管是創建用戶 ID、訂單號還是其他需要唯一性的數據,生成隨機且唯一的 ID 是保證系統健壯性的基礎之一。在 Go 語言中,有很多方法可以實現這一功能,今天我想和大家聊聊如何使用 go-nanoid 這個庫來生成隨機的唯一 ID。go-nanoid 是一個 Go 語言庫,用來高效地生成唯一的隨機 ID(類似於 UUID),並且生成的 ⌘ Read more
Starting a couple of new projects (geez where do I find the time?!):
HomeTunnel:
HomeTunnel is a self-hosted solution that combines secure tunneling, proxying, and automation to create your own private cloud. Utilizing Wireguard for VPN, Caddy for reverse proxying, and Traefik for service routing, HomeTunnel allows you to securely expose your home network services (such as Gitea, Poste.io, etc.) to the Internet. With seamless automation and on-demand TLS, HomeTunnel gives you the power to manage your own cloud-like environment with the control and privacy of self-hosting.
CraneOps:
craneops is an open-source operator framework, written in Go, that allows self-hosters to automate the deployment and management of infrastructure and applications. Inspired by Kubernetes operators, CraneOps uses declarative YAML Custom Resource Definitions (CRDs) to manage Docker Swarm deployments on Proxmox VE clusters.
And finally the legibility of feeds when viewing them in their raw form are worsened as you go from a Twt Subject of (#abcdefg12345) to something like (https://twtxt.net/user/prologic/twtxt.txt 2024-09-22T07:51:16Z).
There is also a ~5x increase cost in memory utilization for any implementations or implementors that use or wish to use in-memory storage (yarnd does for example) and equally a 5x increase in on-disk storage as well. This is based on the Twt Hash going from a 13 bytes (content-addressing) to 63 bytes (on average for location-based addressing). There is roughly a ~20-150% increase in the size of individual feeds as well that needs to be taken into consideration (on the average case).
So really your argument is just that switching to a location-based addressing “just makes sense”. Why? Without concrete pros/cons of each approach this isn’t really a strong argument I’m afraid. In fact I probably need to just sit down and detail the properties of both approaches and the pros/cons of both.
I also don’t really buy the argument of simplicity either personally, because I don’t technically see it much more difficult to take a echo -e "<url>\t<timestamp>\t<content>" | sha256sum | base64 as the Twt Subject or concatenating the <url> <timestamp> – The “effort” is the same. If we’re going to argue that SHA256 or cryptographic hashes are “too complicated” then I’m not really sure how to support that argument.
Gorm 自定義數據類型
在處理數據庫交互時,我們經常會遇到將數據在 Go 結構體和數據庫關係之間來回轉換的需求。今天,我們將深入探討 Gorm 中的自定義數據類型,這是一種強大的工具,可以幫助我們實現靈活的數據映射和自定義邏輯。使用場景:處理軍官等級———–爲了更好地理解自定義數據類型的用途,我們以一個現實的例子來說明:構建一個軟件來存儲和讀取美軍軍官的等級信息。這個例子中,我們定義了兩個結構體:Go 結構 ⌘ Read more
Go 語言併發編程之互斥鎖 sync-Mutex
大家好,我是 frank。「Golang 語言開發棧」公衆號作者。01 介紹Go 標準庫 sync 提供互斥鎖 Mutex。它的零值是未鎖定的 Mutex,即未被任何 goroutine 所持有,它在被首次使用後,不可以複製。我們可以使用 Mutex 限定同一時間只允許一個 goroutine 訪問和修改臨界區。02 使用在介紹怎麼使用 Mutex 之前,我們先閱讀 sync.Mutex 源碼 ⌘ Read more
👋 Reminder folks of the upcoming Yarn.social monthly online meetup:
I hope to see @david@collantes.us @movq@www.uninformativ.de @lyse@lyse.isobeef.org @xuu@txt.sour.is @sorenpeter@darch.dk and hopefully others too @aelaraji@aelaraji.com @falsifian@www.falsifian.org and anyone else that sees this! 🙏 We’re hopefully going to primarily discuss the future of Twtxt and the last few weeks of discussions 🤣
- Event: Yarn.social Online Meetup
- When: 28th September 2024 at 12:00pm UTC (midday)
- Where: Mills Meet : Yarn.social
- Cadence: 4th Saturday of every Month
Agenda:
- Let’s talk about the upcoming changes to the Twtxt spec(s)
- See #xgghhnq
- See #xgghhnq
Alright, before I go and watch Formula 1 😅, I made two PRs regarding the two “competing” ideas:
- https://git.mills.io/yarnsocial/yarn/pulls/1179 –
(replyto:…)
- https://git.mills.io/yarnsocial/yarn/pulls/1180 –
(edit:…)and(delete:…)
As a first step, this summarizes my current understanding. Please comment! 😊
🚀 Marvel movies and holiday cheer kept the crew going! 🎥🎄 ⌘ Read more
@lyse@lyse.isobeef.org yeah, tell us, @prologic@twtxt.net, what isn’t true? 🤔 You can’t just go around, “that’s not true, and that’s not true; and that, and that!” without spelling out exactly what isn’t, and why? For the love of god, why?! 😂
Halfbrick+ Lets You Play Popular iOS Games Like Fruit Ninja, Jetpack Joyride and Mega Jump for $2.99/Month
Halfbrick Studios is a game company best known for super popular iOS titles like Fruit Ninja and Jetpack Joyride, which have historically been freemium titles. Starting last year, Halfbrick decided to go with a different monetization model, offering all of its games for a low monthly fee.
[Halfb … ⌘ Read more
@prologic@twtxt.net cool, I will be there! Are you going to post the regular banner notice? It will serve as a reminder, at least for me.
go:embed 在 Go 開發中的應用與最佳實踐
背景–在使用 Go 開發命令行工具或桌面軟件時,將配置文件、模板,甚至整個前端應用直接嵌入到 Go 二進制文件中是一種提高應用部署效率和簡化操作的有效方法。這種方法可以減少外部依賴,讓應用在沒有額外資源文件的情況下也能獨立運行,特別適合需要便捷分發和部署的場景。自 Go 1.16 版本起,Go 語言官方引入了 //go:embed 指令,使得嵌入靜態資源變得異常簡單而直接。這一新特性大大簡化了 ⌘ Read more
基於反射的輕量級 Go 依賴注入框架
在軟件開發領域,依賴注入(DI)是一種強大的設計模式,它可以幫助我們編寫鬆散耦合、易於測試和維護的代碼。雖然在 Go 語言中,依賴注入的使用不如其他語言(如 Java 或 C#)那麼普遍,但在構建大型、複雜的應用程序時,它仍然可以發揮重要作用。Parsley 就是爲此而生的。它是一個易於使用、基於反射的 Go 依賴注入包,可以無縫地集成到任何 Go 應用程序中。Parsley——-Pars ⌘ Read more
構建 Go RESTful API 的終極指南:Fiber、GORM 和 PostgreSQL
本文將帶你一步步構建一個基於 Go、Fiber 和 GORM 的 RESTful API,並使用 PostgreSQL 作爲數據庫。我們將涵蓋從項目搭建、數據庫配置到 API 路由、認證、授權、錯誤處理等關鍵環節,並附有完整代碼示例和詳細解釋,幫助你快速上手 Go RESTful API 開發。項目搭建—-首先,我們需要創建一個新的 Go 項目並安裝必要的依賴包。 初始化 Go 模塊go mo ⌘ Read more
I wrote some code to try out non-hash reply subjects formatted as (replyto ), while keeping the ability to use the existing hash style.
I don’t think we need to decide all at once. If clients add support for a new method then people can use it if they like. The downside of course is that this costs developer time, so I decided to invest a few hours of my own time into a proof of concept.
With apologies to @movq@www.uninformativ.de for corrupting jenny’s beautiful code. I don’t write this expecting you to incorporate the patch, because it does complicate things and might not be a direction you want to go in. But if you like any part of this approach feel free to use bits of it; I release the patch under jenny’s current LICENCE.
Supporting both kinds of reply in jenny was complicated because each email can only have one Message-Id, and because it’s possible the target twt will not be seen until after the twt referencing it. The following patch uses an sqlite database to keep track of known (url, timestamp) pairs, as well as a separate table of (url, timestamp) pairs that haven’t been seen yet but are wanted. When one of those “wanted” twts is finally seen, the mail file gets rewritten to include the appropriate In-Reply-To header.
Patch based on jenny commit 73a5ea81.
https://www.falsifian.org/a/oDtr/patch0.txt
Not implemented:
- Composing twts using the (replyto …) format.
- Probably other important things I’m forgetting.
Oracle, Microsoft, BlackRock Building Dystopian AI Future
Oracle CEO, Larry Ellison: “Citizens will be on their best behavior because we are constantly recording and reporting everything that’s going on.” ⌘ Read more
@eldersnake@we.loveprivacy.club I wanted to ask you, are you running Headscale and WireGuard on the same VPS? I want to test Headscale, but currently run a small container with WireGuard, and I wonder if I need to stop (and eventually get rid of) the container to get Headscale going. Did you use the provided .deb to install Headscale, or some other method?
@eldersnake@we.loveprivacy.club there has to be less reliance on a single point of failure. It is not so much about creating jobs in the US (which come with it, anyway), but about the ability to produce what’s needed at home too. What’s the trade off? Is it going to be a little bit more expensive to manufacture, perhaps?
Golang 實現 IP 地址掃描
你是否想過哪些設備連接到了家裏的 Wi-Fi 網絡?無論是出於安全目的還是單純的好奇心,我們都可以去了解一下家庭網絡中的設備情況。在本文中,我們將介紹如何使用 Go 構建一個簡單的 IP 地址掃描器,它可以掃描家庭網絡並列出所有活動設備。爲什麼要構建 Ip scanner市面上有很多網絡掃描工具,但自己構建網絡掃描工具能讓我們靈活地理解和修改代碼,以滿足需求。此外,這還是學習 Go 網絡編程的好方 ⌘ Read more
如何用 Go 來構建 LLM 應用
隨着大型語言模型(LLM)及其相關工具(如嵌入模型)在過去一年中能力顯著提升,越來越多的開發者考慮將 LLM 集成到他們的應用程序中。由於 LLM 通常需要專用硬件和大量計算資源,它們通常作爲網絡服務打包,提供 API 供訪問。這就是 OpenAI 和 Google Gemini 等領先 LLM 的 API 工作方式;即使是像 Ollama 這樣的自託管 LLM 工具,也將 LLM 封裝在 RES ⌘ Read more
Golang 使用 upx 減少可執行文件的大小
衆所周知,Golang 的編譯速度是非常之快的。在設計 Go 時,編譯速度是一個重要的考慮因素。但是,你是否關注過 Go 編譯代碼後生成的二進制可執行文件的大小?讓我們來看一個簡單的 HTTP 服務的應用示例:import ( ”fmt” ”net/http” ) func main() { // create a http server and creat ⌘ Read more
I have configured my twtxt.txt as simple as possible. I have setup a publish_command on jenny. Hopefully all works fine, and I am good to go. Next will be setting the announce_me to true. Here we go!
@movq@www.uninformativ.de going a little sideways on this, “*If twtxt/Yarn was to grow bigger, then this would become a concern again. But even Mastodon allows editing, so how much of a problem can it really be? 😅*”, wouldn’t it preparing for a potential (even if very, very, veeeeery remote) growth be a good thing? Mastodon signs all messages, keeps a history of edits, and it doesn’t break threads. It isn’t a problem there.😉 It is here.
I think keeping hashes is a must. If anything for that “feels good” feeling.
Hey, @movq@www.uninformativ.de, a tiny thing to add to jenny, a -v switch. That way when you twtxt “That’s an older format that was used before jenny version v23.04”, I can go and run jenny -v, and “duh!” myself on the way to a git pull. :-D
Regarding jenny development: There have been enough changes in the last few weeks, imo. I want to let things settle for a while (potential bugfixes aside) and then I’m going to cut a new release.
And I guess the release after that is going to include all the threading/hashing stuff – if we can decide on one of the proposals. 😂
@prologic@twtxt.net the real conclusion is, is it going to change, to what, and when? :-P
Go 開發人員開發 WebRTC 的福音
Pion 是 WebRTC API 的純 Golang 實現。開發 WebRTC 應用可以使用該庫,提高開發效率。你可以使用 Pion 去創造一些很棒的東西,以下是一些可以讓你創意源源不斷的想法:發送一個視頻文件到多個瀏覽器,以實現完美同步的電影觀看。 將嵌入式設備上的網絡攝像頭內容發送到瀏覽器,無需額外的服務器。 不需要訂閱發佈,就可以在兩臺服務器之間安全地發送數據。 ⌘ Read more
GVM: Golang 多版本管理利器
本文介紹了 Go Version Manager 的功能和使用方法,介紹瞭如何通過 GVM 在系統上安裝和管理多個 Go 語言版本。原文: GVM: Go Version Manager, for Golang manage multiple versions[1]Go 版本管理器(GVM,Go Version Manager)是一款功能強大的工具,旨在簡化系統中 Go 編程語言不同版本的管理 ⌘ Read more
Go 語言 API 文檔利器:絲襪哥(Swagger)保姆級使用指南大揭祕!
咱們都知道在 API 開發中,文檔是必不可少的一環。swaggo/swag 是一個用於 Go 語言的自動化生成 API 文檔的工具,它可以將代碼註釋轉換爲 Swagger 文檔,方便開發者和用戶理解 API 的使用方法。本文將詳細介紹 swaggo/swag 的使用方式以及它的特性。1. 安裝 Swaggo/Swag先在你的 Go 項目中安裝 swag 命令行工具和 gin-swagger 依賴: ⌘ Read more
構建由大型語言模型(LLM)驅動的 Go 應用程序
隨着過去一年大型語言模型(LLM)及其相關工具(如嵌入模型)的能力顯著增長,越來越多的開發者開始考慮將 LLM 集成到他們的應用程序中。由 於 LLM 通常需要專用硬件和大量的計算資源,它們最常見的形式是作爲提供 API 訪問的網絡服務。這就是領先的 LLM 如 OpenAI 或 Google Gemini 的 API 的工作方式;即使是運行你自己的 LLM 工具,如 Ollama[1],也會將 ⌘ Read more
Go 語言實現 systemctl 管理系統服務
在 Linux 系統中,systemd 已然成爲主流的初始化系統和服務管理器,而 systemctl 命令則是我們與之交互的橋樑。對於 Go 開發者而言,直接使用 Shell 調用 systemctl 固然可行,但難免顯得不夠優雅,並且需要編寫額外的代碼來解析命令輸出。爲解決這一問題,taigrr/systemctl 庫應運而生。它爲 Go 開發者提供了符合習慣用法的 systemctl 綁定, ⌘ Read more
Go 構建一個簡單的負載均衡器
Go–負載均衡器在現代軟件開發中至關重要。作爲開發者你肯定好奇過請求是如何在多個服務器之間分配的,或者爲什麼某些網站即使在高流量時也感覺更快,這就是負載均衡器的作用。沒有負載均衡器在這篇文章中,我們將使用 Go 語言構建一個簡單的應用程序負載均衡器,使用輪詢算法(Round Robin)。這篇文章的目的是一步步理解負載均衡器的內部工作原理。什麼是負載均衡器?負載均衡器是一個系統,它將傳入的網絡流 ⌘ Read more
main.go (but it can be done on a template now, so no reason to touch the code):
@lyse@lyse.isobeef.org fully agree. I have never been a fan of relative times to begin with, so that one will go away, foh sho! :-D
yarnd just doesn’t render the subject. Fair enough. It’s (replyto http://darch.dk/twtxt.txt 2024-09-15T12:50:17Z), and if you don’t want to go on a hunt, the twt hash is weadxga: https://twtxt.net/twt/weadxga
@aelaraji@aelaraji.com this is my change on main.go (but it can be done on a template now, so no reason to touch the code):
<time class="dt-published" datetime="{{ $twt.Created | date "2006-01-02T15:04:05Z07:00" }}">
{{ $twt.Created | date "2006-01-02 15:04:05 MST" }}
</time>
See https://ferengi.one. I am going to further customise things, but that’s a start.
@lyse@lyse.isobeef.org Sorry, I don’t think I ever had charset=utf8. I just noticed that a few days ago. OpenBSD’s httpd might not support including a parameter with the mime type, unfortunately. I’m going to look into it.
Now WTF!? Suddenly, @falsifian@www.falsifian.org’s feed renders broken in my tt Python implementation. Exactly what I had with my Go rewrite. I haven’t touched the Python stuff in ages, though. Also, tt and tt2 do not share any data at all.
By any chance, did you remove the ; charset=utf-8 from your Content-Type: text/plain header, falsifian?
@movq@www.uninformativ.de Non-ASCII characters were broken. Like U+2028, degrees (°), etc.
Turns out I used a silly library to detect the encoding and transform to UTF-8 if needed. When there is no Content-Type header, like for local files, it looks at the first 1024 bytes. Since it only saw ASCII in that region, the damn thing assumed the data to be in Windows-1252 (which for web pages kinda makes sense):
// TODO: change default depending on user's locale?
return charmap.Windows1252, "windows-1252", false
https://cs.opensource.google/go/x/net/+/master:html/charset/charset.go;l=102
This default is hardcoded and cannot be changed.
Trying to be smart and adding automatic support for other encodings turned out to be a bad move on my end. At least I can reduce my dependency list again. :-)
I now just reject everything that explicitly specifies something different than text/plain and an optional charset other than utf-8 (ignoring casing). Otherwise I assume it’s in UTF-8 (just like the twtxt file format specification mandates) and hope for the best.
Hmmmm, I somehow run into an encoding problem where my inserted data end up mangled in the database. But, both SQLite and Go use UTF-8. What’s happening here? :-?
@movq@www.uninformativ.de I did the same. jenny fetches archives, yes, but that twtxt I am referring about is no longer. If you fetch it, but I don’t, there is certainly something going on…
@movq@www.uninformativ.de I figured it will be something like this, yet, you were able to reply just fine, and I wasn’t. Looking at your twtxt.txt I see this line:
2024-09-16T17:37:14+00:00 (#o6dsrga) @<prologic https://twtxt.net/user/prologic/twtxt.txt>
@<quark https://ferengi.one/twtxt.txt> This is what I get. 🤔
Which is using the right hash. Mine, on the other hand, when I replied to the original, old style message (Message-Id: <o6dsrga>), looks like this:
2024-09-16T16:42:27+00:00 (#o) @<prologic https://twtxt.net/user/prologic/twtxt.txt> this was your first twtxt. Cool! :-P
What did you do to make yours work? I simply went to the oldest @prologic@twtxt.net’s entry on my Maildir, and replied to it (jenny set the reply-to hash to #o, even though the Message-Id is o6dsrga). Since jenny can’t fetch archived twtxts, how could I go to re-fetch everything? And, most importantly, would re-fetching fix the Message-Id:?
@prologic@twtxt.net I am going to light some candles this weekend to “La Virgen de Macarena” to make it happen! :-D
Apple Releases tvOS 18 With InSight, New Screen Savers and More
Apple today released tvOS 18, the newest version of the tvOS operating system that runs on the Apple TV 4K and Apple TV HD models.
tvOS 18 can be downloaded using the Settings app on the Apple TV. Open up Settings and go to System > Software Update to get the new software. Apple TV owners who have automatic softwa … ⌘ Read more
Something odd just happened to my twtxt timeline… A bunch of twts dissapered, others were marked to be deleted in mutt. so I nuked my whole twtxt Maildir and deleted my ~/.cache/jenny in order to start with a fresh Pull. I pulled feed as usual. Now like HALF the twts aren’t there 😂 even my my last replay. WTF IS GOING ON? 🤣🤣🤣
If we’re going to ban kids off social, what on earth will they do outside?
Banning access to social media for young people is an honourable idea, but we need to make sure they have other things to do instead. ⌘ Read more
使用 Go 語言生成樣式美觀的 PDF 文件
在當今數字化時代,PDF 已成爲一種不可或缺的文檔格式,它能夠在各種平臺上保持一致的顯示效果。然而,使用傳統的編程語言生成 PDF 文件往往是一項繁瑣而複雜的任務。Maroto 的出現爲 Go 語言開發者帶來了福音,它提供了一種簡潔優雅的方式來創建結構清晰、樣式美觀的 PDF 文檔。Maroto 簡介———Maroto 是一個基於 Go 語言的 PDF 生成庫,其靈感來源於 Boots ⌘ Read more
探索 Goja: 一個 Golang JavaScript 運行時
本文探討了 Golang 生態系統中的 JavaScript 運行時庫 Goja[1] 。Goja 作爲一個在 Go 應用程序中嵌入 JavaScript 的強大工具脫穎而出, 在操作數據和提供無需 go build 步驟的 SDK 方面具有獨特優勢。背景: 爲什麼需要 Goja在我的項目中, 在查詢和操作大型數據集時遇到了挑戰。最初, 所有內容都是用 Go 編寫的, 這很高效, 但在處理複雜的 ⌘ Read more
開源免費定時任務管理系統 Gocron
概覽–Gocron 是一個開源免費的定時任務管理系統。它使用 Go 語言開發,是一個輕量級定時任務集中調度和管理系統,用於替代 Linux-crontab,旨在爲開發者及運維人員提供一個高效、輕量級且用戶友好的任務調度解決方案。作爲 Linux-crontab 的現代化替代品,Gocron 不僅繼承了傳統定時任務管理的靈活性,還融入了強大的 Web 界面管理功能,使得任務配置、監控與維護變得前所 ⌘ Read more
Go1-23 新特性:再開後門,可以記錄未捕獲的 panic 和 throw 日誌了!
大家好,我是煎魚。今天繼續給大家分享 Go1.23 的新特性,這一輪裏還是有不小有意思的驚喜的。其中不得不評本文中的這個新變化。必須得來一篇獨立話題來提一下這個事!過去學習寫 Go 時,初學者入門的教程教一定會提到在使用 panic 時,強烈建議要使用 recover。否則在 goroutine 的場景下很容易出問題,也會導致記不來日誌。新版本後,終於有兜底 Go 程序崩潰的日誌記錄方法了!過於感 ⌘ Read more
Summer, going too fast. :(
Things to do in Salt Lake City
With KubeCon + CloudNativeCon North America 2024 just a few months away we thought it would be fun to ask our ambassadors and other locals about where to go and what to do while we’re all in Salt… ⌘ Read more