Search Results for “#code”

Page 1 of 1

Run Ollama API On macOS With Custom Host Bindings

By default the ollama API runs on the localhost IP address of 127.0.0.1. If you want to host it on all of your Mac's IP addresses it requires that you set a system-wide environment variable. The problem with doing this is that Login Items (in System Settings) can launch before Launch Agents. This means that Ollama (in the menu bar) may not see the host settings. To solve this you need to launch Ollama at startup after a delay.

Here's how to add the host binding for all IP addresses on the Mac and then have Ollama launch 10 seconds after you sign in. This works in macOS 14.5 Sonoma and should work in later versions.

Step 1: Create a launch daemon plist file below. Save it as com.nonsequiturs.ollama.plist.

<?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">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.nonsequiturs.ollama</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/launchctl</string>
        <string>setenv</string>
        <string>OLLAMA_HOST</string>
        <string>0.0.0.0</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>LaunchOnlyOnce</key>
    <true/>
</dict>
</plist>

Step 2: Copy the file to two locations:

/Library/LaunchDaemons/
~/Library/LaunchAgents/

This will set the host bindings at the system level, and also at the user level. So you should be covered no matter how you launch Ollama in the future.

Step 3: Set file permissions on the system-level file.

sudo chown root:wheel /Library/LaunchDaemons/com.nonsequiturs.ollama.plist

sudo chmod 644 /Library/LaunchDaemons/com.nonsequiturs.ollama.plist

Step 4: Install the launch agents:

sudo launchctl bootstrap system /Library/LaunchDaemons/com.nonsequiturs.ollama.plist

launchctl load ~/Library/LaunchAgents/com.nonsequiturs.ollama.plist

Now your system will start up and bind the Ollama host address to all IP addresses on the Mac.

Step 5: To launch Ollama after a 10 second delay, Open Script Editor and create the simple AppleScript file below.

delay 10
tell application "Ollama" to run

In the File menu choose Export, and then export it as type “Application” and name it “LaunchOllamaDelay”. Save it to your user Applications folder.

In System Settings go to Login Items and add the LaunchOllamaDelay application to the startup items. Also remove any existing Ollama startup item.

Now when you restart and sign in, Ollama will launch after 10 seconds which should be enough time for the Launch Agent to have executed. And if Ollama updates itself in the future it should also just work when it restarts.

#YOUREWELCOME #Apple #macOS #ollama #code #tech #ai

Jul 28

Overzealous app design patterns for mouse hover modals, tips, and cards frequently cause user frustration by obscuring the items with which a user wants to interact. I see this all the time in everything from websites to software development IDEs. The solution? Exercise restraint and add options to disable these hover actions.

#developer #code #design #philosophy

Feb 13

Prioritizing Software Features

Being a pragmatist when it comes to software development, I generally prefer simple solutions whenever possible. So when clients are faced with the challenge of determining which features to add to their products, as a starting point I usually recommend looking at user value versus cost to implement.

Given a progressive value scale from a “cup of coffee” at the low end and a “house” at the high end, we can easily see where the best choices lie.

Looking at the first row in this example, if a user values a feature at “house” and your cost to implement is a “cup of coffee” this feature addition becomes a no-brainer.

Likewise if a user values a feature at a “cup of coffee” but it will cost a “house” to build, it's certainly a feature to avoid implementing.

There may be some diamonds in the center blue area, but more information is usually required before we make those decisions.

#code #tech #software #developer

Oct 15, 2023

Mac Pro Tip: When copying a git repository directory to your network file server using rsync, try this:

rsync -brtlvP --chmod=Fu+w --delete-before Code/MyProject/ /Volumes/MyServer/Code/MyProject/

This will copy the files with timestamps but no other attributes, and will also give the file owner (you) full access rights. This ensures that you (or even Windows users with access rights) can overwrite the directory contents later because local read-only files (e.g. in the .git directory) won't be read-only on the server. You can also change the chmod option to customize the rights, like ensuring everyone has full control.

#apple #macos #windows #code #developer #YOUREWELCOME

Jun 14, 2023

Animate CSS Auto Height Without Javascript

Web developers rejoice! There's an easy way to animate the height of an HTML element even if the height is dynamic, determined by its content, with only CSS. This is typically used for navigation menus and the like, and now it's much easier to code and maintain.

The strategy is to actually animate the grid-template-rows not the height. For example, take the following HTML markup:

<div class="menu">
  <div class="inner-wrapper">
    <p>Here is some content.</p>
    <p>Here is some content.</p>
    <p>Here is some content.</p>
  </div>
</div>

The CSS for this markup would be:

.menu {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 100ms;
}

.menu.active {
  grid-template-rows: 1fr;
}

.menu .inner-wrapper {
  overflow: hidden;
}

Initially the outer div will be hidden since it has no overflow and the grid template rows are zero. When you add active to the outer div element's class list, the browser will animate the transition from zero row height to 1fr, which essentially means the height it needs for its content to render.

#css #html #javascript #code #tech #YOUREWELCOME

May 16, 2023

Automate The Installation of All Your Mac Apps Using Homebrew

On macOS it's pretty easy to automate the installation of all your apps, including Mac App Store apps, for those times when you get a new Mac or wipe your current one. As a software developer I find this capability indispensable, as would any professional or power user.

All you need to do is install Homebrew and then use it to install mas (which is an acronym for Mac App Store). Once they are installed, you can install all your software using a convenient Bash script. Homebrew will be used to install non-store apps, and mas will handle installing the Mac App Store apps.

Note: only Mac App Store apps you have already installed previously can be installed with mas. You cannot install new apps you have never installed from the store.

Why Do This?

The most obvious reason to script out your software installations is that it greatly reduces the time to set up a new Mac, as well as ensure that you don't forget to install one or more apps. It also provides a way to update all the apps at once via the brew upgrade command. And it also provides a way to update apps that don't have their own update feature.

Apps installed with mas will be updated normally by the Mac App Store.

How Does This Work?

In order to use this process you need to know the names of the Homebrew formulae/casks for each application, and you also need to know the IDs of the Mac App Store apps for mas. Fortunately this is super easy.

First, Homebrew has a tool for finding software available in their service at https://formulae.brew.sh/. Simply use this to find your apps and make sure you're installing the right ones. Those listed as “casks” are GUI Mac apps (normal apps you don't run from the Terminal). Ones listed as “formulae” are typically command line tools run from the Terminal or services without an interface.

Second, for Mac App Store apps you simply use mas to list what's currently on your computer from the Mac App Store.

mas list

This will give you a list of currently installed apps from the Mac App Store, with their IDs:

1569813296  1Password for Safari      (2.10.0)
975937182   Fantastical               (3.7.12)
409183694   Keynote                   (13.0)
etc.

You can also search for Mac App Store apps by name using the mas search command:

mas search Xcode

This will show a similar result for matches. You can even install all search results with a single “lucky” command. See the mas help for these and other options.

Script Example

Here's an example of a Bash script to get you started. I keep a similar script updated as I use new apps or stop using others. Then I'm ready to go when I have to set up a new or wiped Mac.

# Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# App Store Automation

brew install mas

# Install App Store Apps

mas install 409183694   # Keynote
mas install 409201541   # Pages
mas install 409203825   # Numbers

# Install Non-Store Apps

brew install --cask firefox
brew install --cask knockknock
# etc.

You can name the Bash script something like install-software.sh and execute it in a Terminal like this:

zsh install-software.sh

The first time you use the script will absolutely justify the time spent writing it. The second time you run it you will thank your past self for being so smart 😉

#apple #macos #mac #tech #code #recommendation #YOUREWELCOME

May 2, 2023

Install SQL Server 2022 with Full-Text Search on Apple Silicon Macs

It looks like a recent change to Docker has allowed Macs with Apple Silicon to run a full installation of Microsoft SQL Server 2022 with full-text search in a Docker container.

How is this possible? Docker has a new feature that can use Rosetta 2 for x64 emulation. That means it supports creating an x64-based Linux image/container and installing the free but full version of SQL Server with FTS.

Step 0: Enable Rosetta in Docker

Enable this feature in the Docker settings as seen in the image below. Look in Settings => Features in development.

Step 1: Create The Dockerfile

Take the content below and save it as a text file named Dockerfile. This configuration creates an Ubuntu 20.04 image, then installs the Microsoft package repositories, SQL Server 2022, FTS, and MS Tools.

# Docker image with msssql 2022 with full text search enabled;
# Based on work in: https://github.com/Microsoft/mssql-docker

# Base OS layer: Latest Ubuntu LTS
FROM --platform=linux/amd64 ubuntu:focal

