Skip to content

Instantly share code, notes, and snippets.

View rainforest-of-code's full-sized avatar

rainforest-of-code

View GitHub Profile
@rainforest-of-code
rainforest-of-code / clipboard.md
Created June 28, 2018 13:21 — forked from krisleech/clipboard.md
3 ways to copy to clipboard in Javascript
if(document.queryCommandSupported('copy')) {
        if(text=='') { text = ' '; } // empty inputs do not get selected

        // copy text to off-screen input
        $('#clipboard').val(text);

        // 1.) does copy empty inputs, but adds newline before content
        var range = document.createRange();
 range.selectNode(document.querySelector('#clipboard'));
@rainforest-of-code
rainforest-of-code / update-bundles.sh
Created May 9, 2018 06:30 — forked from janlay/update-repos.sh
Update all Vim bundles for Pathogen
#/bin/sh
cd ~/.vim/bundle
for i in `ls -p`; do
cd "$i"
echo "Updating $i..."
git pull --recurse-submodules | grep -v 'Already up-to-date' | sed 's/^/ /'
[ -f .git/.gitmodules ] && git submodule update | sed 's/^/ /'
cd ..
done
@rainforest-of-code
rainforest-of-code / lambda-cube.tex
Created April 14, 2018 16:36 — forked from joom/lambda-cube.tex
Barendregt's lambda cube in tikzcd, with labels on arrows
\documentclass{standalone}
\usepackage{tikz-cd}
\usepackage{amsmath}
\usepackage{tgpagella}
\begin{document}
\begin{tikzcd}
& & \lambda\omega \arrow[rrr] & & & \lambda\Pi\omega \\
& & & & & \\
\lambda 2 \arrow[rruu] \arrow[rrr] & & & \lambda\Pi 2 \arrow[rruu] & & \\
@rainforest-of-code
rainforest-of-code / index.html
Last active November 11, 2017 10:48
starting template for getting started with react
<head>
<title>My First React Experience</title>
<script src="https://unpkg.com/react@16.0.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.1.0/umd/react-dom.development.js"></script>
</head>
<body>
<div id="app"></div>
<script>
//Will add code here to try React
</script>
@rainforest-of-code
rainforest-of-code / private.xml
Created October 30, 2017 19:01 — forked from burtlo/private.xml
TMUX: Rebinding CAPS LOCK to CTRL + B
<?xml version="1.0"?>
<root>
<appdef>
<appname>Terminal</appname>
<equal>com.apple.Terminal</equal>
</appdef>
<item>
<name>TMUX Key Remappings</name>
<item>
<name>TMUX: Right Control to Ctrl+B</name>
@rainforest-of-code
rainforest-of-code / github-store.js
Created October 27, 2017 08:22 — forked from alexvcasillas/github-store.js
Async Fetching with MobX Actions
import fetch from 'node-fetch';
import { observable, action, runInAction } from 'mobx';
export default class GithubStore {
@observable searchName;
@observable user;
@observable repos;
@observable fetchingData;
constructor() {
@rainforest-of-code
rainforest-of-code / GoConcurrency.md
Created October 20, 2017 10:45 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@rainforest-of-code
rainforest-of-code / coordinating-async-react.md
Created September 19, 2017 19:47 — forked from acdlite/coordinating-async-react.md
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@rainforest-of-code
rainforest-of-code / event-listeners.js
Created September 7, 2017 13:23 — forked from danburzo/README.md
Get all event listeners on the page in Google Chrome
var items = Array.prototype.slice.call(
document.querySelectorAll('*')
).map(function(element) {
var listeners = getEventListeners(element);
return {
element: element,
listeners: Object.keys(listeners).map(function(k) {
return { event: k, listeners: listeners[k] };
})
};
@rainforest-of-code
rainforest-of-code / *state-machine-component.md
Created September 6, 2017 08:14 — forked from developit/*state-machine-component.md
265b lib for building pure functional state machine components. https://npm.im/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

Usage

The API is a single function that accepts 2 pure functions as arguments:

stateMachineComponent(reduce, render)