Skip to content

Instantly share code, notes, and snippets.

View hjr3's full-sized avatar

Herman J. Radtke III hjr3

View GitHub Profile
@hjr3
hjr3 / dc_2017_biblio.md
Last active November 16, 2017 11:38 — forked from BaseCase/dc_2017_biblio.md
List of resources recommended or mentioned by the speakers at Deconstruct 2017

Deconstruct 2017 Bibliography

Here are all of the resources mentioned by Deconstruct 2017 speakers, along with who recommended what. Please post a comment if I missed something or have an error!

DC 2017 Speakers' Choice Gold Medalist

  • Seeing Like a State by James Scott

Books

  • Public Opinion by Walter Lippmann (Evan Czaplicki)
  • A Pattern Language by Christopher Alexander (Brian Marick)
  • Domain Driven Design by Eric Evans (Brian Marick)
@hjr3
hjr3 / mpsc.rs
Created March 2, 2017 19:03
MSPC example that doesn't use wait
#[macro_use] extern crate log;
extern crate env_logger;
extern crate futures;
extern crate tokio_core;
use std::{thread, time};
use futures::{Stream, Sink, Future};
use futures::sync::mpsc;
@hjr3
hjr3 / fork-exec.rs
Created December 23, 2016 02:01 — forked from Geal/fork-exec.rs
extern crate nix;
extern crate libc;
use nix::sys::signal::*;
use nix::unistd::*;
use nix::fcntl::{fcntl,FcntlArg,FdFlag,FD_CLOEXEC};
use libc::c_char;
use std::mem;
use std::str;
@hjr3
hjr3 / exercise1.rs
Created October 27, 2016 04:15
Rust Belt Rust: Building Better Function Interfaces Workshop - Exercise 1
use std::mem;
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct NameString {
inner: String,
}
impl NameString {
pub fn from_str(s: &str) -> NameString {
@hjr3
hjr3 / exercise2.rs
Created October 27, 2016 04:15
Rust Belt Rust: Building Better Function Interfaces Workshop - Exercise 2
use std::borrow::{Borrow, BorrowMut, Cow};
use std::mem;
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct NameString {
inner: String,
}
impl NameString {
pub fn from_str(s: &str) -> NameString {
@hjr3
hjr3 / rust-naming-conventions.md
Created October 20, 2016 14:28
Rust Naming Conventions
Convention Example General Meaning
to_*() str::to_string() A conversion from one type to another that may have an allocation or computation cost. Usually a Borrowed type to Owned type.
as_*() String::as_str() Convert an Owned type into a Borrowed type. It is usually cheap (maybe even zero-cost) to use this function.
into_*() String::into_bytes() Consume a type T and convert it into an Owned type U.
from_*() SocketAddr::from_str() Create an Owned type from an Owned or Borrowed type.
*_mut() str::split_at_mut() Denotes a mutable reference.
try_*() usize::try_from() Method will return a Result or Option type. Usually Result.
with_*() Vec::with_capacity() A constructor that has one or more parameters used to configure the type.
/// Building a Ipv4Header struct
///
/// Ipv4Header has the same byte representation as `struct ip` in C. The
/// builder pattern provides a better interface for dealing with byte order
/// specific unions. It also means we can use types like `Ipv4Addr` instead
/// of `c::in_addr`.
let ip: Ipv4Header = Ipv4HeaderBuilder::new() // sets version and internet header length (ihl)
.tos(Tos::low_delay())
.data_length(::std::mem::size_of::<CarpHeader>()) // calculates proper total length
.random_id()

Keybase proof

I hereby claim:

  • I am hjr3 on github.
  • I am hjr3 (https://keybase.io/hjr3) on keybase.
  • I have a public key whose fingerprint is 0B78 6B54 89BA 2C1A DA27 C22E B772 172A 553C B2D7

To claim this, I am signing this object:

@hjr3
hjr3 / adams-heroku-values.md
Created December 4, 2015 03:39 — forked from adamwiggins/adams-heroku-values.md
My Heroku values

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@hjr3
hjr3 / telegram.rs
Created April 15, 2015 07:33
Example of a solution to the telegram problem using channels in Rust
use std::sync::mpsc::channel;
use std::thread;
fn main() {
let line_length = 40;
let input = vec!("The task is",
"to write a program which",
"accepts",
"lines of text and generates output",