Ollama

1- Installing

1.1 – Linux

On Debian linux, Installing Ollama is a one liner, just enter the following in your terminal

curl -fsSL https://ollama.com/install.sh | sh

Yup, that is it, move on to using Ollama

1.2 Windows and MAC

Just go to https://ollama.com/, download it, and run the installer ! you are done

Using it !

Using Ollama is simple, just open your terminal window or command prompt , then activate your conda environment (Or venv) , and run the following command, for the sake of this example, I will run

conda activate projectName
ollama run llama3.2

llama3.3 with its 70 billion parameters will require a minimum of 64GB of ram, so don’t try that unless you have the RAM for it ! for comparison, 3.2 has 2 billion, which is around 3% of 3.3

It should now probably download about 2GBs of data (The model llama3.2 has around 2 billion parameters) And you are done, Now you can ask it anything

For example, create an article for me explaining this and that,

Once done, just enter “/bye” to exit the ollama prompt and quit the session

If you want to for example clear the context or do anything else, just use the command /? for a list of commands

Now, you have used the lama3.2, but on this ollama models page, you will find that there are many others that you can use !

Others include models that help you with coding, or models that are more targeted towards chat-bot QA, either way, you should take a close look at them, even if for the fun of it

Is ollama running ?

Just visit (http://localhost:11434/) in your browser, and you should see the message (Ollama is running)

Modifying a model’s settings

An example of what you may want to modify may be for example If you have a GPU, but you do not want it to be used by Ollama, to do this, you will need to create a model file, the steps to creating this file for llama 3.2, (The small one) are as follows

# Copy the llama 3.2 base file
ollama show llama3.2:latest --modelfile > ~/cpullama3.2.modelfile
# edit the file ~/cpullama3.2 and edit the FROM line to read
FROM llama3.2:latest
# go to the parameters section, and add the parameters you need
# In our case, PARAMETER num_gpu 0
PARAMETER num_gpu 0
# Create your custom model
ollama create cpullama3.2 --file cpullama3.2.modelfile

The last command above resulted in the following output

transferring model data 
using existing layer sha256:dde5aa3fc5ffc17176b5e8bdc82f587b24b2678c6c66101bf7da77af9f7ccdff
using existing layer sha256:fcc5a6bec9daf9b561a68827b67ab6088e1dba9d1fa2a50d7bbcc8384e0a265d
using existing layer sha256:a70ff7e570d97baaf4e62ac6e6ad9975e04caa6d900d3742d37698494479e0cd
using existing layer sha256:966de95ca8a62200913e3f8bfbf84c8494536f1b94b49166851e76644e966396
using existing layer sha256:fcc5a6bec9daf9b561a68827b67ab6088e1dba9d1fa2a50d7bbcc8384e0a265d
using existing layer sha256:a70ff7e570d97baaf4e62ac6e6ad9975e04caa6d900d3742d37698494479e0cd
creating new layer sha256:650ff8e84978b35dd2f3ea3653ed6bf020a95e7deb031ceae487cdd98dedc2e3
creating new layer sha256:f29c86d4cf6a4072deefa0ff196b7960da63b229686497b02aad4f5202d263ea
writing manifest
success

Above, although you simply created a “model” by copying the existing model’s config file ! nothing more nothing less

Ollama API

So, above, your terminal allowed you to chat with the model, much like what you do when you open Claude or ChatGPT, if you want to access things via API, here is how.

Everything AI – TOC

This blog has plenty of posts about AI, some are about AI tools, others are about installing AI locally, so this post is where I am putting all the AI stuff I have ever blogged about in one place !

The section Local AI is about creating your own AI server using freely available sources, the API section lists all the services that provide an API but can not be installed locally, and the Online Services is where you can get things done via AI online (That can’t be installed locally or accessed programmatically via API)

Continue reading “Everything AI – TOC”

My Flutter notes

I recommend you read this after reading My Dart Notes.

this document is a reminder of everything Dart related ! There is a different one for flutter.

Why ? Because I have a problem, I don’t limit myself to a few languages like normal human beings, I know A LOT of programming languages, and when you don’t use a language long enough, you start messing up which syntax works where, so I create those small “Reminder” pages that I can skim through in an hour before I start working with any language after leaving it for some time !

Mind you, I eventually lose the page “in the (It is on some hard drive somewhere) and that is because after using it a couple of times, I no longer need it. but when i come across old ones, I will post them on this blog.

I am posting this one online because I am composing it now, and I haven’t lost it yet

Continue reading “My Flutter notes”

My Dart Notes

A quick revision of the Dart language syntax

this document is a reminder of everything Dart related ! There is a different one for flutter.

Why ? Because I have a problem, I don’t limit myself to a few languages like normal human beings, I know A LOT of programming languages, and when you don’t use a language long enough, you start messing up which syntax works where, so I create those small “Reminder” pages that I can skim through in an hour before I start working with any language after leaving it for some time !

Mind you, I eventually lose the page “in the (It is on some hard drive somewhere) and that is because after using it a couple of times, I no longer need it. but when i come across old ones, I will post them on this blog.

I am posting this one online because I am composing it now, and I haven’t lost it yet 😉

Classification

  • AOT Compiled for Production, or JIT compiled during development
  • Can also transpile into Javascript
  • Uses Garbage Collector (When AOT, it is bundled with compiled app)
  • Dart is statically typed (Fixed variable types)
  • sound null safe (sound = No mixing of safe and unsafe)
Continue reading “My Dart Notes”

Dart-Flutter VS Kotlin Multi Platform

I am writing this blog post to keep my thoughts in order ! because, true to my nature, I will keep questioning this choice and I will end up going back and forth between writing code in Kotlin and Dart-Flutter, which is not good, because I end up with software that is not uniform, as usual

After reading a book on flutter, and a book on Kotlin multi platform, It looks like it is going in the direction of flutter, It is true that KMP – iOS is now in beta, and things should now be looking good for KMM and KMP, it is not a no brainier and here is why I decided to go with Flutter

First of all, I understand that flutter may or may not lose google’s support any minute now, this is true because google loves to abandon projects, so they just might, everyone online is saying that there are no signs of google dropping support, but the truth is, I can see the effort being put into Jetpack compose and compare it to Flutter, in any case only upper management at google may (or may not) know yet, In any case, Flutter is open source, and even if they drop support today, it will probably still work many years from now, and when it doesn’t, I have never had problems learning new languages in a couple of weeks.

I have been a C++ developer for 25 years, and earlier this year (It is still 2024 right ?), I started learning RUST, the start was hell, my inner child did not want to leave the comfort zone, and kept making up reasons why C++ is eternal and better than RUST, but after some time, I was convinced that we crossed the point of no return, and I started, slowly but steadily to fall in love with RUST.

Now RUST excels in front end and graphical user interfaces (Said no one ever)…. But if I am planning to run rust on Android or iOS, boy oh boy, I might have to reinvent computers

So, the answer is that the front end should be handled by either Dart-Flutter or Kotlin-Multi platform

Now, Why dart-flutter rather than Kotlin Multi Platform and Compose Multi Platform

Before I dive into this, the parts of the application that are expected to require performance are probably going to be written in RUST, while permissions and GUI are expected to be handled by flutter, So why flutter

1- Leaf calls, that is, Leaf calls will not permit the garbage collector to run, which means that it is safe to pass a pointer to underlying data to C, provided that C does not hold on to that pointer after the FFI call returns. This removes the need to copy the data before passing it to C. But we are not planning to use C, we are interested in RUST ! the answer is that this is a proof of concept, also “opaque types” are possible 😉

Ownership and lifetimes in FFI are probably more of a problem in Kotlin as it stands today ! this is because flutter_rust_bridge provides a level of abstraction to avoid dangling pointers etc….

In Kotlin, exposing Rust functions as C-compatible functions will have a library one day (We already have UniFFI ( UniFFI-RS by mozilla ) but it is not as mature, there are variants of this library to do the job, and for kotlin multiplatform it is here (uniffi-kotlin-multiplatform-bindings) also worth mentioning that there is a UniFFI variant for Dart-Flutter !

Rust code will interact with the Android Java APIs through the Java Native Interface (JNI), and only partly controlled by flutter, there is also no reason to assume that a lot of data is going to travel between dart and RUST in most applications, but when there is such a scenario, we know what to do, we chose flutter.

Coding with Claude

I tried using cursor-ai for some time, basically for HTML, CSS, a bit of vanilla JavaScript, and Tailwind, not bad at all with the above, but later, after two weeks, the limit became unusable, turns out the “Free” comes with a 2 week free trial

Without it, you are switched from Claude to “Cursor-small” in the CTRL+L menu, and the autocomplete stops working

In any case, I think subscribing to cursor-ai is a good idea, the time it saves you writing things that are not core to your work is well worth it, but I wanted to experiment with something new, so….

Cursor-AI is basically a modified VS Code, and since Claude 3.5 Sonnet seems to be my favorite coding AI, i researched a bit and found that there is a plugin for VS-Code that does the same if I subscribe to Anthropic API !

So, after getting my API key from anthropic (the people behind Claude), all i needed to do was install a plugin (Tried more than one plugin, CodeGPT, and Cline by Saoud Rizwan), once installed, I need to enter my API key into the settings, and that is it.

Cline suits my needs better than CodeGPT for the time being, but i did not use them extensively yet, so it is too early to declare a winner

Moving from gmail to cpanel

Like thousands of people online… when google decided that my domain’s email is no longer hosted for free, I spent a good year or two paying for the email accounts I have, and if like me, you only need gmail for the sake of email, paying this much for email, a technology from 1971 is a crazy !

If you are the domain admin on google workspaces, you probably know that google will allow you to “Take Out” all the data from all accounts on that domain, I will assume you already did that and you have the file (All mail Including Spam and Trash.mbox).

In a different post, I showed you how to do this with dovecot’s own tools to simply copy the files, but that assumes you run your own server ! this post is for the average user, this is the for dummies of moving email from google gmail (Takout for example) to ANY email account on any platform using a nail clipper and some old socks, just kidding, you only need the socks

So, I decided to move all accounts to a server with cpanel, which is a solid solution.

So i started with my email account, it was very straight forward with mutt (apt install mutt), configure my account, then mount the mbox file and push it all to the server

mutt -f ~/takeout.mbox (T to select all messages)

But you are probably on Windows, so for your sake, I did the second account with software that works on windows, so start by downloading and installing thunderbird, once installed, setup your account, with cpanel and most other providers, all you need to know is your name, email address, and password, thunderbird should be able to find the config for your server automatically 😉 (If you are wondering, Your server publishes it’s own config and thunderbird finds it through the email’s domain)

So, now you can see all the new emails that arrived to the new server, once that happens, close thunderbird, then navigate to your thunderbird profile folder, in my case it is at

~/.thunderbird/RANDOMLETTERS.default-default/Mail/Local Folders

But since you are on windows, it would probably be somewhere inside “roaming/thunderbird/profiles”, shouldn’t be hard to find, once inside your profile, go to /Mail/Local Folders and paste the mbox file you have, start thunderbird and it should display the MBOX file on the left panel under “Local Folders”

Once that happens, you can select the messages you want to move (If you are moving thousands of messages, i would recommend you move them in batches, not all at once), right click, then go to the moveto menu that appears, and select the account/mailbox you want them moved to, and watch them move…

Done ?

Now, you can use FTP to see your mail which should be in the devicot folders, (They are not called devicot folders, it is called maildir, but because you are running devicot, I don’t like to add jargon too quickly)

new, cur, and tmp

other files reference devicot, so we know what we have

Notes

If you need to create a new thundirbird profile, under linux you need to start thunderbird with the following command

thunderbird -ProfileManager

Under windows, the profiles page is on the Help -> Troubleshooting information menu !

Audio breaking and noisy on debian 12

I am not sure that this problem is specific to my setup, where my audio comes from an nvidia 1650 passed through to a KVM virtual machine, but it seems that many people on bare metal are having this problem too

The problem occures randomly, and when it does, pipewire would be consuming a lot of CPU even though no audio is running

pipewire for those of you who don’t know is the new pulse audio, it comes with most modern distributions !

The solution when this happens for now sems to be to restart pipewire !

systemctl --user restart pipewire.service

Flutter “no ScrollPosition attached” SOLVED

════════════ Exception caught by animation library ════════════════
The Scrollbar's ScrollController has no ScrollPosition attached.

The solution to this problem turned out to be, to assign the same scroll controller that I have assigned to the ListView.builder to the Scrollbar !

This problem didn’t exist not long ago, but since the solution is simple, here is a sample code snippet !

So the code to fix was simply this

Widget _buildParticipantDisplay() {
return Scrollbar(
interactive: true,
controller: scrollController,
child: ListView.builder(
itemCount: participants.length,
controller: scrollController,
itemExtent: 60,
itemBuilder: (context, index) {
return ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 50),
title: Text('participant: ${index + 1}'),
trailing: Text(participants[index]),
);
},
),
);
}

Button types in flutter

It should be button shapes or designs, since buttons in flutter all basically work the same way, except for DropDownButton, it is a bit different !

  • ElevatedButton
  • TextButton
  • IconButton: An icon is added to your text button !
  • FloatingActionButton: a circular icon button that hovers over content to promote a primary action in the application. (official Youtube)
  • OutlinedButton: a TextButton with an outlined border
  • DropDownButton: Allow the user to select from a list of values ! (Official Youtube)
  • CupertinoButton: A button in iOS style !

ButtonStyle IS DEPRECATED !, use WidgetStateProperty (Just replace this class name with that) to set (backgroundColor and foregroundColor) , everything else is identical….

ButtonStyle Class

style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.green),
foregroundColor:
MaterialStateProperty.all<Color>(Colors.white),
),

Instead, use

style: ButtonStyle(
backgroundColor:
WidgetStateProperty.all<Color>(Colors.green),
foregroundColor:
WidgetStateProperty.all<Color>(Colors.white),
),

styleFrom() method

ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
foregroundColor: Colors.white,
textStyle:
TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
),
)