THẢO LUẬN

Phân biệt 2 khái niệm Standalone Consumer và Single Consumer Group

  1. Standalone Consumer: (Uncommon)
  • Là một consumer chạy độc lập mà không thuộc về bất kỳ consumer group nào.
  • Thường sử dụng assign() để chỉ định cụ thể các partitions cần consume.
  • Không cần cơ chế group coordinator hoặc partition rebalancing
  1. Single Consumer Group:
  • Một consumer group có đúng một consumer.
  • Sử dụng subscribe() để Kafka tự động phân phối partitions trong topic (toàn bộ partitions được gán cho consumer duy nhất).
  • Vẫn có cơ chế group coordinator, nhưng không có rebalancing vì chỉ có một consumer.
0

"ngoại trừ việc không hỗ trợ hệ điều hành Windows" sài Window và lặng lẽ đi ra

0

vì vậy mới thấy được sự chênh lệch của cloudflare nhé bạn 😅

0

@caonhanqd quá dữ 👍️

0

2025 - Các bạn phải đọc docs và cài thêm thư viên Daphne thì mới triển khai được asgi mới chạy được websocket

0
thg 12 31, 2024 9:26 SA

https://dev.to/codewithshahan/how-to-write-clean-code-tips-for-developers-with-examples-25ic lấy content của người khác thì ít nhất cũng phải để lại nguồn chứ bạn

0
thg 12 30, 2024 10:13 CH

Các bác khi clone plugin zsh-autosuggestions thì clone bằng https, chứ đừng clone bằng ssh nhé:

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

0

bạn gõ câu lệnh mysql_secure_installation chưa. Nếu chưa gõ câu lệnh này rồi setup pass nhé

0

đam mê viết blog e ạ 🤣🤣

0

Uầy xịn, sao anh cân bằng được giữa việc làm ở công ty với viết blog vậy ạ, bài nào cũng chất nữa chứ

+1
thg 12 30, 2024 9:27 SA

Em chào anh ạ! Em đang học lập trình, cấu trúc code nhiều khi em vẫn không hiểu lắm. Hiện em đang muốn tải ảnh về từ webview ios. Em có tìm trên mạng đoạn code và chèn đoạn code vào ví dụ của mình. Như sau ạ: import UIKit import WebKit import Network

