Skip to content

Instantly share code, notes, and snippets.

View yageek's full-sized avatar
🥨

Yannick Heinrich yageek

🥨
View GitHub Profile
@yageek
yageek / gist:c90e8d0e29e813ff5561
Last active October 3, 2015 08:56 — forked from jorgenisaksson/gist:76a8dae54fd3dc4e31c2
Create a CGPath from an NSBezierPath in Swift. Great for CALayers for example.
// Adapted from Cocoa Drawing Guide's "Create a CGPathRef fram an NSBezierPath Object"
func CGPathFromNSBezierPath(nsPath: NSBezierPath) -> CGPath! {
if nsPath.elementCount == 0 {
return nil
}
let path = CGPathCreateMutable()
var didClosePath = false
@yageek
yageek / orhttp_example.go
Created August 31, 2017 16:37 — forked from Yawning/orhttp_example.go
How to dispatch HTTP requests via Tor in Go.
// To the extent possible under law, the Yawning Angel has waived all copyright
// and related or neighboring rights to orhttp_example, using the creative
// commons "cc0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package main
import (
// Things needed by the actual interface.
"golang.org/x/net/proxy"
@yageek
yageek / app.js
Created September 15, 2017 12:48 — forked from Turbo87/app.js
webpack + font-awesome test
require('font-awesome/css/font-awesome.css');
document.body.innerHTML = '<i class="fa fa-fw fa-question"></i>';
@yageek
yageek / Simplify.swift
Created June 14, 2018 12:40 — forked from lachlanhurst/Simplify.swift
Simplification of a 3D polyline using the Ramer–Douglas–Peucker algorithm in Swift
//
// Simplify.swift
//
// Simplification of a 3D-polyline.
// A port of https://github.com/hgoebl/simplify-java for Swift
//
//
// The MIT License (MIT)
//
// Created by Lachlan Hurst on 10/02/2015.
@yageek
yageek / miostdin.rs
Created July 25, 2018 08:59 — forked from vi/miostdin.rs
Simple copy stdin to stdout example using Rust mio
extern crate mio;
use mio::unix::EventedFd;
use std::fs::File;
use mio::{Token, PollOpt, Ready, Poll, Events};
//use mio_uds::UnixStream;
use std::os::unix::io::{FromRawFd};
use std::io::{Read, Write};
@yageek
yageek / miniCas.cpp
Created September 14, 2018 02:48 — forked from andr1972/miniCas.cpp
Algebraic substitution trees, expand variables to subtree with cloning
#include <memory>
#include <string>
#include <vector>
#include <assert.h>
using namespace std;
enum Type { tEmpty, tNum, tVar, tFrac, tProd, tSum };
enum Precedence { precStart, precSum, precFrac, precAtom };
@yageek
yageek / ssh-git-push
Created September 21, 2018 06:50 — forked from t2/ssh-git-push
Github & Bitbucket (SSH) - Port 22 Blocked
# vi ~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
Host bitbucket.org
Hostname altssh.bitbucket.org
Port 443
@yageek
yageek / Thick Line to Polygon JS
Created November 2, 2018 13:24 — forked from kekscom/Thick Line to Polygon JS
A JavaScript method to turn thick lines into polygons
/**
* @author Jan Marsch (@kekscom)
* @example see http://jsfiddle.net/osmbuildings/2e5KX/5/
* @example thickLineToPolygon([{x:50,y:155}, {x:75,y:150}, {x:100,y:100}, {x:50,y:100}], 20)
* @param polyline {array} a list of point objects in format {x:75,y:150}
* @param thickness {int} line thickness
*/
var thickLineToPolygon = (function () {
function getOffsets(a, b, thickness) {
@yageek
yageek / playground.rs
Created December 14, 2018 21:59 — forked from anonymous/playground.rs
Rust code shared from the playground
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
extern crate chrono;
use chrono::NaiveDate;
mod date_serde {

Looking into the Future

futures-rs is the library which will hopefully become a shared foundation for everything async in Rust. However it's already become renowned for having a steep learning curve, even for experienced Rustaceans.

I think one of the best ways to get comfortable with using a library is to look at how it works internally: often API design can seem bizarre or impenetrable and it's only when you put yourself in the shoes of the library author that you can really understand why it was designed that way.

In this post I'll try to put down on "paper" my understanding of how futures work and I'll aim to do it in a visual way. I'm going to assume you're already somewhat familiar with Rust and why futures are a useful tool to have at one's disposal.

For most of this post I'll be talking about how things work today (as of September 2017). At the end I'll touch on what's being proposed next and also make a case for some of the changes I'd like to see.

If you're interested in learning more ab