Skip to content

Instantly share code, notes, and snippets.

View dzfranklin's full-sized avatar

Daniel Franklin dzfranklin

  • Dundee, UK
  • 06:56 (UTC +01:00)
View GitHub Profile
defp deps do
[
{:phoenix, "~> 1.5.3"},
{:phoenix_ecto, "~> 4.1"},
{:ecto_sql, "~> 3.4"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_dashboard, "~> 0.2.0"},
{:telemetry_metrics, "~> 0.4"},
// NOTE: PageRenderer translates coordinates and offsets relative to the start of the page
// to coordinates relative to the backing MultiParagraph, calls functions on it, and
// translates the return values
package org.danielzfranklin.librereader.ui.screen.reader.paginatedText
import android.os.Parcelable
import androidx.compose.foundation.gestures.*
import androidx.compose.foundation.text.selection.*
import androidx.compose.runtime.*
@dzfranklin
dzfranklin / ExposedDropdownMenu.kt
Last active March 3, 2021 15:44
Composable ExposedDropdownMenu
package org.danielzfranklin.librereader.ui.component
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.FocusInteraction
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
@dzfranklin
dzfranklin / logs.txt
Created March 23, 2021 15:17
dmesg logs on the 76da672e5ef3bd85c237770d5a53676f0923796b (the old version I could build)
[ 16.214205] evdi: [I] Initialising logging on level 5
[ 16.214206] evdi: [I] Atomic driver:yes
[ 59.420823] evdi: [D] evdi_add_devices:156 Increasing device count to 1
[ 59.421071] evdi: [D] evdi_crtc_init:389 drm_crtc_init: 0 p0000000056e75eba
[ 59.421096] evdi: [D] evdi_detect:94 (dev=0) poll connector state: disconnected
[ 59.421110] evdi evdi.0: [drm] Cannot find any crtc or sizes
[ 59.421130] evdi: [W] evdi_painter_send_update_ready_if_needed:575 Painter does not exist!
[ 59.421553] [drm] Initialized evdi 1.7.0 20200327 for evdi.0 on minor 1
[ 59.493736] evdi: [D] evdi_detect:94 (dev=0) poll connector state: disconnected
[ 59.493784] evdi: [D] evdi_painter_framebuffer_size:511 Scanout buffer not set.
@dzfranklin
dzfranklin / with_tracing_subscriber.png
Last active April 20, 2021 21:13
tracing-subscriber interferes with debugger
with_tracing_subscriber.png
use ring::digest::{Algorithm, Context, Digest};
use std::{fmt, io};
pub struct WithDigest<W> {
inner: W,
ctx: Context,
}
impl<W> WithDigest<W> {
pub fn new(algorithm: &'static Algorithm, inner: W) -> Self {
Edit: TLDR: If you need to talk to a library that's very hard to write a completely sound abstraction for, consider writing a mostly sound one (with a clear disclaimer) instead of switching to a different language. Obviously this would be stupid if your code operates on untrusted inputs, but plenty of stuff doesn't. I'm writing code that takes input from your kernel.
I've been thinking recently about various articles by people who have given up on Rust projects, such as [the Way Cooler post mortem](http://way-cooler.org/blog/2020/01/09/way-cooler-post-mortem.html). I think one of the problems is that people sometimes feel it's "wrong" to write unsound code in Rust, so they give up or switch to another language, write unsound code in that language, and feel better about it. By unsound I mean unsafe code that is undefined behavior, i.e. violates the memory safety model of rust.
I find it interesting that I'm my experience people newer to writing unsafe Rust tend to see soundness in binary terms, whereas at l
@dzfranklin
dzfranklin / stderr.txt
Created May 6, 2021 16:45
Full output of `cargo build` of lldb-sys
Compiling lldb-sys v0.0.20 (/home/daniel/lldb-sys.rs)
The following warnings were emitted during compilation:
warning: src/lldb/Bindings/SBCommandInterpreterBinding.cpp: In function ‘SBCommandInterpreterRunOptionsOpaque* CreateSBCommandInterpreterRunOptions()’:
warning: src/lldb/Bindings/SBCommandInterpreterBinding.cpp:22:99: error: invalid use of incomplete type ‘class lldb::SBCommandInterpreterRunOptions’
warning: 22 | return reinterpret_cast<SBCommandInterpreterRunOptionsRef>(new SBCommandInterpreterRunOptions());
warning: | ^
warning: In file included from /usr/lib/llvm-11/include/lldb/API/SBBreakpoint.h:12,
warning: from src/lldb/Bindings/SBBreakpointBinding.h:15,
warning: from src/lldb/Bindings/LLDBBinding.h:21,
private class SectionsAnimationState constructor(
initialPosition: PagePosition,
private val renderer: Renderer,
private val onPosition: (PaginatedTextPosition) -> Unit,
) {
private val _positionBacking = mutableStateOf(initialPosition)
private var lastPageReportedToOnPosition = initialPosition.page.roundToInt()
private var _position
get() = _positionBacking.value
set(value) {
package com.backpackingmap.backpackingmap.ui.view
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.FocusInteraction
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier