Instantly share code, notes, and snippets.

View docker-compose.yml
version: "3.2"
services:
rust:
image: rust:1.29.2 # alternatively choose one from https://hub.docker.com/u/japaric/
volumes:
- type: bind
source: './'
target: /app/code
read_only: true
- type: volume
View Makefile
PANDOC ?= $(shell which pandoc)
INPUT_FOLDER ?= $(shell pwd)/src
OUTPUT_FOLDER ?= $(shell pwd)/dist
LIB_FOLDER ?= $(shell pwd)/lib
IMAGES_FOLDER ?= $(INPUT_FOLDER)/figures
REVEAL_TEMPLATE ?= $(LIB_FOLDER)/template.html
MARKDOWN_OPTIONS ?= markdown-citations
FILTER_OPTIONS ?=
# FILTER_OPTIONS ?= --filter pandoc-citeproc
View rust-versioned-serde.md

Ideas for versioned serde struct

Goals

  • version external APIs
    • read (write?) data of older versions
  • be agnostic over protocol (but we'll actually use JSON in our examples)

First draft

View playground.rs
#[macro_use] extern crate serde_derive;
extern crate serde_json;
use std::borrow::Cow;
#[derive(Debug, Deserialize)]
struct Foo<'input> {
#[serde(borrow)]
bar: Cow<'input, str>,
}
View playground.rs
#[macro_use] extern crate serde_derive;
extern crate serde_json;
use std::borrow::Cow;
#[derive(Debug, Deserialize)]
struct Foo<'input> {
#[serde(borrow)]
bar: Cow<'input, str>,
}
View playground.rs
#[macro_use] extern crate serde_derive;
extern crate serde_json;
use std::borrow::Cow;
#[derive(Debug, Deserialize)]
struct Foo<'input> {
bar: Cow<'input, str>,
}
View run_like_fuzzer.rs
/// Add this as integration test
extern crate rsass;
pub fn fuzz_rsass_sass(data: &[u8]) {
use rsass::{OutputStyle, compile_scss};
let _ = compile_scss(data, OutputStyle::Compressed);
}
#[test]
View config_magic.rs
/// just some api ideas
#[test]
fn config_loading() {
let fs = MockFS::new()
.file("/usr/local/etc/foo", "fancy = 10")
.file("~/.config/foo", "fancy = 20")
.file(".env", "LE_PREFIX_FANCY=30");
#[derive(Default, Configure, StructOpt)]
View Cargo.lock
[[package]]
name = "alsa-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
View fixit.fish
function fixit --description 'restart a bunch of macOS services that tend to break'
sudo killall -KILL appleeventsd
sudo killall VDCAssistant
sudo killall AppleCameraAssistant
sudo killall -HUP mDNSResponder
killall Dock
killall Spotlight
end