# Install prerequistes since it is needed to get repo config for SQL server
RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get update && \
    apt-get install -yq curl apt-transport-https gnupg && \
    # Get official Microsoft repository configuration
    curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
    curl https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb --output packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb && \
    curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list | tee /etc/apt/sources.list.d/mssql-server.list && \
    apt-get update  && \
    # Install SQL Server from apt
    apt-get install -y mssql-server && \
    # Install optional packages
    apt-get install -y mssql-server-fts && \
    ACCEPT_EULA=Y apt-get install -y mssql-tools && \
    # Cleanup the Dockerfile
    apt-get clean && \
    rm -rf /var/lib/apt/lists

# Run SQL Server process
CMD /opt/mssql/bin/sqlservr

Step 2: Build The Dockerfile

This will build the Dockerfile and create a Docker image named sqlserver.

docker build -t "sqlserver:latest" .

Step 3: Run the Container

This will create a container from the new image and run it. The sa user will have a password of P@ssw0rdz!, the EULA will be accepted, and port 1433 will be opened.

docker run -d --platform linux/amd64 --name sqlserver -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@ssw0rdz!' -p 1433:1433 sqlserver:latest

At this point you should have SQL Server running! You can also have it start up with Docker by executing the command below:

docker update --restart=always sqlserver

#docker #code #mssql #AppleSilicon #YOUREWELCOME

Apr 27, 2023

I just posted a new open source console application named SqlPkg. It's a wrapper for Microsoft's SqlPackage (a SQL Server backup and deployment tool) that adds missing features. Currently it provides a way to exclude data from specific tables, automatically wipes target databases, and automatically creates non-existent target databases.

#tech #code #csharp #sqlserver #backup

GitHub - argentini/Argentini.SqlPkg: Console application wrapper for Microsoft SqlPackage that adds features like excluding data from specific tables and database purging/creation. (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon)
GitHub - argentini/Argentini.SqlPkg: Console application wrapper for Microsoft SqlPackage that adds features like excluding data from specific tables and database purging/creation. (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon)

github.com

Apr 23, 2023

Here's an interesting #CSS method for styling an adjacent element based on whether an <input> is empty or not.

input[type="search"]:placeholder-shown + i {
    /* input is empty */
    display: none;
}

input[type="search"]:not(:placeholder-shown) + i {
    /* input is not empty */
    display: inline-block;
}

In this case I'm hiding and showing a clickable icon that clears the search text if there is any. No JavaScript needed other than the click event 😃.

#code

Dec 21, 2022

My company #Fynydd just updated SQribe to .NET 7. SQribe is a cross-platform #opensource tool to backup/restore SQL Server databases. It generates T-SQL scripts so you can version your database in git and copy databases across VPNs.

SQribe: Backup and Restore SQL Server Databases on Mac OS, Windows, and Linux
SQribe: Backup and Restore SQL Server Databases on Mac OS, Windows, and Linux

sqribe.app

#tech #software #recommendation #dotnet #csharp #code

Dec 20, 2022

I know I know, another terminal #recommendation. But this one is different in that the input area is more of a text editor, and it isolates the output per command. It also uses AI to help you complete commands much like Github Copilot does for your #code. VERY cool #software #tech. Available for #Apple #Mac now. Will be available for #Windows and #Linux soon.

Warp: Your terminal, reimagined
Warp: Your terminal, reimagined

www.warp.dev

Dec 15, 2022

Software Development is Not Coding

When asked, most people think that software development is about coding; the physical act of programming apps and platforms for servers, computers, and mobile devices. This is not the case.

Software development is the process of solving problems through software. It's a creative process that is centered on discovery and adaptation which uses tactics like programming (coding) to accomplish its ends. Likewise, software development is not the act of reusing existing software for a new purpose. That's just copying bits.

So it is important for those involved in the software development process to understand and acknowledge the following key aspects.

Discovery and adaptation is the focus.

Understanding the problem domain is the key to a successful software development process. And we know the least about a problem domain at the outset. So it doesn't make sense to plan everything out at the beginning. Software development is an exercise in learning. We learn more and more about the problem to be solved as we move through the process. And as the problem domain comes into focus we should be refining or redefining what we should be building as we learn.

Mistakes will be made.

Mistakes help us solve problems and are one way in which we learn. Embrace them. Plan for them.

