Skip to content

Instantly share code, notes, and snippets.

View cderv's full-sized avatar

Christophe Dervieux cderv

View GitHub Profile
@cderv
cderv / Copy-BetweenWslInstance.psm1
Last active December 20, 2023 10:56
Copy files between WSL distributions
# This function, Copy-BetweenWslInstance, is designed to facilitate the copying of files between different WSL distributions.
# It requires the source and destination distributions, folders, and users as parameters.
# If the destination folder or user is not specified, the function will default to using the source folder or user.
# The function employs the wslpath utility to convert the paths into a format that is compatible with WSL.
# Finally, it utilizes the Copy-Item cmdlet to execute the file copying process.
function Copy-BetweenWslInstance {
param(
[Parameter(Mandatory=$true)]
[string]$sourceDistribution,
[Parameter(Mandatory=$true)]
@cderv
cderv / LICENSE.md
Last active October 4, 2023 14:55
Use display math to number equation in Bookdown

Copyright 2023 Christophe Dervieux

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH

@cderv
cderv / sort-text-file.ts
Created July 27, 2023 14:25
Sort Text file content in Typescript
import { readLines } from "https://deno.land/std@0.196.0/io/read_lines.ts";
const f= await Deno.open('tests/timing-for-ci.txt');
let counter = 0
const timedTests = [];
const timed = [];
let test: string;
let time: string;
@cderv
cderv / long-plotly-data.html
Last active July 7, 2023 12:40
Example for downlit bug with long plotly data
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head></head>
<body>
<div id="plotly">
<script type="application/json" data-for="htmlwidget-5fa2f8dac72d5da20b9f">{"x":{"data":[{"x":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103
#!/bin/sh
# Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
@cderv
cderv / README.md
Last active April 19, 2023 09:21
pretty output for `pandoc lua`

We don't get pretty output by default with pandoc lua like we do with --to native

 pandoc -f markdown -t native
![My Image](local/img/jpg)
^Z
[ Figure
    ( "" , [] , [] )
    (Caption
 Nothing [ Plain [ Str "My" , Space , Str "Image" ] ])
@cderv
cderv / test.md
Last active March 20, 2023 17:02
Pandoc GFM TOC demo - bug
@cderv
cderv / update-pandoc.sh
Last active October 9, 2023 10:40
Update scripts - Arch Linux
#! /bin/bash
# Using gh cli
gh --repo jgm/pandoc release download --pattern '*amd64.deb'
sudo dpkg -i $(ls pandoc-*.deb)
rm $(ls pandoc-*.deb)
@cderv
cderv / switch-path.psm1
Last active January 11, 2023 15:25
Switch between Dev and Release Quarto binary
function Switch-Path {
param()
$paths=$([Environment]::GetEnvironmentVariable('Path','User') -Split ";")
$dev = $paths | Select-String -SimpleMatch "quarto-cli\package\dist\bin"
$rel = $paths | Select-String -SimpleMatch "scoop\shims"
@cderv
cderv / setup-sandbox.ps1
Last active December 14, 2023 14:12
Setup Windows sandbox
# --- Setup so tools from github release ----------
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
# --- Tools -----
function Get-GithubLatestRelease {
param (
[parameter(Mandatory)][string]$project, # e.g. paintdotnet/release
[parameter(Mandatory)][string]$pattern, # regex. e.g. install.x64.zip
[switch]$prerelease