class ViewController: UIViewController , WKNavigationDelegate, WKDownloadDelegate{

@IBOutlet weak var webview: WKWebView! override func viewDidLoad() { super.viewDidLoad()

monitorNetwork()

} func monitorNetwork(){ let monitor = NWPathMonitor() monitor.pathUpdateHandler = { path in if path.status == .satisfied{ DispatchQueue.main.async { self.webview.navigationDelegate = self let urlString = URL(string: "http://subdomain1.mywebsite.com.vn") let request = URLRequest(url: urlString!) self.webview.load(request) } }else{ DispatchQueue.main.async { self.Alert(Message: "Thiết bị không kết nối mạng") }

    }
    
}
let queue = DispatchQueue(label: "Network")
monitor.start(queue: queue)

}

func Alert (Message: String){

let alert = UIAlertController(title: "Thông báo", message: Message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Đồng ý", style: UIAlertAction.Style.default, handler: nil))
   self.present(alert, animated: true, completion: nil)

}

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { if let url = navigationAction.request.url, navigationAction.navigationType == .linkActivated {

    if url.absoluteString.hasSuffix(".pdf") || url.absoluteString.hasSuffix(".doc") ||
        url.absoluteString.hasSuffix(".docx") || url.absoluteString.hasSuffix(".xls") ||
        url.absoluteString.hasSuffix(".xlsx") || url.absoluteString.hasSuffix(".jpg") || url.absoluteString.hasSuffix(".jpeg") || url.absoluteString.hasSuffix(".png") || url.absoluteString.hasSuffix(".ppt") || url.absoluteString.hasSuffix(".pptx") {
        
       
       // let fileURL : String = url.absoluteString;
        
      
      
        let downloadTask = URLSession.shared.downloadTask(with: url) {
            urlOrNil, responseOrNil, errorOrNil in
           // check for and handle errors:
            // * errorOrNil should be nil
            // * responseOrNil should be an HTTPURLResponse with statusCode in 200..<299
            
            guard let fileURL = urlOrNil else { return }
            do {
                let documentsURL = try
                    FileManager.default.url(for: .documentDirectory,
                                            in: .userDomainMask,
                                            appropriateFor: nil,
                                            create: false)
                let savedURL = documentsURL.appendingPathComponent(fileURL.lastPathComponent)
                try FileManager.default.moveItem(at: fileURL, to: savedURL)
            } catch {
                print ("file error: \(error)")
            }
        }
        downloadTask.resume()
        
        
      /*  URLSession.shared.downloadTask(with: url, completionHandler: { (tempURL, response, error) in
                print("finished fetching \(url.absoluteString)")
            }).resume()
       */
                
           /*     DispatchQueue.main.async {
                    let url = URL(string: fileURL)
                    let pdfData = try? Data.init(contentsOf: url!)
                    let resDocPath = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!) as URL
                    let pdfFileName = "\(UUID().uuidString).jpg"
                    let filePath = resDocPath.appendingPathComponent(pdfFileName)
                    
                    // Save to File
                    
                    do {
                        try pdfData?.write(to: filePath,options: .atomic)
                        print("File Saved")
                    } catch {
                        print("Some Error in code")
                    }
                    
                }
        */
        
        
        
        decisionHandler(.cancel)
        return
        
     
       
    }
   
   
}
decisionHandler(.allow)

}

func webView(_ webView: WKWebView, navigationResponse: WKNavigationResponse, didBecome download: WKDownload) { download.delegate = self; }

func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) { if navigationResponse.canShowMIMEType { decisionHandler(.allow) } else { decisionHandler(.download) } }

// Download Delegate (to allow downloading PDF) func download(_ download: WKDownload, decideDestinationUsing response: URLResponse, suggestedFilename: String) async -> URL? { let urls = FileManager.default.urls(for: .documentDirectory, in: .allDomainsMask) // for Japanese names. let name = suggestedFilename.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "cannotencode" return URL(string: name, relativeTo: urls[0]) }

} Code file infor.plist như sau:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<dict> <key>CFBundleGetInfoString</key> <string></string> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSAllowsArbitraryLoadsInWebContent</key> <true/> <key>NSExceptionDomains</key> <dict> <key>http://subdomain1.mywebsite.com.vn</key> <string></string> </dict> </dict> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> <key>UISceneStoryboardFile</key> <string>Main</string> </dict> </array> </dict> </dict> </dict>

Sau khi chạy hệ thống báo lỗi như sau: App Transport Security has blocked a cleartext HTTP connection to http://subdomain1.mywebsite.com.vn since it is insecure. Use HTTPS instead or add this domain to Exception Domains in your Info.plist.

Mặc dù em đã thêm subdomain vào file infor rồi ạ. NHỜ ANH CHỈ RÙM EM VỚI Ạ. Cái nữa, liệu trong phần kiểm tra .linkActivated trên ( trước đó khi kích vào link xem ảnh chi tiết web chạy về 1 subdomain2 và tải ảnh từ link gốc subdomain2 liệu được không ạ?)

0

Em chào anh ạ! Em đang học lập trình, cấu trúc code nhiều khi em vẫn không hiểu lắm. Hiện em đang muốn tải ảnh về từ webview ios. Em có tìm trên mạng đoạn code và chèn đoạn code vào ví dụ của mình. Như sau ạ: import UIKit import WebKit import Network

