Skip to content

Instantly share code, notes, and snippets.

use std::collections::hash_set::HashSet;
use std::vec::Vec;
use std::time::{Instant,Duration};
use std::env;
const SAMPLE_INTERVAL : usize = 1000;
fn duration_ns(d : Duration) -> i64 {
return (d.as_secs() as i64) * 1000000000 + (d.subsec_nanos() as i64);
}
BootCurrent: 0001
Timeout: 2 seconds
BootOrder: 0001,0017,0000,0018,0019,001A,001B,001C,0021
Boot0000* Windows Boot Manager HD(1,GPT,d72d73a1-3247-41ca-af0b-cd5af1642048,0x800,0x100000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}....................
Boot0001* ubuntu HD(1,GPT,d72d73a1-3247-41ca-af0b-cd5af1642048,0x800,0x100000)/File(\EFI\ubuntu\grubx64.efi)
Boot0010 Setup FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011 Boot Menu FvFile(126a762d-5758-4fca-8531-201a7f57f850)
Boot0012 Diagnostic Splash Screen FvFile(a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380)
Boot0013 Lenovo Diagnostics FvFile(3f7e615b-0d45-4f80-88dc-26b234958560)
Boot0014 Startup Interrupt Menu FvFile(f46ee6f4-4785-43a3-923d-7f786c3c8479)
$ ruby -e 'puts ("".split(" ")).inspect'
[]
$ perl -MData::Dumper -E 'say Dumper([split(" ", "")])'
$VAR1 = [];
$ python -c 'print "".split(" ")'
['']
# https://play.golang.org/p/qErK71KCsF
@nelhage
nelhage / acha_senate.txt
Created June 12, 2017 20:45
AHCA Senate Call Script
My name is Nelson Elhage. I'm a constituent of the Senator's in zip
code 94102.
I’m calling to express deep concern that Senate Republicans are
threatening to call for a vote on the ACA repeal without any public
hearings, and are keeping the text of the bill hidden from the public.
I urge the Senator to use every procedural tool at her disposal to
stop business as usual in the Senate and prevent this bill from
passing. I urge her to withhold consent when the bill comes to the
@nelhage
nelhage / cxx-move-semantics.cc
Created November 27, 2017 18:22
Which of these compile?
#include <memory>
using namespace std;
void accept_val(unique_ptr<int> i);
void accept_ref(unique_ptr<int> &i);
void accept_cref(const unique_ptr<int> &i);
void accept_rref(unique_ptr<int> &&i);
int main(int argc, char **argv) {
@nelhage
nelhage / README.md
Created April 26, 2018 03:14
Experience report: Trying to map an `FnMut` over a binary tree in Rust

This story is simplified from an attempt to write an AST walker for a toy compiler, but the essential facts are unchanged.

I am fairly new to Rust (but an experienced C++ programmer) and am trying to write a program to map an FnMut over a binary tree. I start with a simple tree definition, and try to write what seems to me to be the straightforward code:

use std::rc::Rc;
#include <thread>
#include <experimental/optional>
#include <atomic>
#include <shared_mutex>
#include <mutex>
#include <iostream>
#include <vector>
using namespace std;
@nelhage
nelhage / float.cc
Last active February 6, 2019 15:42
#include <stdio.h>
#include <math.h>
#include <stdint.h>
static float rt(float x) {
volatile double g = static_cast<double>(x);
return static_cast<float>(g);
}
int main() {
https://www.dropbox.com
https://drive.google.com
https://aws.amazon.com
https://cloud.google.com
https://hangouts.google.com/
https://www.salesforce.com
https://www.bitfinex.com
https://www.coinbase.com/
https://gemini.com/
https://bitbucket.org
@nelhage
nelhage / main.go.c
Last active September 22, 2020 02:49
A Go/C polyglot
// \
/*
#include <stdio.h>
int main() {
printf("Hello, World from C!\n");
return 0;
}
#if 0
//*/