Skip to content

Instantly share code, notes, and snippets.

View cecilemuller's full-sized avatar

Cecile Muller cecilemuller

View GitHub Profile
@cecilemuller
cecilemuller / README.md
Last active October 20, 2023 09:42
Docker Compose Watch

Example for compose watch:

  • "watch" requires a "build" section
  • files created at runtime in the host get copied to the container
  • files deleted in the host aren't deleted in the container
  • files created in the container at build time aren't copied back to the host
  • files created in the container at runtime aren't copied back to the host
  • you'd still need a "volume" if the host must access files generated in the container
@cecilemuller
cecilemuller / commands.sh
Last active August 2, 2023 13:30
LLM on MacOS
brew install llm
llm install llm-llama-cpp
llm install llama-cpp-python
llm llama-cpp download-model https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/resolve/main/llama-2-7b-chat.ggmlv3.q8_0.bin --alias llama2-7b --llama2-chat
llm llama-cpp download-model https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/resolve/main/llama-2-13b-chat.ggmlv3.q8_0.bin --alias llama2-13b --llama2-chat
llm llama-cpp download-model https://huggingface.co/TheBloke/Wizard-Vicuna-7B-Uncensored-GGML/resolve/main/Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin --alias wizard-7b --alias autocomplete
llm -m llama2-7b 'Tell me a joke about a bird' --system 'You are funny'
llm -m llama2-13b 'Tell me a joke about a bird' --system 'You are funny'
@cecilemuller
cecilemuller / pwsh.mjs
Last active July 24, 2023 09:44
Run Powershell 7 commands in Node.js
import {exec} from "node:child_process";
/**
* Runs a Powershell 7 command.
* @param {string} command
* @returns {string}
* @example const stdout = await pwsh(`Write-Output "Hello World"`);
* @example const stdout = await pwsh(`Write-Output "Hello"; Write-Output "World"`);
*/
export async function pwsh(command) {
@cecilemuller
cecilemuller / UIView+distort.swift
Created April 9, 2023 07:43
Swift: distort a UIView to fit arbitrary corners
import UIKit
extension UIView {
/// Updates `anchorPoint`, `frame`, and `layer.transform` to fit arbitrary corners.
/// Based on https://stackoverflow.com/questions/9470493/transforming-a-rectangle-image-into-a-quadrilateral-using-a-catransform3d/39981054#39981054
func distort(topLeft tl: CGPoint, topRight tr: CGPoint, bottomLeft bl: CGPoint, bottomRight br: CGPoint) {
// Frame ----------------------------------------------------------- /
let xmin = min(tr.x, tl.x, bl.x, br.x)
let ymin = min(tr.y, tl.y, bl.y, br.y)
let xmax = max(tr.x, tl.x, bl.x, br.x)
@cecilemuller
cecilemuller / OrientationDamper.swift
Last active February 16, 2023 13:33
Swift Dampers
import simd
// Interpolate a Quaternion without specifying duration, in the style of Herbert Stocker's X3D OrientationDamper:
// https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/sai/Followers/OrientationDamper.html
class OrientationDamper {
private(set) var isActive: Bool = false
private(set) var value: simd_quatf
private(set) var destination: simd_quatf
private(set) var tau: Float
private(set) var tolerance: Float
@cecilemuller
cecilemuller / Example.swift
Last active November 6, 2022 19:56
CSS HSL "linear-gradient" to Swift "CAGradientLayer"
// CSS gradient generated by https://www.joshwcomeau.com/gradient-generator/
// hsl(199deg 95% 55%) 0%
// hsl(140deg 63% 65%) 50%
// hsl(99deg 100% 50%) 100%
let gradient = CAGradientLayer()
// ...
gradient.type = .axial
gradient.colors = [
UIColor.hsl(degrees: 199, saturation: 0.95, lightness: 0.55).cgColor,
@0b5vr
0b5vr / compeko.js
Last active April 3, 2024 03:11
compeko: pack JavaScript into a self-extracting html+deflate
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run
// compeko - pack JavaScript into a self-extracting html+deflate
// v2.0.0
// Copyright (c) 2022-2024 0b5vr
// SPDX-License-Identifier: MIT
// Usage:
// - prepare a js code, which will be fed into `eval`
@cecilemuller
cecilemuller / example.scss
Created January 18, 2022 22:52
Animated CSS Custom Property
// Static value by default:
// https://caniuse.com/css-variables
:root {
--example: 0deg;
}
.myclass {
background-image: linear-gradient( var(--example), red, green 50%, blue );
}
// Animated value where supported:
@cecilemuller
cecilemuller / main.ts
Last active December 20, 2022 10:27
Typescript Webworker
/* eslint-env browser */
import type {IRequestWorker} from "./worker.ts";
const worker = new Worker(new URL("./worker.ts", import.meta.url)) as IRequestWorker;
// Receive from the worker
worker.onmessage = ({data: {myresponse}}) => {
console.log(myresponse);
};