Skip to content

Instantly share code, notes, and snippets.

View PeterDing's full-sized avatar
🪐
Working

Peter Ding PeterDing

🪐
Working
View GitHub Profile

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

@darren
darren / nlc.sh
Last active November 30, 2023 05:04
国家图书馆Wifi自动登录脚本
#!/usr/bin/env bash
USERNAME= #改成你的读者卡号
PASSWORD= #改成你的读者卡密码
LOGINURL="http://192.168.180.11:8080/nlcwlan/QueryGuest"
PASSWORD=$(echo $PASSWORD|base64)
UA="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"
@mitchwongho
mitchwongho / Docker
Last active June 26, 2024 07:28
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
301 https://github.com/zxdrive/imouto.host
def getToken(session):
session.get('http://www.baidu.com')
token = session.get('https://passport.baidu.com/v2/api/?getapi&class=login&tpl=pp&tangram=false').text
token_index = token.index('login_token')+len('login_token')+2
token = token[token_index:-1]
token = token[0:token.index("'")]
return token
def getvcode(codestring):
url = 'https://passport.baidu.com/cgi-bin/genimage?'+codestring
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@horsley
horsley / dns.php
Created January 25, 2013 09:18
Simple PHP code act as a dig tool to find dns records
<?php
$result = array();
$result_html = '';
if (isset($_POST['domain']) && !empty($_POST['domain'])) {
$domain_regex = '/[a-z\d][a-z\-\d\.]+[a-z\d]/i';
if (preg_match($domain_regex, $_POST['domain'])) {
if ($url = parse_url($_POST['domain'])) { //compatible when user post an url instead of a domain
if (isset($url['host'])) {
$result = dns_get_record($url['host'], DNS_A + DNS_AAAA + DNS_CNAME);
} else if (isset($url['path'])) {
@yevgenko
yevgenko / .Xdefaults
Created August 24, 2011 02:58
URxvt settings with solarized theme
!-------------------------------------------------------------------------------
! Xft settings
!-------------------------------------------------------------------------------
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight