Skip to content

Instantly share code, notes, and snippets.

View HenrikJoreteg's full-sized avatar

Henrik Joreteg HenrikJoreteg

View GitHub Profile
@HenrikJoreteg
HenrikJoreteg / persist-to-ls-redux-middleware.js
Created January 8, 2016 23:24
Example redux middleware
import { STAR_PERSON, MET_PERSON, UPDATE_NOTES, SET_URL } from '../constants/action-types'
import { LS_KEY } from '../constants/localstorage-keys'
import tryit from 'tryit'
import debounce from 'lodash.debounce'
const userPreferenceActions = [STAR_PERSON, MET_PERSON, UPDATE_NOTES]
function writeToLocalStorage (getState) {
let data = {
starred: {},
@HenrikJoreteg
HenrikJoreteg / README.md
Last active September 20, 2021 01:36
Minimalist routing in Redux

Why would you want to do this? Because you often don't need more. It's nice to not have to think about your "router" as this big special thing.

Instead, with this approch, your app's current pathname is just another piece of state, just like anything else.

This also means that when doing server-side rendering of a redux app, you can just do:

var app = require('your/redux/app')
var React = require('react')
@HenrikJoreteg
HenrikJoreteg / index.js
Last active August 29, 2015 14:22
requirebin sketch
var AmpersandModel = require('ampersand-model');
var Model = AmpersandModel.extend({
props: {
name: 'string',
greetingType: ['string', true, 'long']
},
derived: {
greeting: {
deps: ['name', 'greetingType'],
@HenrikJoreteg
HenrikJoreteg / gumroad-analytics-api.js
Created April 24, 2015 20:50
Gumroad Sales Data "API"
// There's no way to retrieve detailed sales info from Gumroad.com through
// their official API.
// This bypasses that by posting a login form and then hitting an API only accessible
// via AJAX with a session cookie
// you just need USERNAME and PASSWORD set as environment variables where this is ran
var request = require('request');
module.exports = function (cb) {
@HenrikJoreteg
HenrikJoreteg / notes.md
Created April 9, 2015 16:29
Ampersand Core Syncup 4/9/2015

Ampersand Core Syncup 4/9/2015

(Syncup happened via Chat this morning due to folks being busy)

News:

Gar:

@HenrikJoreteg
HenrikJoreteg / notes.md
Created March 26, 2015 16:20
Ampersand Core Syncup - March 26, 2015

Ampersand Core Syncup 3/26/2015

Present

Gar, Philip, Henrik

Discussed

  • amp/lodash blog post published, hopefully people feel like the switch is now "official" we can start to switch all the things to lodash.*
  • Consider making ampersand-cli generated site fully static and deployable to surge.sh. Remove/simplify moonboots from ampersand-cli app. At the time the tools were not there and were not that great. Now they are, let's simplify things.
  • Henrik requesting review of: https://github.com/henrikjoreteg/hjs-webpack as simplified mechanism to configure webpack (it's a bit of a pain)
  • We still need to publish ampersand-react mixin. (Henrik building something with it currently to give it go)
@HenrikJoreteg
HenrikJoreteg / notes.md
Last active August 29, 2015 14:16
Ampersand Core Syncup - March 12, 2015

Ampersand Core Meeting 3/12/2015

present:

  • Gar
  • Henrik
  • Philip

Updates

  • WhatsApp is using Ampersand and React in their web app. They saw me tweet about it the official React twitter account retweeted it too. Shortly thereafter I got a nice email some folks from WhatsApp thanking us for Ampersand and asking for an address to send a gift to, so that was fun.
@HenrikJoreteg
HenrikJoreteg / router.js
Created March 9, 2015 21:26
ampersand router with auth checks
var Router = require('ampersand-router');
var app = require('ampersand-app');
function auth(authLevel, fn) {
return function () {
if (authLevel === 'required' && !app.me.loggedIn) {
this.redirectTo('/login');
return;
}
@HenrikJoreteg
HenrikJoreteg / index.js
Created February 27, 2015 19:26
requirebin sketch
var AmpersandView = require('ampersand-view');
var PersonRowView = AmpersandView.extend({
template: "<h2>This is the first ampersand View </h2>"
});
var personView = new PersonRowView()
personView.render();
document.body.appendChild(personView.el);
@HenrikJoreteg
HenrikJoreteg / inbox.html
Created October 23, 2014 17:59
"view source" of Google Inbox
<html lang="en-US" jsl="$t t-Tkdr7Li1J_A;$x 0;" jsvs="true;'en-US';" jsan=
"t-Tkdr7Li1J_A,0.lang" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org" />
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Inbox &#8211; hjoreteg@gmail.com</title>
<link class="i1Vy9" href=