Skip to content

Instantly share code, notes, and snippets.

@trobertsonsf
trobertsonsf / Getting_Started_With_Immutable.js
Last active November 8, 2016 04:02
Immutable.js can have a bit of a steep learning curve, this is trying to show you how to do basic things and why you should care.
(() => {
/****************************
Before you start, you should watch this: https://www.youtube.com/watch?v=I7IdS-PbEgI
*****************************/
/****************************
NOTE: You need Immutable to be defined globally for this to work
I go to: https://facebook.github.io/immutable-js/
Open dev tools and paste it into the console
*****************************/
/****************************
@staltz
staltz / slim-cycle-core.js
Created September 22, 2015 12:35
Cycle.js without sanity checks and comments in a single file. Don't use this, use normal Cycle.js. :-)
let Rx = require(`rx`)
function makeRequestProxies(drivers) {
let requestProxies = {}
for (let name in drivers) {
if (drivers.hasOwnProperty(name)) {
requestProxies[name] = new Rx.ReplaySubject(1)
}
}
return requestProxies
@iammerrick
iammerrick / LazilyLoad.js
Last active August 7, 2019 14:15
Lazily Load Code Declaratively in React + Webpack
import React from 'react';
const toPromise = (load) => (new Promise((resolve) => (
load(resolve)
)));
class LazilyLoad extends React.Component {
constructor() {
super(...arguments);

Thanks everyone for participating in the quiz!
Many of you have posted correct answers.

What we know:

A top-level App component returns <Button /> from its render() method.

Question:

>What is the relationship between `` and this in that `Button`’s `render()`?

@mfellner
mfellner / graphql.ts
Created July 8, 2019 20:42
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {

3 Gripes With React

I started using React 3.5 years ago, and I still love it. It was such a well-designed solution that not much has changed since then, only superficial stuff like naming. What I learned then is still wholly applicable today because it's such a good idea (although now you can choose from many other libraries). On top of that, we now benefit from an entirely new architecture (fiber) without changing much.

@gvsrepins
gvsrepins / terminator-config
Created August 19, 2017 14:54
Terminator config to act like Guake terminal
[global_config]
always_on_top = True
borderless = True
enabled_plugins = LaunchpadCodeURLHandler, APTURLHandler, LaunchpadBugURLHandler
sticky = True
tab_position = bottom
[keybindings]
hide_window = F12
[layouts]
[[default]]
import React from 'react'
import { render } from 'react-dom'
import { Match, Link, BrowserRouter as Router } from 'react-router'
import matchSorter from 'match-sorter'
import './styles.css'
const API = 'http://localhost:3000'
const token = localStorage.booksToken || Math.random().toString()
localStorage.booksToken = token
let UserContext = React.createContext();
class App extends React.Component {
state = {
user: null,
setUser: user => {
this.setState({ user });
}
};
@ryanflorence
ryanflorence / Performance Conditionally Rendered Content in React.md
Last active December 30, 2023 18:12
Performance Conditionally Rendered Content in React

Performance and Conditionally Rendered Content in React

First, this is not about if in JSX. It's just the simplest example to talk about (and a lot of people tried to do it at first a long time ago).

Some react components conditionally render content. When React first went public, a lot of us coming from handlebars really wanted "if" syntax. This gist isn't just about If components though, it's about