class ViewController: UIViewController , WKNavigationDelegate, WKDownloadDelegate{

@IBOutlet weak var webview: WKWebView! override func viewDidLoad() { super.viewDidLoad()

monitorNetwork()

} func monitorNetwork(){ let monitor = NWPathMonitor() monitor.pathUpdateHandler = { path in if path.status == .satisfied{ DispatchQueue.main.async { self.webview.navigationDelegate = self let urlString = URL(string: "http://subdomain1.mywebsite.com.vn") let request = URLRequest(url: urlString!) self.webview.load(request) } }else{ DispatchQueue.main.async { self.Alert(Message: "Thiết bị không kết nối mạng") }

    }
    
}
let queue = DispatchQueue(label: "Network")
monitor.start(queue: queue)

}

func Alert (Message: String){

let alert = UIAlertController(title: "Thông báo", message: Message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Đồng ý", style: UIAlertAction.Style.default, handler: nil))
   self.present(alert, animated: true, completion: nil)

}

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { if let url = navigationAction.request.url, navigationAction.navigationType == .linkActivated {

    if url.absoluteString.hasSuffix(".pdf") || url.absoluteString.hasSuffix(".doc") ||
        url.absoluteString.hasSuffix(".docx") || url.absoluteString.hasSuffix(".xls") ||
        url.absoluteString.hasSuffix(".xlsx") || url.absoluteString.hasSuffix(".jpg") || url.absoluteString.hasSuffix(".jpeg") || url.absoluteString.hasSuffix(".png") || url.absoluteString.hasSuffix(".ppt") || url.absoluteString.hasSuffix(".pptx") {
        
       
       // let fileURL : String = url.absoluteString;
        
      
      
        let downloadTask = URLSession.shared.downloadTask(with: url) {
            urlOrNil, responseOrNil, errorOrNil in
           // check for and handle errors:
            // * errorOrNil should be nil
            // * responseOrNil should be an HTTPURLResponse with statusCode in 200..<299
            
            guard let fileURL = urlOrNil else { return }
            do {
                let documentsURL = try
                    FileManager.default.url(for: .documentDirectory,
                                            in: .userDomainMask,
                                            appropriateFor: nil,
                                            create: false)
                let savedURL = documentsURL.appendingPathComponent(fileURL.lastPathComponent)
                try FileManager.default.moveItem(at: fileURL, to: savedURL)
            } catch {
                print ("file error: \(error)")
            }
        }
        downloadTask.resume()
        
        
      /*  URLSession.shared.downloadTask(with: url, completionHandler: { (tempURL, response, error) in
                print("finished fetching \(url.absoluteString)")
            }).resume()
       */
                
           /*     DispatchQueue.main.async {
                    let url = URL(string: fileURL)
                    let pdfData = try? Data.init(contentsOf: url!)
                    let resDocPath = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!) as URL
                    let pdfFileName = "\(UUID().uuidString).jpg"
                    let filePath = resDocPath.appendingPathComponent(pdfFileName)
                    
                    // Save to File
                    
                    do {
                        try pdfData?.write(to: filePath,options: .atomic)
                        print("File Saved")
                    } catch {
                        print("Some Error in code")
                    }
                    
                }
        */
        
        
        
        decisionHandler(.cancel)
        return
        
     
       
    }
   
   
}
decisionHandler(.allow)

}

func webView(_ webView: WKWebView, navigationResponse: WKNavigationResponse, didBecome download: WKDownload) { download.delegate = self; }

func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) { if navigationResponse.canShowMIMEType { decisionHandler(.allow) } else { decisionHandler(.download) } }

// Download Delegate (to allow downloading PDF) func download(_ download: WKDownload, decideDestinationUsing response: URLResponse, suggestedFilename: String) async -> URL? { let urls = FileManager.default.urls(for: .documentDirectory, in: .allDomainsMask) // for Japanese names. let name = suggestedFilename.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "cannotencode" return URL(string: name, relativeTo: urls[0]) }

} Code file infor.plist như sau:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<dict> <key>CFBundleGetInfoString</key> <string></string> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSAllowsArbitraryLoadsInWebContent</key> <true/> <key>NSExceptionDomains</key> <dict> <key>http://subdomain1.mywebsite.com.vn</key> <string></string> </dict> </dict> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> <key>UISceneStoryboardFile</key> <string>Main</string> </dict> </array> </dict> </dict> </dict>

