Skip to content

Instantly share code, notes, and snippets.

View cderv's full-sized avatar

Christophe Dervieux cderv

View GitHub Profile
@cderv
cderv / update-pandoc.sh
Last active May 3, 2024 09:31
Update scripts - Ubuntu
#! /bin/bash
# Using gh cli
# check tool requirement
if [[ -z $(command -v gh) ]]
then
echo "Github CLI tool (gh) needs to be installed. See https://cli.github.com/"
exit 1
fi
@cderv
cderv / 00-New setup.md
Last active March 26, 2024 10:09
New computer setup
# installed by winget
winget install PowerShell-Preview
winget install git
git config --global user.name "Christophe Dervieux"
git config --global user.email christophe.dervieux@gmail.com
winget install rstudio
winget install vscode
winget install -e R
winget install Github.GithubDesktop
@cderv
cderv / README.md
Last active February 21, 2024 15:56
revdepcheck helpers

Script that helps me with revdepcheck

Getting setup

Download the scripts

get_gist <- function(where = "revdep/tools") {
  gist_id <- "7018c926b14ec45d1a34e70e018db2d5"
 fs::dir_create(where)
@cderv
cderv / about_download_methods.md
Last active January 12, 2024 02:43
download file methods in R

download.file methods in R

Working on a PR for remotes package (this PR), I looked into how download.file methods evolved with R version, trying to understand how it works depending on the system or the url type.

Here is my understanding.

History of download.file

from R news

R 3.3.0

@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 / 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
@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 / 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