Skip to content

Instantly share code, notes, and snippets.

View CYBAI's full-sized avatar
🇹🇼
λf. (λx. f (x x)) (λx. f (x x))

cybai (Haku) CYBAI

🇹🇼
λf. (λx. f (x x)) (λx. f (x x))
View GitHub Profile
@CYBAI
CYBAI / randomInt.js
Last active August 29, 2015 14:05
Get random value between two values
/**
* This function generates a random Integer between two numbers min and max.
*/
function (min, max) {
return Math.floor(Math.random() * max) + min;
}
@CYBAI
CYBAI / JSDC-2014.md
Last active August 29, 2015 14:07
My memo of JSDC 2014

JSDC 2014

Day 1

The Future of the Enterprise Web App

Q1: What's the perspective service of Sencha
Q2: How to improve Sencha with Sencha service

@CYBAI
CYBAI / String.prototype.replaceAt.js
Last active August 29, 2015 14:08
Replace character at particular index
/**
* String replace character at particular index(es)
* @param {Int or IntArray} index [index to start]
* @param {String} character [character which you want to replace]
* @return {String} [Replaced character]
*/
String.prototype.replaceAt = function(index, character) {
if (typeof index !== 'number' && index instanceof Array !== true) {
throw Error('Please pass a number or an array of number as first argument and your index is ' + index);
}
@CYBAI
CYBAI / LazyLoad.js
Last active November 12, 2015 04:39 — forked from yocontra/LazyLoad.js
lazy loading react components, useful for video/audio/etc
import React from 'react';
import ReactDOM from 'react-dom';
import isVisible from './isVisible';
class LazyLoad extends React.Components {
constructor() {
super();
this.props = {
distance: 100
};

Multiple MySQL Versions with Homebrew

For homebrew version 0.9.5.

brew -v # => Homebrew 0.9.5

Install the current version of mysql.

# Install current mysql version

brew install mysql

@CYBAI
CYBAI / iterm.scpt
Created June 30, 2016 01:39 — forked from gnachman/iterm.scpt
Replace /Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/iterm.scpt with this.
set itermRunning to (application "iTerm" is running)
set scriptPath to quoted form of POSIX path of ((path to me as text) & "::" & "start.sh")
set user_shell to do shell script "dscl /Search -read /Users/$USER UserShell | awk '{print $2}'"
tell application "iTerm"
activate
if not (exists window 1) or (itermRunning = false) then
reopen
end if
@CYBAI
CYBAI / step3.js
Last active August 5, 2016 14:49
Fix step3 in `transducing in javascript` from `getify`
function add1(v) { return v + 1; }
function isOdd(v) { return v % 2 == 1; }
function sum(total,v) { return total + v; }
function listReduction(list,v) {
list.push(v);
return list;
}
function mapReducer(fn) {
@CYBAI
CYBAI / modern-web-2016.md
Last active September 15, 2016 22:21
Note for Modern Web 2016
@CYBAI
CYBAI / tmux-cheatsheet.markdown
Created May 31, 2017 07:25 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

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