Skip to content

Instantly share code, notes, and snippets.

#[link(name="python2.7")]
extern {
fn Py_SetProgramName(name: *u8);
fn Py_Initialize();
fn PyRun_SimpleString(command: *u8);
fn Py_Finalize();
}
fn main() {
let args = std::os::args();
@mcpherrinm
mcpherrinm / hello.rs
Last active November 24, 2022 19:21
Hello World in Rust without the runtime (libcore and libc only)
#![no_std]
extern crate core;
use core::option::{None, Some};
use core::iter::Iterator;
use core::str::StrSlice;
#[lang="stack_exhausted"]
pub extern "C" fn rust_stack_exhausted() {
unsafe { core::intrinsics::abort() }
}
@mcpherrinm
mcpherrinm / yolo.patch
Created June 3, 2014 05:58
Add YOLO support to rust
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 00c07ce..e691821 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -921,8 +921,9 @@ impl<'a> Parser<'a> {
return true
}
- if token::is_keyword(keywords::Unsafe, &self.token) ||
- token::is_keyword(keywords::Once, &self.token) {
@mcpherrinm
mcpherrinm / ascii2pem.sh
Created February 11, 2016 04:55
pem support wrappers for der2ascii
#!/bin/bash
while [[ $# > 0 ]]; do
case $1 in
-i|-in|--in) input="-i $2"
shift 2
;;
-o|-out|--out) output="-out $2"
shift 2
;;
*) echo "Usage of ascii2pem:"
#[link(name = "bar", vers = "0.0", author = "otters")];
pub fn foobar() {
io::println("baz");
}
@mcpherrinm
mcpherrinm / cat.rs
Created February 9, 2013 07:37
simple cat program that seems broken
use io::ReaderUtil;
fn main() {
let file = path::Path("input");
let f = result::unwrap(io::file_reader(&file));
for f.each_char() |i| {
io::print(fmt!("%c", i));
}
}
set nocompatible
let g:no_rust_conceal = 1
syntax on " syntax highlighting
set background=dark
" Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
set -g prefix2 C-s
bind-key b send-prefix
bind-key s send-prefix -2
set -g status-bg black
set -g status-fg white
set-window-option -g window-status-current-bg blue
set-window-option -g window-status-current-fg white
set -g base-index 1
set -s escape-time 0
set -g history-limit 1000000
@mcpherrinm
mcpherrinm / instructions.md
Last active October 25, 2015 02:35
Crosscompiling Rust to Arm

I want to write Rust code on my computer (x86_64, Ubuntu 14.04) and produce arm executables. I found hints on the internet, but not a concise set of instructions on what to do. So I wrote them down exactly:

apt-get install g++-arm-linux-gnueabihf
git clone https://github.com/mozilla/rust.git
mkdir rust/build-cross
cd rust/build-cross
../configure --target=arm-unknown-linux-gnueabihf --prefix=$HOME/local/rust-cross
make -j8 && make install