Skip to content

Instantly share code, notes, and snippets.

View dralletje's full-sized avatar
🛰️
😱🦁🤨

Michiel Dral dralletje

🛰️
😱🦁🤨
View GitHub Profile
@dralletje
dralletje / awesome-line-wrapping.js
Created October 13, 2022 19:40
Latest version of my soft-wrapping codemirror extension
/**
* Plugin that makes line wrapping in the editor respect the identation of the line.
* It does this by adding a line decoration that adds padding-left (as much as there is indentation),
* and adds the same amount as negative "text-indent". The nice thing about text-indent is that it
* applies to the initial line of a wrapped line.
*
* The identation decorations have to happen in a StateField (without access to the editor),
* because they change the layout of the text :( The character width I need however, is in the editor...
* So I do this ugly hack where I, in `character_width_listener`, I fire an effect that gets picked up
* by another StateField (`extra_cycle_character_width`) that saves the character width into state,
### A Pluto.jl notebook ###
# v0.17.1
using Markdown
using InteractiveUtils
# ╔═╡ 19f83c25-828c-4cf3-9086-9088e51f07f9
import HypertextLiteral: @htl
# ╔═╡ fc30418d-ed9a-4287-be30-ed1fa4ec3fc7
### A Pluto.jl notebook ###
# v0.17.1
using Markdown
using InteractiveUtils
# ╔═╡ 169b7cf5-e220-43e9-8041-6d22936bb5bd
import Pkg
# ╔═╡ e24a3b1f-bc46-44e6-83d7-fa0f98011fd8
### A Pluto.jl notebook ###
# v0.17.1
using Markdown
using InteractiveUtils
# ╔═╡ 19f83c25-828c-4cf3-9086-9088e51f07f9
import HypertextLiteral: @htl
# ╔═╡ fc30418d-ed9a-4287-be30-ed1fa4ec3fc7
### A Pluto.jl notebook ###
# v0.17.1
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
@dralletje
dralletje / awesome-line-wrapping.js
Created September 25, 2021 20:25
Codemirror 6 line wrapping that preserves indentation
import _ from "lodash"
import { StateEffect, StateField } from "@codemirror/state"
import { EditorView, Decoration } from "@codemirror/view"
/**
* Plugin that makes line wrapping in the editor respect the identation of the line.
* It does this by adding a line decoration that adds padding-left (as much as there is indentation),
* and adds the same amount as negative "text-indent". The nice thing about text-indent is that it
* applies to the initial line of a wrapped line.
*
@dralletje
dralletje / ColoredTerminal.jl
Last active November 18, 2023 22:25
Colored `with_terminal` for Pluto.jl
### A Pluto.jl notebook ###
# v0.15.1
using Markdown
using InteractiveUtils
# ╔═╡ 2da76520-1615-11ec-1ad7-8f93957b2e6e
import IOCapture
# ╔═╡ 7d63286d-2320-49bf-a8a1-e538f53ba829
@dralletje
dralletje / Stacktrace.md
Created May 3, 2021 19:46
BoundsError: attempt to access 1-element Vector{String} at index [2]

BoundsError: attempt to access 1-element Vector{String} at index [2]

  1. getindex @ array.jl:801[inlined]
  2. (::NCAUtilities.var"#73#77"{Module})(::DataFrames.DataFrame, ::String, ::Int64) @ NCAUtilities.jl:179
  3. _broadcast_getindex_evalf @ broadcast.jl:648[inlined]
  4. _broadcast_getindex @ broadcast.jl:621[inlined]
  5. getindex @ broadcast.jl:575[inlined]
  6. copyto_nonleaf!(::Vector{Publish.Objects.Table{DataFrames.DataFrame}}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, NCAUtilities.var"#73#77"{Module}, Tuple{Base.Broadcast.Extruded{Vector{DataFrames.DataFrame}, Tuple{Bool}, Tuple{Int64}}, Base.RefValue{String}, Int64}}, ::Base.OneTo{Int64}, ::Int64, ::Int64) @ broadcast.jl:1078
  7. copy @ broadcast.jl:930[inlined]
  8. materialize @ broadcast.jl:883[inlined]
### A Pluto.jl notebook ###
# v0.14.0
using Markdown
using InteractiveUtils
# ╔═╡ 46b1e7b2-8460-11eb-3454-f7fa9542f903
begin
import Pkg
Pkg.add([
### A Pluto.jl notebook ###
# v0.14.0
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))