31 May '16, 8pm

Helix Intro - #Rust + #Ruby without the glue.

// Rust Code extern crate libc; use std::{ptr, slice}; use std::marker::PhantomData; #[repr(C)] #[allow(raw_pointer_derive)] #[derive(Copy, Clone)] pub struct Buf<'a> { ptr: *mut u8, len: usize, marker: PhantomData<&'a ()>, } impl<'a> Buf<'a> { pub fn as_slice(self) -> &'a str { unsafe { let s = slice::from_raw_parts(self.ptr as *const u8, self.len); std::str::from_utf8_unchecked(s) } } } #[no_mangle] pub extern "C" fn fast_blank(buf: Buf) -> bool { buf.as_slice().unwrap().chars().all(|c| c.is_whitespace()) } // C Code #include <ruby.h> #include <ruby/encoding.h> typedef struct { void* data; size_t len; } fast_blank_buf_t; static inline fast_blank_buf_t STR2BUF(VALUE str) { return (fast_blank_buf_t) { .data = RSTRING_PTR(str), .len = RSTRING_LEN(str), }; } int fast_blank(fast_blank_buf_t); static VALUE rb_string_blank_p(VALUE str) { return fast_blank(STR2BUF(str)) ? Qtrue ...

Full article: http://blog.skylight.io/introducing-helix/

Tweets

“Intro: Why I chose Node.js over Ruby on Rails”...

medium.com 30 May '16, 1am

Intro: Why I chose Node.js over Ruby on Rails After a period of web development using PHP and later on Ruby on Rails, I ha...