Skip to content

Instantly share code, notes, and snippets.

View adrianmcli's full-sized avatar
:shipit:
What's happening?

Adrian Li adrianmcli

:shipit:
What's happening?
View GitHub Profile
@adrianmcli
adrianmcli / tutorial-refactor.js
Created January 6, 2017 19:24
A refactor of André Staltz's example twitter program in his tutorial on RxJS: https://gist.github.com/staltz/868e7e9bc2a7b8c1f754
// UI Event Streams --------------------------------------------
const refreshButton = document.querySelector('.refresh');
const closeButton1 = document.querySelector('.close1');
const closeButton2 = document.querySelector('.close2');
const closeButton3 = document.querySelector('.close3');
const refreshClickStream = Rx.Observable.fromEvent(refreshButton, 'click');
const close1ClickStream = Rx.Observable.fromEvent(closeButton1, 'click');
const close2ClickStream = Rx.Observable.fromEvent(closeButton2, 'click');
const close3ClickStream = Rx.Observable.fromEvent(closeButton3, 'click');
@adrianmcli
adrianmcli / simple-event-loop-example.js
Created January 6, 2017 20:26
A simple event loop example. Guess the output (answer in the comments).
var a = "hey";
var cb = function() { console.log(a); }
setTimeout(cb, 1000);
// let's make a delay of 3 seconds
var timestamp = Date.now() + 3000;
while (Date.now() < timestamp);
// now that 3 seconds have passed,
@adrianmcli
adrianmcli / typing-clock.js
Last active January 8, 2017 20:59
Tracks how long you've been typing by creating a stream of state change-events and then sampling from that stream every second.
/*** Helper Functions ***/
const showTyping = () => $('.typing').text('User is typing...');
const showIdle = () => $('.typing').text('');
const updateTimer = (x) => $('.timer').text(x);
const handleTypingStateChange = state =>
state === 1 ? showTyping() : showIdle();
/*** Program Logic ***/
@adrianmcli
adrianmcli / typing-clock-2.js
Last active January 8, 2017 21:01
Tracks how long you've been typing by starting a counting stream every time a typing event has been detected.
/*** Helper Functions ***/
const showTyping = () => $('.typing').text('User is typing...');
const showIdle = () => $('.typing').text('');
const updateTimer = (x) => $('.timer').text(x);
/*** Program Logic ***/
// declare shared streams
const inputEvents$ = Rx.Observable.fromEvent($('#input'), 'input').share();
@adrianmcli
adrianmcli / typing-tracker.js
Created January 9, 2017 03:22
A React component that tracks how long you've been typing in the textarea. There is also an indicator to show when you are typing.
import React from 'react';
import Rx from 'rxjs/Rx';
import { observeComponent, fromComponent } from 'observe-component/rxjs';
// Create the component with the listeners we want
const TextArea = observeComponent('onInput')('textarea');
export default class MyComponent extends React.Component {
constructor() {
super();
/*** Hot Stream ***/
// there is only "one real" invocation of the stream
const count$ = Rx.Observable.interval(1000).share();
count$.subscribe(x => console.log('A' + x));
setTimeout(() => {
count$.subscribe(x => console.log(' B' + x));
}, 2000);
{"keys": ["tab"], "command": "expand_abbreviation_by_tab", "context":
[
{ "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" },
{ "match_all": true, "key": "selection_empty" },
{ "operator": "equal", "operand": false, "match_all": true, "key": "has_next_field" },
{ "operand": false, "operator": "equal", "match_all": true, "key": "auto_complete_visible" },
{ "match_all": true, "key": "is_abbreviation" }
]
}
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"ecmaFeatures": {
"modules": true,
"jsx": true

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@adrianmcli
adrianmcli / .zshrc
Created January 29, 2017 00:59
My zsh config file
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/adrianli/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"