Sau khi chạy hệ thống báo lỗi như sau: App Transport Security has blocked a cleartext HTTP connection to http://subdomain1.mywebsite.com.vn since it is insecure. Use HTTPS instead or add this domain to Exception Domains in your Info.plist.

Mặc dù em đã thêm subdomain vào file infor rồi ạ. NHỜ ANH CHỈ RÙM EM VỚI Ạ. Cái nữa, liệu trong phần kiểm tra .linkActivated trên ( trước đó khi kích vào link xem ảnh chi tiết web chạy về 1 subdomain2 và tải ảnh từ link gốc subdomain2 liệu được không ạ?)

0
thg 12 30, 2024 9:20 SA

Em chào anh ạ! Em đang học lập trình, cấu trúc code nhiều khi em vẫn không hiểu lắm. Hiện em đang muốn tải ảnh về từ webview ios. Em có tìm trên mạng đoạn code và chèn đoạn code vào ví dụ của mình. Như sau ạ: import UIKit import WebKit import Network

class ViewController: UIViewController , WKNavigationDelegate, WKDownloadDelegate{

@IBOutlet weak var webview: WKWebView!
override func viewDidLoad() {
    super.viewDidLoad()
    
    monitorNetwork()
}
func monitorNetwork(){
    let monitor = NWPathMonitor()
    monitor.pathUpdateHandler = {
        path in
        if path.status == .satisfied{
            DispatchQueue.main.async {
                self.webview.navigationDelegate = self
                let urlString = URL(string: "http://subdomain1.mywebsite.com.vn")
                let request = URLRequest(url: urlString!)
                self.webview.load(request)
            }
        }else{
            DispatchQueue.main.async {
                self.Alert(Message: "Thiết bị không kết nối mạng")
            }
            
        }
        
    }
    let queue = DispatchQueue(label: "Network")
    monitor.start(queue: queue)
    
}

func Alert (Message: String){
       
    let alert = UIAlertController(title: "Thông báo", message: Message, preferredStyle: UIAlertController.Style.alert)
    alert.addAction(UIAlertAction(title: "Đồng ý", style: UIAlertAction.Style.default, handler: nil))
       self.present(alert, animated: true, completion: nil)
    
       
   } 

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
    if let url = navigationAction.request.url, navigationAction.navigationType == .linkActivated {
        
        if url.absoluteString.hasSuffix(".pdf") || url.absoluteString.hasSuffix(".doc") ||
            url.absoluteString.hasSuffix(".docx") || url.absoluteString.hasSuffix(".xls") ||
            url.absoluteString.hasSuffix(".xlsx") || url.absoluteString.hasSuffix(".jpg") || url.absoluteString.hasSuffix(".jpeg") || url.absoluteString.hasSuffix(".png") || url.absoluteString.hasSuffix(".ppt") || url.absoluteString.hasSuffix(".pptx") {
            
           
           // let fileURL : String = url.absoluteString;
            
          
          
            let downloadTask = URLSession.shared.downloadTask(with: url) {
                urlOrNil, responseOrNil, errorOrNil in
               // check for and handle errors:
                // * errorOrNil should be nil
                // * responseOrNil should be an HTTPURLResponse with statusCode in 200..<299
                
                guard let fileURL = urlOrNil else { return }
                do {
                    let documentsURL = try
                        FileManager.default.url(for: .documentDirectory,
                                                in: .userDomainMask,
                                                appropriateFor: nil,
                                                create: false)
                    let savedURL = documentsURL.appendingPathComponent(fileURL.lastPathComponent)
                    try FileManager.default.moveItem(at: fileURL, to: savedURL)
                } catch {
                    print ("file error: \(error)")
                }
            }
            downloadTask.resume()
            
            
          /*  URLSession.shared.downloadTask(with: url, completionHandler: { (tempURL, response, error) in
                    print("finished fetching \(url.absoluteString)")
                }).resume()
           */
                    
               /*     DispatchQueue.main.async {
                        let url = URL(string: fileURL)
                        let pdfData = try? Data.init(contentsOf: url!)
                        let resDocPath = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!) as URL
                        let pdfFileName = "\(UUID().uuidString).jpg"
                        let filePath = resDocPath.appendingPathComponent(pdfFileName)
                        
                        // Save to File
                        
                        do {
                            try pdfData?.write(to: filePath,options: .atomic)
                            print("File Saved")
                        } catch {
                            print("Some Error in code")
                        }
                        
                    }
            */
            
            
            
            decisionHandler(.cancel)
            return
            
         
           
        }
       
       
    }
    decisionHandler(.allow)
}