We cannot predict the future.

Perfect plans are usually perfectly wrong. It is impossible to perfectly know the steps, mistakes, discoveries, interruptions, and goals for a project, nor the time impact of each, all in advance.

Estimates are guesses about the future.

Great software doesn't just manifest in one go. It springs forth in a deficient state and evolves over time. This makes guessing about its future state with any accuracy a fools errand. It also means that creating precise specifications for those guesses can be a waste of time.

Accuracy and precision are not the same. Something can be very precise but horribly wrong. This has been shown by various studies, including those in the Microsoft Press book Rapid Development by Steve McConnell. According to the book it doesn't matter how diligent or thorough an estimate may be. The data shows that when compared to a more broad, high-level, or piecemeal approach based on past experience, the error bounds are largely the same.

Right-fit planning works.

We must understand the level of precision that makes sense. For example, it doesn't make sense to plan an entire project with the same precision as planning next week's work. Likewise, planning specific deliverables for dates far out into the future is also problematic. Small time horizons increase the accuracy of our guesses.

Release often.

By deploying changes frequently, we allow the entire team to steer the direction of the project early and often. This agile approach will ensure that the final product performs as it should for its users.

#tech #code #philosophy #Fynydd

Jun 22, 2022

I just posted a new SQL Server ORM library for .NET 6.0 (C#) named DataStore, which uses JSON object storage and a fluent-style querying pattern.

GitHub - argentini/Argentini.DataStore: SQL Server ORM library that stores models as JSON data with custom indexed computed columns for fast search and ordering (like mongodb). DataStore uses a fluent pattern for powerful querying and ordering of paged data, and parallel bulk saves (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon)
GitHub - argentini/Argentini.DataStore: SQL Server ORM library that stores models as JSON data with custom indexed computed columns for fast search and ordering (like mongodb). DataStore uses a fluent pattern for powerful querying and ordering of paged data, and parallel bulk saves (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon)

github.com

#tech #code #csharp #dotnet

May 28, 2022

I built a virtual Enigma Machine using .NET 6.0 and C#. Unlike the original hardware, this one can encipher the entire UTF-16 character set! It's configurable and very strong for a keyless cipher.

GitHub - argentini/Argentini.Enigma: A virtual Enigma Machine that enciphers and deciphers UTF-16 strings, and which can be used for keyless encryption in mobile, desktop, and server apps (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon).
GitHub - argentini/Argentini.Enigma: A virtual Enigma Machine that enciphers and deciphers UTF-16 strings, and which can be used for keyless encryption in mobile, desktop, and server apps (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon).

github.com

#tech #code #csharp #dotnet

May 27, 2022

I updated my Benford's Law project to .NET 6.0 and C# 10. What is it? It uses the law of anomalous numbers to determine if data or images have been altered.

GitHub - argentini/Argentini.Benford: Experiment with Benford's Law to find data anomalies in number lists and images (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon)
GitHub - argentini/Argentini.Benford: Experiment with Benford's Law to find data anomalies in number lists and images (Windows, macOS, Linux, .NET 7.0, x64, Arm64, Apple Silicon)

github.com

#tech #code #csharp #dotnet

May 27, 2022

My company #Fynydd just released SQribe as an #opensource project! It’s a cross-platform tool to backup/restore SQL Server databases. It generates T-SQL scripts so you can version your database in git and copy databases across VPNs.

SQribe: Backup and Restore SQL Server Databases on Mac OS, Windows, and Linux
SQribe: Backup and Restore SQL Server Databases on Mac OS, Windows, and Linux

sqribe.app

#tech #software #recommendation #dotnet #csharp #code

Dec 3, 2020

My company, #Fynydd, has some availability in the next quarter to take on new project work. If you could use help with user interface design, a desktop or mobile app, marketing website, intranet, or software service product, let me know. We'd love to help!

Fynydd: Software Development and Hosting
Fynydd: Software Development and Hosting

fynydd.com

#tech #recommendation #code

Jun 28, 2018

The more I use other languages & web dev platforms, the more I appreciate the power and reliability of C# and .NET.

ASP.NET MVC Pattern | .NET
ASP.NET MVC Pattern | .NET

asp.net

#code #dotnet #tech #csharp

Dec 1, 2016

Page 1 of 1
Pageof 1

Copyright © 2024 Michael Argentini. All rights reserved.