Skip to content

Instantly share code, notes, and snippets.

Ryan Levick rylev

Block or report user

Report or block rylev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rylev
rylev / rust-in-large-organizations-notes.md
Last active Oct 3, 2019
Rust in Large Organizations Notes
View rust-in-large-organizations-notes.md

Rust in Large Organizations

Initially taken by Niko Matsakis and lightly edited by Ryan Levick

Agenda

  • Introductions
  • Cargo inside large build systems
  • FFI
  • Foundations and financial support
@rylev
rylev / windows-crates.rb
Created Jul 22, 2019
Top Windows Crates
View windows-crates.rb
require "open-uri"
require "json"
PAGE_SIZE=100
NUM_PAGES=1
crates = (1..NUM_PAGES).flat_map do |page|
res = JSON.parse(URI.parse("https://crates.io/api/v1/crates?keyword=windows&page=#{page}&per_page=#{PAGE_SIZE}").read)
res["crates"].map {|c| {name: c["name"], repo: c["repository"]} }
end
@rylev
rylev / proposal.md
Last active Apr 13, 2019
File API Proposal
View proposal.md

First we have FileList which is simply a list of Files. This is an opaque struct that offers a way to iterate over Files and get individual files by index:

#[derive(Debug, Clone)]
struct FileList { ... }

impl FileList {
  fn get(index: usize) -> Option<File> { ... }

  fn len(&self) -> usize { ... }
@rylev
rylev / learn.md
Created Mar 5, 2019
How to Learn Rust
View learn.md

Learning Rust

The following is a list of resources for learning Rust as well as tips and tricks for learning the language faster.

Warning

Rust is not C or C++ so the way your accustomed to do things in those languages might not work in Rust. The best way to learn Rust is to embrace its best practices and see where that takes you.

The generally recommended path is to start by reading the books, and doing small coding exercises until the rules around borrow checking become intuitive. Once this happens, then you can expand to more real world projects. If you find yourself struggling hard with the borrow checker, seek help. It very well could be that you're trying to solve your problem in a way that goes against how Rust wants you to work.

@rylev
rylev / crates.rb
Created Mar 1, 2019
Script for downloading the most popular crates and finding how many times they use the unsafe keyword.
View crates.rb
require "open-uri"
require "json"
PAGE_SIZE=100
NUM_PAGES=2
crates = []
(1..NUM_PAGES).each do |page|
res = JSON.parse(URI.parse("https://crates.io/api/v1/crates?page=#{page}&per_page=#{PAGE_SIZE}").read)
puts res
crates += res["crates"].map {|c| {name: c["name"], repo: c["repository"]} }
@rylev
rylev / main.rs
Created Sep 12, 2018
Bubble Sort In Rust
View main.rs
fn main() {
let mut sortable: [i32; 5] = [5, 8, 2, 7, 6];
let length = sortable.len();
let mut swapped = true;
print_array(&sortable);
while swapped {
swapped = false;
for i in 1..length {
@rylev
rylev / rainbow.a
Created Mar 21, 2017
Rainbows on Atari 2600
View rainbow.a
PROCESSOR 6502; set processor
INCLUDE "vcs.h" ; include helpful stuff
INCLUDE "macro.h" ; include helpful stuff
Seg Code ; set code segment
ORG $F000 ; code should start at 0xF000
BGColor equ $81 ; Reserve space at 0x81
Start
@rylev
rylev / example.ts
Last active Mar 17, 2017
TypeScript
View example.ts
function divide(num1: number | undefined, num2: number | undefined): number | 'no!' | undefined {
if (num1 === undefined || num2 === undefined) { return }
// num1 and num2 now have type number
if (num2 === 0) { return 'no!'}
return num1 / num2
}
@rylev
rylev / bubble.rs
Created Dec 6, 2014
Bubble Sort Written In Rust
View bubble.rs
fn bubble_sort(numbers: &Vec<i64>, compare_fn: |i64, i64| -> i64) -> Vec<i64> {
let mut temp;
let mut target = numbers.clone();
let length = numbers.len();
for _ in range(0, length) {
for j in range(0, length - 1) {
if compare_fn(target[j], target[j+1]) > 0 {
temp = target[j+1];
target[j+1] = target[j];
@rylev
rylev / example.rs
Created Nov 27, 2014
Compiler Bug Error
View example.rs
use std::io::File; use std::io::FileMode::Open;
use std::io::FileAccess::{Write,ReadWrite};
use std::io::IoResult;
use std::fmt::{Show,Formatter,Error};
const MAX_DATA: uint = 512;
const MAX_ROWS: uint = 100;
struct Field {
You can’t perform that action at this time.