Skip to content

Instantly share code, notes, and snippets.

View jaredpalmer's full-sized avatar

Jared Palmer jaredpalmer

View GitHub Profile
@jaredpalmer
jaredpalmer / Login.js
Last active February 25, 2017 22:16
Login
import React from 'react';
import axios from 'axios';
import Link from 'react-router-dom/Link';
import qs from 'query-string';
import Helmet from 'react-helmet';
import { setToken } from '../utils/auth';
import {
Page,
Block,
Card,
@jaredpalmer
jaredpalmer / package.json
Created December 15, 2016 15:45
Webpack Node.js with live reload.
{
"version": "0.0.1",
"scripts": {
"start": "npm-run-all --parallel watch:server watch:build",
"watch:build": "NODE_ENV='development' webpack --watch",
"watch:server": "nodemon \"./build/server/main.js\" --watch \"./build/server\""
},
"devDependencies": {
"babel-core": "^6.20.0",
"babel-loader": "^6.2.9",
@jaredpalmer
jaredpalmer / apiErrorHandler.js
Created November 30, 2016 14:44
api error handler
return function apiErrorHandler(err, req, res, next) {
var status = err.status || err.statusCode || 500;
if (status < 400) status = 500;
res.statusCode = status;
var body = {
status: status
};
// show the stacktrace when not in production
@jaredpalmer
jaredpalmer / error.js
Created November 30, 2016 14:43
errors
'use strict'
const uuid = require('node-uuid')
class APIError extends Error {
constructor (opts) {
super(opts)
Error.captureStackTrace(this, APIError)
this.name = this.constructor.name || 'APIError'
this.code = opts.code || 500
@jaredpalmer
jaredpalmer / EditableText.js
Created November 24, 2016 17:58
EditableText.js
/**
* This is converted from @palantir/blueprint's editable text.
*
* @see http://blueprintjs.com/docs/#components.editable
*/
import React, {Component} from 'react'
import classNames from 'classnames'
import { clamp, safeInvoke } from '../utils'
import PureRender from "pure-render-decorator";
@jaredpalmer
jaredpalmer / index.js
Created November 21, 2016 21:57
require models dir
const fs = require('fs')
const path = require('path')
const models = path.join(__dirname, 'models')
fs.readdirSync(models)
.filter(file => ~file.indexOf('.js'))
.forEach(file => require(path.join(models, file)))
@jaredpalmer
jaredpalmer / solid_nav.html
Created November 11, 2016 16:01
solid nav nunjucks
<nav class="nav xs-border-bottom-lighter xs-relative flex xs-flex-justify-start xs-flex-items-center fill-white xs-px2" style="height: 50px; line-height: 50px;" >
<a class="xs-flex-grow-0 xs-inline-block xs-mr3 bold link-gray caps" style="letter-spacing: .1em;" href="/">Palmer</a>
{% if user %}
<div class="xs-flex-grow-1 xs-text-left">
<a class="xs-inline-block xs-mr1 bold" href="/admin">Dashboard</a>
<a class="xs-inline-block xs-mr1 bold" href="/admin/users">Users</a>
<a class="xs-inline-block xs-mr1 bold" href="/admin">Companies</a>
<a class="xs-inline-block xs-mr1 bold" href="/admin">News</a>
<a class="xs-inline-block xs-mr1 bold" href="/admin">Events</a>
</div>
@jaredpalmer
jaredpalmer / sentry.js
Created November 10, 2016 20:28
node-sentry
import _ from 'lodash';
import s from 'underscore.string';
import chalk from 'chalk';
import parseValidationError from './parse-validation-error';
import sentry from './sentry';
import config from '../config';
// sentry supported log levels:
@jaredpalmer
jaredpalmer / Login.react.js
Created November 8, 2016 21:52
React SPA OAuth Login
import React, { Component } from 'react';
import {withRouter} from 'react-router';
import auth from '../auth';
class Login extends Component {
constructor() {
super()
this.state ={
error: true
};
@jaredpalmer
jaredpalmer / base.css
Created July 21, 2016 17:39
Instagram.com CSS Base Styles (Flex Box)
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym,
address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i,
center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr,
th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav,
output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;