Skip to content

Instantly share code, notes, and snippets.

@ericstumper
ericstumper / index.html
Created Jan 24, 2020
Fixed header example
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
body {
margin: 0;
View reducer.js
[LOAD_METER_DATA_LATEST_FRAME]: (state, action) => {
const currentPropertyId = state.data.findIndex(
x => x.id === action.payload
);
return {
...state,
data: {
...state.data,
[currentPropertyId]: {
...state.data[currentPropertyId],
@ericstumper
ericstumper / 0_reuse_code.js
Created Feb 6, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ericstumper
ericstumper / index.js
Created Jul 3, 2016
Navigation component handling logout
View index.js
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-apollo';
import { push } from 'react-router-redux';
import { Link, IndexLink } from 'react-router';
import * as authActionCreators from 'actions/auth';
import { deleteToken } from 'mutations/auth';
import styles from './styles.css';
@ericstumper
ericstumper / state.json
Created Jul 3, 2016
State after one user logging in, logging out directly after and another user logging in afterwards
View state.json
This file has been truncated, but you can view the full file.
{
"monitorState": {},
"actionsById": {
"0": {
"type": "PERFORM_ACTION",
"action": {
"type": "@@INIT"
},
"timestamp": 1467536860691,
@ericstumper
ericstumper / context.ex
Created Jun 10, 2016
Guardian Authentication with Absinthe GraphQL in Elixir
View context.ex
defmodule Languafy.Web.Context do
@behaviour Plug
import Plug.Conn
alias Languafy.User
def init(opts), do: opts
def call(conn, _) do
case build_context(conn) do
{:ok, context} ->
@ericstumper
ericstumper / schema.ex
Created Jun 9, 2016
JWT Token creation with Absinthe and Guardian
View schema.ex
defmodule Languafy.Schema do
use Absinthe.Schema
import_types Languafy.Schema.Types
query do
@desc "Get an App User"
field :user, type: :user do
arg :id, non_null(:id)
resolve &Languafy.Resolver.User.find/2
end
View router.ex
defmodule Languafy.Router do
use Languafy.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end