Skip to content

Instantly share code, notes, and snippets.

View timbuckley's full-sized avatar

Tim Buckley timbuckley

  • Aline
  • NYC
View GitHub Profile
@timbuckley
timbuckley / SassMeister-input-HTML.html
Created February 27, 2015 18:14
Generated by SassMeister.com.
<h1>animate a circle to a line in CSS</h1>
<h2>requires box-reflect (-webkit-)</h2>
<div class="shape">hover me
<div class="quarter-circle"></div>
<div class="quarter-circle"></div>
<div class="quarter-circle"></div>
</div>
var menuInput = "Lunch Box,Roast Beef\nTotto Ramen,Miso Noodles\nLunch Box,Turkey\nTotto Ramen,Kimchee\nEl Centro,Enchiladas\nBengal Tiger,Garlic Naan\nLunch Box,Tomato Avocado\nTotto Ramen,Spicy Noodles\nLunch Box,Soup of the Day\nBengal Tiger,Saag Paneer\nTotto Ramen,Pork Bun\nIsland Burgers and Shakes,Fries\nBengal Tiger,Chicken Tikka Masala\nEl Centro,Chips and Guacamole\nIsland Burgers and Shakes,Chocolate Milkshake\nTotto Ramen,Hot Tea\nIsland Burgers and Shakes,Cheddar Burger\nBengal Tiger,Chicken Vindaloo\nIsland Burgers and Shakes,Garden Burger\nEl Centro,Fajitas";
// Nested list of restaurant-item pairs.
var menuObj = {},
pairs = menuInput
.split("\n")
.map(function(pair) {return pair.split(',')}); //in ES6: pair => pair.split(',')
// Build into menuObj.
@timbuckley
timbuckley / logger.js
Created March 24, 2016 17:02
Super simple logging middleware for Redux
import Conf from '../conf' // Various app-level options, including a logging flag.
const logger = store => next => action => {
// Middleware format.
// - Logs each action as they come in,
// - Dispatches the action, and
// - Logs the new state.
if (Conf.logging && typeof console.group === 'function') {
console.group(action.type)
console.info('📲 dispatching', action)
@timbuckley
timbuckley / my-component.js
Created March 24, 2016 18:55
How to export/include a utility function.
import { percentage } from '../utils.js'
// Component goes here.
(defn flatten [nested]
(reduce
(fn [acc el]
(concat acc (if (sequential? el)
(flatten el)
[el])))
[]
nested))
import React from 'react'
class AppTemplate extends React.Component {
componentWillMount() {
this.props.veritfyUserToken()
}
render() {
if (this.props.state.loading) {
return (
import React, { Component } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Settings from '../components/scenes/settings'
import * as settingActions from '../actions/settings'
import * as signUpActions from '../actions/sign-up'
import * as loginActions from '../actions/login'
import * as routerActions from '../actions/router'
We couldn’t find that file to show.
function itemsReducer(state, action) {
switch(action.type) {
case 'UPDATE_ITEM':
return state.items.map(i => itemReducer(i, action))
default:
return state
}
}
function itemReducer(state, action) {
// === Action Creators ===
export function posItemRequest(itemBody) {
return {
type: 'ITEM_POST_REQUEST',
payload: {
itemBody: itemBody
}
}
}