Deno, LangChain, Ollama, and structured outputs

When working with LLMs programmatically, it’s important to receive a structured response from the model. This makes it easier to parse and use the output in your application. In this post, we’ll walk through how to define a schema using zod and query an Ollama model with the help of LangChain. For simplicity, we’ll use Deno, so make sure it’s installed on your system. You can find the full code here: https://github.com/hosainnet/ai-experiments/tree/main/deno-ollama-structured-response — let’s break it down. ...

September 25, 2025 · 2 min · 252 words · Me

Unit Testing React Native Components

tldr: github.com/hosainnet/RNUnitTests I’ve recently jumped ship to React/React Native (and JS in general) and one of the first hurdles for me was figuring out how to unit test RN component code. As many of us starting out, you’ll have probably come across the snowflake project for guidance and inspiration (which deserves credit for most of the content in this post). However since it’s a big project with a large set of dependencies and files, I wanted to go through the minimal setup needed to go from react-native init AwesomeProject to being able to run npm test and get some results back. ...

January 31, 2016 · 5 min · 934 words · Me

Dependency Injection With Dagger 2 and Android

Dependency Injection is one of the patterns we use in software development to achieve separation of concerns, making our code maintainable and testable. Consider the following Activity code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://reddit.com") .addConverterFactory(GsonConverterFactory.create()) .build(); ApiService apiService = retrofit.create(ApiService.class); apiService.getUser("reddit") .enqueue(new Callback<User>() { @Override public void onResponse(Response<User> response, Retrofit retrofit) { displayUserDetails(response.body().getData()); } @Override public void onFailure(Throwable t) { } }); } The code above uses Retrofit to consume the Reddit API through an ApiService and display some basic information about a given user. ...

November 7, 2015 · 5 min · 985 words · Me

Getting Started With Android Development Using Groovy 2.4 and Android Studio

Groovy 2.4 was released last month with native support for Android development. In this post I’ll explain how to set up a new Android Studio project with Groovy support as I couldn’t find a decent tutorial to explain it for newcomers (like myself). Why Groovy? If you’re new to Groovy, you may ask why would I want to do this? In short: less code = (hopefully) less buggy and more readable code. Here are some of the benefits of using Groovy over Java: ...

February 7, 2015 · 4 min · 793 words · Me

Grails Upgrade Part 1: 2.1.3 to 2.2.5

We have recently upgraded a fairly large web application from 2.1.3 to 2.4.4. Since it’s a big jump, we split the task into multiple grails upgraded so this post will focus on 2.1.3 to 2.2.5. The best place to start is the official upgrade documentation page. Here are some of the things we’ve encountered during the upgrade: ###“delete() does not work in withNewSession”### Sessions are now always flushed after withNewSession closure is executed, unless flush mode is manual: https://jira.grails.org/browse/GRAILS-9739 ...

January 26, 2015 · 1 min · 180 words · Me

Hello World!

January 1, 2015 · 0 min · 0 words · Me