Skip to content

Instantly share code, notes, and snippets.

View kwikwag's full-sized avatar

kwikwag kwikwag

  • Developer of the world
View GitHub Profile
@kwikwag
kwikwag / README.md
Created October 6, 2026 19:50
Workaround - fix clef-flash on Windows ollama 0.35.1 by patching the GGUF file

How it works

  1. Runs ollama show <model> --modelfile and finds the GGUF blob that contains clef.* tensors.
  2. Moves the clef.* tensors to the front of the data section, which puts them below 4 GiB, and reorders the tensor table to match.
  3. Runs ollama create <new-name> with the original Modelfile and the new path, then deletes the temporary copy.
  4. If the head is already below 4 GiB, it exits without doing anything.

It needs about 10 GB of temporary disk (TEMP or TMPDIR) plus about 10 GB for the new model.

import multiprocessing.managers
import multiprocessing.pool
import queue
from contextlib import contextmanager
import torch
_was_init = False
@kwikwag
kwikwag / node-engine-strict.js
Created April 29, 2025 09:31
A script that ensures your project runs with a Node.js version that satisfies the `engines.node` field in your `package.json`, using either NVM or the system-installed Node.js.
/*
# `node-engine-strict.js`
A script that ensures your project runs with a Node.js version that satisfies
the `engines.node` field in your `package.json`.
It works by checking for a compatible version installed via **NVM** (Node
Version Manager), and will fall back to the system-installed Node.js if it's
compatible. If neither is suitable, the script exits with an error.
@kwikwag
kwikwag / install-docker.sh
Created May 3, 2021 07:48
Install Docker on Ubuntu/Debian
#!/bin/bash
# based on https://docs.docker.com/engine/install/debian/
# and https://docs.docker.com/engine/install/ubuntu/
# at 2021-05-03
dist=$(lsb_release --id --short | awk '{ print tolower($0) }')
: : : Set up the Docker repository && \
sudo apt update && \
sudo apt -y install \
apt-transport-https \
import argparse
import os
import random
parser = argparse.ArgumentParser()
parser.add_argument('file')
args = parser.parse_args()
data = []
read_size = 1024 * 4
@kwikwag
kwikwag / rect_red.svg
Created April 16, 2018 06:57
SVG img tag sizing problem
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwikwag
kwikwag / build.bat
Created August 22, 2017 22:54
Windows build batch file for Live555, based on instructions by @nspool
@rem Place this file at the live/ directory of the downloaded LIVE555 source files.
@rem Based on instructions at https://nspool.github.io/2016/02/building-live555/
@rem Tested with Visual Studio 2015 on Windows 10
@echo off
if exist "%TEMP%\sed.vbs" goto skip_gen_sed
> "%TEMP%\sed.vbs" (
REM thanks to https://stackoverflow.com/questions/127318/is-there-any-sed-like-utility-for-cmd-exe
@echo.Dim pat, patparts, rxp, inp
@echo.pat = WScript.Arguments(0^)
@kwikwag
kwikwag / test-split-tail-head.py
Created May 12, 2017 17:53
Python: splitting a string into two parts at the nth delimiter
from timeit import timeit
import re
def a(s, delim, n):
'''
Two-param split, retaining head
'''
r = s.split(delim, n)[n]
return s[:-len(r)-len(delim)], r
import timeit
from math import pow
import sys
# Python 2/3 compatible
# note : alternative versions of this file had pow(x,0.33) replaced with
# sqrt(x) or max(x,33,1,2,3,4,5,6,6,7,8,9) to see the effect of the
# number of arguments on run times.
#!/usr/bin/env python
import re
import fastnumbers
def is_int1(v):
try:
int(v)
return True
except ValueError: