Skip to content

Instantly share code, notes, and snippets.

View z0w0's full-sized avatar
💭
hmu

Zack Corr z0w0

💭
hmu
View GitHub Profile
@z0w0
z0w0 / cvimrc
Created October 24, 2017 22:43
My cvim configuration
set nohud
set nosmoothscroll
set noautofocus
set typelinkhints
let barposition = "bottom"
let scrollstep = 100
let vimcommand = "nvim-qt"
let qmark T = ["http://todoist.com"]
@z0w0
z0w0 / rustpkg.md
Last active October 19, 2020 14:45
What's Rustpkg?

What's Rustpkg?

Rustpkg is a revamp of Cargo that brings awesome new features such as a build system described in build scripts. It's a purely functional package manager that has no central sources of any kind, but rather installs via URLs. It's similar to how Go's go get tool works, except Rustpkg requires a central metadata file (pkg.rs) in the repository, archive or folder in order to figure out how to build the package. This is a side effect of Rustpkg allowing multiple crates to be defined in a single package (i.e. a package is defined as a set of crates rather than a package being exactly the same as one crate). There's a plan to make it so the pkg.rs is not needed for single-crate packages,

@z0w0
z0w0 / pkg.rs
Created February 11, 2013 13:35
Example of rustpkg for @bjz
#[pkg(id = "com.bjz.gl",
vers = "0.1.0")];
#[pkg_crate(file = "src/gl.rc")];
use run;
#[pkg_do(build)] // ran before declarative crates (i.e. this will run and then the crate defined above will)
fn build() {
run::run_program(~"lua", ~[~"LoadGen.lua". ~"-style=pointer_rust",
~"-spec=gl", ~"-version=3.3", ~"-profile=core",
@z0w0
z0w0 / error
Created February 9, 2013 12:48
Re-exporting glob issue in Rust
error: failed to resolve imports
src/sdl.rc:19:8: 19:17 error: unresolved import
src/sdl.rc:19 pub use event::*;
^~~~~~~~~
src/event.rs:1:4: 1:16 error: unresolved import
src/event.rs:1 use libc::c_int;
^~~~~~~~~~~~
src/cd.rs:1:4: 1:16 error: unresolved import
src/cd.rs:1 use libc::c_int;
^~~~~~~~~~~~
@z0w0
z0w0 / rustpkg_w_lib.rs
Last active December 12, 2015 07:48
Really hacky example of how to compile a CC file using rustpkg. Rustpkg needs heaps of changes before I would even suggest doing anything like this.
// this is a horrible way to do it, but it would work
#[pkg(id = "com.frozencow.some_binding",
vers = "0.1.1")];
#[pkg_crate(file = "src/some_binding.rc")]; // the binding has FFI stuff that links to -lsome_lib
// this would be wrapped by default..
fn cc(path: &Path) {
run::run_program(~"cc", ~[~"-shared", ~"-o", rustpkg::build_dir().push(~"lib").push(~"some_lib.so").to_str(), path.to_str()]);
}
@z0w0
z0w0 / haul.md
Last active February 9, 2017 10:27
Haul, a purely functional package manager for Rust

Haul

Features

  • Purely functional
    • Different versions of packages can coexist
    • Each package must have a UUID, so packages with conflicting names can coexist
  • Build logic
    • Each package's metadata and build logic is written in a central Rust source file, package.rs
  • Dependencies are declared in the package file and will be fetched and installed before
@z0w0
z0w0 / gist:3608372
Created September 3, 2012 10:20
Quickcheck in Rust
// each argument is randomized (error if the argument is not a primitive type or string)
#[quickcheck(tries = 1000)]
fn even(number: int) {
return number % 2 == 0;
}
@z0w0
z0w0 / gist:3562579
Created September 1, 2012 01:50
Tests using Rust's JIT
cfg: shell host triple i686-unknown-linux-gnu
cfg: enabling more debugging (CFG_ENABLE_DEBUG)
cfg: host for i686-unknown-linux-gnu is i386
cfg: unix-y environment
cfg: using gcc
cfg: no llnextgen found, omitting grammar-verification
cfg: including dist rules
cfg: including test rules
run rpass-full: i686-unknown-linux-gnu/stage2/bin/compiletest
enum key {
key_a,
key_b
}
enum event {
quit,
key(key)
}
@z0w0
z0w0 / net.rs
Created January 12, 2012 02:30
Extended IP address parsing for net.rs
/*
Module: net
*/
import core::{vec, uint, str};
/* Section: Types */
/*
Tag: ip_addr