Skip to content

Instantly share code, notes, and snippets.

Avatar
⚛️
.

klarstrup

⚛️
.
View GitHub Profile
View gist:58890468c71d4d3eb050
### Keybase proof
I hereby claim:
* I am klarstrup on github.
* I am klarstrup (https://keybase.io/klarstrup) on keybase.
* I have a public key whose fingerprint is 9129 7D8F BCB7 5415 EFB3 E745 FB89
498E 9466 6C27
To claim this, I am signing this object:
View gulpfile.js
var gulp = require('gulp');
var babel = require('gulp-babel');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var cssnano = require('gulp-cssnano');
var livereload = require('gulp-livereload');
var uglify = require('gulp-uglify');
var requirejsOptimize = require('gulp-requirejs-optimize');
View gist:644d74be0ea7670cd824243e7918c2ed
const albums = new ReactiveVar([]);
export default createContainer(() =>{
HTTP.get('https://graph.facebook.com/' + this.props.clubId + "/albums?fields=id,name" + token, function(err, resp) {
albums.set(resp.data.data.map(c => <a key={c.id} href={'../gallery/' + c.id}>{c.name}</a>))
});
return {albums : albums.get()};
}, App);
View gist:84df3873b5e02fc760037cbb917b41e1
const albums = new ReactiveVar([]);
export default createContainer(() =>{
HTTP.get('https://graph.facebook.com/' + this.props.clubId + "/albums?fields=id,name" + token, function(err, resp) {
albums.set(resp.data.data.map(c => <a key={c.id} href={'../gallery/' + c.id}>{c.name}</a>))
});
return {albums : albums.get()};
}, App);
View keyChange.js
const keyChange = (oldProps, newProps, propsHandlersMap = {}) =>
R.forEachObjIndexed((handler, keysString) => {
const keys = keysString.split(',');
if (!R.equals(R.pick(keys)(oldProps), R.pick(keys)(newProps))) {
handler(newProps);
}
})(propsHandlersMap);
// This little baby will(combined with those R utility functions) help
// reduce your componentWillReceiveProps methods like so:
View meiosis.js
/*global ReactDOM, flyd*/
// -- Utility code
const nestUpdate = (update, prop) => func =>
update(model => ({ ...model, [prop]: func(model[prop]) }));
const nest = (create, update, prop) => {
const component = create(nestUpdate(update, prop));
const result = { ...component };
@klarstrup
klarstrup / SassMeister-input.scss
Created Jul 4, 2018
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (vundefined)
// Compass (vundefined)
// dart-sass (v1.6.2)
// ----
.foo {
color: blue;
& > .bar { color: red; }
}
View useQueryParam.js
import qs from "qs";
import { useEffect, useMemo, useState } from "react";
import { useRouter } from "../routing";
const identity = a => a;
const defined = a => typeof a !== "undefined";
const fromQueryString = query => qs.parse(query, { ignoreQueryPrefix: true });
const toQueryString = object => qs.stringify(object, { addQueryPrefix: true });
export default function useQueryParam(