Skip to content

Instantly share code, notes, and snippets.

View carols10cents's full-sized avatar

Carol (Nichols || Goulding) carols10cents

View GitHub Profile
@carols10cents
carols10cents / crate-publish.md
Last active December 2, 2019 19:17
Current and proposed crate publish procedure in diff format

Proposed

Notes

  • We enforce a 50MB max in nginx
  • We should add a configuration entry for the global max size of the metadata (we currently use max tarball size several places)
  • A few guidelines I tried to follow:
    • Identify and reject invalid requests as quickly as possible.
    • Minimize the work done while holding a database connection, especially after entering the main transaction.
  • The final main transaction may need to repeat some queries to ensure it doesn't rely on data obtained outside of the transaction.
$ dig -t ns crates.io
; <<>> DiG 9.10.6 <<>> -t ns crates.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25517
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
@carols10cents
carols10cents / learn-rust.md
Last active October 28, 2019 13:21
Carol's Recommended Resources for learning Rust

Installing Rust

  • Go to rustup.rs and follow the instructions there. Rustup helps you keep Rust up to date.

Learning Rust

@carols10cents
carols10cents / ajax_settings.coffee
Last active April 11, 2019 16:35
One way to get Rails and Backbone CSRF protection working
# In your Backbone app, wherever you want -- we put this in lib/ajax_settings.coffee
define [
'backbone',
'cookie' # This is https://github.com/js-coder/cookie.js,
# we have a bower-compatible fork at https://github.com/thinkthroughmath/cookie.js
], (Backbone, cookie) ->
init: ->
# This overrides all ajax requests sent through Backbone. We could have set this in jQuery
# since Backbone ultimately calls the jQuery ajax functions, but we decided we shouldn't be
# doing ajax requests outside of Backbone anyway.
@carols10cents
carols10cents / crate-breakage-saga.md
Last active December 19, 2018 12:59
Descriptions of the breakages I'm experiencing today
  • I'm using rustc 1.9.0-dev (28c9fdafc 2016-04-11), cargo 0.10.0. Yes, I run nightly but don't update it every night. dealwithit.gif

  • I wanted to get back to working on eeyore. Master compiles fine.

  • I want to use this branch of hubcaps I've been working on, and that I rebased on hubcaps master today.

  • I changed eeyore's Cargo.toml to use my collabs branch of hubcaps (hubcaps = { git = "https://github.com/carols10cents/hubcaps", branch = "collabs" }) and ran cargo update. Perhaps I should have run cargo update -p hubcaps here...

  • Now compiling eeyore, I get:

/Users/carolnichols/.cargo/registry/src/github.com-88ac128001ac3a9a/bodyparser-0.1.0/src/lib.rs:78:18: 78:21 error: the trait bound `persistent::Read<MaxBodyLength>: plugin::Plugin<iron::Request<'_, '_>>` is not satisfied [E0277]
/Users/carolnichols/.cargo/registry/src/github.com-88ac128001ac3a9a/bodyparser-0.1.0/src/lib.rs:78                 
@carols10cents
carols10cents / playground.rs
Last active October 31, 2018 00:18 — forked from rust-play/playground.rs
Code shared from the Rust Playground
fn save_status(text: &str) -> Result<i64, &'static str> {
if text.len() > 200 {
return Err("status is too long, must be under 200 bytes");
}
let id = save_to_database(text)?;
// log id to server logs
fn main() {
let s = String::from("book");
// Add code here that calls the pluralize function
println!(
"I have one {}, you have two {}",
s,
you_add_something_here,
);

I currently have this working diesel code:

    let recent_downloads = sql::<Nullable<BigInt>>("SUM(crate_downloads.downloads)");
    let most_recently_downloaded = crates
        .left_join(
            crate_downloads::table.on(id.eq(crate_downloads::crate_id)
                .and(crate_downloads::date.gt(date(now - 90.days())))),
        )
        .group_by(id)
@carols10cents
carols10cents / abstract.md
Created December 3, 2017 16:16
Morgantown codes abstract

What is this Rust thing anyway?

Rust is a new systems programming language out of Mozilla research aiming to be a safer alternative to C and C++ without sacrificing performance. Come learn how Rust prevents buffer overflows, ensures memory safety, and prevents data races while also providing modern development workflows through Cargo and an ever-growing ecosystem of open source libraries on Crates.io. Hear about how companies like Mozilla, npm, Dropbox, and Chucklefish are using Rust to make better software. Discover how you can get involved with Rust's friendly community!

curl 'https://api.github.com/teams/866115/memberships/Manishearth' -H 'Accept: application/vnd.github.v3+json' -H 'User-Agent: hello!' -H 'Authorization: token INSERTTOKENHERE'