Skip to content

Instantly share code, notes, and snippets.

View dherman's full-sized avatar

Dave Herman dherman

View GitHub Profile
@dherman
dherman / windows-strategy.md
Last active June 26, 2018 00:33
Notion strategy for Windows

Goal: Per-User Installation Model

  • install Notion executables in user path
  • install Notion files in user profile
  • install Notion registry settings in HKCU

Goal: Per-Console Env Mutation

  • Notion command is a pair of .cmd and .ps1 wrapper scripts
  • cmd.exe sees the .cmd script
@dherman
dherman / v8_trace.md
Last active June 16, 2018 03:41
SOLVED: I missed a conditional

Why doesn't this throw an exception?

SOLVED: It checks the length and returns without throwing in NEW_STRING

  } else if (length > i::String::kMaxLength) {                             \
    result = MaybeLocal<String>();                                         \

ASSERTION: DCHECK((isolate)-&gt;has_pending_exception())

dherman-mn1:cargo-edit dherman$ RUST_LOG=cargo=trace cargo install cargo-edit --git https://github.com/dherman/cargo-edit
Updating git repository `https://github.com/dherman/cargo-edit`
TRACE 2018-06-07T15:22:15Z: cargo::sources::git::source: updating git source `GitRemote { url: "https://github.com/dherman/cargo-edit" }`
DEBUG 2018-06-07T15:22:15Z: cargo::sources::git::utils: skipping gc as there's only 2 pack files
DEBUG 2018-06-07T15:22:15Z: cargo::sources::git::utils: doing a fetch for https://github.com/dherman/cargo-edit
DEBUG 2018-06-07T15:22:15Z: cargo::sources::git::utils: initiating fetch of refs/heads/*:refs/heads/* from https://github.com/dherman/cargo-edit
INFO 2018-06-07T15:22:15Z: cargo::sources::git::utils: update submodules for: "/Users/dherman/.cargo/git/checkouts/cargo-edit-d8e23e4da1869f61/0684637/"
TRACE 2018-06-07T15:22:15Z: cargo::ops::cargo_read_manifest: looking for root package: /Users/dherman/.cargo/git/checkouts/cargo-edit-d8e23e4da1869f61/0684637, source_id=https://github.com
@dherman
dherman / variant-a.rs
Last active May 7, 2018 23:43
a few variations on VM 2.0
// VARIANT A: SINGLE VM TRAIT WITH "VM" CONVENTION
// trait Vm<'a>: a context-sensitive view into the VM
// - Call<'a> impl Vm<'a>
// - MethodCall<'a, C: Class> impl Vm<'a>
// - ModuleInit<'a> impl Vm<'a>
// convention: name the Call `vm`
// all APIs that call into JS take an &mut impl Vm
fn extract_usage(s: &str) -> &str {
let (start, _) = s.match_indices("Usage:").next().unwrap();
let s = &s[start..];
let (end, _) = s.match_indices("\n\n").next().unwrap();
let s = &s[..end];
s.trim()
}
@dherman
dherman / 1-catalog-result.rs
Last active February 10, 2018 05:46
A/B comparison with `Fallible` and without
use std::collections::BTreeSet;
use std::fs::{File, remove_dir_all};
use std::io::{self, Write};
use std::str::FromStr;
use std::string::ToString;
use lazycell::LazyCell;
use readext::ReadExt;
use reqwest;
use toml;
@dherman
dherman / serde_custom.rs
Created February 4, 2018 17:51
example code of custom serialization/deserialization
#[derive(Eq, PartialEq, Clone)]
pub struct ToolVersion(Version);
impl Serialize for ToolVersion {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let &ToolVersion(ref version) = self;
let unparsed = format!("{}", version);
serializer.serialize_str(&unparsed[..])
}
}
// examples of `deserialize_with` and `serialize_with` in serde
#[derive(Serialize, Deserialize, Eq, PartialEq)]
#[serde(untagged)]
pub enum Version {
#[serde(serialize_with = "serialize_public")]
#[serde(deserialize_with = "deserialize_public")]
Public(String)
}
@dherman
dherman / classes_two_point_oh.rs
Last active December 20, 2017 06:52
classes 2.0
#[macro_use]
extern crate neon;
struct GreeterInternals {
greeting: String,
separator: String
};
classic_module! {
//! The `neon` crate provides the entire [Neon](https://www.neon-bindings.com/) API.
extern crate neon_runtime;
extern crate cslice;
#[cfg(test)]
extern crate rustc_version;
pub mod mem;
pub mod vm;