Skip to content

Instantly share code, notes, and snippets.

View steveklabnik's full-sized avatar
🦀
Rustacean

Steve Klabnik steveklabnik

🦀
Rustacean
View GitHub Profile
@steveklabnik
steveklabnik / main.rs
Last active January 16, 2018 13:32 — forked from jefftime/main.rs
#![feature(lang_items, start)]
#![no_std]
#[link(name = "c")]
extern {
fn puts(s: *const u8) -> isize;
fn abort() -> !;
}
#[lang = "panic_fmt"]
@steveklabnik
steveklabnik / boot.asm
Created July 6, 2017 16:16 — forked from faraazahmad/boot.asm
error on make
global start
section .text
bits 32
start:
; Point the first entry of the level 4 page table to the first entry in the
; p3 table
mov eax, p3_table
or eax, 0b11 ;
mov dword [p4_table + 0], eax
fn add_to_mutable_reference(x: &mut i32) {
*x +=1;
}
#[test]
fn mutable_reference_test() {
let mut x = 5;
let y = &mut x;
mutable_reference(y);

9:05- 9:25 1. Welcome and Introduction (20min)

  • Operational Stuff (10min) [Ashley]

    • Introduction to instructors
    • Where are all the materials
    • Explain the schedule, when are breaks
    • Code of Conduct
    • What to do if you need help
  • What is the intermezzOS project? (10min) [Steve]

@steveklabnik
steveklabnik / playground.rs
Last active August 9, 2016 15:29 — forked from anonymous/playground.rs
Shared via Rust Playground
struct Lib {
// whatever... but it implements Drop
}
impl Lib {
fn get_widget() -> &LibWidget {
// unimportant (I think), but LibWidget implements Drop
}

code

Bits and pieces. gist

extern crate gl;
extern crate glutin;
extern crate libc;
use std::io::prelude::*;
use std::io;
use std::fs::File;
fn main(){
let s = read_file("model.obj");
@steveklabnik
steveklabnik / gist:18789c7d46b248dfcdb1
Created September 7, 2015 15:43
Issue with binding ownership and scopes in Rust
pub struct Command {
cmd: String,
}
impl Command {
pub fn new(cmd: &str) -> Command {
Command {
cmd: String::from(cmd),
}
}
@steveklabnik
steveklabnik / file.rs
Last active September 6, 2015 21:40 — forked from anonymous/file.rs
fn move_enemies(&mut self) {
self.enemies = self.enemies.into_iter().map(|enemy| {
let between = Range::new(0, 4);
let mut rng = rand::thread_rng();
let desired_move: (i8, i8) = match between.ind_sample(&mut rng) {
0 => (0, -1),
1 => (0, 1),
2 => (-1, 0),
3 => (1, 0),
_ => (0, 0), // This shouldn't happen.
@steveklabnik
steveklabnik / main.rs
Created August 18, 2015 20:04 — forked from shadoi/main.rs
#[macro_use]
extern crate nickel;
extern crate yaml_rust;
use nickel::{ Nickel, HttpRouter };
use yaml_rust::{ Yaml, YamlEmitter };
mod yaml_handler;
fn get_yaml() -> String {