Posts

Showing posts with the label code

Mobile Dev: Why YouTube Embeds Started Failing in Our App (Error 15/153) and What We Did

About a month ago, we noticed that embedding YouTube videos in our mobile app (iOS & Android) started returning Error 15 or Error 153 . These embeds had been working for years with no code changes on our side. We discovered that many other developers were seeing the same error, especially in webviews inside apps, so the timing was curious. The likely cause It appears that YouTube’s embed policy enforcement has tightened: if the embed request originates from an app or webview that does not supply a valid Referer or Origin , YouTube may refuse to play the video (hence the 15/153 error codes). This meshes with policy guidance in the YouTube “Required Minimum Functionality” documentation, which states that apps must provide certain identifying information including origin. Source:  Google for Developers Additionally, many mobile WebView implementations (on iOS & Android) often send an empty or missing referer header by default, which then leads to this embed rejection. Ou...

AI: Using ChatGPT to Translate Language Packs

Image
Thanks to the advent of accessible LLMs like ChatGPT, translating a language pack for an application is now easy and quick. There was a time when we relied on Google Sheets with the translate function for this task—not only was it difficult to maintain, but it was also less accurate. With tools like ChatGPT, translations can be customised for an application’s context, and most importantly, the format of the language pack is easily retained. You can simply copy the translated pack as a ready-to-use file without needing any further processing. Cost effective and efficient! Try this step-by-step : Load your language pack (e.g., JSON, XML). Paste it into ChatGPT, specifying context, desired tone, and any important instructions. Copy the translated output and use it directly in your app. This is a simple example (I think the instructions could be written better, pardon me).

Java: Use Constants For Maintainability

Encountering repeated variable declarations, such as configurations and error messages, across multiple functions and classes is more common than you might think, especially with junior developers. Often, similar variables are needed in different parts of the code and are simply redeclared—leading to, you guessed it, a maintenance nightmare! The solution is simple: Constants ! Using constants makes your code more readable and maintainable because declared values are reusable, reducing careless errors. As a bonus, static variables are handled efficiently by the JVM. For best practice, make sure that constant variables are: static - The variable belongs to the class rather than any specific instance, so there's only one instance of the variable. final - The value cannot be reassigned after it's set. Example Usage: Disclosure:  This entry is based on a collection of my personal notes, and some of the information may be outdated or no longer relevant. If you notice any inaccu...

Java: Try-with-resources to Simplify Resource Management

Discovering try-with-resources many years ago was quite a revelation. Before this, I needed to be disciplined in handling resource management, especially with streams and database connections. Admittedly, I sometimes forgot to close resources, which inevitably led to memory leaks. With try-with-resources , the close() method is called automatically when exiting the block, preventing memory leaks caused by unclosed resources. Additionally, it simplifies your code by eliminating the need for an explicit finally block to handle resource cleanups. Classes with the AutoCloseable Interface: Database Connections Streams Files Sockets Beyond the standard classes that implement the AutoCloseable interface, you can also create your own classes that support this feature. For more details, read here:  Baeldung: Java – Try with Resources Disclosure:  This entry is based on a collection of my personal notes, and some of the information may be outdated or no longer relevant. If you ...

Java: For Loop Optimisation

When discussing for loops in Java, we often overlook whether certain formats are more efficient than others. Whether for readability or performance, understanding these differences can be important. The optimization here is minor (a micro-optimization, so to speak) and may vary in significance depending on factors such as the JVM used. However, in the spirit of writing efficient code, this approach can help your functions run more efficiently in certain scenarios. For more information and test data, check out this Stack Overflow thread:  For Loop Optimisation Disclosure:  This entry is based on a collection of my personal notes, and some of the information may be outdated or no longer relevant. If you notice any inaccuracies, please let me know in the comments. I appreciate your feedback and will correct the entry as needed. :)