Skip to content

Instantly share code, notes, and snippets.

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

rainforest-of-code

View GitHub Profile
@JoshCheek
JoshCheek / program.c
Last active April 6, 2018 17:28
Memory allocation, NULL, dereferencing.
// After you think you understand this program, try writing it yourself until
// you can get it to work, the first time, without error ^_^
//
// ALSO: remember:
// $ gcc program.c # compile
// $ ./a.out # run
// We'll get `printf` from standard input/output's header file
#include <stdio.h>
import React from 'react';
import lively from 'lively';
// Global registry and resize handler
let _registeredInstances = [];
function register(inst) {
if (_registeredInstances.length === 0) {
window.addEventListener('resize', onResize);
}
@ArunMichaelDsouza
ArunMichaelDsouza / amd-medium-portals.jsx
Created November 11, 2017 13:28
React 16 portals demo
class Info extends Component {
constructor(props) {
super(props);
}
render() {
return <Modal><Text text=“This is the text” /></Modal>;
}
}
@evancz
evancz / data-interchange.md
Last active July 16, 2025 00:25
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@acdlite
acdlite / coordinating-async-react.md
Last active June 17, 2024 11:56
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?

@rushilgupta
rushilgupta / GoConcurrency.md
Last active May 9, 2025 10:20
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

@busypeoples
busypeoples / Flow_Chapter_Two.md
Last active September 5, 2017 14:29
Chapter 2: Using Flow

Back To The Basics

Chapter 2: Using Flow

Introduction

Why does it make sense to use FlowType or TypeScript when working with JavaScript? To give an appropriate answer, the best idea would be to build a small game or application to make the benefits clear.

@alexvcasillas
alexvcasillas / github-store.js
Created May 4, 2017 08:35
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() {
import express from 'express';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import App from './components/App';
import {flushServerSideRequires} from 'react-loadable';
let app = express();
let webpackStats = require('./output-webpack-stats.json');