Skip to content

Instantly share code, notes, and snippets.

@kellyrmilligan
kellyrmilligan / metamanager.js
Created January 8, 2015 15:08
sample code for meta manager mixin for reactjs
'use strict';
// data structure that is in the props
// head = {
// title: 'title'
// description: 'description'
// canonical: 'http://www.whatever.com'
// link: [
// {
// href: "https://www.nextpage.com",
@kellyrmilligan
kellyrmilligan / gist:aba9dd155ed77dc579faa8d022ec65a6
Last active May 9, 2016 18:38
scroll cache module and raf loop
export default {
scrollY: '',
getScrollY() {
return (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
},
init() {
window.addEventListener('scroll', (e) => {
this.scrollY = this.getScrollY();
@kellyrmilligan
kellyrmilligan / maxLoot.js
Created October 8, 2016 01:56
algo examples
const readline = require('readline');
process.stdin.setEncoding('utf8');
let n = null
let w = null
let firstParamsSet = false
let values = []
const rl = readline.createInterface({
import React, { PropTypes, Component } from 'react'
class ContextExample extends Component {
static childContextTypes = {
config: PropTypes.object,
}
getChildContext() {
@kellyrmilligan
kellyrmilligan / bucket-policy-s3-example
Last active June 8, 2017 13:24
bucket policy example for deploying to s3 with circleci
{
"Version": "2012-10-17",
"Id": "Policy1489770524467",
"Statement": [
{
"Sid": "Stmt1489770487230",
"Effect": "Allow",
"Principal": {
"AWS": "[arn of iam user you created for circleci]"
},
class Page extends Component {
static fetch(match, location, options) {
//return a promise to be resolved later, superagent as an example
return request('GET', '/search')
}
render() {
//your stuff
}
reactRouterFetch(routeConfig, location, { dispatch })
.then((results) => {
this.setState({
isAppFetching: false
})
})
.catch((err) => {
this.setState({
isAppFetching: false,
appFetchingError: err
import React, { Component } from 'react'
import { withRouter } from 'react-router'
import reactRouterFetch from 'react-router-fetch'
class App extends Component {
state = {
isAppFetching: false,
appFetchingError: null
}
@kellyrmilligan
kellyrmilligan / circle-example.yml
Last active April 27, 2017 15:45
example circle ci yml
deployment:
prod:
branch: master
commands:
- NODE_ENV=production REACT_APP_GIT_SHA=$CIRCLE_SHA1 REACT_APP_ROLLBAR_TOKEN=$ROLLBAR_TOKEN yarn run build
<% if (process.env.NODE_ENV !== 'development') { %>
<script>
var _rollbarConfig = {
accessToken: '%REACT_APP_ROLLBAR_TOKEN%',
captureUncaught: true,
captureUnhandledRejections: true,
payload: {
environment: '%NODE_ENV%',
client: {
javascript: {