iPhone 16 Pro Max to Feature New 48MP Wide and Ultra Wide Cameras
Apple’s iPhone 16 Pro Max will boast a bigger main camera sensor while both iPhone 16 Pro models will feature a 48-megapixel Ultra Wide camera for the first time, claims a rumor coming out of Asia.
According to Weibo user OvO Baby Sauce OvO, the main camera of the iPhone 16 Pro Max will be based on an advanced c … ⌘ Read more
Golang 實現枚舉的多種方式及最佳實踐
枚舉提供了一種表示一組命名常量的方式。雖然 Go 語言沒有內置的枚舉類型,但開發者可以通過常量 / 自定義類型來模擬類似枚舉的行爲。枚舉在編程語言中扮演着至關重要的角色,提供了一種簡潔而富有表現力的方式來定義一組命名常量。雖然像 Java 或 C# 這樣的語言提供了對枚舉的內置支持,但 Go 採用了不同的方法。在 Go 中,枚舉並不是一種原生的語言特性,但開發者有幾種技術可供使用,以實現類似的功能 ⌘ Read more
“Magic Clock” for Plan 9 (and p9p). http://a.9srv.net/src/img/magicclock-p9p.png http://a.9srv.net/src/magicclock.c (man and other info at http://a.9srv.net/src/).
I’ve been out a few hours again. I came across a dozen or so forest mice. I heard tons of squeaking and saw a lighting fast moving seething mass under leaves and groves. It was impossible to capture anything but I could watch it for two, three minutes. They even seemed to come as close as 20 centimeters judging by the rustle and moving plant leaves. Pretty cool.
But heaps of people had to fire up their noise machines today. That clouded my overall joy in nature. Once a commercial airliner was about to fade away in the distance, the next one already adumbrated itself. Lots of prop planes and even a helicopter. Obnoxious loud super cars and motorcycles with broken off mufflers or I don’t know what. My felt hat amplifies the sound I noted.
Luckily, the sun hid behind the clouds most of the time, so I survived the 25°C. Even hotter tomorrow, yikes!
Use an iPad as an HDMI Display with Orion & a USB-C Capture Card
You can turn your iPad into a portable HDMI display with the help of a neat app named Orion, plus a USB-C Capture Card. How this works is really straight forward; you connect the USB-C Capture Card dongle to the iPad Pro USB-C port, then you connect your device to that dongle via HDMI, that … Read More ⌘ Read more
USB Hub & External Monitors Not Working After MacOS Sonoma 14.4 Update for Some Mac Users
Some Mac users are discovering that USB-C hubs and external monitors are no longer working with their Mac after updating to macOS Sonoma 14.4. This issue can apparently impact anything connected to the USB Hub as well, leaving the USB hub devices undetected by the Mac, including keyboards, mice, external displays, SD card readers, cameras, … [Read More] … ⌘ Read more
STM32MP2 MPU Series Enhances Performance with 64-bit Architecture and 1.35 TOPS NPU
Last week, STMicroelectronics unveiled the STM32MP2 series, its second-generation line of 64-bit industrial microprocessors. Designed for intelligent edge computing, this new series is tailored for a broad range of applications, including smart factories, healthcare, buildings, and infrastructure. These are ST’s first MPUs to contain a 64-bit central processing unit (CPU). In c … ⌘ Read more
Armed robbers force victim to drive to Virginia, then abandon him in Maryland
D.C. police are looking for at least three suspects connected to an armed kidnapping that spanned across the DMV this weekend. According to the Metropolitan Police Department, around 12:30 a.m. on Sunday, Feb. 25, a man arranged to meet up with someone via social media to sell some items. The victim and suspect agreed to meet at 25th Street and L … ⌘ Read more
Bowser unveils $400M plan to revitalize Downton DC
Mayor Muriel Bowser unveiled a $400 million plan Monday she hopes will help revitalize Downtown D.C. FOX 5’s Bob Barnard has the story. ⌘ Read more
Unexploded WW2 Bomb Removed From Back Yard in Plymouth
More than 100 British Army and Royal Navy personnel assisted in the removal of an unexploded 500 kg bomb from the back yard of a home in Plymouth on Friday, February 23. Footage released by Devon and Cornwall Police shows cranes lifting the bomb from the soil onto the back of a truck to be driven out of the city. The bomb was discovered on February 20, the UK’s Ministry of Defence said, c … ⌘ Read more
Bolsonaro Supporters Flood Street in Sao Paulo
Former Brazilian president Jair Bolsonaro ridiculed accusations against him of orchestrating a failed coup in front of tens of thousands of his supporters gathered in Sao Paulo on Sunday, February 25. Police are investigating if Bolsonaro incited what amounted to a failed coup after losing the 2022 election, and say he edited a draft presidential decree that would have declared a state of emergency and c … ⌘ Read more
US airman sets himself on fire outside Israeli Embassy in Washington, D.C.: The Morning Rundown, Feb. 26, 2024
A U.S. Air Force member set himself on fire outside the Israeli Embassy in Washington D.C., protesting Israel’s operations in Gaza. ⌘ Read more
Golang 泛型入門指南
Go 語言中的泛型是指一種語言特性,允許創建可以處理不同類型的函數、數據結構和接口。換句話說,泛型使得可以創建不受特定類型或數據結構限制的代碼。如果我們此前有使用 Java 或者 C++ 的經驗,那麼會很好理解。在 Go 語言引入泛型之前,開發人員必須編寫多個函數來處理不同類型的數據。這種方法通常很繁瑣,並導致代碼重複。有了泛型,開發人員可以編寫更簡潔和可重用的代碼,可以處理不同類型的數據。Go ⌘ Read more
@prologic@twtxt.net High five, I’m “generation Java” as well! 😂 There were some leftovers of C++, we used that in the computer graphics courses in Uni a lot. But pretty much anything else that involved programming was Java.
(There was nothing even remotely resembling CS in our “high school”. That school neither had the required teachers nor the equipment / PCs.)
I finished my data structures classes with C++ and the next year they changed it out with Java. When i transferred up after my assoc degree it was C++ using the counter-strike source game engine.
Video: C Programming on System 6 - Carl Update, Test Suite, Malloc Tracing ⌘ Read more
@movq@www.uninformativ.de before this century. Back when colleges taught C++ instead of Java for CS degrees.
使用 Gin 框架中的 PureJSON 發送未轉義的 JSON
當我們使用 Go 的 Gin web 框架來構建 RESTful API 時,通常會遇到返回 JSON 響應的需求。Gin 框架提供了c.JSON方法來以 JSON 格式發送回覆,同時它會對特殊字符進行轉義,比如把 < 轉換爲 \u003c。但在某些情況下,我們需要發送未轉義的 JSON 數據,這時我們就可以使用 Gin 框架中的c.PureJSON方法。在 Gin 框架中,c.PureJSON方 ⌘ Read more
Forlinx Embedded FET-D9360-C SoM Accommodates D9-Pro Processor and Up to 16GB RAM
In partnership with SemiDrive, Forlinx Embedded has introduced the FET-D9360-C System on Module (SoM), featuring the D9-Pro high-performance industrial processor. This SoM is designed for industrial applications demanding multi-display capabilities with resolutions up to 2K@60Hz. The SoM utilizes the SemiDrive D9 Pro processor, which includes six ARM Cortex-A55 high-performance cor … ⌘ Read more
Wasm on Go
本篇內容,是對極客兔兔: Go WebAssembly (Wasm) 簡明教程 [1] 的實踐與記錄,主體內容來自這篇博客,推薦閱讀原文。 是否需要搭建 wasm 環境? WebAssembly 上手 [2]如果是 C/C++,需要藉助 emcc,將 C 和 C++ 代碼編譯到 WebAssembly 和 JavaScript。在 Mac 上,brew install emscripten然後 ⌘ Read more
Golang 有必要實現 async-await 嗎?
前言 今天在某站上面看到一個大佬解釋 Golang 中的錯誤處理 err !=nil 時,直接用 Javascript 的 async/await 來解釋。async/await 語法糖在 C#, Python 和 Javascript 中是很常見的異步協程寫法,而在 Golang 中則是使用 goroutine 機制。這時習慣或者喜歡 async/await 語法糖的人可能就會有疑問:Gola ⌘ Read more
ebpf-go 初體驗
前言我們在《用 eBPF/XDP 來替代 LVS》系列、《一張圖感受真實的 TCP 狀態轉移》系列,以及《如何終結已存在的 TCP 連接?》系列文章中,均通過純 C 語言和 libbpf1 這個庫來運用 eBPF。但是很多的場景中(尤其是雲原生場景),我們出於避免重複造輪子、更快的迭代速度、運行時安全等原因,會選擇 go 語言來進行開發,ebpf-go2 這個庫就是當前最好的選擇。今天,我們就對 ⌘ Read more
原來可以這麼使用 Protobuf
*1. Protobuf 簡介1.1 Protobuf 是什麼Protocol Buffers (簡稱 Protobuf) 是 Google 公司開源的一種輕便高效的結構化數據存儲格式, 以及用於序列化和反序列化結構化數據的代碼生成器。它可以用於通訊協議和數據存儲等領域。Protobuf 是以 .proto 文件形式定義結構化數據的方式和格式。並且通過代碼生成器生成各平臺 (Java、C++、Py ⌘ Read more
Go 調用 C– 動態庫實現車牌識別
前言—–很久沒更新博客,這次正好趁着這次機會來更新一個稍微有點意思的內容,利用 C++ 中 Opencv、TensorRT 等庫編譯出動態庫供 Go 調用,再寫個簡單的 api 對上傳的車輛圖片進行車牌識別。究其原因,天下苦 Java 久矣,每次寫 JNI 去給公司 Java 後端服務調用,而我不喜歡 Java 那我每次寫好的模型動態庫就到此爲止了?白白浪費之前那麼多計算資源於心不忍,因此打 ⌘ Read more
沒想到,Go 語言垃圾回收是這樣工作的!
*1. 垃圾回收概述1.1 什麼是垃圾回收垃圾回收 (Garbage Collection,GC) 是一種自動內存管理的機制, 用於自動釋放那些不再被程序使用的內存。它的主要思想是程序在申請內存時不需要釋放, 而是由垃圾回收器在程序運行的過程中找出那些不再使用的內存並回收它們。這與 C/C++ 語言中的手動內存管理形成對比, C/C++ 程序員需要自己跟蹤內存的分配和釋放。而 Go 語言中內存的分 ⌘ Read more
Go 調用 C-C– 函數全攻略
*一、Go 語言調用 C/C++ 函數cgo 基礎及工作原理Go 語言通過 cgo 和 C 語言的 ABI(Application Binary Interface) 進行交互。cgo 會生成相應的 C 代碼, 與 Go 代碼一起編譯成可執行文件或動態庫。cgo 的工作流程主要分爲 3 步:(1) 預處理: 將 Go 源碼中的 C 代碼塊提取出來, 生成 .c 和 .h 文件(2) 編譯: 調用 ⌘ Read more
Cost-efficient $39.90 Travel Router with Dual GbE Ports and Flexible Storage Options
Recently, SeeedStudio introduced the LinkStar-H28K-0408, a compact, pocket-sized router that offers advanced connectivity options. This device is equipped with Dual Gigabit Ethernet ports for high-speed internet access and includes a versatile USB Type-C port with Power Delivery support, enhancing its usability and convenience for various applications. Differing from the LinkS … ⌘ Read more
I’m really bad at competitive programming. 🙄 For today’s #AdventOfCode puzzle, I spent an eternity trying to understand exactly what kind of bG9naWMgY2lyY3VpdAo= the puzzle input describes – I haven’t done that in well over a decade, so I made little progress. I knew right from the start that SSBoYWQgdG8gbG9vayBmb3IgY3ljbGUgbGVuZ3RocyBhbmQgdGhlbiBmaW5kIHRoZSBMQ00K. It just didn’t occur to me to just run my program on cGFydGlhbCBpbnB1dAo= and print those numbers. 🥴 I only did that after over 4 hours (including time to debug my nasty C code) and then, boom, solution …
每個 Go 程序員必犯之錯
說起每個程序員必犯的錯誤,那還得是 “循環變量” 這個錯誤了,就連 Go 的開發者都犯過這個錯誤,這個錯誤在 Go 的 FAQ 中也有提到 What happens with closures running as goroutines?[1]:func main() { var wg sync.WaitGroup values := []string{“a”, ”b”, ”c”} ⌘ Read more
Today’s Advent of Code puzzle was rather easy (luckily), so I spent the day doing two other things:
- Explore VGA a bit: How to draw pixels on DOS all by yourself without a library in graphics mode 12h?
- Explose XMS a bit: How can I use more than 640 kB / 1 MB on DOS?
Both are … quite awkward. 😬 For VGA, I’ll stick to using the Borland Graphics Interface for now. Mode 13h is great, all pixels are directly addressable – but it’s only 320x200. Mode 12h (640 x 480 with 16 colors) is pretty horrible to use with all the planes and what not.
As per this spec, I’ve written a small XMS example that uses 32 MB of memory:
https://movq.de/v/9ed329b401/xms.c
It works, but it appears the only way to make use of this memory is to copy data back and forth between conventional memory and extended memory. I don’t know how useful that is going to be. 🤔 But at least I know how it works now.
Go 語言控制協程 -goroutine- 的併發數量,有哪些好的解決方法
在使用協程併發處理某些任務時, 其併發數量往往因爲各種因素的限制不能無限的增大. 例如網絡請求、數據庫查詢等等。從運行效率角度考慮,在相關服務可以負載的前提下(限制最大併發數),儘可能高的併發。在 Go 語言中,可以使用一些方法來控制協程(goroutine)的併發數量,以防止併發過多導致資源耗盡或性能下降。以下是一些常見的方法:1. 使用信號量(Semaphore):可以使用 Go 語言中的 c ⌘ Read more
Started on a activitypub client, gtk4, c, made on OpenBSD, been quite nice learning experience so far, a bit adjustment from the usual way I do things. I have not done a project in pure c before.
Got token stuff sorted, and posting, next is getting the timeline (and gui for that etc).
@eapl.me@eapl.me I have many fond memories of Turbo pascal and Turbo C(++). They really did have a great help system. And debug tools! Its rare for language docs to be as approachable. QBasic was great. As was PHP docs when I first came into web.
It is a pleasure to work with the help system of Borland’s Turbo C++ 3.0 on DOS. The descriptions are clear and concise. There are short and simple examples. Pretty much every help page is cross-refenced and those links can be clicked.
Go 語言 CSP 編程實戰:通道通信技術
*概述通信順序進程(Communicating Sequential Processes,CSP)是一種併發編程的形式化理論,由計算機科學家 Tony Hoare 於 1978 年提出。在 Go 語言中,CSP 被廣泛應用,通過通道(Channel)實現了簡單且強大的併發模型。本文將介紹 Go 語言中的 CSP 概念,通過詳細的示例代碼和註釋,理解 CSP 的運作原理和在 Go 中的實現。1. C ⌘ Read more
Apple Black Friday Deals from Amazon Available Now
Black Friday is here, and Amazon is offering fantastic deals on a broad range of Apple products. From AirPods, AirTags, Apple Watch, iPad models, MacBook Air, and MacBook Pro, there are fantastic deals, and even more, enjoy these Black Friday discounts. AirPods Deals, from $79 Save big the 2nd generation AirPods Pro with USB-C charging, … [Read More](https://osxdaily.com/2023/11/24/apple-black-friday-deals-from-amazon-available-now/ … ⌘ Read more
Apple Black Friday Deals from Amazon Available Now
Black Friday is here, and Amazon is offering fantastic deals on a broad range of Apple products. From AirPods, AirTags, Apple Watch, iPad models, MacBook Air, and MacBook Pro, there are fantastic deals, and even more, enjoy these Black Friday discounts. AirPods Deals, from $79 Save big the 2nd generation AirPods Pro with USB-C charging, … [Read More](https://osxdaily.com/2023/11/24/apple-black-friday-deals-from-amazon-available-now/ … ⌘ Read more
Something weird is happening to the new APC UPS - it has an USB Type-C port - but it seems that the power supply is a bit wonky.
Энтони Дэниелс продал голову C-3PO со съёмок «Новой надежды» на аукционе почти за 850 тысяч долларов
А также рукоять светового меча Дарта Сидиуса.
So Youtube rea really cracking down on Ad-blockers. The new popup is a warning saying you can watch 3 videos before you can watch no more. Not sure for how long. I guess my options are a) wait for the ad-blockers to catch-up b) pay for Youtube c) Stop using Youtube.
I think I’m going with c) Stop using Youtube.
iOS 16.7.2, iPadOS 16.7.2, iOS 15.8, & iPadOS 15.8 Released for Older iPhone & iPad Models
Apple has released a series of software updates for older model iPhone and iPad devices, that have either not yet updated to iOS 17 and iPadOS 17, or are not able to run those versions of system software. The updates include important security fixes, and are therefore recommended for all users to install, especially if … [Read More](https://osxdaily.c … ⌘ Read more
ICYMI: improved C++ vulnerability coverage and CodeQL support for Lombok
The effectiveness of a static application security solution hinges on its ability to provide extensive vulnerability coverage and support for a wide range of languages and frameworks. Today, we’re highlighting two releases that’ll help you discover more vulnerabilities in your codebase, so you can ship more secure software.
The post [ICYMI: improved C++ vulnerability coverage and CodeQL support … ⌘ Read more
On my blog: Free Culture Book Club — C-Man https://john.colagioia.net/blog/2023/09/23/c-man.html #freeculture #bookclub
Video: C Programming on System 6 - VCF Midwest, Wi-Fi DA ⌘ Read more
@prologic@twtxt.net I think the API is is fine :). But to be honest - one thing that would help me is a commandline curl example on how to upload a image, I take these curl commands through a converter that makes it into libcurl c++ code which I then use :) If you could help me with such a image upload curl example then I’d appreciate it! (I’m currently missing media upload).. And having that feature would be great! :)
@prologic@twtxt.net it’ll be nice to get away from google for a while. also moved all my cloud files to proton drive (got tired of self-hosting). I want a mac too, the m2 laptop. But that will be later. but Im unsure how software development is done on it, if its easy to for example code your own stuff (c++), and also I have no idea how gui realted things are handled. but that makes it fun as well - figuring out all that stuff.
Time to dive into threading and c++. I will start with making the file/image downloader threaded, then I’ll make the timeline fetching and all that threaded as well.
I need to add multithreading to the desktop client, I have not done that before in c++ - so that’ll be fun to figure out. I need it for the fetching of the timeline so that it happens in a separate thread. That way the GUI does not freeze while fetching the timeline. Also need to add a status bar that can show what the application is working on.
So, I kinda regret installing NixOS, I had forgotten why I did not use it for c++ stuff last time. But I learned about ‘flakes’ so Im checking into that now to see if I can use that to my advantage to make it easier. So I’ll give it some more time to see if I can learn what I need to build yarn desktop client on it.
Today is nearly 18 C. snow pack is melting fast.
Improvements to CodeQL’s data flow library for C++
These changes will improve the experience for custom query authors and enable better precision in some of our standard queries. Learn how to enable them for your custom queries. ⌘ Read more
A lot of more work needs to be done, but at least now I got the basic timeline stuff done, took a good while to figure out how to solve it, but now I know. The reason why the statuses are cut short on some is because of html tags and stuff like that - c++ is a bit picky with strings and stuff like that. but I’ll get that sorted as well.
At least I can show the first screenshot. Keep in mind the GUI is not at all finished, I’m working on the basics first, implement all the features, then I work on finishing touches.
Posting from c++, fltk GUI.
So, progress is going smooth!
No I have compiled libcurl with openssl, and I fetch token already.
so next is creating three functions - one for posting, one for the login and fetching token (now I have just testing login when application starts), and the fetch the timeline. Then I need the gui.
Progressed faster in 2 hours in c++ then days with rust…
Okay, so I spent about one hour setting up cmake, fltk and libcurl for c++, got all that running now.
I still need to fix the cmake script a bit, but I have a working verison now with this.
I will now add the same curl stuff I had in rust in c++, then work on the gui and all that.
So I will drop rust, and go for c++ instead, much easier for me. Was worth a try in rust, but for now that’s not for me to be honest, I much faster and better in c++.
Im very close to making the decision to just rewrite what I have in c++ instead. I feel I would have done this much faster with that. I’ll think about it until tomorrow. I’ll probably do that anyways just to see. just start with cmake and get started with it.
Found what I needed finally.. I now created a struct with this crate:
https://crates.io/crates/arraystring
That works for what I need, damn this has been annoying to find a solution too.
I can now store the strings I need in the struct, and use that in all the functions.
Also works with the GUI callback stuff, so it solves the Issue I’ve been having.
I have now added gui elements for server url, username, password.
And functions for fetching the timeline with the supplied info.
So now I can finally start working on the timeline GUI.
It’s been in a way easier then expected, but also somethings are a bit tricky.
I could easily have done the same in c++ much faster, but the whole point here was to learn more rust.
And for that it’s been going well.
Also, I’m struggling a bit with some basic stuff, for example variables, does not work the same way as I’m used to with c++ it seems, so it’s a bit confusing, re-using variables as input to several functions does not seem to be as straight forward as I’m used too - so I need to find some more info about stuff like that.
Also the callback stuff for buttons and such is really weird to me. But I’ll stick with it.
I will try and write a small cli example project in rust, that will let you post a message on yarn through a server url. Once I have that - I will then try and write a client with GUI and all that. I have not used rust much - but I really want to learn it more. I usually stick with c++. Not sure how much time it’ll take to get started, but I’ll give it a try.
So I looked up how to do it. It did not work. I Git cloned https://github.com/dgoulet/torsocks and followed the build instructions. I tried using it and got Looking up check.torproject.org1676676356 PERROR torsocks[16470]: socks5 libc connect: Connection refused (in socks5_connect() at socks5.c:202)
On the topic of Programming Languages and Telemetry. I’m kind of curious… Do any of these programming language and their toolchains collect telemetry on their usage and effectively “spy” on your development?
- Python
- C
- C++
- Java
- C#
- Visual Basic
- Javascript
- SQL
- Assembly Language
- PHP
Exploring the Edge of the Universe with Janna Levin | Podcast Highlights ⌘ Read more
pass
on my machine:
@abucci@anthony.buc.ci So.. The issue is that its showing the password by default? Would making an alias to always include the -c help? We can probably engage Jason with a PR to enable a more hardened approach when desired. I’ve spoken to him before and is generally a pretty open to ideas.
I found this app that was created by the gopass author that does copy by default and has a tui or GUI mode https://github.com/cortex/ripasso
@kdx@kdx.re: I suggest you to try twtwt client, it’s also written in C: https://github.com/win0err/twtwt
I’d start by dumping Donatello, the D.C. And get some youngsters on that D line that can keep up.
@abucci@anthony.buc.ci did you know about the chip inside USB-C cables?
https://connectorsupplier.com/usb-type-c-what-you-need-to-know/
some groups have created their own chips that have hidden keyloggers that can phone home over network connections.
I made a thing. Its a multi password type checker. Using the PHC string format we can identify a password hashing format from the prefix $name$
and then dispatch the hashing or checking to its specific format.
I have found the issue with this very subtle bug.. the cache was returning a slice that would be mutated. The mutation involved appending an item and then sorting. because the returned slice is just a pointer+length the sort would modify the same memory.
CACHE Returned slice
original: [A B C D] [A B C D]
add: [A B C D] E [A B C D E]
sort: [E A B C] D [A B C D E]
fix found here:
https://git.mills.io/yarnsocial/yarn/pulls/1072
How The War in Ukraine Will Shape The Future with Irwin Redlener ⌘ Read more
@prologic@twtxt.net It’s called “cgod” and it isn’t written in C or Go? I want my money back…
I also like Gopher more than Gemini. The problem Gemini is trying to solve is better solved by just writing static HTML 4.01 pages.
I was just reminded of this interpreter for an APL/J-like language by Arthur Whitney, the absolute weirdest bit of C code I’ve actually gotten something out of, and thought I’d share: https://code.jsoftware.com/wiki/Essays/Incunabulum
Video: C Programming on System 6 - VCF Midwest, Wikipedia Reader, and Subterm
I attended the Vintage Computer Festival Midwest 17 and wrote two new programs. ⌘ Read more
working with c++, windows, cmake and wxwidgets reminded me on why I want to learn more rust. rust and crates makes it really easy to get up and running, crossplatform. scrapping what I did today, I’ll start over and force my self to learn rust.
@carsten@yarn.zn80.net I have the same problem, at work I work with c÷÷, c#, java, python and qt. I want to learn more rust, but its a pain to get into.
(cont.)
Just to give some context on some of the components around the code structure.. I wrote this up around an earlier version of aggregate code. This generic bit simplifies things by removing the need of the Crud functions for each aggregate.
Domain ObjectsA domain object can be used as an aggregate by adding the event.AggregateRoot
struct and finish implementing event.Aggregate. The AggregateRoot implements logic for adding events after they are either Raised by a command or Appended by the eventstore Load or service ApplyFn methods. It also tracks the uncommitted events that are saved using the eventstore Save method.
type User struct {
Identity string ```json:"identity"`
CreatedAt time.Time
event.AggregateRoot
}
// StreamID for the aggregate when stored or loaded from ES.
func (a *User) StreamID() string {
return "user-" + a.Identity
}
// ApplyEvent to the aggregate state.
func (a *User) ApplyEvent(lis ...event.Event) {
for _, e := range lis {
switch e := e.(type) {
case *UserCreated:
a.Identity = e.Identity
a.CreatedAt = e.EventMeta().CreatedDate
/* ... */
}
}
}
Events
Events are applied to the aggregate. They are defined by adding the event.Meta
and implementing the getter/setters for event.Event
type UserCreated struct {
eventMeta event.Meta
Identity string
}
func (c *UserCreated) EventMeta() (m event.Meta) {
if c != nil {
m = c.eventMeta
}
return m
}
func (c *UserCreated) SetEventMeta(m event.Meta) {
if c != nil {
c.eventMeta = m
}
}
Reading Events from EventStore
With a domain object that implements the event.Aggregate
the event store client can load events and apply them using the Load(ctx, agg)
method.
// GetUser populates an user from event store.
func (rw *User) GetUser(ctx context.Context, userID string) (*domain.User, error) {
user := &domain.User{Identity: userID}
err := rw.es.Load(ctx, user)
if err != nil {
if err != nil {
if errors.Is(err, eventstore.ErrStreamNotFound) {
return user, ErrNotFound
}
return user, err
}
return nil, err
}
return user, err
}
OnX Commands
An OnX command will validate the state of the domain object can have the command performed on it. If it can be applied it raises the event using event.Raise() Otherwise it returns an error.
// OnCreate raises an UserCreated event to create the user.
// Note: The handler will check that the user does not already exsist.
func (a *User) OnCreate(identity string) error {
event.Raise(a, &UserCreated{Identity: identity})
return nil
}
// OnScored will attempt to score a task.
// If the task is not in a Created state it will fail.
func (a *Task) OnScored(taskID string, score int64, attributes Attributes) error {
if a.State != TaskStateCreated {
return fmt.Errorf("task expected created, got %s", a.State)
}
event.Raise(a, &TaskScored{TaskID: taskID, Attributes: attributes, Score: score})
return nil
}
Crud Operations for OnX Commands
The following functions in the aggregate service can be used to perform creation and updating of aggregates. The Update function will ensure the aggregate exists, where the Create is intended for non-existent aggregates. These can probably be combined into one function.
// Create is used when the stream does not yet exist.
func (rw *User) Create(
ctx context.Context,
identity string,
fn func(*domain.User) error,
) (*domain.User, error) {
session, err := rw.GetUser(ctx, identity)
if err != nil && !errors.Is(err, ErrNotFound) {
return nil, err
}
if err = fn(session); err != nil {
return nil, err
}
_, err = rw.es.Save(ctx, session)
return session, err
}
// Update is used when the stream already exists.
func (rw *User) Update(
ctx context.Context,
identity string,
fn func(*domain.User) error,
) (*domain.User, error) {
session, err := rw.GetUser(ctx, identity)
if err != nil {
return nil, err
}
if err = fn(session); err != nil {
return nil, err
}
_, err = rw.es.Save(ctx, session)
return session, err
}
Just testing my new fancy twtwt client written in C
GitHub enables the development of functional safety applications by adding support for coding standards AUTOSAR C++ and CERT C++
GitHub is excited to announce the release of CodeQL queries that implement the standards CERT C++ and AUTOSAR C++. These queries can aid developers looking to demonstrate ISO 26262 Part 6 process compliance. ⌘ Read more
Monerotopia Presentation and Website News
Just a note that within two hours (11AM NY time), my edited Monerotopia presentation with slides and all will be premiering here on the Monero Talk channel on YouTube.
I did already do an extended commentary and explanation of my talk here on my PeerTube channel, and I might put this an the edited talk onto my YouTube channel if I feel like it. You shou … ⌘ Read more
🙰 c
second, there’s predictions. a prediction is Done when it’s made. you could add comments, explanations, models &c, but the prediction can be Done and stand there on its own. (there is a slight problem with the fact that predictions need to be updated over time, though, so there is some Piling there as well).
Annotate PDFs on Linux
This post is about a GUI tool called pdfrankestein that
fills a gap on mostly Linux machines where a powerful and easy to use
PDF annotator does not exist.
Adobe Acrobat® on Windows and Mac allow you to add text, drawings and
signatures to PDF documents. This is useful when filling forms or
marking notes to send back to someone. Such a tool with similar
capabilities and easy of use does not exist on Linux. The reason that’s
often cited is that PDF is a c … ⌘ Read more
https://traditionsofconflict.com/blog/2019/10/4/sacred-metal, and now consider computer programming (especially the terminology of wizards/gurus, programming as magic, the SICP cover &c!)
B.C. premier John Horgan all insults toward Victoria protests
Video: C Programming on System 6 - Talking to the Modem
Starting work on adding a serial module to join the console and telnet inputs, to allow calls through a modem. I got stuck for a while trying to figure out why writes to the serial port would hang the machine. ⌘ Read more
Live Streaming a Macintosh Plus
Since recording a handful of C Programming on System 6 videos, I’ve occasionally wanted to live-stream the more casual daily programming being done on my Macintosh Plus. After getting all of the pieces together, I now have a working self-hosted broadcasting setup. ⌘ Read more
Livestream brought you by Starlink
I got Starlink/Soylink and I might, might be able to do a livestream from my house.
Come see if it works here:
Livestream brought you by Starlink
I got Starlink/Soylink and I might, might be able to do a livestream from my house.
Come see if it works here:
https://videos.lukesmith.xyz/w/6HaEr5NtP61H1fZC3FdXC9
I will start sometime soon once I get things set up. I should have a chat module open now on my PeerTube instance now. ⌘ Read more
Golang《基于 MIME 协议的邮件信息解析》部分实现
Golang 邮件 golang 中邮件相关的包net/mail
net/smtp
net/textproto
mime
mime/multipart
mime/quotedprintable
基于 smtp 包的邮件发送示例,基于官方文档:
<span class="c">// Set up authentication information.</span>
<span class="n">auth</span> <span class="o">:=</span> <span class="n">smtp</span><span class="o">.</span><span class="n">PlainAuth</span><span class="p">(</span><span class="s">""</span><span class="p">,</span> <span class="s">"xxxx@qq.com"</span><span class="p">,</span> <span class="s">"xxxxx"</span><s ... ⌘ [Read more](https://gocn.vip/topics/20948)
GoCN 每日新闻 (2022-01-08)
- Go 1.17.6/1.16.13 版本发布https://groups.google.com/g/golang-announce/c/95ZD3rKn4DI/m/93cyN8F1BAAJ
- 高效的 Go 错误处理https://earthly.dev/blog/golang-errors/
- 从零实现一个 RedisClient 了解 Redis 协议https://mauricio.github.io/2022/01/07/redis-protocol.html
- Golang 简洁架构实战[https://zh … ⌘ Read more
Video: C Programming on System 6 - A New On-Disk Database Format
It’s a new year and my computer is still old. ⌘ Read more
GoCN 每日新闻 (2022-01-07)
GoCN 每日新闻 (2022-01-07)
- 用 golang 在 tor 网络上安全的私有部署共享文件服务https://github.com/R4yGM/garlicshare
- 一个极速的 golang 全栈 web 开发包https://github.com/mikestefanello/pagoda
- ch 一个 clickhouse 客户端,比 rust 和 c++ 的都快https://github.com/go-faster/ch
- 用 gosec 扫描 go 源码的漏洞[https://jcdan3.medium. … ⌘ Read more
** Forth, a tool for cultivating community **
I watch most of the recordings of the Forth2020’s Zoom chats. A topic that comes up from time to time is how to get more folks interested in Forth — especially younger folks. In my weird little corner of the internet I can say that there are certainly young folks interested in Forth!
I wonder if the issue at play is less one of interest, and more one of cross c … ⌘ Read more
[深圳] 百度 BFE 项目招聘 Go 研发工程师
团队简介百度智能负载均衡团队负责维护 BFE 开源项目,并研发负载均衡商业产品。
BFE 是基于 Go 语言的七层负载均衡系统,已经在百度内经过多年的研发,每天转发万亿级的请求。BFE 于 2019 年 7 月开源,2020 年 6 月成为 CNCF 官方项目。
除百度以外,BFE 已经被 360、用友网络、招商银行、央视网等公司或机构使用。
BFE 开源项目地址:
Go 中这么多创建 error 的方式,你真的了解它们各自的应用场景吗
大家好,我是渔夫子。今天从应用场景的角度来聊聊我对 error 的理解。
原文链接: https://mp.weixin.qq.com/s/ncEemMJ0kQayVPJrnF9aew
01 什么是 Error在 Go 中,error 是一种内建的数据类型。在 Go 中被定义为一个接口,定义如下:
<span class="c">// The error built-in interface type is the conventional interface for< ... ⌘ [Read more](https://gocn.vip/topics/20911)
Video: C Programming on System 6 - Implementing Chat
Let’s have a chat. ⌘ Read more
蚂蚁 - 可信原生技术部 - 专用编程语言设计研发 (杭州 P7-8)
工作内容- 从事云原生配置策略语言的设计研发工作,服务云原生基础设施管理场景
- 从事区块链智能合约专用编程语言的设计及研发工作,服务区块链链智能合约场景
- 深度参与开源社区项目
- 熟练掌握 rust、golang、c/c++、java、python 中的一种或多种
- 熟悉现代编程语言设计理念、技术及研发体系,熟悉编译技术�� … ⌘ Read more
高性能中文分词库 gojieba
gojieba 是什么?gojieba
是 Python 知名分词库结巴 jieba
的 Go 语言实现版本,底层分词算法由 C++ 实现,具备很高的性能; gojieba
解决了在做文本分析,文本搜索相关业务功能时的分词需求。
gojieba
支持多种分词方式:
- 全模式:把文本中所有可能的� … ⌘ Read more
Video: C Programming on System 6 - User Authentication and Telnet Negotiation
I review some recent commits covering user authentication and telnet negotiation, then write some ANSI output code and a broken function for returning a number’s ordinal string. ⌘ Read more
『新闻快讯』网上带回血都是假的么《手机搜狐网 8》
网上带回血都是假的么【老师 Q-6306172】【诚信誷√zh58 典 vip√】〔复.制.到·U·C·浏·览·器·才·能·打·开〕〔大·发·官·方·直·属·平·台) 『信.誉.平.台』『实.力.雄.厚』『大.额.无.忧』『顶.尖.计.划』【8 年无黑史】【千万人推荐】【金 - 牌-导 - 师-单 - 带,推 - 荐-顶 - 级-信 - 誉-】
假设你刚刚玩,我来教教你 假设现已玩很久了,却不稳,我来拉� … ⌘ Read more
『9 新闻资讯』真正正确的倍投 6 种方法《手机搜狐网 0》
真正正确的倍投 6 种方法【老师 Q-6306172】【诚信誷√zh58 典 vip√】〔复.制.到·U·C·浏·览·器·才·能·打·开〕〔大·发·官·方·直·属·平·台) 『信.誉.平.台』『实.力.雄.厚』『大.额.无.忧』『顶.尖.计.划』【8 年无黑史】【千万人推荐】【金 - 牌-导 - 师-单 - 带,推 - 荐-顶 - 级-信 - 誉-】
假设你刚刚玩,我来教教你 假设现已玩很久了,却不稳,�� … ⌘ Read more