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 /
Created Dec 6, 2014
Bubble Sort Written In Rust
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 /
Last active Mar 9, 2020
Rust in Large Organizations Notes

Rust in Large Organizations

Initially taken by Niko Matsakis and lightly edited by Ryan Levick


  • Introductions
  • Cargo inside large build systems
  • FFI
  • Foundations and financial support
rylev / sort.ex
Created Oct 9, 2013
Sort Algorithms in Elixir
View sort.ex
## Sort Algorithms in Elixir
# Selection Sort
defmodule Selection do
def sort(list) when is_list(list) do
do_selection(list, [])
def do_selection([head|[]], acc) do
rylev /
Created Mar 5, 2019
How to Learn Rust

Learning Rust

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


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 / windows-crates.rb
Created Jul 22, 2019
Top Windows Crates
View windows-crates.rb
require "open-uri"
require "json"
crates = (1..NUM_PAGES).flat_map do |page|
res = JSON.parse(URI.parse("{page}&per_page=#{PAGE_SIZE}").read)
res["crates"].map {|c| {name: c["name"], repo: c["repository"]} }
rylev /
Last active Apr 13, 2019
File API Proposal

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 / 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"
crates = []
(1..NUM_PAGES).each do |page|
res = JSON.parse(URI.parse("{page}&per_page=#{PAGE_SIZE}").read)
puts res
crates += res["crates"].map {|c| {name: c["name"], repo: c["repository"]} }
rylev /
Created Sep 12, 2018
Bubble Sort In Rust
fn main() {
let mut sortable: [i32; 5] = [5, 8, 2, 7, 6];
let length = sortable.len();
let mut swapped = true;
while swapped {
swapped = false;
for i in 1..length {
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
rylev / example.ts
Last active Mar 17, 2017
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
You can’t perform that action at this time.