Skip to content

Instantly share code, notes, and snippets.

View jurassix's full-sized avatar
🐢
hello world

Clint Ayres jurassix

🐢
hello world
View GitHub Profile
@albertstill
albertstill / PostIndex.js
Last active August 4, 2020 00:53
Facebook Relay continuous scrolling example
class PostIndex extends React.Component {
state = { loading: false };
componentDidMount() {
window.onscroll = () => {
if (!this.state.loading
&& (window.innerHeight + window.scrollY)
>= document.body.offsetHeight) {
this.setState({loading: true}, () => {
@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
@chenglou
chenglou / gist:34b155691a6f58091953
Last active April 5, 2021 19:15
Better feature for React key

key is pretty much crucial for state perservation in React. As of React 0.13 it can't do the following things:

  • Clone state
<Comp key={1} /><Comp key={1} />
  • Preserve component state across different parents:
@clouddueling
clouddueling / common.fabric.js
Last active June 15, 2021 18:33
common.fabric module for angular/common
/**
* http://fabricjs.com/js/kitchensink/controller.js
* http://fabricjs.com/js/kitchensink/utils.js
* http://fabricjs.com/js/kitchensink/app_config.js
* http://fabricjs.com/events/
* view-source:http://fabricjs.com/kitchensink/
*/
(function() {
@slimsag
slimsag / regex.go
Created January 23, 2020 05:46
Go | Golang | Regex replace all byte submatches | regexp.ReplaceAllSubmatchFunc |
// replaceAllSubmatchFunc is the missing regexp.ReplaceAllSubmatchFunc; to use it:
//
// pattern := regexp.MustCompile(...)
// data = replaceAllSubmatchFunc(pattern, data, func(groups [][]byte) [][]byte {
// // mutate groups here
// return groups
// })
//
// This snippet is MIT licensed. Please cite by leaving this comment in place. Find
// the latest version at:
@getify
getify / 1.js
Last active June 30, 2022 16:35
fun little experiment... a point-free definition for "copySession()" (essentially a shallow object copy)
// function copySession(sess) {
// return { ...sess };
// }
var copySession = compose(
reduce(
compose(
flip,
binary,
uncurry,
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@davinkevin
davinkevin / MultipartFileSender
Created February 10, 2015 16:31
Implementing HTTP byte-range requests in Spring 4 and other framework...
package lan.dk.podcastserver.utils.multipart;
import lan.dk.podcastserver.utils.MimeTypeUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@paf31
paf31 / 24days.md
Last active August 8, 2023 05:53
24 Days of PureScript

This blog post series has moved here.

You might also be interested in the 2016 version.

@idibidiart
idibidiart / GraphQL-Architecture.md
Last active September 16, 2023 18:36
Building an Agile, Maintainable Architecture with GraphQL

Building a Maintainable, Agile Architecture for Realtime, Transactional Apps

A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.

With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.

We use GraphQL to dyn