func webView(_ webView: WKWebView, navigationResponse: WKNavigationResponse, didBecome download: WKDownload) {
        download.delegate = self;
    }

func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
    if navigationResponse.canShowMIMEType {
        decisionHandler(.allow)
    } else {
        decisionHandler(.download)
    }
}


   // Download Delegate (to allow downloading PDF)
   func download(_ download: WKDownload, decideDestinationUsing response: URLResponse, suggestedFilename: String) async -> URL? {
       let urls = FileManager.default.urls(for: .documentDirectory, in: .allDomainsMask)
       // for Japanese names.
       let name = suggestedFilename.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "cannotencode"
       return URL(string: name, relativeTo: urls[0])
   }

} Code file infor.plist như sau:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<dict> <key>CFBundleGetInfoString</key> <string></string> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSAllowsArbitraryLoadsInWebContent</key> <true/> <key>NSExceptionDomains</key> <dict> <key>http://subdomain1.mywebsite.com.vn</key> <string></string> </dict> </dict> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> <key>UISceneStoryboardFile</key> <string>Main</string> </dict> </array> </dict> </dict> </dict>

Sau khi chạy hệ thống báo lỗi như sau: App Transport Security has blocked a cleartext HTTP connection to http://subdomain1.mywebsite.com.vn since it is insecure. Use HTTPS instead or add this domain to Exception Domains in your Info.plist.

Mặc dù em đã thêm subdomain vào file infor rồi ạ. NHỜ ANH CHỈ RÙM EM VỚI Ạ. Cái nữa, liệu trong phần kiểm tra .linkActivated trên ( trước đó khi kích vào link xem ảnh chi tiết web chạy về 1 subdomain2 và tải ảnh từ link gốc subdomain2 liệu được không ạ?)

0

Đây là những khó khăn mình từng gặp khi làm việc với DynamoDB. Nếu có điểm nào chưa đúng hoặc cần bổ sung, rất mong mọi người góp ý và cùng chia sẻ thêm giải pháp để hoàn thiện hơn nhé! 🙇

image.png

+1
thg 12 30, 2024 2:01 SA

GORM nó chỉ nhận là orm library, bác lại ném nó thành framework bài viết cũng lấy từ nguồn https://dev.to/empiree/top-5-popular-frameworks-and-libraries-for-go-in-2024-c6n 2024 chỉnh lại thành 2025, ảo thật

0
Avatar
đã bình luận cho bài viết
thg 12 29, 2024 2:30 SA

Bạn dịch khó hiểu qúa. Ví dụ với cách diễn đạt sơ sài quá

0

Atomic operation chủ yếu phù hợp với các tác vụ đơn giản, nó không phù hợp với yêu cầu phức tạp với nhiều điều kiện đi kèm => bạn cho mình ví dụ phức tạp như thế nào là ko dùng đc cái này đc ko ?

0
thg 12 27, 2024 12:10 CH

sợ chỉ là cảm giác thôi e 😃)

0
thg 12 27, 2024 6:17 SA

có bác nào làm module gửi link forgot password khi user yêu cầu chưa ạ, cho em xin bài hướng dẫn

0
Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí