Skip to content

Instantly share code, notes, and snippets.

View 46bit's full-sized avatar
🏳️‍🌈

Miki Mokrysz 46bit

🏳️‍🌈
View GitHub Profile
@46bit
46bit / main.rs
Last active June 10, 2017 19:42 — forked from alexcrichton/main.rs
extern crate futures;
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread;
use std::sync::Arc;
use std::time::{Instant, Duration};
use futures::{Async, Future};
use futures::executor::{self, Spawn};
use futures::task::Unpark;
@46bit
46bit / gadts.rs
Last active March 1, 2017 16:31 — forked from Sgeo/gadts.rs
Gadts in Rust (I tried to see if I could hack in trait-based generics for each variant. Nope. :-()
use std::marker::PhantomData;
use std::ptr;
use std::mem;
use std::ops::Add;
/// This type is only every inhabited when S is nominally equivalent to T
#[derive(Debug)]
pub struct Is<S, T>(PhantomData<(*const S, *const T)>);
// Construct a proof of the fact that a type is nominally equivalent
@46bit
46bit / sirpent-protocol.md
Last active January 14, 2017 03:39 — forked from qlkzy/sirpent.md
Reworked into non-RPC protocol that tidies up existing implemented protocol. Partway complete.

TODOS

  • Lay out possible errors (on advisory basis) and possible causes of death.
  • Specify resolution to "In that case those players despite dying also win."

Sirpent Protocol v0.3-incomplete

By David Morris and Michael Mokrysz.

fn writeall_stdout(socket: TcpStream) -> IoFuture<()> {
let iter = iter::repeat(()).map(|()| Ok(()));
stream::iter(iter).fold(socket, move |socket, ()| {
let buf = vec![0;1024];
tokio_core::io::read(socket, buf).map(|(socket, _, num_bytes)| {
println!("Read {} bytes", num_bytes);
socket
})
}).map(|_| ()).boxed()
}
@46bit
46bit / .block
Created July 13, 2016 18:59 — forked from mbostock/.block
Streamgraph
license: gpl-3.0
@46bit
46bit / delta.rb
Created December 15, 2015 02:51 — forked from issyl0/delta.rb
require 'nokogiri'
require 'open-uri'
require 'net/http'
# Get the video title from each of the Delta Tube videos, if they exist.
(1..5000).each do |id|
url = URI.parse("http://www.delta-tube.com/video/#{id}")
req = Net::HTTP.new(url.host, url.port)
res = req.request_head(url.path)
@46bit
46bit / ajaxify-html5.js
Created June 22, 2011 01:14 — forked from balupton/README.md
Ajaxify a Website with the HTML5 History API using History.js and ScrollTo
(function(window,undefined){
// Prepare our Variables
var
History = window.History,
$ = window.jQuery,
document = window.document;
// Check to see if History.js is enabled for our Browser
if ( !History.enabled ) {