Skip to content

Instantly share code, notes, and snippets.

View cecilemuller's full-sized avatar

Cecile Muller cecilemuller

View GitHub Profile
@cecilemuller
cecilemuller / package.json
Last active April 16, 2024 17:59
Subpath Imports:
{
"imports": {
"#components/*": "./src/components/*",
"#functions/*": "./src/functions/*"
}
}
@cecilemuller
cecilemuller / prettierPlugin.ts
Created April 15, 2024 07:35
Vite Plugin: Prettier
import type {PluginOption} from "vite";
import {format} from "prettier";
/**
* Format HTML pages using Prettier.
*/
export function prettierPlugin(): PluginOption {
return {
name: "prettier",
transformIndexHtml: {
@cecilemuller
cecilemuller / vite.config.js
Created April 4, 2024 15:51
Vite: multiple entries, independant output paths
/* eslint-env node */
import {fileURLToPath} from "node:url";
/**
* @returns {import("vite").PluginOption}
*/
function buildPlugin(pages) {
return {
name: "change-html-output",
enforce: "post",
@cecilemuller
cecilemuller / README.md
Last active April 2, 2024 01:04
Vite generates en empty script when `build.rollupOptions.input` is set

Merely setting build.rollupOptions.input forces a script to be generated even if the page has none (whereas the default behavior doesn't generate the empty js file):

vite.config.js points to the same default location:

export default {
    build: {
        rollupOptions: {
            input: "index.html"
        }
 }
@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 / extension.cjs
Last active August 15, 2023 01:25
VSCode: Open Webview Developer Tools automatically
/* eslint-env node */
"use strict";
const vscode = require("vscode");
function activate(context) {
const provider = new ExampleProvider(context.extensionUri);
context.subscriptions.push(
vscode.window.registerWebviewViewProvider("example", provider)
);
// ...
@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 / parse-lnk.ps1
Last active July 23, 2023 12:16
PowerShell: parse .lnk file
$sh = New-Object -ComObject WScript.Shell; $sh.CreateShortcut("example.lnk").TargetPath
@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 / noncopyable.swift
Created June 8, 2023 11:13
Swift 5.9: Noncopyable struct
// Noncopyable struct: passed by reference
// and only one variable can hold the reference.
struct User: ~Copyable {
var name: String
// Read-only
func read() {
print(self.name)
// self.name = "BBBBB" // Error: 'self' is immutable
}